|
|
@ -1,13 +1,13 @@ |
|
|
|
import { Cell, Address, internal, beginCell, contractAddress, toNano, fromNano, SendMode } from "ton"; |
|
|
|
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 { TON } from "./helpers"; |
|
|
|
import { wallet_data, owner, default_content, workchain, client } from './config'; |
|
|
|
import { wallet_data, owner, default_content, workchain, client } from './config'; |
|
|
|
import { TONB } from "../output/jetton_TONB"; |
|
|
|
import { TONB } from "../output/jetton_TONB"; |
|
|
|
import { TONBWallet } from '../output/jetton_TONBWallet'; |
|
|
|
import { TONBWallet } from '../output/jetton_TONBWallet'; |
|
|
|
import { Distribution, AddressList } from '../output/jetton_TONBWallet'; |
|
|
|
import { Distribution, AddressList } from '../output/jetton_TONBWallet'; |
|
|
|
import { Dictionary } from 'ton-core'; |
|
|
|
import { Dictionary } from 'ton-core'; |
|
|
|
import { PseudoStaking, storeSetOwner, storeInitiateBlacklistVote } from '../output/jetton_PseudoStaking'; |
|
|
|
import { PseudoStaking, storeSetOwner, storeInitiateBlacklistVote, storeFinishVote, RequestUnstake } from '../output/jetton_PseudoStaking'; |
|
|
|
import { Foundation } from '../output/jetton_Foundation'; |
|
|
|
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 }) { |
|
|
|
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(); |
|
|
|
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'); |
|
|
|
console.log('📤Sending deposit message to ', tonb, ' with value ', value_, '💎TON'); |
|
|
|
let value = BigInt(value_); |
|
|
|
let value = BigInt(value_); |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
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.endCell(); |
|
|
|
// let msg_body = msg_body_b.storeUint(0x8999b164, 32).storeUint(value, 257).endCell();
|
|
|
|
// let msg_body = msg_body_b.storeUint(0x8999b164, 32).storeUint(value, 257).endCell();
|
|
|
|
let msg_value = value as bigint + toNano('0.1'); |
|
|
|
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(); |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
storeWithdraw({ amount: value as bigint, $$type: 'Withdraw' })(msg_body_b); |
|
|
|
storeWithdraw({ amount: value as bigint, $$type: 'Withdraw' })(msg_body_b); |
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
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 }); |
|
|
|
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) { |
|
|
|
export async function transfer(wallet: any, secretKey: Buffer, value_: bigint | number, tonb: Address, to: Address) { |
|
|
|
let value = BigInt(value_); |
|
|
|
let value = BigInt(value_); |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
storeTokenTransfer({
|
|
|
|
storeTokenTransfer({ |
|
|
|
amount: value as bigint, destination: to, queryId: 0n,
|
|
|
|
amount: value as bigint, destination: to, queryId: 0n, |
|
|
|
forwardTonAmount: 0n, $$type: 'TokenTransfer', |
|
|
|
forwardTonAmount: 0n, $$type: 'TokenTransfer', |
|
|
|
forwardPayload: beginCell().endCell(), |
|
|
|
forwardPayload: beginCell().endCell(), |
|
|
|
responseDestination: null, customPayload: null |
|
|
|
responseDestination: null, customPayload: null |
|
|
|
})(msg_body_b); |
|
|
|
})(msg_body_b); |
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
let msg_value = toNano('0.11'); |
|
|
|
let msg_value = toNano('0.11'); |
|
|
|
let wallet_addr = await getWalletAddress(tonb, wallet.address); |
|
|
|
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) { |
|
|
|
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); |
|
|
|
return client.open(tonb); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ export async function getFoundation( |
|
|
|
admins?: Address[], |
|
|
|
admins?: Address[], |
|
|
|
admin_percents?: bigint[], |
|
|
|
admin_percents?: bigint[], |
|
|
|
founders?: Address[], |
|
|
|
founders?: Address[], |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (!admins) { |
|
|
|
if (!admins) { |
|
|
|
admins = [owner]; |
|
|
|
admins = [owner]; |
|
|
|
admin_percents = [100n]; |
|
|
|
admin_percents = [100n]; |
|
|
@ -125,7 +125,7 @@ export async function getFoundationOpen( |
|
|
|
admins?: Address[], |
|
|
|
admins?: Address[], |
|
|
|
admin_percents?: bigint[], |
|
|
|
admin_percents?: bigint[], |
|
|
|
founders?: Address[], |
|
|
|
founders?: Address[], |
|
|
|
) { |
|
|
|
) { |
|
|
|
let foundation = await getFoundation(tonb_address, admins, admin_percents, founders); |
|
|
|
let foundation = await getFoundation(tonb_address, admins, admin_percents, founders); |
|
|
|
return client.open(foundation); |
|
|
|
return client.open(foundation); |
|
|
|
} |
|
|
|
} |
|
|
@ -210,11 +210,47 @@ export async function changeTONBOwner(wallet: any, secretKey: Buffer, tonb: Addr |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function createBlacklistVote( |
|
|
|
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) { |
|
|
|
vote_time: bigint, adminIndex: bigint, quorum_percent: bigint = 50n) { |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
let msg_body_b = beginCell(); |
|
|
|
storeInitiateBlacklistVote({ $$type: 'InitiateBlacklistVote', wallet: target, vote_time, adminIndex, quorum_percent })(msg_body_b); |
|
|
|
storeInitiateBlacklistVote({ $$type: 'InitiateBlacklistVote', wallet: target, vote_time, adminIndex, quorum_percent })(msg_body_b); |
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
let msg_body = msg_body_b.endCell(); |
|
|
|
let msg_value = toNano('1.01'); |
|
|
|
let msg_value = toNano('1.01'); |
|
|
|
await sendMessage(wallet, secretKey, { value: msg_value, to: foundation, body: msg_body }); |
|
|
|
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 }); |
|
|
|
} |
|
|
|
} |