Use estimateGas error (as per updated implementation) (#4131)
* Use estimateGas error (as per updated implementation) * EXCEPTION_ERROR as per #4142
This commit is contained in:
committed by
Nicolas Gotchac
parent
311730ea95
commit
389e4e3bc0
@@ -62,6 +62,10 @@ export default class GasPriceEditor {
|
||||
this.errorTotal = errorTotal;
|
||||
}
|
||||
|
||||
@action setEstimatedError = (errorEstimated = ERRORS.gasException) => {
|
||||
this.errorEstimated = errorEstimated;
|
||||
}
|
||||
|
||||
@action setEstimated = (estimated) => {
|
||||
transaction(() => {
|
||||
const bn = new BigNumber(estimated);
|
||||
@@ -69,11 +73,11 @@ export default class GasPriceEditor {
|
||||
this.estimated = estimated;
|
||||
|
||||
if (bn.gte(MAX_GAS_ESTIMATION)) {
|
||||
this.errorEstimated = ERRORS.gasException;
|
||||
this.setEstimatedError(ERRORS.gasException);
|
||||
} else if (bn.gte(this.gasLimit)) {
|
||||
this.errorEstimated = ERRORS.gasBlockLimit;
|
||||
this.setEstimatedError(ERRORS.gasBlockLimit);
|
||||
} else {
|
||||
this.errorEstimated = null;
|
||||
this.setEstimatedError(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,6 +82,24 @@ describe('ui/GasPriceEditor/store', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setEstimatedError', () => {
|
||||
it('sets the value as provided', () => {
|
||||
store.setEstimatedError('errorTest');
|
||||
expect(store.errorEstimated).to.equal('errorTest');
|
||||
});
|
||||
|
||||
it('sets the null value as provided', () => {
|
||||
store.setEstimatedError('errorTest');
|
||||
store.setEstimatedError(null);
|
||||
expect(store.errorEstimated).to.be.null;
|
||||
});
|
||||
|
||||
it('sets a default error when none provided', () => {
|
||||
store.setEstimatedError();
|
||||
expect(store.errorEstimated).to.equal(ERRORS.gasException);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setEstimated', () => {
|
||||
it('sets the value', () => {
|
||||
store.setEstimated('789');
|
||||
|
||||
Reference in New Issue
Block a user