aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-18 10:26:03 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-15 02:49:29 +0800
commit285fb3deadd0413bf993557575a3f96a840f0e10 (patch)
tree8970de6db324e3773146f61265e0b44d03976a60 /packages/utils
parent797d7c7878e33ce012259a6a5db5335e9dc838ba (diff)
downloaddexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.gz
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.bz2
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.lz
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.xz
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.tar.zst
dexon-sol-tools-285fb3deadd0413bf993557575a3f96a840f0e10.zip
Progress
Diffstat (limited to 'packages/utils')
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/types/set.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts
index 00059a4b6..f97f0bac3 100644
--- a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts
+++ b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts
@@ -134,20 +134,21 @@ export abstract class AbstractSetDataType extends DataType {
const block = new SetCalldataBlock(this.getDataItem().name, this.getSignature(), parentName);
// Create blocks for members of set.
const memberCalldataBlocks: CalldataBlock[] = [];
- const childMap = _.cloneDeep(this._memberIndexByName);
- _.forOwn(obj, (value: any, key: string) => {
- if (!(key in childMap)) {
+ let duplicateObj = _.cloneDeep(obj) as {[key:string]: any};
+ _.forEach(this._memberIndexByName, (memberIndex: number, memberName: string) => {
+ if (!(memberName in obj)) {
throw new Error(
- `Could not assign tuple to object: unrecognized key '${key}' in object ${this.getDataItem().name}`,
+ `Could not assign tuple to object: missing field '${memberName}' in object ${obj}`,
);
}
- const memberBlock = this._members[this._memberIndexByName[key]].generateCalldataBlock(value, block);
+ const memberValue: any = duplicateObj[memberName];
+ const memberBlock = this._members[memberIndex].generateCalldataBlock(memberValue, block);
memberCalldataBlocks.push(memberBlock);
- delete childMap[key];
+ delete duplicateObj[memberName];
});
// Sanity check that all members have been included.
- if (Object.keys(childMap).length !== 0) {
- throw new Error(`Could not assign tuple to object: missing keys ${Object.keys(childMap)}`);
+ if (Object.keys(duplicateObj).length !== 0) {
+ throw new Error(`Could not assign tuple to object: unrecognized keys ${Object.keys(duplicateObj)}`);
}
// Associate member blocks with Set block.
block.setMembers(memberCalldataBlocks);