accept hex string as input of type 'uin256'

pull/64/head
lixp 4 years ago
parent 1b977860ad
commit f0e8056f84
  1. 7
      packages/harmony-contract/src/abi/abiCoder.ts

@ -683,7 +683,12 @@ class CoderNumber extends Coder {
encode(value: BN | number | string): Uint8Array {
let result;
try {
let v = new BN(value);
let v: BN;
if (typeof value == 'string' && value.startsWith('0x')) {
v = new BN(value.slice(2), 'hex');
} else {
v = new BN(value);
}
if (this.signed) {
let bounds = MaxUint256.maskn(this.size * 8 - 1);
if (v.gt(bounds)) {

Loading…
Cancel
Save