38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Address, toNano } from '@ton/core';
|
|
import { Vault } from '../wrappers/Vault';
|
|
import { NetworkProvider, sleep } from '@ton/blueprint';
|
|
|
|
export async function run(provider: NetworkProvider, args: string[]) {
|
|
const ui = provider.ui();
|
|
|
|
const address = Address.parse(args.length > 0 ? args[0] : await ui.input('Vault address'));
|
|
|
|
if (!(await provider.isContractDeployed(address))) {
|
|
ui.write(`Error: Contract at address ${address} is not deployed!`);
|
|
return;
|
|
}
|
|
|
|
const vault = provider.open(Vault.createFromAddress(address));
|
|
|
|
const counterBefore = await vault.getCounter();
|
|
|
|
await vault.sendIncrease(provider.sender(), {
|
|
increaseBy: 1,
|
|
value: toNano('0.05'),
|
|
});
|
|
|
|
ui.write('Waiting for counter to increase...');
|
|
|
|
let counterAfter = await vault.getCounter();
|
|
let attempt = 1;
|
|
while (counterAfter === counterBefore) {
|
|
ui.setActionPrompt(`Attempt ${attempt}`);
|
|
await sleep(2000);
|
|
counterAfter = await vault.getCounter();
|
|
attempt++;
|
|
}
|
|
|
|
ui.clearActionPrompt();
|
|
ui.write('Counter increased successfully!');
|
|
}
|