You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

98 lines
3.0 KiB

const subcommand = require('subcommand');
const { deployTONB, deposit, withdraw, transfer, blacklistAddress } = require('./utils/interactions');
const { wallet_data, client } = require('./utils/config');
const { randomAddress, TON } = require('./utils/helpers');
const { toNano, Address } = require('ton');
const match = subcommand([
{
name: 'deposit',
options: [
{
name: 'amount',
help: 'Amount of TON to deposit',
default: '0.45'
},
{
name: 'wallet',
abbr: 'w',
default: '0',
required: false
}
],
async command(opts) {
let {my_wallet, secretKey} = await wallet_data(parseInt(opts._[1]));
let tonb_addr = await deployTONB(undefined, true);
await deposit(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr);
}
},
{
name: 'withdraw',
options: [
{
name: 'amount',
abbr: 'a',
help: 'Amount of TON to withdraw',
default: '0.2'
},
{
name: 'wallet',
abbr: 'w',
default: '0',
required: false
}
],
async command(opts) {
let {my_wallet, secretKey} = await wallet_data(parseInt(opts._[1]));
let tonb_addr = await deployTONB(undefined, true);
await withdraw(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr);
}
},
{
name: 'transfer',
options: [
{
name: 'amount',
help: 'Amount of TON to transfer',
default: '0.2'
},
{
name: 'address',
help: 'Address to transfer TON to',
default: randomAddress()
}],
async command(opts) {
let {my_wallet, secretKey} = await wallet_data();
let tonb_addr = await deployTONB(undefined, true);
await transfer(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr, opts._[1]);
}
},
{
name: 'blacklist',
options: [
{
name: 'address',
},
{
name: 'wallet',
abbr: 'w',
default: '0',
required: false
}
],
async command(opts) {
let {my_wallet, secretKey} = await wallet_data(parseInt(opts._[1]));
let tonb_addr = await deployTONB(undefined, true);
if (!opts._[0]) {
opts._[0] = 'kQD7zbEMaWC2yMgSJXmIF7HbLr1yuBo2GnZF_CJNkUiGSVZ8'// my_wallet.address;
}
let addr = Address.parse(opts._[0]);
await blacklistAddress(my_wallet, secretKey, tonb_addr, addr);
}
}
]);
const argv = process.argv.slice(2);
let opts = match(argv);