Fix/pre simulation#180
Conversation
alexshchur
commented
Mar 17, 2026
- add preliminary simulation for "non-encrypted" txs: shield, claim, unshield
-
- disable "write contract" button if simulation fails
- as for the txs that do contain encrypted inputs (e.g. send) - we can't simulate them preliminarily, because we only encrypt at the time of writing
…hield, claim, unshield)
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
…DO: apply the same to unshield and claim flows)
…ed after approval yet
architect-dev
left a comment
There was a problem hiding this comment.
Couple small requests
| return getCofheTokenShieldCallArgs({ token, amount: amountWei, account }).main; | ||
| }, [account, isValidShieldAmount, shieldAmount, token]); | ||
|
|
||
| const shieldSimulation = useCofheSimulateWriteContract(shieldCallArgs, { |
There was a problem hiding this comment.
If this function doesn't involve encrypting any inputs, can we use the standard viem simulation instead of a custom version?
There was a problem hiding this comment.
We do use standard viem simulation. It's exposed as a method, not as a hook, though.
We need the simulation results in the render function, hence we either need our own small hook or use wagmi (we don't currently have wagmi in the react package)
| } | ||
|
|
||
| // Dual tokens: unshield takes uint64 | ||
| const amount = BigInt.asUintN(64, rawAmount); |
There was a problem hiding this comment.
I'm not familiar with this pattern. What happens if rawAmount is outside the range for a uint64?
There was a problem hiding this comment.
it was first introduced here. I reused the existing code
if keeps the low 64 bits, so if it overflows, it'll start over, i.e. 2^64+777 -> 777
now that it caught attention, maybe instead of such a conversion we need to check if it's within the range and then throw error?
…ixProtocol/cofhesdk into fix/pre-simulation
…l/cofhesdk into fix/decouple-approval-on-shield
…shield feat: decouple approval tx from shield tx