diff --git a/src/lib/trades.spec.ts b/src/lib/trades.spec.ts index 29d324ed..566e76ee 100644 --- a/src/lib/trades.spec.ts +++ b/src/lib/trades.spec.ts @@ -166,8 +166,8 @@ describe('when getting the trade signature', () => { domain = { name: offchainMarketplaceContract.name, version: offchainMarketplaceContract.version, - salt: SALT, - verifyingContract: offchainMarketplaceContract.address + verifyingContract: offchainMarketplaceContract.address, + salt: SALT } values = { @@ -182,7 +182,7 @@ describe('when getting the trade signature', () => { externalChecks: trade.checks.externalChecks?.map(externalCheck => ({ contractAddress: externalCheck.contractAddress, selector: externalCheck.selector, - value: externalCheck.value, + value: '0x', required: externalCheck.required })) }, @@ -190,13 +190,13 @@ describe('when getting the trade signature', () => { assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)) + extra: '0x' })), received: trade.received.map(asset => ({ assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)), + extra: '0x', beneficiary: asset.beneficiary })) } @@ -274,14 +274,14 @@ describe('when getting the trade to accept', () => { assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)), + extra: '0x', beneficiary: beneficiaryAddress })), received: trade.received.map(asset => ({ assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)), + extra: '0x', beneficiary: asset.beneficiary })) }) diff --git a/src/lib/trades.ts b/src/lib/trades.ts index 094e3ff9..57b22a81 100644 --- a/src/lib/trades.ts +++ b/src/lib/trades.ts @@ -97,9 +97,8 @@ export function generateTradeValues(trade: Omit) { externalChecks: trade.checks.externalChecks?.map(externalCheck => ({ contractAddress: externalCheck.contractAddress, selector: externalCheck.selector, - value: ethers.utils.hexlify( - ethers.utils.toUtf8Bytes(externalCheck.value) - ), + // '0x' is the default value for value bytes (0 bytes) + value: externalCheck.value ? externalCheck.value : '0x', required: externalCheck.required })) }, @@ -107,13 +106,15 @@ export function generateTradeValues(trade: Omit) { assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)) + // '0x' is the default value for value bytes (0 bytes) + extra: asset.extra ? asset.extra : '0x' })), received: trade.received.map(asset => ({ assetType: asset.assetType, contractAddress: asset.contractAddress, value: getValueForTradeAsset(asset), - extra: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(asset.extra)), + // '0x' is the default value for value bytes (0 bytes) + extra: asset.extra ? asset.extra : '0x', beneficiary: asset.beneficiary })) }