aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-28 09:23:01 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:11 +0800
commitd6645b8a9116d92ac15f0b64f46566bf7f5447f1 (patch)
tree3f75cc0550c382224d1e96b3b31c83e018e4d208 /packages
parent029b8d59507df25aa9c7d1b096c8d873eb6ae4da (diff)
downloaddexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar.gz
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar.bz2
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar.lz
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar.xz
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.tar.zst
dexon-sol-tools-d6645b8a9116d92ac15f0b64f46566bf7f5447f1.zip
Explicit encoding rules in tests.
Diffstat (limited to 'packages')
-rw-r--r--packages/utils/test/abi_encoder/evm_data_types_test.ts129
-rw-r--r--packages/utils/test/abi_encoder/methods_test.ts37
-rw-r--r--packages/utils/test/abi_encoder/optimizer_test.ts31
-rw-r--r--packages/utils/test/abi_encoder/return_values_test.ts11
4 files changed, 106 insertions, 102 deletions
diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts
index 11cebda55..9ef80a560 100644
--- a/packages/utils/test/abi_encoder/evm_data_types_test.ts
+++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts
@@ -10,6 +10,7 @@ chaiSetup.configure();
const expect = chai.expect;
describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
+ const encodingRules: AbiEncoder.EncodingRules = { optimize: false }; // optimizer is tested separately.
describe('Array', () => {
it('Fixed size; Static elements', async () => {
// Create DataType object
@@ -18,7 +19,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = [new BigNumber(5), new BigNumber(6)];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -33,7 +34,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = [new BigNumber(5), new BigNumber(6)];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -48,7 +49,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = ['Hello', 'world'];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -63,7 +64,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = ['Hello', 'world'];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -81,7 +82,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array3 = ['0x18192021'];
const args = [array1, array2, array3];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000405060708000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004091011120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000041011121300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000414151617000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000041819202100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -99,7 +100,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array3 = ['0x18192021'];
const args = [array1, array2, array3];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000301020304000000000000000000000000000000000000000000000000000000000506070800000000000000000000000000000000000000000000000000000000091011120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021011121300000000000000000000000000000000000000000000000000000000141516170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011819202100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -116,7 +117,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array2 = ['0x10111213', '0x14151617', '0x18192021'];
const args = [array1, array2];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x010203040000000000000000000000000000000000000000000000000000000005060708000000000000000000000000000000000000000000000000000000000910111200000000000000000000000000000000000000000000000000000000101112130000000000000000000000000000000000000000000000000000000014151617000000000000000000000000000000000000000000000000000000001819202100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -133,7 +134,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array2 = ['0x10111213', '0x14151617', '0x18192021'];
const args = [array1, array2];
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000401020304000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004050607080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040910111200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000410111213000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004141516170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041819202100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -149,7 +150,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = ['Hello', 'world'];
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw('Expected array of 3 elements, but got array of length 2');
});
it('Static size; Too Many Elements', async () => {
@@ -160,7 +161,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = ['Hello', 'world'];
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw('Expected array of 1 elements, but got array of length 2');
});
it('Element Type Mismatch', async () => {
@@ -171,7 +172,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = [new BigNumber(1), 'Bad Argument'];
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
});
@@ -188,7 +189,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = { field_1: new BigNumber(-5), field_2: true };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -208,7 +209,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = { field_1: 'Hello, World!', field_2: '0xabcdef0123456789' };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c6421000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008abcdef0123456789000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -228,7 +229,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = { field: [new BigNumber(1), new BigNumber(2)] };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -248,7 +249,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = { field: [new BigNumber(1), new BigNumber(2)] };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -270,7 +271,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array2 = ['0x09101112', '0x13141516'];
const args = { field: [array1, array2] };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x0102030400000000000000000000000000000000000000000000000000000000050607080000000000000000000000000000000000000000000000000000000009101112000000000000000000000000000000000000000000000000000000001314151600000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -292,7 +293,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const array2 = ['0x09101112', '0x13141516'];
const args = { field: [array1, array2] };
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004010203040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040506070800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000004091011120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041314151600000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -322,7 +323,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
field_4: '0xabcdef0123456789',
};
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c6421000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008abcdef0123456789000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -343,7 +344,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = { field_1: new BigNumber(-5) };
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw('Could not assign tuple to object: missing keys field_2');
});
it('Bad Key', async () => {
@@ -358,7 +359,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = { unknown_field: new BigNumber(-5) };
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw("Could not assign tuple to object: unrecognized key 'unknown_field' in object Tuple");
});
});
@@ -371,7 +372,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = '0xe41d2489571d322189246dafa5ebde1f4699f498';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -386,7 +387,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = 'e4';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw(`Invalid address: '${args}'`);
});
it('Invalid Address - input is not 20 bytes', async () => {
@@ -397,7 +398,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0xe4';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw(`Invalid address: '${args}'`);
});
});
@@ -410,7 +411,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = true;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -424,7 +425,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = false;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -448,7 +449,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -462,7 +463,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(-1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -476,7 +477,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = max256BitInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -490,7 +491,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = min256BitInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = `0x8000000000000000000000000000000000000000000000000000000000000000`;
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -505,7 +506,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = max256BitInteger.plus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('Int256 - Value too small', async () => {
@@ -516,7 +517,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = min256BitInteger.minus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('Int32 - Positive Base Case', async () => {
@@ -526,7 +527,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -540,7 +541,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(-1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -554,7 +555,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = max32BitInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x000000000000000000000000000000000000000000000000000000007fffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -568,7 +569,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = min32BitInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = `0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000`;
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -583,7 +584,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = max32BitInteger.plus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('Int32 - Value too small', async () => {
@@ -594,7 +595,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = min32BitInteger.minus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
});
@@ -614,7 +615,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -628,7 +629,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = max256BitUnsignedInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -642,7 +643,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = min256BitUnsignedInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = `0x0000000000000000000000000000000000000000000000000000000000000000`;
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -657,7 +658,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = max256BitUnsignedInteger.plus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('UInt256 - Value too small', async () => {
@@ -668,7 +669,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = min256BitUnsignedInteger.minus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('UInt32 - Positive Base Case', async () => {
@@ -678,7 +679,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = new BigNumber(1);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -692,7 +693,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = max32BitUnsignedInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x00000000000000000000000000000000000000000000000000000000ffffffff';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -706,7 +707,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = min32BitUnsignedInteger;
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = `0x0000000000000000000000000000000000000000000000000000000000000000`;
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -721,7 +722,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = max32BitUnsignedInteger.plus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
it('UInt32 - Value too small', async () => {
@@ -732,7 +733,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = min32BitUnsignedInteger.minus(1);
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw();
});
});
@@ -745,7 +746,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = '0x05';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0500000000000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -759,7 +760,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = '0x05';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0500000000000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -773,7 +774,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = '0x00010203';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0001020300000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -788,7 +789,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
const args = '0x1a18';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x1a18000000000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -803,7 +804,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Construct args to be encoded
const args = '0x0001020304050607080911121314151617181920212223242526272829303132';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x0001020304050607080911121314151617181920212223242526272829303132';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -818,7 +819,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
const args = '0x1a18bf61';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs = '0x1a18bf6100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
// Decode Encoded Args and validate result
@@ -834,7 +835,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0x0102030405';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw(
'Tried to assign 0x0102030405 (5 bytes), which exceeds max bytes that can be stored in a bytes4',
);
@@ -847,7 +848,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0x010203040506070809101112131415161718192021222324252627282930313233';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw(
'Tried to assign 0x010203040506070809101112131415161718192021222324252627282930313233 (33 bytes), which exceeds max bytes that can be stored in a bytes32',
);
@@ -860,7 +861,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0102030405060708091011121314151617181920212223242526272829303132';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw("Tried to encode non-hex value. Value must inlcude '0x' prefix.");
});
it('Should throw when pass in bad hex (include a half-byte)', async () => {
@@ -871,7 +872,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0x010';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw('Tried to assign 0x010, which is contains a half-byte. Use full bytes only.');
});
});
@@ -885,7 +886,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
const args = '0x1a18bf61';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000041a18bf6100000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -902,7 +903,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const bytesLength = 40;
const args = '0x' + '61'.repeat(bytesLength);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000002861616161616161616161616161616161616161616161616161616161616161616161616161616161000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -935,7 +936,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '01';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw("Tried to encode non-hex value. Value must inlcude '0x' prefix.");
});
it('Should throw when pass in bad hex (include a half-byte)', async () => {
@@ -946,7 +947,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const args = '0x010';
// Encode Args and validate result
expect(() => {
- dataType.encode(args);
+ dataType.encode(args, encodingRules);
}).to.throw('Tried to assign 0x010, which is contains a half-byte. Use full bytes only.');
});
});
@@ -960,7 +961,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Note: There will be padding because this is a bytes32 but we are only passing in 4 bytes.
const args = 'five';
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x00000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -977,7 +978,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const bytesLength = 40;
const args = 'a'.repeat(bytesLength);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000002861616161616161616161616161616161616161616161616161616161616161616161616161616161000000000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
@@ -994,7 +995,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const strLength = 40;
const args = '0x' + 'a'.repeat(strLength);
// Encode Args and validate result
- const encodedArgs = dataType.encode(args);
+ const encodedArgs = dataType.encode(args, encodingRules);
const expectedEncodedArgs =
'0x000000000000000000000000000000000000000000000000000000000000002a30786161616161616161616161616161616161616161616161616161616161616161616161616161616100000000000000000000000000000000000000000000';
expect(encodedArgs).to.be.equal(expectedEncodedArgs);
diff --git a/packages/utils/test/abi_encoder/methods_test.ts b/packages/utils/test/abi_encoder/methods_test.ts
index c870f4f04..837020883 100644
--- a/packages/utils/test/abi_encoder/methods_test.ts
+++ b/packages/utils/test/abi_encoder/methods_test.ts
@@ -10,11 +10,12 @@ chaiSetup.configure();
const expect = chai.expect;
describe('ABI Encoder: Method Encoding / Decoding', () => {
+ const encodingRules: AbiEncoder.EncodingRules = { optimize: false }; // optimizer is tested separately.
it('Types with default widths', async () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.typesWithDefaultWidthsAbi);
const args = [new BigNumber(1), new BigNumber(-1), '0x56', [new BigNumber(1)], [new BigNumber(-1)], ['0x56']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x09f2b0c30000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000015600000000000000000000000000000000000000000000000000000000000000';
@@ -33,7 +34,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
arrayOfTuples.push([new BigNumber(++value), new BigNumber(++value)]);
}
const args = [arrayOfTuples];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x9eb20969000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010';
@@ -52,7 +53,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
arrayOfTuples.push([new BigNumber(++value), new BigNumber(++value)]);
}
const args = [arrayOfTuples];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x63275d6e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010';
@@ -71,7 +72,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
arrayOfTuples.push([new BigNumber(++value), new BigNumber(++value).toString()]);
}
const args = [arrayOfTuples];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0xdeedb00f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000013400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000138000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023136000000000000000000000000000000000000000000000000000000000000';
@@ -90,7 +91,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
arrayOfTuples.push([new BigNumber(++value), new BigNumber(++value).toString()]);
}
const args = [arrayOfTuples];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x60c847fb000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000013400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000138000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023132000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000023136000000000000000000000000000000000000000000000000000000000000';
@@ -112,7 +113,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
[[new BigNumber(++value), new BigNumber(++value)], [new BigNumber(++value), new BigNumber(++value)]],
]);
}
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0xc2f47d6f00000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000d400000000000000000000000000000000000000000000000000000000000000e600000000000000000000000000000000000000000000000000000000000000039000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003d000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000003f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001500000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001d000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000001f000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000230000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000027000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000035000000000000000000000000000000000000000000000000000000000000003600000000000000000000000000000000000000000000000000000000000000370000000000000000000000000000000000000000000000000000000000000038';
@@ -141,7 +142,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
],
]);
}
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x81534ebd0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000137000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000139000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000231320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002313300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000231350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000231370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002313800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023139000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000232300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000023231000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000232320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000232350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002323600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000232370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002323800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002333100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023332000000000000000000000000000000000000000000000000000000000000';
@@ -154,7 +155,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.staticArrayDynamicMembersAbi);
const args = [['Brave', 'New', 'World']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x243a6e6e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
@@ -167,7 +168,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generaet calldata
const method = new AbiEncoder.Method(AbiSamples.staticArrayDynamicMembersAbi);
const args = [['Brave', 'New', 'World']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x243a6e6e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
@@ -180,7 +181,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.dynamicArrayDynamicMembersAbi);
const args = [['Brave', 'New', 'World']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005427261766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034e657700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
@@ -193,7 +194,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.dynamicArrayStaticMembersAbi);
const args = [[new BigNumber(127), new BigNumber(14), new BigNumber(54)]];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x4fc8a83300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000036';
@@ -206,7 +207,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.staticArrayAbi);
const args = [[new BigNumber(127), new BigNumber(14), new BigNumber(54)]];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0xf68ade72000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000036';
@@ -219,7 +220,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.stringAbi);
const args = [['five', 'six', 'seven']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000373697800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005736576656e000000000000000000000000000000000000000000000000000000';
@@ -233,7 +234,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// This is dynamic because it has dynamic members
const method = new AbiEncoder.Method(AbiSamples.staticTupleAbi);
const args = [[new BigNumber(5), new BigNumber(10), new BigNumber(15), false]];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0xa9125e150000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000000';
@@ -247,7 +248,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// This is dynamic because it has dynamic members
const method = new AbiEncoder.Method(AbiSamples.dynamicTupleAbi);
const args = [[new BigNumber(5), 'five']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x5b998f3500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000';
@@ -261,7 +262,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
// This is dynamic because it has dynamic members
const method = new AbiEncoder.Method(AbiSamples.dynamicTupleAbi);
const args = [[new BigNumber(5), 'five']];
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x5b998f3500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046669766500000000000000000000000000000000000000000000000000000000';
@@ -285,7 +286,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
true,
];
// Validate calldata
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
const expectedCalldata =
'0x312d4d42000000000000000000000000000000000000000000000000000000000f4d9feefffffffffffffffffffffffffffffffffffffffffffffffffffffffff0b26012000000000000000000000000000000000000000000000000000000000006a0444300000000000000000000000000000000000000000000000000000000000000000102030405060708091112131415161718192021222324252627282930313200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000180000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f4980000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000003800010203040506070809111213141516171819202122232425262728293031320809111213141516171819202122232425262728293031320000000000000000000000000000000000000000000000000000000000000000000000000000002c4c6974746c65207065746572207069706572207069706564206120706970696e672070657070657220706f740000000000000000000000000000000000000000';
expect(calldata).to.be.equal(expectedCalldata);
@@ -353,7 +354,7 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
someTupleWithDynamicTypes,
someArrayOfTuplesWithDynamicTypes,
};
- const calldata = method.encode(args);
+ const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
'0x4b49031c000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000088000000000000000000000000000000000000000000000000000000000000009800000000000000000000000000000000000000000000000000000000000000ae0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000034746865206c6974746c6520706970696e67207069706572207069706564206120706970696e6720706970706572207061707065720000000000000000000000000000000000000000000000000000000000000000000000000000000000000081746865206b6964206b6e6f777320686f7720746f20777269746520706f656d732c20776861742063616e204920736179202d2d2049206775657373207468657265732061206c6f74204920636f756c642073617920746f2074727920746f2066696c6c2074686973206c696e6520776974682061206c6f74206f6620746578742e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000163874563783498732482743928742389723894723984700000000000000000000000000000000000000000000000000000000000000000000000000000000006e72834723982374239847239847298472489274987489742847289472394874987498478743294237434923473298472398423748923748923748923472389472894789474893742894728947389427498237432987423894723894732894723894372498237498237428934723980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027283473298473248923749238742398742398472894729843278942374982374892374892743982000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000000b736f6d6520737472696e670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013736f6d6520616e6f7468657220737472696e67000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024746865726520617265206a75737420746f6f206d616e7920737472696e6773757020696e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046865726500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002079616c6c2067686f6e6e61206d616b65206d65206c6f7365206d79206d696e640000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000034746865206c6974746c6520706970696e67207069706572207069706564206120706970696e6720706970706572207061707065720000000000000000000000000000000000000000000000000000000000000000000000000000000000000081746865206b6964206b6e6f777320686f7720746f20777269746520706f656d732c20776861742063616e204920736179202d2d2049206775657373207468657265732061206c6f74204920636f756c642073617920746f2074727920746f2066696c6c2074686973206c696e6520776974682061206c6f74206f6620746578742e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0ac511500000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000081746865206b6964206b6e6f777320686f7720746f20777269746520706f656d732c20776861742063616e204920736179202d2d2049206775657373207468657265732061206c6f74204920636f756c642073617920746f2074727920746f2066696c6c2074686973206c696e6520776974682061206c6f74206f6620746578742e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003d69d500000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498000000000000000000000000000000000000000000000000000000000000004e616b64686a61736a6b646861736a6b6c647368646a6168646b6a73616864616a6b73646873616a6b646873616a6b646861646a6b617368646a6b73616468616a6b646873616a6b64687361646a6b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002829384723894723843743289742389472398473289472348927489274894738427428947389facdea0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000089b51500000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000746dafa5ebde1f4699f4981d3221892e41d24895000000000000000000000000000000000000000000000000000000000000004e6b73646873616a6b646873616a6b646861646a6b617368646a6b73616468616a6b646873616a6b64687361646a6b616b64686a61736a6b646861736a6b6c647368646a6168646b6a73616864616a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002829384723894398473289472348927489272384374328974238947274894738427428947389facde100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fa3150000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000089571d322189e415ebde1f4699f498d24246dafa000000000000000000000000000000000000000000000000000000000000004e73646873616a6b646873616a6b646861646a6b617368646a616b64686a61736a6b646861736a6b6c647368646a6168646b6a73616864616a6b6b73616468616a6b646873616a6b64687361646a6b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002838947238437432829384729742389472398473289472348927489274894738427428947389facdef000000000000000000000000000000000000000000000000';
diff --git a/packages/utils/test/abi_encoder/optimizer_test.ts b/packages/utils/test/abi_encoder/optimizer_test.ts
index 27443fe48..18aa6549a 100644
--- a/packages/utils/test/abi_encoder/optimizer_test.ts
+++ b/packages/utils/test/abi_encoder/optimizer_test.ts
@@ -10,6 +10,7 @@ chaiSetup.configure();
const expect = chai.expect;
describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
+ const encodingRules: AbiEncoder.EncodingRules = { optimize: true };
it('Duplicate Dynamic Arrays with Static Elements', async () => {
// Generate calldata
const method = new AbiEncoder.Method(OptimizedAbis.duplicateDynamicArraysWithStaticElements);
@@ -17,7 +18,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const array2 = array1;
const args = [array1, array2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x7221063300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000096';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -32,7 +33,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const array2 = array1;
const args = [array1, array2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0xbb4f12e300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -47,7 +48,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const array2 = array1;
const args = [array1, array2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x7f8130430000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000096';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -64,7 +65,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const array2 = array1;
const args = [array1, array2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x9fe31f8e0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -78,7 +79,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const strings = ['Hello', 'World', 'Hello', 'World'];
const args = [strings];
// Validate calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x13e751a900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -92,7 +93,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple = ['Hello', 'Hello'];
const args = [tuple];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x16780a5e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -109,7 +110,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const method = new AbiEncoder.Method(OptimizedAbis.duplicateStrings);
const args = ['Hello', 'Hello'];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x07370bfa00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -127,7 +128,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const value = '0x01020304050607080910111213141516171819202122232425262728293031323334353637383940';
const args = [value, value];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x6045e42900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002801020304050607080910111213141516171819202122232425262728293031323334353637383940000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -142,7 +143,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple2 = tuple1;
const args = [tuple1, tuple2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x564f826d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000006792a000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -158,7 +159,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple2 = [tuple1[0], new BigNumber(2)];
const args = [tuple1, tuple2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x564f826d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -174,7 +175,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple2 = [array, 'extra argument to prevent exactly matching the tuples'];
const args = [tuple1, tuple2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x18970a9e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000c80000000000000000000000000000000000000000000000000000000000000035657874726120617267756d656e7420746f2070726576656e742065786163746c79206d61746368696e6720746865207475706c65730000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -190,7 +191,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple2 = [nestedTuple, 'extra argument to prevent exactly matching the tuples'];
const args = [tuple1, tuple2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x0b4d2e6a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c6421000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035657874726120617267756d656e7420746f2070726576656e742065786163746c79206d61746368696e6720746865207475706c65730000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -220,7 +221,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const twoDimArray2 = [['Hello', 'World'], ['Bar']];
const args = [twoDimArray1, twoDimArray2];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x0d28c4f900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003466f6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005576f726c640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000034261720000000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -235,7 +236,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const tuple = [[array[0]], [array[1]], [array[2]], [array[3]]];
const args = [array, tuple];
// Validata calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0x5b5c78fd0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000e1';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
@@ -250,7 +251,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
const str = 'Hello';
const args = [array, str];
// Validate calldata
- const optimizedCalldata = method.encode(args, { optimize: true });
+ const optimizedCalldata = method.encode(args, encodingRules);
const expectedOptimizedCalldata =
'0xe0e0d34900000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000005576f726c64000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000';
expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata);
diff --git a/packages/utils/test/abi_encoder/return_values_test.ts b/packages/utils/test/abi_encoder/return_values_test.ts
index 3215509f1..a8cdd6ca3 100644
--- a/packages/utils/test/abi_encoder/return_values_test.ts
+++ b/packages/utils/test/abi_encoder/return_values_test.ts
@@ -10,6 +10,7 @@ chaiSetup.configure();
const expect = chai.expect;
describe('ABI Encoder: Return Value Encoding/Decoding', () => {
+ const encodingRules: AbiEncoder.EncodingRules = { optimize: false }; // optimizer is tested separately.
it('No Return Value', async () => {
// Decode return value
const method = new AbiEncoder.Method(ReturnValueAbis.noReturnValues);
@@ -22,7 +23,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => {
// Generate Return Value
const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue);
const returnValue = ['0x01020304'];
- const encodedReturnValue = method.encodeReturnValues(returnValue);
+ const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules);
const decodedReturnValue = method.decodeReturnValues(encodedReturnValue);
// Validate decoded return value
expect(decodedReturnValue).to.be.deep.equal(returnValue);
@@ -31,7 +32,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => {
// Generate Return Value
const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues);
const returnValue = ['0x01020304', '0x05060708'];
- const encodedReturnValue = method.encodeReturnValues(returnValue);
+ const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules);
const decodedReturnValue = method.decodeReturnValues(encodedReturnValue);
// Validate decoded return value
expect(decodedReturnValue).to.be.deep.equal(returnValue);
@@ -40,7 +41,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => {
// Generate Return Value
const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue);
const returnValue = ['0x01020304'];
- const encodedReturnValue = method.encodeReturnValues(returnValue);
+ const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules);
const decodedReturnValue = method.decodeReturnValues(encodedReturnValue);
// Validate decoded return value
expect(decodedReturnValue).to.be.deep.equal(returnValue);
@@ -49,7 +50,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => {
// Generate Return Value
const method = new AbiEncoder.Method(ReturnValueAbis.multipleDynamicReturnValues);
const returnValue = ['0x01020304', '0x05060708'];
- const encodedReturnValue = method.encodeReturnValues(returnValue);
+ const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules);
const decodedReturnValue = method.decodeReturnValues(encodedReturnValue);
// Validate decoded return value
expect(decodedReturnValue).to.be.deep.equal(returnValue);
@@ -58,7 +59,7 @@ describe('ABI Encoder: Return Value Encoding/Decoding', () => {
// Generate Return Value
const method = new AbiEncoder.Method(ReturnValueAbis.mixedStaticAndDynamicReturnValues);
const returnValue = ['0x01020304', '0x05060708'];
- const encodedReturnValue = method.encodeReturnValues(returnValue);
+ const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules);
const decodedReturnValue = method.decodeReturnValues(encodedReturnValue);
// Validate decoded return value
expect(decodedReturnValue).to.be.deep.equal(returnValue);