Skip to content

Commit 951cdb6

Browse files
feat: warn before sending transactions with fees
1 parent 199b457 commit 951cdb6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Spinner } from './spinner.js';
2+
import { askForAcknowledgment } from './askForAcknowledgment.js';
3+
4+
export async function warnBeforeTxFees({
5+
spinner,
6+
chain,
7+
}: {
8+
spinner: Spinner;
9+
chain: string;
10+
}): Promise<void> {
11+
if (chain !== 'bellecour') {
12+
await askForAcknowledgment({
13+
spinner,
14+
message:
15+
'This method requires sending blockchain transactions, transaction fees may be applied. Would you like to continue?',
16+
});
17+
}
18+
}

cli/src/cmd/deploy.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { addDeploymentData } from '../utils/cacheExecutions.js';
2323
import { deployTdxApp, getIExecTdx } from '../utils/tdx-poc.js';
2424
import { useTdx } from '../utils/featureFlags.js';
2525
import { ensureBalances } from '../cli-helpers/ensureBalances.js';
26+
import { warnBeforeTxFees } from '../cli-helpers/warnBeforeTxFees.js';
2627

2728
export async function deploy({ chain }: { chain?: string }) {
2829
const spinner = getSpinner();
@@ -32,6 +33,7 @@ export async function deploy({ chain }: { chain?: string }) {
3233
const chainName = chain || defaultChain;
3334
const chainConfig = getChainConfig(chainName);
3435
spinner.info(`Using chain ${chainName}`);
36+
await warnBeforeTxFees({ spinner, chain: chainConfig.name });
3537

3638
const signer = await askForWallet({ spinner });
3739
const userAddress = await signer.getAddress();

cli/src/cmd/run.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { getIExecTdx, WORKERPOOL_TDX } from '../utils/tdx-poc.js';
2222
import { useTdx } from '../utils/featureFlags.js';
2323
import { ensureBalances } from '../cli-helpers/ensureBalances.js';
2424
import { askForAcknowledgment } from '../cli-helpers/askForAcknowledgment.js';
25+
import { warnBeforeTxFees } from '../cli-helpers/warnBeforeTxFees.js';
2526

2627
export async function run({
2728
iAppAddress,
@@ -77,6 +78,7 @@ export async function runInDebug({
7778
const chainName = chain || defaultChain;
7879
const chainConfig = getChainConfig(chainName);
7980
spinner.info(`Using chain ${chainName}`);
81+
await warnBeforeTxFees({ spinner, chain: chainConfig.name });
8082

8183
// Is valid iApp address
8284
if (!ethers.isAddress(iAppAddress)) {

0 commit comments

Comments
 (0)