aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/test/abi
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-10 10:59:27 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commit41e01e98064b129f588d72ed25267f4865c58f5c (patch)
tree194e741b271d863d88d18c9b14471f336f43b633 /packages/order-utils/test/abi
parent0835cf0ea2bb3c2c18d2a5d44ec914e2945af1b0 (diff)
downloaddexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar.gz
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar.bz2
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar.lz
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar.xz
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.tar.zst
dexon-0x-contracts-41e01e98064b129f588d72ed25267f4865c58f5c.zip
making progress on basic example
Diffstat (limited to 'packages/order-utils/test/abi')
-rw-r--r--packages/order-utils/test/abi/data_type.ts15
-rw-r--r--packages/order-utils/test/abi/evm_data_types.ts7
2 files changed, 13 insertions, 9 deletions
diff --git a/packages/order-utils/test/abi/data_type.ts b/packages/order-utils/test/abi/data_type.ts
index 201eb89f9..c1e352508 100644
--- a/packages/order-utils/test/abi/data_type.ts
+++ b/packages/order-utils/test/abi/data_type.ts
@@ -95,15 +95,17 @@ export abstract class MemberDataType extends DataType {
private members: DataType[];
private isArray: boolean;
protected arrayLength: number | undefined;
+ protected arrayElementType: string | undefined;
- public constructor(dataItem: DataItem, isArray: boolean = false, arrayLength?: number) {
+ public constructor(dataItem: DataItem, isArray: boolean = false, arrayLength?: number, arrayElementType?: string) {
super(dataItem);
this.memberMap = {};
this.members = [];
this.isArray = isArray;
this.arrayLength = arrayLength;
+ this.arrayElementType = arrayElementType;
if (isArray && arrayLength !== undefined) {
[this.members, this.memberMap] = this.createMembersWithLength(dataItem, arrayLength);
} else if (!isArray) {
@@ -119,10 +121,10 @@ export abstract class MemberDataType extends DataType {
let members: DataType[] = [];
let memberMap: MemberMap = {};
- _.each(dataItem.components, (dataItem: DataItem) => {
+ _.each(dataItem.components, (memberItem: DataItem) => {
const childDataItem = {
- type: dataItem.type,
- name: `${dataItem.name}.${dataItem.name}`,
+ type: memberItem.type,
+ name: `${dataItem.name}.${memberItem.name}`,
} as DataItem;
const child = DataTypeFactory.create(childDataItem, this);
members.push(child);
@@ -133,12 +135,13 @@ export abstract class MemberDataType extends DataType {
}
private createMembersWithLength(dataItem: DataItem, length: number): [DataType[], MemberMap] {
+ console.log(dataItem);
let members: DataType[] = [];
let memberMap: MemberMap = {};
const range = _.range(length);
_.each(range, (idx: number) => {
const childDataItem = {
- type: dataItem.type,
+ type: this.arrayElementType,
name: `${dataItem.name}[${idx.toString(10)}]`,
} as DataItem;
const components = dataItem.components;
@@ -164,7 +167,7 @@ export abstract class MemberDataType extends DataType {
}
let members = this.members;
- if (this.arrayLength === undefined) {
+ if (this.isArray && this.arrayLength === undefined) {
[members,] = this.createMembersWithLength(this.getDataItem(), value.length);
}
diff --git a/packages/order-utils/test/abi/evm_data_types.ts b/packages/order-utils/test/abi/evm_data_types.ts
index 4dffedb8d..1bd4f0d51 100644
--- a/packages/order-utils/test/abi/evm_data_types.ts
+++ b/packages/order-utils/test/abi/evm_data_types.ts
@@ -347,9 +347,10 @@ export class SolArray extends MemberDataType {
}
const isArray = true;
+ const arrayElementType = matches[1];
const arrayLength = (matches[2] === '') ? undefined : parseInt(matches[2], 10);
- super(dataItem, isArray, arrayLength);
- this.elementType = matches[1];
+ super(dataItem, isArray, arrayLength, arrayElementType);
+ this.elementType = arrayElementType;
this.arraySignature = this.computeSignature();
}
@@ -388,7 +389,7 @@ export class Method extends MemberDataType {
public selector: string;
constructor(abi: MethodAbi) {
- super({ type: 'method', name: abi.name });
+ super({ type: 'method', name: abi.name, components: abi.inputs });
this.methodSignature = this.computeSignature();
this.selector = this.methodSelector = this.computeSelector();