Skip to content

Commit

Permalink
fix: Remove bytes conversion (#656)
Browse files Browse the repository at this point in the history
* fix: Remove bytes conversion

* fix: tests

* fix: revert domain order
  • Loading branch information
cyaiox authored Dec 22, 2024
1 parent 173f412 commit 41a09d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/lib/trades.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -182,21 +182,21 @@ 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
}))
},
sent: trade.sent.map(asset => ({
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
}))
}
Expand Down Expand Up @@ -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
}))
})
Expand Down
11 changes: 6 additions & 5 deletions src/lib/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,24 @@ export function generateTradeValues(trade: Omit<TradeCreation, 'signature'>) {
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
}))
},
sent: trade.sent.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'
})),
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
}))
}
Expand Down

0 comments on commit 41a09d8

Please sign in to comment.