Closed gregdhill closed 1 year ago
Separated into another ticket https://github.com/interlay/interbtc-ui/issues/1240 Related: it'd be a good idea to dry-run in advance to get quick feedback on failing transactions. I made this PoC about a year ago:
let request_redeem = api.tx.redeem.requestRedeem(2000, {P2WPKHv0: '0x01197bcaf42e278fcca2b55275cd64b25d240e7c'}, vault_id);
const transactionAPI = new DefaultTransactionAPI(api, userKeyring);
let myNonce = await api.rpc.system.accountNextIndex(userKeyring.address);
const signed = request_redeem.sign(userKeyring, { nonce: myNonce});
const result = await signed.dryRun(transactionAPI.getAccount()!);
// A technically valid but failing transaction returns Ok(Err(...))
const resultOk = result.isOk && result.asOk.isOk;
console.log("isOk", resultOk);
And you can get the fees with
const paymentInfo = await signed.paymentInfo(transactionAPI.getAccount()!);
console.log("fee", paymentInfo.partialFee.toNumber());
This ticket's scope was reduced and dry-running should be added separately https://github.com/interlay/interbtc-ui/issues/1240
Running Lighthouse audit...
Use https://polkadot.js.org/docs/api/cookbook/tx/#how-do-i-estimate-the-transaction-fees