diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-01 07:12:56 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-01 07:12:56 +0800 |
commit | f0473b03207da4d25139967702d47d44e00d499c (patch) | |
tree | 0a3bf19119c47e3a90afb83f8182e017021fba2e /packages | |
parent | fcc627e6e1b99cd9536fc7b97b45e61897ee11b6 (diff) | |
download | dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar.gz dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar.bz2 dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar.lz dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar.xz dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.tar.zst dexon-sol-tools-f0473b03207da4d25139967702d47d44e00d499c.zip |
Fix metadata offsets
Diffstat (limited to 'packages')
-rw-r--r-- | packages/order-utils/src/asset_proxy_utils.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/order-utils/src/asset_proxy_utils.ts b/packages/order-utils/src/asset_proxy_utils.ts index 5a084deba..55f2d56df 100644 --- a/packages/order-utils/src/asset_proxy_utils.ts +++ b/packages/order-utils/src/asset_proxy_utils.ts @@ -3,8 +3,8 @@ import { BigNumber } from '@0xproject/utils'; import BN = require('bn.js'); import ethUtil = require('ethereumjs-util'); -const ERC20_PROXY_METADATA_BYTE_LENGTH = 20; -const ERC721_PROXY_METADATA_BYTE_LENGTH = 52; +const ERC20_PROXY_METADATA_BYTE_LENGTH = 21; +const ERC721_PROXY_METADATA_BYTE_LENGTH = 53; export const assetProxyUtils = { encodeAssetProxyId(assetProxyId: AssetProxyId): Buffer { @@ -65,7 +65,8 @@ export const assetProxyUtils = { }), but got ${assetProxyId}`, ); } - const encodedTokenAddress = encodedProxyMetadata.slice(0, ERC20_PROXY_METADATA_BYTE_LENGTH); + const addressOffset = ERC20_PROXY_METADATA_BYTE_LENGTH - 1; + const encodedTokenAddress = encodedProxyMetadata.slice(0, addressOffset); const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress); const erc20ProxyData = { assetProxyId, @@ -99,10 +100,11 @@ export const assetProxyUtils = { }), but got ${assetProxyId}`, ); } - const addressOffset = 20; + const addressOffset = ERC20_PROXY_METADATA_BYTE_LENGTH - 1; const encodedTokenAddress = encodedProxyMetadata.slice(0, addressOffset); const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress); - const encodedTokenId = encodedProxyMetadata.slice(addressOffset, ERC721_PROXY_METADATA_BYTE_LENGTH); + const tokenIdOffset = ERC721_PROXY_METADATA_BYTE_LENGTH - 1; + const encodedTokenId = encodedProxyMetadata.slice(addressOffset, tokenIdOffset); const tokenId = assetProxyUtils.decodeUint256(encodedTokenId); const erc721ProxyData = { assetProxyId, |