diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-08 02:44:22 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:10 +0800 |
commit | dfa9e435af7477bddb147a8af3700143b27b5dc6 (patch) | |
tree | 7d448217a13160363e90b0c4cac17750e6575c69 /packages | |
parent | fc0e7b1132f8956c470a49b0e964d9ca1812e591 (diff) | |
download | dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar.gz dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar.bz2 dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar.lz dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar.xz dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.tar.zst dexon-sol-tools-dfa9e435af7477bddb147a8af3700143b27b5dc6.zip |
Implemented Address
Diffstat (limited to 'packages')
-rw-r--r-- | packages/order-utils/test/abi_encoder_test.ts | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/packages/order-utils/test/abi_encoder_test.ts b/packages/order-utils/test/abi_encoder_test.ts index 292e615f3..7fb091019 100644 --- a/packages/order-utils/test/abi_encoder_test.ts +++ b/packages/order-utils/test/abi_encoder_test.ts @@ -309,9 +309,6 @@ namespace AbiEncoder { public abstract assignValue(value: any): void; public abstract getSignature(): string; - public abstract encodeToCalldata(calldata: Calldata): void; - - // abstract match(type: string): Bool; } export abstract class StaticDataType extends DataType { @@ -333,16 +330,13 @@ namespace AbiEncoder { } public assignValue(value: string) { - const hexValue = ethUtil.bufferToHex(new Buffer(value)); + const evmWordWidth = 32; + const hexValue = ethUtil.bufferToHex(ethUtil.setLengthLeft(ethUtil.toBuffer(value), evmWordWidth)); this.assignHexValue(hexValue); } public getSignature(): string { - throw 1; - } - - public encodeToCalldata(calldata: Calldata): void { - throw 2; + return `address`; } public static matchGrammar(type: string): boolean { @@ -634,8 +628,6 @@ namespace AbiEncoder { public getHexValue(): string { let offset = new BigNumber(0); if (this.memblock !== undefined) { - console.log('Abs Offset = ', JSON.stringify(this.destDataType.getAbsoluteOffset())); - console.log('Local Offset = ', JSON.stringify(this.destDataType.getOffset())); switch (this.memblock.getSection()) { case CalldataSection.PARAMS: offset = this.destDataType.getAbsoluteOffset(); @@ -786,6 +778,19 @@ describe.only('ABI Encoder', () => { }); }); + describe.only('Address', () => { + const testAddressDataItem = { name: 'testAddress', type: 'address' }; + it('Valid Address', async () => { + const addressDataType = new AbiEncoder.Address(testAddressDataItem); + addressDataType.assignValue('0xe41d2489571d322189246dafa5ebde1f4699f498'); + const expectedAbiEncodedAddress = '0x000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; + + console.log(addressDataType.getHexValue()); + console.log(expectedAbiEncodedAddress); + expect(addressDataType.getHexValue()).to.be.equal(expectedAbiEncodedAddress); + }); + }); + describe('String', () => { const testStringDataItem = { name: 'testString', type: 'string' }; it('Less than 32 bytes', async () => { |