diff options
author | Greg Hysen <hysz@users.noreply.github.com> | 2019-01-15 03:48:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-15 03:48:17 +0800 |
commit | 1c25d8e997456c248470d925cf6702e46d959a62 (patch) | |
tree | 4e2c77924445247b2916d7713e058ba3466b70a5 /packages/utils/src/abi_encoder/abstract_data_types/data_type.ts | |
parent | fc89b97818eda9c7447273b5728c1ba8fbb5cdf5 (diff) | |
parent | b0817854e81512ad95cca4d842a671304ae3b94a (diff) | |
download | dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar.gz dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar.bz2 dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar.lz dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar.xz dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.tar.zst dexon-sol-tools-1c25d8e997456c248470d925cf6702e46d959a62.zip |
Merge pull request #1475 from 0xProject/feature/monorepo/useNewAbiEncoder
Use Compressed Calldata in Contract Wrappers
Diffstat (limited to 'packages/utils/src/abi_encoder/abstract_data_types/data_type.ts')
-rw-r--r-- | packages/utils/src/abi_encoder/abstract_data_types/data_type.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts index 13cc87e2a..f23324721 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts @@ -51,8 +51,26 @@ export abstract class DataType { return value; } + public decodeAsArray(returndata: string, rules?: DecodingRules): any[] { + const value = this.decode(returndata, rules); + const valuesAsArray = _.isObject(value) ? _.values(value) : [value]; + return valuesAsArray; + } + + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this._dataItem.name) || !isDetailed) { + return this.getSignatureType(); + } + const name = this.getDataItem().name; + const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); + const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; + const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; + const detailedSignature = `${shortName} ${this.getSignatureType()}`; + return detailedSignature; + } + public abstract generateCalldataBlock(value: any, parentBlock?: CalldataBlock): CalldataBlock; public abstract generateValue(calldata: RawCalldata, rules: DecodingRules): any; - public abstract getSignature(): string; + public abstract getSignatureType(): string; public abstract isStatic(): boolean; } |