fix: tada withdrawal failure caused due to strict conditions#8186
fix: tada withdrawal failure caused due to strict conditions#8186
Conversation
f35f20b to
19938af
Compare
19938af to
3661c2b
Compare
| if (recipient.address === output.address && recipient.amount === output.amount) { | ||
| if ( | ||
| recipient.address === output.address && | ||
| (recipient.amount === 'max' || BigInt(output.amount) >= BigInt(recipient.amount)) |
There was a problem hiding this comment.
recipient.amount is the withdrawal amount. Max is a flag that we use internally to find out if it is a max withdrawal. amount can never be max. Please remove this condition
| if (recipient.address === output.address && recipient.amount === output.amount) { | ||
| if ( | ||
| recipient.address === output.address && | ||
| (recipient.amount === 'max' || BigInt(output.amount) >= BigInt(recipient.amount)) |
There was a problem hiding this comment.
BigInt(output.amount) >= BigInt(recipient.amount) this condition will allow withdrawals exceeding the expected amount and will not flag any buggy behaviour in build. As the issue is with the fee address deposits from the same enterprise as the fee address, let's check if the certs from the tx is 2 (one for sender and the other for gas tank), if so, BigInt(output.amount) >= BigInt(recipient.amount) can be validated
| const multiAssets = output.multiAssets as CardanoWasm.MultiAsset; | ||
| const tokenQty = multiAssets.get_asset(policyScriptHash, assetName); | ||
| return tokenQty && tokenQty.to_str() === recipient.amount; | ||
| return tokenQty && (recipient.amount === 'max' || BigInt(tokenQty.to_str()) >= BigInt(recipient.amount)); |
There was a problem hiding this comment.
Given the issue is with the fee address deposits which does not include tokens, this change is not required
| }); | ||
|
|
||
| it('should succeed when recipient amount is max', async () => { | ||
| const txPrebuild = newTxPrebuild(); |
There was a problem hiding this comment.
Please fix/add test cases with new changes
TICKET: CSHLD-34