|
|
@ -1,7 +1,7 @@ |
|
|
|
const subcommand = require('subcommand'); |
|
|
|
const subcommand = require('subcommand'); |
|
|
|
|
|
|
|
|
|
|
|
const { deployTONB, deposit, withdraw, transfer, blacklistAddress, getTONBOpen, getFoundationOpen, changeTONBOwner, createBlacklistVote } = require('./utils/interactions'); |
|
|
|
const { deployTONB, deposit, withdraw, transfer, blacklistAddress, getTONBOpen, getFoundationOpen, changeTONBOwner, createBlacklistVote, castVote, finishVote, requestUnstake, collectProfit } = require('./utils/interactions'); |
|
|
|
const { wallet_data, client, client4 } = require('./utils/config'); |
|
|
|
const { wallet_data, client, client4, staking_addr } = require('./utils/config'); |
|
|
|
const { randomAddress, TON } = require('./utils/helpers'); |
|
|
|
const { randomAddress, TON } = require('./utils/helpers'); |
|
|
|
const { toNano, Address } = require('ton'); |
|
|
|
const { toNano, Address } = require('ton'); |
|
|
|
const { TONB } = require('./output/jetton_TONB'); |
|
|
|
const { TONB } = require('./output/jetton_TONB'); |
|
|
@ -32,8 +32,8 @@ const match = subcommand([ |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts._[1])); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let tonb_addr = await deployTONB(undefined, true); |
|
|
|
let tonb_addr = (await getTONBOpen(undefined, staking_addr)).address; |
|
|
|
await deposit(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr); |
|
|
|
await deposit(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -54,8 +54,8 @@ const match = subcommand([ |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts._[1])); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let tonb_addr = await deployTONB(undefined, true); |
|
|
|
let tonb_addr = (await getTONBOpen(undefined, staking_addr)).address; |
|
|
|
await withdraw(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr); |
|
|
|
await withdraw(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -74,7 +74,7 @@ const match = subcommand([ |
|
|
|
}], |
|
|
|
}], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(); |
|
|
|
let tonb_addr = await deployTONB(undefined, true); |
|
|
|
let tonb_addr = (await getTONBOpen(undefined, staking_addr)).address; |
|
|
|
await transfer(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr, opts._[1]); |
|
|
|
await transfer(my_wallet, secretKey, parseFloat(opts._[0]) * 1000000000, tonb_addr, opts._[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -92,8 +92,8 @@ const match = subcommand([ |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts._[1])); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let tonb_addr = await deployTONB(undefined, true); |
|
|
|
let tonb_addr = (await getTONBOpen(undefined, staking_addr)).address; |
|
|
|
if (!opts._[0]) { |
|
|
|
if (!opts._[0]) { |
|
|
|
opts._[0] = 'kQD7zbEMaWC2yMgSJXmIF7HbLr1yuBo2GnZF_CJNkUiGSVZ8'// my_wallet.address;
|
|
|
|
opts._[0] = 'kQD7zbEMaWC2yMgSJXmIF7HbLr1yuBo2GnZF_CJNkUiGSVZ8'// my_wallet.address;
|
|
|
|
} |
|
|
|
} |
|
|
@ -114,7 +114,7 @@ const match = subcommand([ |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let tonb = await getTONBOpen(); |
|
|
|
let tonb = await getTONBOpen(undefined, staking_addr); |
|
|
|
let addr = Address.parse(opts._[0]); |
|
|
|
let addr = Address.parse(opts._[0]); |
|
|
|
if (opts._[1]) { |
|
|
|
if (opts._[1]) { |
|
|
|
let tonb_addr = Address.parse(opts._[1]); |
|
|
|
let tonb_addr = Address.parse(opts._[1]); |
|
|
@ -139,20 +139,15 @@ const match = subcommand([ |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen()).address); |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
if (opts._[1]) { |
|
|
|
if (opts._[1]) { |
|
|
|
let foundation_addr = Address.parse(opts._[1]); |
|
|
|
let foundation_addr = Address.parse(opts._[1]); |
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
} |
|
|
|
} |
|
|
|
let addr = Address.parse(opts._[0]); |
|
|
|
let addr = Address.parse(opts._[0]); |
|
|
|
let adminIndex = BigInt(parseInt(opts.w)); |
|
|
|
let adminIndex = BigInt(parseInt(opts.w)); |
|
|
|
// let msg = {
|
|
|
|
|
|
|
|
// $$type: 'InitiateBlacklistVote', wallet: addr,
|
|
|
|
|
|
|
|
// vote_time: 10n, quorum_percent: 50n, adminIndex // An admin has to create the vote
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// await foundation.send(my_wallet, { value: toNano('1.1') }, msg);
|
|
|
|
|
|
|
|
await createBlacklistVote(my_wallet, secretKey, foundation.address,
|
|
|
|
await createBlacklistVote(my_wallet, secretKey, foundation.address,
|
|
|
|
addr, 10n, adminIndex); |
|
|
|
addr, 40n, adminIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
@ -167,7 +162,7 @@ const match = subcommand([ |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen()).address); |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
if (opts._[1]) { |
|
|
|
if (opts._[1]) { |
|
|
|
let foundation_addr = Address.parse(opts._[1]); |
|
|
|
let foundation_addr = Address.parse(opts._[1]); |
|
|
|
foundation = client4.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
foundation = client4.open(Foundation.fromAddress(foundation_addr)); |
|
|
@ -195,14 +190,73 @@ const match = subcommand([ |
|
|
|
], |
|
|
|
], |
|
|
|
async command(opts) { |
|
|
|
async command(opts) { |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen()).address); |
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
if (opts._[2]) { |
|
|
|
if (opts._[2]) { |
|
|
|
let foundation_addr = Address.parse(opts._[2]); |
|
|
|
let foundation_addr = Address.parse(opts._[2]); |
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
} |
|
|
|
} |
|
|
|
await foundation.send(my_wallet, { value: toNano('0.1') }, { |
|
|
|
let adminIndex = BigInt(parseInt(opts.w)); |
|
|
|
$$type: 'VoteMsg', voteId: opts._[0], vote: opts._[1], adminIndex: BigInt(parseInt(opts.w)) |
|
|
|
await castVote(my_wallet, secretKey, foundation.address, parseInt(opts._[0]), parseInt(opts._[1]), adminIndex); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'finish-vote', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'vote-id' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'foundation-address', |
|
|
|
|
|
|
|
required: false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
wal_opt |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
async command(opts) { |
|
|
|
|
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
|
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
|
|
|
|
if (opts._[1]) { |
|
|
|
|
|
|
|
let foundation_addr = Address.parse(opts._[1]); |
|
|
|
|
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let adminIndex = BigInt(parseInt(opts.w)); |
|
|
|
|
|
|
|
await finishVote(my_wallet, secretKey, foundation.address, parseInt(opts._[0]), adminIndex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'request-unstake', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'foundation-address', |
|
|
|
|
|
|
|
required: false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
async command(opts) { |
|
|
|
|
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
|
|
|
|
if (opts._[0]) { |
|
|
|
|
|
|
|
let foundation_addr = Address.parse(opts._[0]); |
|
|
|
|
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let { my_wallet, secretKey } = await wallet_data(); |
|
|
|
|
|
|
|
await requestUnstake(my_wallet, secretKey, foundation.address, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'collect-profit', |
|
|
|
|
|
|
|
options: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'foundation-address', |
|
|
|
|
|
|
|
required: false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
wal_opt |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
async command(opts) { |
|
|
|
|
|
|
|
let foundation = await getFoundationOpen((await getTONBOpen(undefined, staking_addr)).address); |
|
|
|
|
|
|
|
if (opts._[0]) { |
|
|
|
|
|
|
|
let foundation_addr = Address.parse(opts._[0]); |
|
|
|
|
|
|
|
foundation = client.open(Foundation.fromAddress(foundation_addr)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let { my_wallet, secretKey } = await wallet_data(parseInt(opts.w)); |
|
|
|
|
|
|
|
await collectProfit(my_wallet, secretKey, foundation.address, parseInt(opts.w)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
]); |
|
|
|
]); |
|
|
|