diff --git a/packages/marketplace/test/utils/assets.ts b/packages/marketplace/test/utils/assets.ts index 4629c79077..2703999e3e 100644 --- a/packages/marketplace/test/utils/assets.ts +++ b/packages/marketplace/test/utils/assets.ts @@ -108,66 +108,23 @@ export const AssetERC1155 = async ( value: value, }); -export const AssetBundle = async ( - erc20: {token: Contract; value: Numeric}[], - erc721: { - token: Contract; - tokenId: Numeric; - }[], - erc1155: { - token: Contract; - tokenId: Numeric; - value: Numeric; - }[] -): Promise => { - const erc20Details = []; - for (const x of erc20) { - erc20Details.push([await x.token.getAddress(), x.value]); - } - const erc721Details = []; - for (const x of erc721) { - erc721Details.push([ - await x.token.getAddress(), - x.tokenId, - // TODO: Test value !=1 - 1, - ]); - } - const erc1155Details = []; - for (const x of erc1155) { - erc1155Details.push([await x.token.getAddress(), x.tokenId, x.value]); - } - return { - assetType: { - assetClass: BUNDLE_ASSET_CLASS, - data: AbiCoder.defaultAbiCoder().encode( - [ - 'tuple(address, uint256)[]', - 'tuple(address, uint256, uint256)[]', - 'tuple(address, uint256, uint256)[]', - ], - [erc20Details, erc721Details, erc1155Details] - ), - }, - // TODO: It make sense tho have multipler bundles >1 ???? - value: 1, - }; -}; - export function hashAssetType(a: AssetType) { if (a.assetClass === AssetClassType.INVALID_ASSET_CLASS) { throw new Error('Invalid assetClass' + a.assetClass); } - // There is aproblem with solidityPackedKeccak256 and byte4 => a.assetClass + '0'.repeat(56) - return solidityPackedKeccak256( - ['bytes32', 'uint256', 'bytes32'], - [ASSET_TYPE_TYPEHASH, a.assetClass, keccak256(a.data)] + return keccak256( + AbiCoder.defaultAbiCoder().encode( + ['bytes32', 'uint256', 'bytes32'], + [ASSET_TYPE_TYPEHASH, a.assetClass, keccak256(a.data)] + ) ); } export function hashAsset(a: Asset) { - return solidityPackedKeccak256( - ['bytes32', 'bytes32', 'uint256'], - [ASSET_TYPEHASH, hashAssetType(a.assetType), a.value] + return keccak256( + AbiCoder.defaultAbiCoder().encode( + ['bytes32', 'bytes32', 'uint256'], + [ASSET_TYPEHASH, hashAssetType(a.assetType), a.value] + ) ); }