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.

100 lines
3.4 KiB

const main = require('../contracts/main');
const subcommand = require('subcommand');
2 years ago
const {Address, SendMode, InternalMessage, CommonMessageInfo, StateInit, CellMessage, Cell} = require("ton");
const {getWallet} = require("../contracts/main");
const {sendInternalMessageWithWallet} = require("../contracts/utils");
2 years ago
const {hex} = require("../build/jetton-wallet.compiled.json")
const argv = process.argv.slice(2);
let commands = [
{
name: 'deposit',
options: [
{
name: 'minter',
help: 'The jetton address'
},
{
name: 'amount',
}
],
command: async function deposit(args) {
let [walletContract, walletKey] = await getWallet();
await sendInternalMessageWithWallet({
walletContract, secretKey: walletKey.secretKey, value: (parseFloat(args._[1]) + 0.2) * main.TON(), to: Address.parse(args._[0]),
body: main.depositMsg((parseFloat(args._[1]) * main.TON()))
})
}
},
{
name: 'withdraw',
options: [
{
name: 'minter',
help: 'The jetton address'
},
{
name: "amount"
}
],
command: async function withdraw(args) {
let [walletContract, walletKey] = await getWallet();
await sendInternalMessageWithWallet({
walletContract, secretKey: walletKey.secretKey, value: 0.15 * main.TON(), to: Address.parse(args._[0]),
body: main.withdrawMsg((parseFloat(args._[1]) * main.TON()))
})
}
2 years ago
},
{
name: 'transfer',
options: [
{
2 years ago
name: 'my_wallet',
help: 'The jetton wallet address'
2 years ago
},
{
name: "amount"
},
{
name: "target"
}
],
command: async function transfer(args) {
let [walletContract, walletKey] = await getWallet();
await sendInternalMessageWithWallet({
2 years ago
walletContract, secretKey: walletKey.secretKey, value: 0.15 * main.TON(), to: Address.parse(args._[0]),
2 years ago
body: main.transferMsg((parseFloat(args._[1]) * main.TON()), Address.parse(args._[2]))
})
}
2 years ago
},
{
name: "deploy",
options: [
{
name: "minter",
},
{
name: "account"
}
],
command: async function deploy(args) {
let [walletContract, walletKey] = await getWallet();
let address = main.getJettonAddress(Address.parse(args._[1]), Address.parse(args._[0]), Cell.fromBoc(hex)[0]);
await sendInternalMessageWithWallet({
walletContract, secretKey: walletKey.secretKey, value: 0.15 * main.TON(), to: address,
body: new CommonMessageInfo({
body: null,
stateInit: new StateInit({ code: Cell.fromBoc(hex)[0], data: main.walletData({
balance: 0, ownerAddress: Address.parse(args._[1]),
jettonWalletCode: Cell.fromBoc(hex)[0],
jettonMasterAddress: Address.parse(args._[0])
}) }),
})
})
}
}
]
let match = subcommand(commands);
let opts = match(argv);