Skip to content

Commit

Permalink
Updated ABI Number coder for BigNumber API change.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Apr 15, 2020
1 parent 7dcefcb commit 284771e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/abi/src.ts/coders/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ export class NumberCoder extends Coder {
let v = BigNumber.from(value);

// Check bounds are safe for encoding
let maxUintValue = MaxUint256.maskn(writer.wordSize * 8);
let maxUintValue = MaxUint256.mask(writer.wordSize * 8);
if (this.signed) {
let bounds = maxUintValue.maskn(this.size * 8 - 1);
let bounds = maxUintValue.mask(this.size * 8 - 1);
if (v.gt(bounds) || v.lt(bounds.add(One).mul(NegativeOne))) {
this._throwError("value out-of-bounds", value);
}
} else if (v.lt(Zero) || v.gt(maxUintValue.maskn(this.size * 8))) {
} else if (v.lt(Zero) || v.gt(maxUintValue.mask(this.size * 8))) {
this._throwError("value out-of-bounds", value);
}

v = v.toTwos(this.size * 8).maskn(this.size * 8);
v = v.toTwos(this.size * 8).mask(this.size * 8);

if (this.signed) {
v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize);
Expand All @@ -41,7 +41,7 @@ export class NumberCoder extends Coder {
}

decode(reader: Reader): any {
let value = reader.readValue().maskn(this.size * 8);
let value = reader.readValue().mask(this.size * 8);

if (this.signed) {
value = value.fromTwos(this.size * 8);
Expand Down

0 comments on commit 284771e

Please sign in to comment.