diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-19 13:44:26 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-01-15 02:49:29 +0800 |
commit | 2f1454e90e5fd7d85c4deb3a8c674043e8a14564 (patch) | |
tree | 65ce021b55cf9e384e808bba94b2979d9c73f170 /packages/utils/src/abi_encoder/evm_data_types | |
parent | b89f9869492e369370bcef593d69e59172f13da4 (diff) | |
download | dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar.gz dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar.bz2 dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar.lz dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar.xz dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.tar.zst dexon-0x-contracts-2f1454e90e5fd7d85c4deb3a8c674043e8a14564.zip |
Working for almost every test
Diffstat (limited to 'packages/utils/src/abi_encoder/evm_data_types')
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/int.ts | 5 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/method.ts | 7 | ||||
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/uint.ts | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types/int.ts b/packages/utils/src/abi_encoder/evm_data_types/int.ts index f1dcf5ea1..c9f734799 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/int.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts @@ -47,9 +47,12 @@ export class IntDataType extends AbstractBlobDataType { return encodedValue; } - public decodeValue(calldata: RawCalldata): BigNumber { + public decodeValue(calldata: RawCalldata): BigNumber|number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, this._minValue, this._maxValue); + if (this._width === 8) { + return value.toNumber(); + } return value; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/method.ts b/packages/utils/src/abi_encoder/evm_data_types/method.ts index b1cd1377f..c777902e8 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/method.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/method.ts @@ -8,6 +8,7 @@ import { AbstractSetDataType } from '../abstract_data_types/types/set'; import { constants } from '../utils/constants'; import { DecodingRules, EncodingRules } from '../utils/rules'; +import { ArrayDataType } from './array'; import { TupleDataType } from './tuple'; export class MethodDataType extends AbstractSetDataType { @@ -44,6 +45,12 @@ export class MethodDataType extends AbstractSetDataType { return returnValues; } + public decodeReturnValuesAsArray(returndata: string, rules?: DecodingRules): any { + const returnValues = this.decodeReturnValues(returndata, rules); + const returnValuesAsArray = _.isObject(returnValues) ? _.values(returnValues) : [returnValues]; + return returnValuesAsArray; + } + public getSignature(): string { return this._methodSignature; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/uint.ts b/packages/utils/src/abi_encoder/evm_data_types/uint.ts index 5180f0cf3..06cde4eea 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts @@ -46,9 +46,12 @@ export class UIntDataType extends AbstractBlobDataType { return encodedValue; } - public decodeValue(calldata: RawCalldata): BigNumber { + public decodeValue(calldata: RawCalldata): BigNumber|number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue); + if (this._width === 8) { + return value.toNumber(); + } return value; } |