Skip to content

Commit

Permalink
fix: Incorrectly building trade byte parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Dec 21, 2024
1 parent 94f3ceb commit d77d014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions webapp/src/utils/trades.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,21 @@ describe('when getting the trade signature', () => {
externalChecks: trade.checks.externalChecks?.map(externalCheck => ({
contractAddress: externalCheck.contractAddress,
selector: externalCheck.selector,
value: externalCheck.value,
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))
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)),
extra: asset.extra ? asset.extra : '0x',
beneficiary: asset.beneficiary
}))
}
Expand Down Expand Up @@ -199,15 +199,15 @@ describe('when getting the trade to accept', () => {
assetType: TradeAssetType.ERC20,
contractAddress: '0x123',
amount: '2',
extra: ''
extra: '0x'
}
],
received: [
{
assetType: TradeAssetType.ERC721,
contractAddress: '0x123',
tokenId: '1',
extra: '',
extra: '0x',
beneficiary: '0x123123'
}
]
Expand Down Expand Up @@ -235,14 +235,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: asset.extra ? asset.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: asset.extra ? asset.extra : '0x',
beneficiary: asset.beneficiary
}))
})
Expand Down
9 changes: 6 additions & 3 deletions webapp/src/utils/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,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 extra 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 extra bytes (0 bytes)
extra: asset.extra ? asset.extra : '0x',
beneficiary: asset.beneficiary
}))
}
Expand Down

0 comments on commit d77d014

Please sign in to comment.