Merge pull request #1716 from 0xProject/contracts-asset-proxy/updateProxyId
ERC1155 ProxyId - ERC1155Token -> ERC1155Assets
This commit is contained in:
commit
31568e7abb
@ -26,7 +26,7 @@ contract ERC1155Proxy is
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Id of this proxy.
|
// Id of this proxy.
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Token(address,uint256[],uint256[],bytes)"));
|
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Assets(address,uint256[],uint256[],bytes)"));
|
||||||
|
|
||||||
function ()
|
function ()
|
||||||
external
|
external
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
web3Wrapper,
|
web3Wrapper,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { RevertReason } from '@0x/types';
|
import { AssetProxyId, RevertReason } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
@ -123,8 +123,7 @@ describe('ERC1155Proxy', () => {
|
|||||||
});
|
});
|
||||||
it('should have an id of 0x9645780d', async () => {
|
it('should have an id of 0x9645780d', async () => {
|
||||||
const proxyId = await erc1155Proxy.getProxyId.callAsync();
|
const proxyId = await erc1155Proxy.getProxyId.callAsync();
|
||||||
// proxy computed using -- bytes4(keccak256("erc1155Token(address,uint256[],uint256[],bytes)"));
|
const expectedProxyId = AssetProxyId.ERC1155;
|
||||||
const expectedProxyId = '0x9645780d';
|
|
||||||
expect(proxyId).to.equal(expectedProxyId);
|
expect(proxyId).to.equal(expectedProxyId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"pr": 1705
|
"pr": 1705
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"note": "Added encoding/decoding fdor ERC1155 asset data",
|
"note": "Added encoding/decoding for ERC1155 asset data",
|
||||||
"pr": 1661
|
"pr": 1661
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -91,7 +91,7 @@ export const assetDataUtils = {
|
|||||||
tokenValues: BigNumber[],
|
tokenValues: BigNumber[],
|
||||||
callbackData: string,
|
callbackData: string,
|
||||||
): string {
|
): string {
|
||||||
const abiEncoder = AbiEncoder.createMethod('ERC1155Token', ERC1155AssetDataAbi);
|
const abiEncoder = AbiEncoder.createMethod('ERC1155Assets', ERC1155AssetDataAbi);
|
||||||
const args = [tokenAddress, tokenIds, tokenValues, callbackData];
|
const args = [tokenAddress, tokenIds, tokenValues, callbackData];
|
||||||
const assetData = abiEncoder.encode(args, encodingRules);
|
const assetData = abiEncoder.encode(args, encodingRules);
|
||||||
return assetData;
|
return assetData;
|
||||||
@ -106,7 +106,7 @@ export const assetDataUtils = {
|
|||||||
if (assetProxyId !== AssetProxyId.ERC1155) {
|
if (assetProxyId !== AssetProxyId.ERC1155) {
|
||||||
throw new Error(`Invalid assetProxyId. Expected '${AssetProxyId.ERC1155}', got '${assetProxyId}'`);
|
throw new Error(`Invalid assetProxyId. Expected '${AssetProxyId.ERC1155}', got '${assetProxyId}'`);
|
||||||
}
|
}
|
||||||
const abiEncoder = AbiEncoder.createMethod('ERC1155Token', ERC1155AssetDataAbi);
|
const abiEncoder = AbiEncoder.createMethod('ERC1155Assets', ERC1155AssetDataAbi);
|
||||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||||
const decodedAssetData = abiEncoder.decode(assetData, decodingRules) as ERC1155AssetDataNoProxyId;
|
const decodedAssetData = abiEncoder.decode(assetData, decodingRules) as ERC1155AssetDataNoProxyId;
|
||||||
return {
|
return {
|
||||||
|
@ -27,7 +27,7 @@ const KNOWN_ERC1155_ENCODING = {
|
|||||||
callbackData:
|
callbackData:
|
||||||
'0x025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000001',
|
'0x025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000001',
|
||||||
assetData:
|
assetData:
|
||||||
'0x9645780d0000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000003e90000000000000000000000000000000000000000000000000000000000002711000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000007d10000000000000000000000000000000000000000000000000000000000004e210000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000',
|
'0xa7cb5fb70000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000003e90000000000000000000000000000000000000000000000000000000000002711000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000007d10000000000000000000000000000000000000000000000000000000000004e210000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000',
|
||||||
};
|
};
|
||||||
const KNOWN_MULTI_ASSET_ENCODING = {
|
const KNOWN_MULTI_ASSET_ENCODING = {
|
||||||
amounts: [new BigNumber(70), new BigNumber(1), new BigNumber(18)],
|
amounts: [new BigNumber(70), new BigNumber(1), new BigNumber(18)],
|
||||||
@ -37,7 +37,7 @@ const KNOWN_MULTI_ASSET_ENCODING = {
|
|||||||
KNOWN_ERC1155_ENCODING.assetData,
|
KNOWN_ERC1155_ENCODING.assetData,
|
||||||
],
|
],
|
||||||
assetData:
|
assetData:
|
||||||
'0x94cfcdd7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000024f47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c4800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002049645780d0000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000003e90000000000000000000000000000000000000000000000000000000000002711000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000007d10000000000000000000000000000000000000000000000000000000000004e210000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c4800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
'0x94cfcdd7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000024f47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000204a7cb5fb70000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c480000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000003e90000000000000000000000000000000000000000000000000000000000002711000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000007d10000000000000000000000000000000000000000000000000000000000004e210000000000000000000000000000000000000000000000000000000000000044025717920000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c4800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('assetDataUtils', () => {
|
describe('assetDataUtils', () => {
|
||||||
|
@ -163,7 +163,7 @@ export enum AssetProxyId {
|
|||||||
ERC20 = '0xf47261b0',
|
ERC20 = '0xf47261b0',
|
||||||
ERC721 = '0x02571792',
|
ERC721 = '0x02571792',
|
||||||
MultiAsset = '0x94cfcdd7',
|
MultiAsset = '0x94cfcdd7',
|
||||||
ERC1155 = '0x9645780d',
|
ERC1155 = '0xa7cb5fb7',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ERC20AssetData {
|
export interface ERC20AssetData {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user