|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
import { Cell, Address, internal, beginCell, contractAddress, toNano, fromNano, SendMode } from "ton"; |
|
|
|
|
import { storeDeposit, storeWithdraw, storeTokenTransfer, storeBlacklistWallet } from "../output/jetton_TONB"; |
|
|
|
|
import { storeDeposit, storeWithdraw, storeTokenTransfer, storeBlacklistWallet, storeVoteMsg } from "../output/jetton_TONB"; |
|
|
|
|
import { TON } from "./helpers"; |
|
|
|
|
import { wallet_data, owner, default_content, workchain, client } from './config'; |
|
|
|
|
import { TONB } from "../output/jetton_TONB"; |
|
|
|
|
import { TONBWallet } from '../output/jetton_TONBWallet'; |
|
|
|
|
import { Distribution, AddressList } from '../output/jetton_TONBWallet'; |
|
|
|
|
import { Dictionary } from 'ton-core'; |
|
|
|
|
import { PseudoStaking, storeSetOwner, storeInitiateBlacklistVote } from '../output/jetton_PseudoStaking'; |
|
|
|
|
import { Foundation } from '../output/jetton_Foundation'; |
|
|
|
|
import { PseudoStaking, storeSetOwner, storeInitiateBlacklistVote, storeFinishVote, RequestUnstake } from '../output/jetton_PseudoStaking'; |
|
|
|
|
import { Foundation, storeCollectProfit, storeRequestUnstake } from '../output/jetton_Foundation'; |
|
|
|
|
|
|
|
|
|
export async function sendMessage(wallet: any, secretKey: Buffer, msg: { value: string | bigint, to: Address, bounce?: boolean, init?: { code?: Cell, data?: Cell }, body?: any }) { |
|
|
|
|
let seqno: number = await wallet.getSeqno(); |
|
|
|
@ -24,7 +24,7 @@ export async function deposit(wallet: any, secretKey: Buffer, value_: bigint | n
|
|
|
|
|
console.log('📤Sending deposit message to ', tonb, ' with value ', value_, '💎TON'); |
|
|
|
|
let value = BigInt(value_); |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeDeposit({amount: value as bigint, $$type: 'Deposit'})(msg_body_b); |
|
|
|
|
storeDeposit({ amount: value as bigint, $$type: 'Deposit' })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
// let msg_body = msg_body_b.storeUint(0x8999b164, 32).storeUint(value, 257).endCell();
|
|
|
|
|
let msg_value = value as bigint + toNano('0.1'); |
|
|
|
@ -38,19 +38,19 @@ export async function withdraw(wallet: any, secretKey: Buffer, value_: bigint |
|
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeWithdraw({ amount: value as bigint, $$type: 'Withdraw' })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('0.11'); |
|
|
|
|
let msg_value = toNano('0.2'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: tonb, body: msg_body }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function transfer(wallet: any, secretKey: Buffer, value_: bigint | number, tonb: Address, to: Address) { |
|
|
|
|
let value = BigInt(value_); |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeTokenTransfer({
|
|
|
|
|
amount: value as bigint, destination: to, queryId: 0n,
|
|
|
|
|
storeTokenTransfer({ |
|
|
|
|
amount: value as bigint, destination: to, queryId: 0n, |
|
|
|
|
forwardTonAmount: 0n, $$type: 'TokenTransfer', |
|
|
|
|
forwardPayload: beginCell().endCell(), |
|
|
|
|
responseDestination: null, customPayload: null |
|
|
|
|
})(msg_body_b); |
|
|
|
|
})(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('0.11'); |
|
|
|
|
let wallet_addr = await getWalletAddress(tonb, wallet.address); |
|
|
|
@ -97,7 +97,7 @@ export async function getTONB(owner2?: Address, tonb_content?: any, add_staking:
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function getTONBOpen(tonb_content?: any, add_staking: boolean | Address = false) { |
|
|
|
|
let tonb = await getTONB(tonb_content, add_staking); |
|
|
|
|
let tonb = await getTONB(undefined, tonb_content, add_staking); |
|
|
|
|
return client.open(tonb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ export async function getFoundation(
|
|
|
|
|
admins?: Address[], |
|
|
|
|
admin_percents?: bigint[], |
|
|
|
|
founders?: Address[], |
|
|
|
|
) { |
|
|
|
|
) { |
|
|
|
|
if (!admins) { |
|
|
|
|
admins = [owner]; |
|
|
|
|
admin_percents = [100n]; |
|
|
|
@ -125,7 +125,7 @@ export async function getFoundationOpen(
|
|
|
|
|
admins?: Address[], |
|
|
|
|
admin_percents?: bigint[], |
|
|
|
|
founders?: Address[], |
|
|
|
|
) { |
|
|
|
|
) { |
|
|
|
|
let foundation = await getFoundation(tonb_address, admins, admin_percents, founders); |
|
|
|
|
return client.open(foundation); |
|
|
|
|
} |
|
|
|
@ -210,11 +210,47 @@ export async function changeTONBOwner(wallet: any, secretKey: Buffer, tonb: Addr
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function createBlacklistVote( |
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, target: Address,
|
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, target: Address, |
|
|
|
|
vote_time: bigint, adminIndex: bigint, quorum_percent: bigint = 50n) { |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeInitiateBlacklistVote({ $$type: 'InitiateBlacklistVote', wallet: target, vote_time, adminIndex, quorum_percent })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('1.01'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function castVote( |
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, voteId: bigint, vote: bigint, adminIndex: bigint) { |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeVoteMsg({ $$type: 'VoteMsg', voteId, vote, adminIndex })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('0.05'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function finishVote( |
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, voteId: bigint) { |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeFinishVote({ $$type: 'FinishVote', voteId })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('1.05'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function requestUnstake( |
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, founderIndex: bigint) { |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeRequestUnstake({ $$type: 'RequestUnstake', founderIndex })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('0.05'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function collectProfit( |
|
|
|
|
wallet: any, secretKey: Buffer, foundation: Address, adminIndex: bigint) { |
|
|
|
|
let msg_body_b = beginCell(); |
|
|
|
|
storeCollectProfit({ $$type: 'CollectProfit', adminIndex })(msg_body_b); |
|
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
|
let msg_value = toNano('0.05'); |
|
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
|
} |