From 354f7053dc3f322412da64460ae8295a6076b3e0 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 30 Nov 2018 15:35:48 -0800 Subject: Use new AbiEncoder, add logic for encoding/decoding MultiAsset assetData --- packages/order-utils/src/constants.ts | 58 ++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'packages/order-utils/src/constants.ts') diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts index 10029dcc3..be7f3a885 100644 --- a/packages/order-utils/src/constants.ts +++ b/packages/order-utils/src/constants.ts @@ -7,10 +7,10 @@ export const constants = { UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1), TESTRPC_NETWORK_ID: 50, ADDRESS_LENGTH: 20, - ERC20_ASSET_DATA_BYTE_LENGTH: 36, - ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH: 53, - SELECTOR_LENGTH: 4, - BASE_16: 16, + ERC20_ASSET_DATA_MIN_CHAR_LENGTH_WITH_PREFIX: 74, + ERC721_ASSET_DATA_MIN_CHAR_LENGTH_WITH_PREFIX: 136, + MULTI_ASSET_DATA_MIN_CHAR_LENGTH_WITH_PREFIX: 266, + SELECTOR_CHAR_LENGTH_WITH_PREFIX: 10, INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite ZERO_AMOUNT: new BigNumber(0), EIP712_DOMAIN_NAME: '0x Protocol', @@ -48,4 +48,54 @@ export const constants = { { name: 'data', type: 'bytes' }, ], }, + ERC20_METHOD_ABI: { + constant: false, + inputs: [ + { + name: 'tokenContract', + type: 'address', + }, + ], + name: 'ERC20Token', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + ERC721_METHOD_ABI: { + constant: false, + inputs: [ + { + name: 'tokenContract', + type: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'ERC721Token', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + MULTI_ASSET_METHOD_ABI: { + constant: false, + inputs: [ + { + name: 'amounts', + type: 'uint256[]', + }, + { + name: 'nestedAssetData', + type: 'bytes[]', + }, + ], + name: 'MultiAsset', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, }; -- cgit v1.2.3 From 5720589515d321e2d2db87c8337ee3f6340a0ef8 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Thu, 3 Jan 2019 11:18:33 -0800 Subject: Add tests for recursive MAP decoding --- packages/order-utils/src/constants.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/order-utils/src/constants.ts') diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts index be7f3a885..1248a5576 100644 --- a/packages/order-utils/src/constants.ts +++ b/packages/order-utils/src/constants.ts @@ -3,6 +3,7 @@ import { BigNumber } from '@0x/utils'; export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', NULL_BYTES: '0x', + NULL_ERC20_ASSET_DATA: '0xf47261b00000000000000000000000000000000000000000000000000000000000000000', // tslint:disable-next-line:custom-no-magic-numbers UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1), TESTRPC_NETWORK_ID: 50, -- cgit v1.2.3 From 24564b986daa703f66e54f85abf4782d99a40f94 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Fri, 4 Jan 2019 14:31:25 -0800 Subject: Minimize unnecessary type assertions --- packages/order-utils/src/constants.ts | 107 ++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'packages/order-utils/src/constants.ts') diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts index 1248a5576..a9a687719 100644 --- a/packages/order-utils/src/constants.ts +++ b/packages/order-utils/src/constants.ts @@ -1,4 +1,58 @@ import { BigNumber } from '@0x/utils'; +import { MethodAbi } from 'ethereum-types'; + +const ERC20_METHOD_ABI: MethodAbi = { + constant: false, + inputs: [ + { + name: 'tokenContract', + type: 'address', + }, + ], + name: 'ERC20Token', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', +}; + +const ERC721_METHOD_ABI: MethodAbi = { + constant: false, + inputs: [ + { + name: 'tokenContract', + type: 'address', + }, + { + name: 'tokenId', + type: 'uint256', + }, + ], + name: 'ERC721Token', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', +}; + +const MULTI_ASSET_METHOD_ABI: MethodAbi = { + constant: false, + inputs: [ + { + name: 'amounts', + type: 'uint256[]', + }, + { + name: 'nestedAssetData', + type: 'bytes[]', + }, + ], + name: 'MultiAsset', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', +}; export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', @@ -49,54 +103,7 @@ export const constants = { { name: 'data', type: 'bytes' }, ], }, - ERC20_METHOD_ABI: { - constant: false, - inputs: [ - { - name: 'tokenContract', - type: 'address', - }, - ], - name: 'ERC20Token', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - ERC721_METHOD_ABI: { - constant: false, - inputs: [ - { - name: 'tokenContract', - type: 'address', - }, - { - name: 'tokenId', - type: 'uint256', - }, - ], - name: 'ERC721Token', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, - MULTI_ASSET_METHOD_ABI: { - constant: false, - inputs: [ - { - name: 'amounts', - type: 'uint256[]', - }, - { - name: 'nestedAssetData', - type: 'bytes[]', - }, - ], - name: 'MultiAsset', - outputs: [], - payable: false, - stateMutability: 'nonpayable', - type: 'function', - }, + ERC20_METHOD_ABI, + ERC721_METHOD_ABI, + MULTI_ASSET_METHOD_ABI, }; -- cgit v1.2.3