forked from tornadocash/tornado-cli
Improve withdrawal confirmation tables
This commit is contained in:
parent
0a305433ba
commit
4512834388
42
dist/cli.js
vendored
42
dist/cli.js
vendored
@ -188082,18 +188082,39 @@ Connected with Tovarish Relayer ${(_a = tovarishClient.selectedRelayer) == null
|
||||
({ fee, refund, proof, args } = yield getProof());
|
||||
yield TornadoProxy.withdraw.estimateGas(instanceAddress, proof, ...args, withdrawOverrides);
|
||||
}
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth ? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals) : BigInt(0);
|
||||
const txFeeString = !isEth ? `( ${Number(formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth )( ${(Number(formatUnits(txFeeInToken, decimals)) / Number(amount) * 100).toFixed(5)}% )` : `( ${(Number(formatUnits(txFee, decimals)) / Number(amount) * 100).toFixed(5)}% )`;
|
||||
const withdrawTable = new (cli_table3_default())();
|
||||
withdrawTable.push([{ colSpan: 2, content: "Withdrawal Info", hAlign: "center" }]);
|
||||
if (!walletWithdrawal) {
|
||||
withdrawTable.push(
|
||||
[{ colSpan: 2, content: "Withdraw", hAlign: "center" }],
|
||||
["Withdrawal", `${amount} ${currency.toUpperCase()}`],
|
||||
["Relayer", `${(_c = relayerClient == null ? void 0 : relayerClient.selectedRelayer) == null ? void 0 : _c.url}`],
|
||||
[{ colSpan: 2, content: "Withdrawal Info", hAlign: "center" }],
|
||||
[
|
||||
"Deposit Date",
|
||||
`${depositDate.toLocaleDateString()} ${depositDate.toLocaleTimeString()} (${moment_default().unix(depositEvent.timestamp).fromNow()})`
|
||||
],
|
||||
["From", depositEvent.from],
|
||||
["Deposit Transaction", depositEvent.transactionHash],
|
||||
["Commitment", depositEvent.commitment],
|
||||
["Gas Price", `${formatUnits(gasPrice, "gwei")} gwei`],
|
||||
["Gas Limit", gasLimit],
|
||||
[
|
||||
"Transaction Fee",
|
||||
`${Number(formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ${txFeeString}`
|
||||
]
|
||||
);
|
||||
if (!walletWithdrawal) {
|
||||
const relayerFeePercent = Number((_c = relayerClient == null ? void 0 : relayerClient.selectedRelayer) == null ? void 0 : _c.tornadoServiceFee) || 0;
|
||||
const relayerFee = BigInt(denomination) * BigInt(Math.floor(1e4 * relayerFeePercent)) / BigInt(1e4 * 100);
|
||||
withdrawTable.push(
|
||||
["Relayer", `${(_d = relayerClient == null ? void 0 : relayerClient.selectedRelayer) == null ? void 0 : _d.url}`],
|
||||
[
|
||||
"Relayer Fee",
|
||||
`${formatUnits(relayerFee, decimals)} ${currency.toUpperCase()} ( ${relayerFeePercent}% )`
|
||||
],
|
||||
[
|
||||
"Total Fee",
|
||||
`${formatUnits(fee, decimals)} ${currency.toUpperCase()} ( ${(Number(fee) / Number(denomination) * 100).toFixed(5)}% )`
|
||||
],
|
||||
["Relayer Fee Percent", `${(_d = relayerClient == null ? void 0 : relayerClient.selectedRelayer) == null ? void 0 : _d.tornadoServiceFee}%`],
|
||||
[
|
||||
"Amount to receive",
|
||||
`${Number(formatUnits(denomination - fee, decimals)).toFixed(5)} ${currency.toUpperCase()}`
|
||||
@ -188111,17 +188132,8 @@ Connected with Tovarish Relayer ${(_a = tovarishClient.selectedRelayer) == null
|
||||
args
|
||||
});
|
||||
} else {
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth ? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals) : BigInt(0);
|
||||
const txFeeString = !isEth ? `(${Number(formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth) (${(Number(formatUnits(txFeeInToken, decimals)) / Number(amount) * 100).toFixed(5)}%)` : `(${(Number(formatUnits(txFee, decimals)) / Number(amount) * 100).toFixed(5)}%)`;
|
||||
withdrawTable.push(
|
||||
[{ colSpan: 2, content: "Withdraw", hAlign: "center" }],
|
||||
["Withdrawal", `${amount} ${currency.toUpperCase()}`],
|
||||
["Signer", `${signer == null ? void 0 : signer.address}`],
|
||||
[
|
||||
"Transaction Fee",
|
||||
`${Number(formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ` + txFeeString
|
||||
],
|
||||
["Amount to receive", `${amount} ${currency.toUpperCase()}`],
|
||||
["To", recipient],
|
||||
["Nullifier", nullifierHex]
|
||||
|
@ -1204,21 +1204,50 @@ export function tornadoProgram() {
|
||||
await TornadoProxy.withdraw.estimateGas(instanceAddress, proof, ...args, withdrawOverrides);
|
||||
}
|
||||
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth
|
||||
? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals)
|
||||
: BigInt(0);
|
||||
const txFeeString = !isEth
|
||||
? `( ${Number(formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth )` +
|
||||
`( ${((Number(formatUnits(txFeeInToken, decimals)) / Number(amount)) * 100).toFixed(5)}% )`
|
||||
: `( ${((Number(formatUnits(txFee, decimals)) / Number(amount)) * 100).toFixed(5)}% )`;
|
||||
|
||||
const withdrawTable = new Table();
|
||||
withdrawTable.push([{ colSpan: 2, content: 'Withdrawal Info', hAlign: 'center' }]);
|
||||
withdrawTable.push(
|
||||
[{ colSpan: 2, content: 'Withdrawal Info', hAlign: 'center' }],
|
||||
[
|
||||
'Deposit Date',
|
||||
`${depositDate.toLocaleDateString()} ${depositDate.toLocaleTimeString()} (${moment.unix(depositEvent.timestamp).fromNow()})`,
|
||||
],
|
||||
['From', depositEvent.from],
|
||||
['Deposit Transaction', depositEvent.transactionHash],
|
||||
['Commitment', depositEvent.commitment],
|
||||
['Gas Price', `${formatUnits(gasPrice, 'gwei')} gwei`],
|
||||
['Gas Limit', gasLimit],
|
||||
[
|
||||
'Transaction Fee',
|
||||
`${Number(formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ${txFeeString}`,
|
||||
],
|
||||
);
|
||||
|
||||
// withdraw using relayer
|
||||
if (!walletWithdrawal) {
|
||||
const relayerFeePercent = Number(relayerClient?.selectedRelayer?.tornadoServiceFee) || 0;
|
||||
const relayerFee =
|
||||
(BigInt(denomination) * BigInt(Math.floor(10000 * relayerFeePercent))) / BigInt(10000 * 100);
|
||||
|
||||
withdrawTable.push(
|
||||
[{ colSpan: 2, content: 'Withdraw', hAlign: 'center' }],
|
||||
['Withdrawal', `${amount} ${currency.toUpperCase()}`],
|
||||
['Relayer', `${relayerClient?.selectedRelayer?.url}`],
|
||||
[
|
||||
'Relayer Fee',
|
||||
`${formatUnits(relayerFee, decimals)} ${currency.toUpperCase()} ` + `( ${relayerFeePercent}% )`,
|
||||
],
|
||||
[
|
||||
'Total Fee',
|
||||
`${formatUnits(fee, decimals)} ${currency.toUpperCase()} ` +
|
||||
`( ${((Number(fee) / Number(denomination)) * 100).toFixed(5)}% )`,
|
||||
],
|
||||
['Relayer Fee Percent', `${relayerClient?.selectedRelayer?.tornadoServiceFee}%`],
|
||||
[
|
||||
'Amount to receive',
|
||||
`${Number(formatUnits(denomination - fee, decimals)).toFixed(5)} ${currency.toUpperCase()}`,
|
||||
@ -1241,24 +1270,8 @@ export function tornadoProgram() {
|
||||
});
|
||||
} else {
|
||||
// withdraw from wallet
|
||||
|
||||
const txFee = gasPrice * gasLimit;
|
||||
const txFeeInToken = !isEth
|
||||
? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals)
|
||||
: BigInt(0);
|
||||
const txFeeString = !isEth
|
||||
? `(${Number(formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth) ` +
|
||||
`(${((Number(formatUnits(txFeeInToken, decimals)) / Number(amount)) * 100).toFixed(5)}%)`
|
||||
: `(${((Number(formatUnits(txFee, decimals)) / Number(amount)) * 100).toFixed(5)}%)`;
|
||||
|
||||
withdrawTable.push(
|
||||
[{ colSpan: 2, content: 'Withdraw', hAlign: 'center' }],
|
||||
['Withdrawal', `${amount} ${currency.toUpperCase()}`],
|
||||
['Signer', `${signer?.address}`],
|
||||
[
|
||||
'Transaction Fee',
|
||||
`${Number(formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ` + txFeeString,
|
||||
],
|
||||
['Amount to receive', `${amount} ${currency.toUpperCase()}`],
|
||||
['To', recipient],
|
||||
['Nullifier', nullifierHex],
|
||||
|
Loading…
Reference in New Issue
Block a user