@sign-global/tokentable 0.4.2-beta.2 → 0.4.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/airdrop/common/index.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js +1 -1
- package/dist/cjs/airdrop/constants/chain-config.js.map +1 -1
- package/dist/esm/airdrop/common/index.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.d.ts +1 -1
- package/dist/esm/airdrop/constants/chain-config.js +1 -1
- package/dist/esm/airdrop/constants/chain-config.js.map +1 -1
- package/package.json +2 -9
- package/src/airdrop/AirdropClient.ts +0 -307
- package/src/airdrop/SignatureAirdropClient.ts +0 -378
- package/src/airdrop/common/index.ts +0 -54
- package/src/airdrop/common/projectDataForTon.ts +0 -79
- package/src/airdrop/constants/chain-config.ts +0 -107
- package/src/airdrop/constants/index.ts +0 -9
- package/src/airdrop/constants/network.ts +0 -78
- package/src/airdrop/contracts/evm/AirdropService.ts +0 -181
- package/src/airdrop/contracts/evm/SignatureAirdropService.ts +0 -114
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureClient.ts +0 -63
- package/src/airdrop/contracts/evm/contracts/AirdropSignatureFeeClient.ts +0 -61
- package/src/airdrop/contracts/evm/contracts/AirdropV2Client.ts +0 -37
- package/src/airdrop/contracts/evm/contracts/AirdropV3Client.ts +0 -49
- package/src/airdrop/contracts/evm/contracts/AirdropV3FeeClient.ts +0 -16
- package/src/airdrop/contracts/evm/contracts/AirdropV4Client.ts +0 -36
- package/src/airdrop/contracts/evm/contracts/ContractBaseClient.ts +0 -85
- package/src/airdrop/contracts/evm/contracts/DeployClient.ts +0 -35
- package/src/airdrop/contracts/evm/contracts/FeeCollectorClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/KycClient.ts +0 -21
- package/src/airdrop/contracts/evm/contracts/abis/Airdrop.json +0 -674
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV2.json +0 -676
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3.json +0 -740
- package/src/airdrop/contracts/evm/contracts/abis/AirdropV3_Fee.json +0 -678
- package/src/airdrop/contracts/evm/contracts/abis/CustomFeeNativeAirdropV4.json +0 -701
- package/src/airdrop/contracts/evm/contracts/abis/Deployer.json +0 -271
- package/src/airdrop/contracts/evm/contracts/abis/ERC721.json +0 -737
- package/src/airdrop/contracts/evm/contracts/abis/FeeCollector.json +0 -322
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenECDSADistributor.json +0 -564
- package/src/airdrop/contracts/evm/contracts/abis/FungibleTokenWithFeesECDSADistributor.json +0 -260
- package/src/airdrop/contracts/evm/contracts/abis/KycHook.json +0 -312
- package/src/airdrop/contracts/index.ts +0 -4
- package/src/airdrop/contracts/solana/AirdropSignatureClient.ts +0 -242
- package/src/airdrop/contracts/solana/FeeCollectorClient.ts +0 -43
- package/src/airdrop/contracts/solana/SignatureAirdropService.ts +0 -51
- package/src/airdrop/contracts/solana/SolanaContractClient.ts +0 -126
- package/src/airdrop/contracts/solana/fee_collector.json +0 -1063
- package/src/airdrop/contracts/solana/fee_collector.ts +0 -1069
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.json +0 -1573
- package/src/airdrop/contracts/solana/fungible_token_distributor_solana.ts +0 -1579
- package/src/airdrop/contracts/ton/AirdropClientV1.ts +0 -122
- package/src/airdrop/contracts/ton/AirdropClientV2.ts +0 -118
- package/src/airdrop/contracts/ton/AirdropClientV21.ts +0 -131
- package/src/airdrop/contracts/ton/AirdropClientV3.ts +0 -127
- package/src/airdrop/contracts/ton/AirdropService.ts +0 -150
- package/src/airdrop/contracts/ton/TonContractBaseClient.ts +0 -236
- package/src/airdrop/contracts/ton/v1/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v1/utils/constants.ts +0 -42
- package/src/airdrop/contracts/ton/v1/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v1/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v1/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v1/wrappers/JettonMinter.ts +0 -81
- package/src/airdrop/contracts/ton/v1/wrappers/JettonWallet.ts +0 -73
- package/src/airdrop/contracts/ton/v1/wrappers/Leaf.ts +0 -88
- package/src/airdrop/contracts/ton/v1/wrappers/MerkleTokenDistributor.ts +0 -317
- package/src/airdrop/contracts/ton/v1/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v2/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v2/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v2/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v2/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v2/utils/ton.utils.ts +0 -102
- package/src/airdrop/contracts/ton/v2/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v2/wrappers/MerkleTokenDistributor.ts +0 -340
- package/src/airdrop/contracts/ton/v2/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v21/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v21/utils/constants.ts +0 -48
- package/src/airdrop/contracts/ton/v21/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v21/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v21/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v21/wrappers/Leaf.ts +0 -69
- package/src/airdrop/contracts/ton/v21/wrappers/MerkleTokenDistributor.ts +0 -346
- package/src/airdrop/contracts/ton/v21/wrappers/index.ts +0 -2
- package/src/airdrop/contracts/ton/v3/build/Leaf.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/build/MerkleTokenDistributor.compiled.json +0 -1
- package/src/airdrop/contracts/ton/v3/utils/constants.ts +0 -43
- package/src/airdrop/contracts/ton/v3/utils/date.utils.ts +0 -11
- package/src/airdrop/contracts/ton/v3/utils/index.ts +0 -3
- package/src/airdrop/contracts/ton/v3/utils/ton.utils.ts +0 -84
- package/src/airdrop/contracts/ton/v3/wrappers/Leaf.ts +0 -68
- package/src/airdrop/contracts/ton/v3/wrappers/MerkleTokenDistributor.ts +0 -316
- package/src/airdrop/contracts/ton/v3/wrappers/index.ts +0 -2
- package/src/airdrop/index.ts +0 -10
- package/src/airdrop/services/index.ts +0 -166
- package/src/airdrop/services/wallet-service/ton/WalletService.ts +0 -226
- package/src/airdrop/services/wallet-service/ton/index.ts +0 -1
- package/src/airdrop/strategies/AirdropStrategyFactory.ts +0 -31
- package/src/airdrop/strategies/EvmAirdropStrategy.ts +0 -81
- package/src/airdrop/strategies/IAirdropStrategy.ts +0 -26
- package/src/airdrop/strategies/StrategyCache.ts +0 -34
- package/src/airdrop/strategies/TonAirdropStrategy.ts +0 -77
- package/src/airdrop/tests/index.test.ts +0 -387
- package/src/airdrop/types/index.ts +0 -200
- package/src/index.ts +0 -3
- package/src/utils/api-client.ts +0 -69
- package/src/utils/index.ts +0 -3
- package/src/utils/utils.ts +0 -45
- package/src/utils/web3.ts +0 -172
- package/src/wallets/WalletBase.ts +0 -92
- package/src/wallets/WalletFactory.tsx +0 -35
- package/src/wallets/index.ts +0 -3
- package/src/wallets/providers/evm/EvmWallet.ts +0 -101
- package/src/wallets/providers/evm/index.tsx +0 -56
- package/src/wallets/providers/index.ts +0 -4
- package/src/wallets/providers/solana/index.tsx +0 -133
- package/src/wallets/providers/ton/TonWallet.ts +0 -153
- package/src/wallets/providers/ton/index.tsx +0 -41
- package/src/wallets/types.ts +0 -45
- package/src/wallets/utils/index.ts +0 -61
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { TonClient } from '@ton/ton';
|
|
2
|
-
import { Sender, SenderArguments, beginCell, storeStateInit, Address, Cell, storeMessage } from '@ton/core';
|
|
3
|
-
import { CHAIN, TonConnectUI } from '@tonconnect/ui-react';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import { TonWalletService } from '../../services';
|
|
6
|
-
import { retry } from '../../../utils';
|
|
7
|
-
import { Event } from 'tonapi-sdk-js';
|
|
8
|
-
import { getHttpEndpoint } from '@orbs-network/ton-access';
|
|
9
|
-
|
|
10
|
-
export interface IAirdropOption {
|
|
11
|
-
chainId: string;
|
|
12
|
-
address: string;
|
|
13
|
-
walletClient?: TonConnectUI;
|
|
14
|
-
tonClient?: TonClient;
|
|
15
|
-
version?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let cachedTonClient: TonClient | null = null;
|
|
19
|
-
|
|
20
|
-
export class TonContractBaseClient {
|
|
21
|
-
chainId: string;
|
|
22
|
-
address: string;
|
|
23
|
-
walletClient?: TonConnectUI;
|
|
24
|
-
private eventBus: EventEmitter;
|
|
25
|
-
private counter: number = 0;
|
|
26
|
-
tonClient?: TonClient;
|
|
27
|
-
|
|
28
|
-
constructor({ chainId, address, walletClient, tonClient }: IAirdropOption) {
|
|
29
|
-
this.chainId = chainId;
|
|
30
|
-
this.address = address;
|
|
31
|
-
this.walletClient = walletClient;
|
|
32
|
-
this.eventBus = new EventEmitter();
|
|
33
|
-
this.tonClient = tonClient;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
waitForContractDeployment = async (provider: TonClient, contractAddress: Address): Promise<Address> => {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
const checkDeployment = async () => {
|
|
39
|
-
try {
|
|
40
|
-
const isDeployed = await provider.isContractDeployed(contractAddress);
|
|
41
|
-
if (isDeployed) {
|
|
42
|
-
resolve(contractAddress);
|
|
43
|
-
} else {
|
|
44
|
-
// 每3秒检查一次
|
|
45
|
-
setTimeout(checkDeployment, 3000);
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
reject(error);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
checkDeployment();
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
async getTonClient() {
|
|
57
|
-
if (cachedTonClient) {
|
|
58
|
-
return cachedTonClient;
|
|
59
|
-
}
|
|
60
|
-
if (this.tonClient) {
|
|
61
|
-
cachedTonClient = this.tonClient;
|
|
62
|
-
} else {
|
|
63
|
-
const endpoint = await getHttpEndpoint({ network: this.chainId === CHAIN.TESTNET ? 'testnet' : 'mainnet' });
|
|
64
|
-
cachedTonClient = new TonClient({ endpoint });
|
|
65
|
-
}
|
|
66
|
-
return cachedTonClient;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getTxByBOC = ({ boc: exBoc, userAddress }: { boc: string; userAddress: string }): Promise<string> => {
|
|
70
|
-
const myAddress = Address.parse(userAddress);
|
|
71
|
-
|
|
72
|
-
return retry(
|
|
73
|
-
async () => {
|
|
74
|
-
const client = await this.getTonClient();
|
|
75
|
-
const transactions = await client.getTransactions(myAddress, {
|
|
76
|
-
limit: 5
|
|
77
|
-
});
|
|
78
|
-
for (const tx of transactions) {
|
|
79
|
-
const inMsg = tx.inMessage;
|
|
80
|
-
if (inMsg?.info.type === 'external-in') {
|
|
81
|
-
const inBOC = inMsg?.body;
|
|
82
|
-
if (typeof inBOC === 'undefined') {
|
|
83
|
-
throw new Error('Invalid external');
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const extHash = Cell.fromBase64(exBoc).hash().toString('hex');
|
|
87
|
-
const inHash = beginCell().store(storeMessage(inMsg)).endCell().hash().toString('hex');
|
|
88
|
-
|
|
89
|
-
console.log(' hash BOC', extHash);
|
|
90
|
-
console.log('inMsg hash', inHash);
|
|
91
|
-
console.log('checking the tx', tx, tx.hash().toString('hex'));
|
|
92
|
-
|
|
93
|
-
// Assuming `inBOC.hash()` is synchronous and returns a hash object with a `toString` method
|
|
94
|
-
if (extHash === inHash) {
|
|
95
|
-
console.log('Tx match');
|
|
96
|
-
const txHash = tx.hash().toString('hex');
|
|
97
|
-
console.log(`Transaction Hash: ${txHash}`);
|
|
98
|
-
console.log(`Transaction LT: ${tx.lt}`);
|
|
99
|
-
return txHash;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
throw new Error('Transaction not found');
|
|
104
|
-
},
|
|
105
|
-
{ retries: 30, delay: 1000 }
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
waitForTransaction = async (onLoading?: () => void): Promise<Event | null> => {
|
|
110
|
-
const TonConnectUI = this.walletClient;
|
|
111
|
-
const boc = await this.onTransactionHash();
|
|
112
|
-
console.log(boc, 'boc');
|
|
113
|
-
|
|
114
|
-
if (!TonConnectUI) {
|
|
115
|
-
throw new Error('TonConnectUI is not initialized');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 兼容bybit web3钱包,boc为对象
|
|
119
|
-
if (typeof boc !== 'string') {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
onLoading?.();
|
|
124
|
-
|
|
125
|
-
let receipt: Event | null = null;
|
|
126
|
-
try {
|
|
127
|
-
const hash = await this.getTxByBOC({
|
|
128
|
-
boc,
|
|
129
|
-
userAddress: TonConnectUI.account!.address
|
|
130
|
-
});
|
|
131
|
-
console.log(hash, 'hash');
|
|
132
|
-
receipt = await TonWalletService?.waitForTransaction({
|
|
133
|
-
hash,
|
|
134
|
-
chainId: this.chainId,
|
|
135
|
-
address: TonConnectUI.account!.address
|
|
136
|
-
});
|
|
137
|
-
} catch (e) {
|
|
138
|
-
console.log(e, 'err');
|
|
139
|
-
const hash = Cell.fromBase64(boc).hash().toString('hex');
|
|
140
|
-
console.log(hash, 'hash');
|
|
141
|
-
receipt = await TonWalletService?.waitForTransactionLegacy({
|
|
142
|
-
hash,
|
|
143
|
-
chainId: this.chainId,
|
|
144
|
-
contractAddress: this!.address,
|
|
145
|
-
address: TonConnectUI.account!.address
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
console.log(receipt, 'tt');
|
|
149
|
-
return receipt;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
waitForTransactionForLegacy = async (): Promise<Event | null> => {
|
|
153
|
-
// 兼容ios Transaction was not sent
|
|
154
|
-
const TonConnectUI = this.walletClient;
|
|
155
|
-
if (!TonConnectUI) {
|
|
156
|
-
throw new Error('TonConnectUI is not initialized');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const receipt = await TonWalletService?.waitForTransactionLegacy({
|
|
160
|
-
hash: '',
|
|
161
|
-
chainId: this.chainId,
|
|
162
|
-
// contractAddress: this!.address,
|
|
163
|
-
address: TonConnectUI.account!.address
|
|
164
|
-
});
|
|
165
|
-
console.log(receipt, 'tt');
|
|
166
|
-
return receipt;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
onTransactionHash(): Promise<string> {
|
|
170
|
-
this.counter++;
|
|
171
|
-
return new Promise((resolve, reject) => {
|
|
172
|
-
console.log(this.counter, 'once counter');
|
|
173
|
-
this.eventBus.once(`transactionHash_${this.counter}`, (boc: string) => {
|
|
174
|
-
if (boc) {
|
|
175
|
-
resolve(boc);
|
|
176
|
-
} else {
|
|
177
|
-
reject('error');
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
get connection(): { sender: Sender; senderDeploy: Sender; connected: boolean } {
|
|
184
|
-
const TonConnectUI = this.walletClient;
|
|
185
|
-
if (!TonConnectUI) {
|
|
186
|
-
throw new Error('TonConnectUI is not initialized');
|
|
187
|
-
}
|
|
188
|
-
if (!TonConnectUI.connected) {
|
|
189
|
-
throw new Error('wallet is not connected, please logout and login again');
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
senderDeploy: {
|
|
193
|
-
send: async (args: SenderArguments) => {
|
|
194
|
-
console.log(args, 'args');
|
|
195
|
-
const res = await TonConnectUI.sendTransaction({
|
|
196
|
-
messages: [
|
|
197
|
-
{
|
|
198
|
-
address: args.to.toString(),
|
|
199
|
-
amount: args.value.toString(),
|
|
200
|
-
payload: args.body?.toBoc().toString('base64') || '',
|
|
201
|
-
stateInit: args.init
|
|
202
|
-
? beginCell().storeWritable(storeStateInit(args.init)).endCell().toBoc().toString('base64')
|
|
203
|
-
: undefined
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
validUntil: Date.now() + 5 * 60 * 1000
|
|
207
|
-
});
|
|
208
|
-
console.log(res, this.counter, 'emit');
|
|
209
|
-
this.eventBus.emit(`transactionHash_${this.counter}`, res.boc);
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
sender: {
|
|
213
|
-
send: async (args: SenderArguments) => {
|
|
214
|
-
console.log(args, TonConnectUI, 'aa');
|
|
215
|
-
try {
|
|
216
|
-
const res = await TonConnectUI.sendTransaction({
|
|
217
|
-
messages: [
|
|
218
|
-
{
|
|
219
|
-
address: args.to.toString(),
|
|
220
|
-
amount: args.value.toString(),
|
|
221
|
-
payload: args.body?.toBoc().toString('base64')
|
|
222
|
-
}
|
|
223
|
-
],
|
|
224
|
-
validUntil: Date.now() + 6 * 60 * 1000 // 5 minutes
|
|
225
|
-
});
|
|
226
|
-
this.eventBus.emit(`transactionHash_${this.counter}`, res.boc);
|
|
227
|
-
console.log(res, 'transaction res');
|
|
228
|
-
} catch (e) {
|
|
229
|
-
console.log(e, 'err');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
connected: TonConnectUI.connected
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"hex":"b5ee9c7241022e010008a0000114ff00f4a413f4bcf2c80b0102012006020128f2d31fd33f028210503d1c97bae3025b840ff2f00302fef057f84521baf2a4f8276f22308210042c1d80bef2b0f842c001f26801d4d3ff30f864885210f90001f900baf26420d739f2aad30701c003f2ab21d765aa00a6025220f9415f03f84401d4308307f40e6fa131f2adf80071f843f844f845a4f058f842c8cb00c9f8448210d0d5f405c8cb1f14cb3f12cc12cbffccc971801005040024c8cb05f843cf1670fa02cb6accc98306fb0000000201480c070201200b080201200a090025bbc01f057f844f842c8cb00f843cf16cbffc98000dbaf13f057f8428000dbd817f82bfc22c0202c91f0d020148130e020120100f001dd81e465802c678b65ffe59fe4f6aa40201201211002ff76a268698000fc317d2000fc31e9ff80fc32699f987c32c00276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c01404f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee300211e1d1c1502f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee300211b1602f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee300211a1701ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051131801ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0031900428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa230201202b200103aee02101f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be2202ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee300202a2302f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee30020292402f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee30020282501ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a12601fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d6310000027001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a0010201202d2c0063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e840008bd1b088831c02456f8007434c0c05c6c2456f83e900c0074c7f4cfcc40608426871dda6ea386bc15fe10c4b1c17ca8f4ffcc3e112ebcabdc3e10fe113e117c163816e103fcbc223e50a66"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"hex":"b5ee9c7241024601000c35000114ff00f4a413f4bcf2c80b01020162130202012008030201200504000db8461f055f84580201480706000db1ecfc157e12e0000db3aafc157e112002015810090201580d0a0201200c0b0010abe0f055f847f8480010a8e0f055f059f05a0201e70f0e000bb92f055f84a8000bba9f055f84680201201211000db1a7fc157e1320000db0643c157e10a00202c92c1402014820150201201b160201481a17020120191800bd2082bebc201c3ec09c7232e3dc3232c7c073c5f25c60043232c17e12f3c5be12be80b2dab3325c7ec01c08208403e29fa97232c7c572cfd63e8088b3c59633c584b2c01c7e80b2c0325c60063232c17e11b3c59c3e80b2dab33260c1bec02000173e4020c27232c2b2fff27420003157020c8cb00f828cf1612cbffcb3fc9f84976c8cb04ccccc980201201f1c0201201e1d00574c85003fa0201cf16cb00c9c85006cf165004cf1612cb1fcb1fccc904c8cb3f5003cf16cbff12ccccc9ed548007f5ed44d0d33f01f862fa4001f863d3ff01f864d401d0fa4001f865fa4001f866d31f01f867d31f01f868d430f869d430d0fa0001f86afa4001f86bd30030f86c800276be401c1cb232c072c004b2c1f2fff2743e900c20103a3c02104f62082300de0b6b3a7640000ba9b30823025b946ebc0b36173e08200c354218235c702bd3a30fc0000be228238070c1cc73b00c80000bbb0f2f420c1008e1282300de0b6b3a76400005202a3f04712a984e020821b782dace9d9aa18bee30f01a7648238056bc75e2d6310000021822056bc75e2d631aa18bee300212b2a292202f4822056bc75e2d631aa17be8e2701822056bc75e2d631aa17a101824adf0ab5a80a22c61ab5a7008238056bc75e2d63100000a984de21822056bc75e2d631aa16be8e2601822056bc75e2d631aa16a10182403f1fce3da636ea5cf8508238056bc75e2d63100000a984de21823815af1d78b58c400000bee30021282302f482380ad78ebc5ac6200000be8e260182380ad78ebc5ac6200000a1018238280e60114edb805d038238056bc75e2d63100000a984de218238056bc75e2d63100000be8e26018238056bc75e2d63100000a10182380ebc5fb417461211108238056bc75e2d63100000a984de218232b5e3af16b1880000bee30021272401ec82315af1d78b58c40000be8e250182315af1d78b58c40000a101823806f5f17757889379378238056bc75e2d63100000a984de218238056bc75e2d6310000021a0511382380ad78ebc5ac6200000a98466a0511382381043561a8829300000a98466a05113823815af1d78b58c400000a98466a051132501ea82381b1ae4d6e2ef500000a98466a0511382382086ac351052600000a98466a05113823825f273933db5700000a98466a05113822056bc75e2d631aa16a98466a05113823830ca024f987b900000a98466a0511382383635c9adc5dea00000a98466a0511382383ba1910bf341b00000a98466a0032600428238410d586a20a4c00000a98412a08238056bc75e2d63100000a984018064a984004a018232b5e3af16b1880000a101823808f00f760a4b2db55d8238056bc75e2d63100000a984004c01823815af1d78b58c400000a101823927fa27722cc06cc5e28238056bc75e2d63100000a984003830822056bc75e2d631aa18a18261855144814a7ff805980ff0084000005020821b782dace9d9aa17be8e18821b782dace9d9aa17a182501425982cf597cd205cef73809171e20042821b782dace9d9aa18a18288195e54c5dd42177f53a27172fa9ec630262827aa23020120382d0103aee02e01f62082300de0b6b3a7640000b98e1182300de0b6b3a76400005202a984f03ba3e0702182b05803bcc5cb9634ba4cfb2213f784019318ed4dcb6017880faa35be8e23308288195e54c5dd42177f53a27172fa9ec630262827aa23a904821b782dace9d9aa18de2182708bcc0026baae9e45e470190267a230cfaa18be2f02ea8e1c0182501425982cf597cd205cef7380a90401821b782dace9d9aa17a0dea76401a764208261855144814a7ff805980ff0084000be8e2a8238056bc75e2d631000008261855144814a7ff805980ff0084000a98401822056bc75e2d631aa18a001de20824adf0ab5a80a22c61ab5a700bee30020373002f882403f1fce3da636ea5cf850be8e268238056bc75e2d6310000082403f1fce3da636ea5cf850a98401822056bc75e2d631aa16a001de20823927fa27722cc06cc5e2be8e268238056bc75e2d63100000823927fa27722cc06cc5e2a98401823815af1d78b58c400000a001de208238280e60114edb805d03bee30020363102f482380ebc5fb41746121110be8e268238056bc75e2d6310000082380ebc5fb41746121110a984018238056bc75e2d63100000a001de20823808f00f760a4b2db55dbe8e258238056bc75e2d63100000823808f00f760a4b2db55da984018232b5e3af16b1880000a001de20823806f5f1775788937937bee30020353201ec823806248f33704b286603be8e258238056bc75e2d63100000823806248f33704b286603a984018230ad78ebc5ac620000a001de20823805c548670b9510e7acbe8e258238056bc75e2d63100000823805c548670b9510e7aca98401823056bc75e2d6310000a001de208238056bc75e2d63100000a13301fe8238056bc75e2d631000005122a012a98453008238056bc75e2d63100000a9845c8238056bc75e2d63100000a9842073a90413a051218238056bc75e2d63100000a9842075a90413a051218238056bc75e2d63100000a9842077a90413a051218238056bc75e2d63100000a9842079a90413a0598238056bc75e2d6310000034001ca984800ba904a0aa00a08064a904004a8238056bc75e2d63100000823806f5f1775788937937a9840182315af1d78b58c40000a001004c8238056bc75e2d631000008238280e60114edb805d03a9840182380ad78ebc5ac6200000a001004e8238056bc75e2d63100000824adf0ab5a80a22c61ab5a700a98401822056bc75e2d631aa17a0010201203a390063a46410e0804c45896c678b00d180ef381038c70a023d5486531812d40950025503815210e0002298731819d5016780e4e84004ebd0c8871c02497c0f83434c0c05c6c2497c0f83e900c0074c7f4cfc8a08411903f076ea38a8d16fc157e10f1c17ca8fe900c0831c03c993e10be113e117e11be11fe123e127e12be12fe130426bc15b808a08416003133eeb8c088a08417515a406eb8c088a0841cfb70f4aeb8c088a084285fd0f86ea4443423b04e48e493233f055f84312c705f2a3fa0030702082100f8a7ea5c8cb1f14cb3f58fa02f843cf16f843cf1612cb008208989680fa02cb00c9718018c8cb05f846cf1670fa02cb6accc98040fb00e0228210c46600a8bae3022282100c281f96bae30222821010354bedbae30222821026d65fa9ba41403f3c01708e25345bf055f843c705f2a3d30030f842f843f844f845f846f847f848f849f84af84b5509f056e0028210d0d5f405bae3025f04840ff2f03d01a2f05501d4d3ffd430d0d30030f268547320ed44ed45ed478e265b82109a1c7769c8cb1f12cb3fcbffc9718010c8cb055003cf1670fa0212cb6accc98040fb00ed67ed65ed64737fed118aed41edf101f2ff3e00c6f84cf2718209312d00f84aa0820a625a00a0820afaf080a015bef2b0d739f2aad30701c003f2abf84401d3ff59baf2acd43052308307f40e6fa1f2adfa40fa00d31f30f823bbf2a6f847f823bbf2a6f823f848bbf2a604f059f05a13c705f2ae02f05b0070345bf055f843c705f2a3fa403020c700f264f842f843f844f845f846f847f848f849f84af84c109a1089107810671056104510344130f0560070345bf055f843c705f2a3fa003020c100f264f842f843f844f845f846f847f848f849f84bf84c109a1089107810671056104510341023f056005e6c41f055fa40d31fd31fd3ff305321bef26420c000f264f842f843f845f849f84af84bf84c106a105910781047f056009e6c21f055f8435220c705f2a3fa00305122a1820afaf080b9f264c88280576974686472617720636f6d706c6574656401cb8f70c8cb1f01cf17c9718010c8cb055003cf165003fa02cb6accc970fb000046345bf055f843c705f2a3d33f30f843f844f845f846f847f848f849f84af84bf84cf05601c8345bf055f843c705f2a3d31fd430885210f90001f900baf264218210f00aed53ba8e19f842f843f844f845f846f847f848f84af84bf84c2a5520f056de018210cdb4d337ba8e1afb04f842f843f844f845f846f847f848f849f84af84bf84cf0569130e2450000eff29ead"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export enum OpCode { // CRC32 hash
|
|
2
|
-
ChangeAdmin = 1178663965, // 0x4641444d
|
|
3
|
-
ChangeCode = 1476445391, // 0x57f8f8f
|
|
4
|
-
ChangePaused = 2809239666, // 0xa7a7a7a2
|
|
5
|
-
ChangeVersion = 1564829953, // 0x5d5d5d61
|
|
6
|
-
DeployLeaf = 2334832459, // 0x8b8b8b8b
|
|
7
|
-
Withdraw = 1944962002, // 0x73737372
|
|
8
|
-
WithdrawTokens = 2709472225, // 0xa1a1a1a1
|
|
9
|
-
Claim = 1346182295, // 0x50505057
|
|
10
|
-
ProcessClaim = 3503682565, // 0xd0d5f405
|
|
11
|
-
SetBaseParams = 3295019176, // 0xc4c4c4c8
|
|
12
|
-
SetClaimFee = 203956118, // 0xc2c2c2c6
|
|
13
|
-
SetClaimFeeAddress = 271928301, // 0x103103d
|
|
14
|
-
SetPaused = 651583401 // 0x27272729
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum CodeType { // CRC32 hash
|
|
18
|
-
Leaf = 4027247955, // 0xf0f0f0f3
|
|
19
|
-
TokenDistributor = 3451179831 // 0xcececece
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export enum ErrorCode {
|
|
23
|
-
UnknownOP = 0xffff, // 65535
|
|
24
|
-
ExpiredMessage = 0x20, // 32
|
|
25
|
-
RepeatedMessage = 0x21, // 33
|
|
26
|
-
InvalidSignature = 0x22, // 34
|
|
27
|
-
Unauthorized = 0x23, // 35
|
|
28
|
-
InvalidMessageParams = 0x24, // 36
|
|
29
|
-
UnsupportedOperation = 0x25, // 37
|
|
30
|
-
TimeInactive = 0x26, // 38
|
|
31
|
-
InvalidProof = 0x27, // 39
|
|
32
|
-
LeafUsed = 0x28, // 40
|
|
33
|
-
IncorrectFees = 0x29, // 41
|
|
34
|
-
IsProofExotic = 0x2a, // 42
|
|
35
|
-
TreeExceeded = 0x2b, // 43
|
|
36
|
-
InvalidTree = 0x2c, // 44
|
|
37
|
-
NotFound = 0x2d, // 45
|
|
38
|
-
WrongSender = 0x2e, // 46
|
|
39
|
-
InvalidIndex = 0x2f, // 47
|
|
40
|
-
NotEnoughTokens = 0x30, // 48
|
|
41
|
-
ContractPaused = 0x31 // 49
|
|
42
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function dateToUnixTimestamp(date: Date): number {
|
|
2
|
-
return Math.floor(date.getTime() / 1000);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function unixTimestampToDate(timestamp: number): Date {
|
|
6
|
-
return new Date(timestamp * 1000);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function addOneHour(date: Date): Date {
|
|
10
|
-
return new Date(date.getTime() + 60 * 60 * 1000);
|
|
11
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Address, BitString, Cell, Slice, beginCell, contractAddress, crc32c, toNano } from '@ton/core';
|
|
2
|
-
|
|
3
|
-
export function stringToSlice(str: string): Slice {
|
|
4
|
-
return beginCell().storeStringTail(str).endCell().asSlice();
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function sliceToString(slice: Slice): string {
|
|
8
|
-
const cell = beginCell().storeSlice(slice).endCell();
|
|
9
|
-
return cell.beginParse().loadStringTail();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function stringToInt(str: string): number {
|
|
13
|
-
return str ? parseInt(Buffer.from(str).toString('hex'), 16) : 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function intToString(int: number): string {
|
|
17
|
-
return Buffer.from(int.toString(16), 'hex').toString('utf-8');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function bufferToInt(buf: Buffer): number {
|
|
21
|
-
return buf.readUInt32BE(0);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function intToBuffer(int: number): Buffer {
|
|
25
|
-
return Buffer.from(int.toString(16), 'hex');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function sliceToAddress(slice: Slice): Address {
|
|
29
|
-
const cell = beginCell().storeSlice(slice).endCell();
|
|
30
|
-
return cell.beginParse().loadAddress();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function addressToSlice(address: Address): Slice {
|
|
34
|
-
return beginCell().storeAddress(address).endCell().asSlice();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function stringToBitString(str: string): BitString {
|
|
38
|
-
return new BitString(Buffer.from(str), 0, str.length * 8);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function bitStringToString(bits: BitString, len: number): string {
|
|
42
|
-
const decoder = new TextDecoder();
|
|
43
|
-
const subBuffer = bits.subbuffer(0, len);
|
|
44
|
-
|
|
45
|
-
return subBuffer ? decoder.decode(subBuffer) : '';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function stringToCell(str: string): Cell {
|
|
49
|
-
return beginCell().storeStringTail(str).endCell();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function cellToString(cell: Cell): string {
|
|
53
|
-
return cell.beginParse().loadStringTail();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function stringToCrc32(str: string): number {
|
|
57
|
-
return crc32c(Buffer.from(str)).readUint32BE();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getContractAddress(code: Cell, data: Cell): Address {
|
|
61
|
-
return contractAddress(0, { code, data });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function arraysToCell(arrays: (Slice | Cell | Address | number)[], bits = 32): Cell {
|
|
65
|
-
const cell = beginCell();
|
|
66
|
-
|
|
67
|
-
arrays.forEach((item) => {
|
|
68
|
-
if (item instanceof Slice) {
|
|
69
|
-
cell.storeSlice(item);
|
|
70
|
-
} else if (item instanceof Cell) {
|
|
71
|
-
cell.storeRef(item);
|
|
72
|
-
} else if (item instanceof Address) {
|
|
73
|
-
cell.storeAddress(item);
|
|
74
|
-
} else if (typeof item === 'number') {
|
|
75
|
-
cell.storeUint(item, bits);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return cell.endCell();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function coinsToSlice(coins: string): Slice {
|
|
83
|
-
return beginCell().storeCoins(toNano(coins)).endCell().asSlice();
|
|
84
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from '@ton/core';
|
|
2
|
-
|
|
3
|
-
export type JettonMinterConfig = {
|
|
4
|
-
admin: Address;
|
|
5
|
-
content: Cell;
|
|
6
|
-
walletCode: Cell;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function jettonMinterConfigToCell(config: JettonMinterConfig): Cell {
|
|
10
|
-
return beginCell()
|
|
11
|
-
.storeCoins(0)
|
|
12
|
-
.storeAddress(config.admin)
|
|
13
|
-
.storeRef(config.content)
|
|
14
|
-
.storeRef(config.walletCode)
|
|
15
|
-
.endCell();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class JettonMinter implements Contract {
|
|
19
|
-
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
20
|
-
|
|
21
|
-
static createFromAddress(address: Address) {
|
|
22
|
-
return new JettonMinter(address);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static createFromConfig(config: JettonMinterConfig, code: Cell, workchain = 0) {
|
|
26
|
-
const data = jettonMinterConfigToCell(config);
|
|
27
|
-
const init = { code, data };
|
|
28
|
-
return new JettonMinter(contractAddress(workchain, init), init);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
|
|
32
|
-
await provider.internal(via, {
|
|
33
|
-
value,
|
|
34
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
35
|
-
body: beginCell().endCell()
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async sendMint(
|
|
40
|
-
provider: ContractProvider,
|
|
41
|
-
via: Sender,
|
|
42
|
-
value: bigint,
|
|
43
|
-
forwardValue: bigint,
|
|
44
|
-
recipient: Address,
|
|
45
|
-
amount: bigint
|
|
46
|
-
) {
|
|
47
|
-
await provider.internal(via, {
|
|
48
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
49
|
-
body: beginCell()
|
|
50
|
-
.storeUint(21, 32)
|
|
51
|
-
.storeUint(0, 64)
|
|
52
|
-
.storeAddress(recipient)
|
|
53
|
-
.storeCoins(forwardValue)
|
|
54
|
-
.storeRef(
|
|
55
|
-
beginCell()
|
|
56
|
-
.storeUint(0x178d4519, 32)
|
|
57
|
-
.storeUint(0, 64)
|
|
58
|
-
.storeCoins(amount)
|
|
59
|
-
.storeAddress(this.address)
|
|
60
|
-
.storeAddress(this.address)
|
|
61
|
-
.storeCoins(0)
|
|
62
|
-
.storeUint(0, 1)
|
|
63
|
-
.endCell()
|
|
64
|
-
)
|
|
65
|
-
.endCell(),
|
|
66
|
-
value: value + forwardValue
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async getWalletAddressOf(provider: ContractProvider, address: Address) {
|
|
71
|
-
return (
|
|
72
|
-
await provider.get('get_wallet_address', [{ type: 'slice', cell: beginCell().storeAddress(address).endCell() }])
|
|
73
|
-
).stack.readAddress();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async getWalletCode(provider: ContractProvider) {
|
|
77
|
-
const stack = (await provider.get('get_jetton_data', [])).stack;
|
|
78
|
-
stack.skip(4);
|
|
79
|
-
return stack.readCell();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from '@ton/core';
|
|
2
|
-
|
|
3
|
-
export type JettonWalletConfig = {
|
|
4
|
-
owner: Address;
|
|
5
|
-
minter: Address;
|
|
6
|
-
walletCode: Cell;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function jettonWalletConfigToCell(config: JettonWalletConfig): Cell {
|
|
10
|
-
return beginCell()
|
|
11
|
-
.storeCoins(0)
|
|
12
|
-
.storeAddress(config.owner)
|
|
13
|
-
.storeAddress(config.minter)
|
|
14
|
-
.storeRef(config.walletCode)
|
|
15
|
-
.endCell();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class JettonWallet implements Contract {
|
|
19
|
-
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
20
|
-
|
|
21
|
-
static createFromAddress(address: Address) {
|
|
22
|
-
return new JettonWallet(address);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static createFromConfig(config: JettonWalletConfig, code: Cell, workchain = 0) {
|
|
26
|
-
const data = jettonWalletConfigToCell(config);
|
|
27
|
-
const init = { code, data };
|
|
28
|
-
return new JettonWallet(contractAddress(workchain, init), init);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
|
|
32
|
-
await provider.internal(via, {
|
|
33
|
-
value,
|
|
34
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
35
|
-
body: beginCell().endCell()
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async sendTransfer(
|
|
40
|
-
provider: ContractProvider,
|
|
41
|
-
via: Sender,
|
|
42
|
-
value: bigint,
|
|
43
|
-
forwardValue: bigint,
|
|
44
|
-
recipient: Address,
|
|
45
|
-
amount: bigint,
|
|
46
|
-
forwardPayload: Cell
|
|
47
|
-
) {
|
|
48
|
-
await provider.internal(via, {
|
|
49
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
50
|
-
body: beginCell()
|
|
51
|
-
.storeUint(0x0f8a7ea5, 32)
|
|
52
|
-
.storeUint(0, 64)
|
|
53
|
-
.storeCoins(amount)
|
|
54
|
-
.storeAddress(recipient)
|
|
55
|
-
.storeAddress(via.address)
|
|
56
|
-
.storeUint(0, 1)
|
|
57
|
-
.storeCoins(forwardValue)
|
|
58
|
-
.storeUint(1, 1)
|
|
59
|
-
.storeRef(forwardPayload)
|
|
60
|
-
.endCell(),
|
|
61
|
-
value: value + forwardValue
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async getJettonBalance(provider: ContractProvider) {
|
|
66
|
-
const state = await provider.getState();
|
|
67
|
-
if (state.state.type !== 'active') {
|
|
68
|
-
return 0n;
|
|
69
|
-
}
|
|
70
|
-
const res = await provider.get('get_wallet_data', []);
|
|
71
|
-
return res.stack.readBigNumber();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, toNano } from '@ton/core';
|
|
2
|
-
import { OpCode } from '../utils';
|
|
3
|
-
|
|
4
|
-
export type LeafConfig = {
|
|
5
|
-
used?: boolean;
|
|
6
|
-
distributor: Address;
|
|
7
|
-
index: bigint;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const MIN_CLAIM_FEE = toNano('0.11');
|
|
11
|
-
|
|
12
|
-
export function leafConfigToCell(config: LeafConfig): Cell {
|
|
13
|
-
const { distributor, index } = config;
|
|
14
|
-
|
|
15
|
-
const initState = beginCell()
|
|
16
|
-
.storeBit(false)
|
|
17
|
-
.storeAddress(distributor)
|
|
18
|
-
.storeUint(index, 256)
|
|
19
|
-
.storeUint(0, 64)
|
|
20
|
-
.endCell();
|
|
21
|
-
|
|
22
|
-
return initState;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class Leaf implements Contract {
|
|
26
|
-
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
27
|
-
|
|
28
|
-
static createFromAddress(address: Address) {
|
|
29
|
-
return new Leaf(address);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static createFromConfig(config: LeafConfig, code: Cell, workchain = 0) {
|
|
33
|
-
const data = leafConfigToCell(config);
|
|
34
|
-
const init = { code, data };
|
|
35
|
-
return new Leaf(contractAddress(workchain, init), init);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async getSeqno(provider: ContractProvider): Promise<number> {
|
|
39
|
-
const result = await provider.get('get_seqno', []);
|
|
40
|
-
|
|
41
|
-
return result.stack.readNumber();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async getIsUsed(provider: ContractProvider): Promise<boolean> {
|
|
45
|
-
const result = await provider.get('get_is_used', []);
|
|
46
|
-
const isUsed = result.stack.readNumber();
|
|
47
|
-
|
|
48
|
-
return !!isUsed;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getLeafData(provider: ContractProvider): Promise<LeafConfig> {
|
|
52
|
-
const result = await provider.get('get_leaf_data', []);
|
|
53
|
-
const cellHash = result.stack.readCell().beginParse();
|
|
54
|
-
|
|
55
|
-
const isUsed = cellHash.loadUint(1);
|
|
56
|
-
const distributor = cellHash.loadAddress();
|
|
57
|
-
const index = cellHash.loadUint(256);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
used: !!isUsed,
|
|
61
|
-
index: BigInt(index),
|
|
62
|
-
distributor
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async sendLeafFees(_provider: ContractProvider, via: Sender, claimFee: bigint, code: Cell, data: Cell) {
|
|
67
|
-
await via.send({
|
|
68
|
-
bounce: false,
|
|
69
|
-
to: this.address,
|
|
70
|
-
value: MIN_CLAIM_FEE + claimFee,
|
|
71
|
-
init: {
|
|
72
|
-
code,
|
|
73
|
-
data
|
|
74
|
-
},
|
|
75
|
-
body: beginCell().endCell()
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async sendClaim(provider: ContractProvider, proof: Cell, index: bigint, queryId = 0) {
|
|
80
|
-
const messageBody = beginCell()
|
|
81
|
-
.storeUint(OpCode.Claim, 32)
|
|
82
|
-
.storeUint(queryId, 64)
|
|
83
|
-
.storeRef(proof)
|
|
84
|
-
.storeUint(index, 256)
|
|
85
|
-
.endCell();
|
|
86
|
-
await provider.external(messageBody);
|
|
87
|
-
}
|
|
88
|
-
}
|