wan-ton-sdk 0.0.6
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/Bridge.compile.ts +8 -0
- package/Bridge.ts +645 -0
- package/Bridge.ts.org +647 -0
- package/Fake.compile.ts +8 -0
- package/GroupApprove.compile.ts +6 -0
- package/GroupApprove.ts +274 -0
- package/JettonMinter.compile.ts +5 -0
- package/JettonMinter.ts +135 -0
- package/JettonWallet.compile.ts +5 -0
- package/JettonWallet.ts +127 -0
- package/README.md +24 -0
- package/Signature.compile.ts +6 -0
- package/Signature.ts +105 -0
- package/address.compile.ts +8 -0
- package/client/1.json +1730 -0
- package/client/client.ts +73 -0
- package/client/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +15 -0
- package/client/log/wan-ton-sdk.out.2024-12-19 +0 -0
- package/code/decode.spec.ts +81 -0
- package/code/encode-decode.ts +622 -0
- package/code/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +20 -0
- package/code/log/wan-ton-sdk.out.2025-01-15 +0 -0
- package/code/log/wan-ton-sdk.out.2025-01-20 +0 -0
- package/code/userLock.ts +291 -0
- package/common.ts +62 -0
- package/config/config-ex.ts +25 -0
- package/config/config.ts +1 -0
- package/const/const-value.ts +33 -0
- package/contractAccess/bridgeAccess.ts +60 -0
- package/contractAccess/groupApproveAccess.ts +59 -0
- package/data/EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs.json +7348 -0
- package/db/Db.spec.ts +193 -0
- package/db/Db.ts +736 -0
- package/db/DbAccess.spec.ts +23 -0
- package/db/DbAccess.ts +174 -0
- package/db/common.ts +94 -0
- package/db/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +15 -0
- package/db/log/wan-ton-sdk.out.2025-04-21 +0 -0
- package/event/getEvents.ts +441 -0
- package/event/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +15 -0
- package/event/log/wan-ton-sdk.out.2024-12-19 +0 -0
- package/example/0:1.txt +1 -0
- package/example/AddToken-ex.ts +148 -0
- package/example/README.md +21 -0
- package/example/addSmg-ex.ts +78 -0
- package/example/addTokenPair-ex.ts +73 -0
- package/example/compileContract-ex.ts +10 -0
- package/example/converTranToTonTran.ts +43 -0
- package/example/createDb-ex.ts +8 -0
- package/example/dbFeedTrans-ex.ts +20 -0
- package/example/delTokenPair-ex.ts +63 -0
- package/example/deploy-ex.ts +68 -0
- package/example/getAllEvents-ex.ts +61 -0
- package/example/getAllTrans.ts +32 -0
- package/example/getContractState-ex.ts +33 -0
- package/example/getEventByHash-ex.ts +39 -0
- package/example/getEvents-ex.ts +55 -0
- package/example/getJettonInfo-ex.ts +44 -0
- package/example/getTokenPair-ex.ts +47 -0
- package/example/getTransByRange-ex.ts +81 -0
- package/example/getTransaction-ex.ts +62 -0
- package/example/isTranSuccess-ex.ts +33 -0
- package/example/locateTx-ex.ts +44 -0
- package/example/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +55 -0
- package/example/log/wan-ton-sdk.out.2025-04-21 +447 -0
- package/example/log/wan-ton-sdk.out.2025-04-22 +1918 -0
- package/example/log/wan-ton-sdk.out.2025-04-23 +4216 -0
- package/example/log/wan-ton-sdk.out.2025-04-24.gz +0 -0
- package/example/log/wan-ton-sdk.out.2025-04-25 +46814 -0
- package/example/log/wan-ton-sdk.out.2025-04-27.gz +0 -0
- package/example/log/wan-ton-sdk.out.2025-04-28 +4966 -0
- package/example/log/wan-ton-sdk.out.2025-04-29 +1328 -0
- package/example/log/wan-ton-sdk.out.2025-04-30 +9 -0
- package/example/mintToken-ex.ts +82 -0
- package/example/setFee-ex.ts +82 -0
- package/example/setFeeProxy.ts +70 -0
- package/example/smgRelease-ex.ts +173 -0
- package/example/upgradeBridgeSc-ex.ts +49 -0
- package/example/userLock-ex.ts +78 -0
- package/fee/fee.ts +23 -0
- package/index.ts +67 -0
- package/jest.config.ts +9 -0
- package/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +20 -0
- package/log/wan-ton-sdk.out.2025-04-21 +0 -0
- package/log/wan-ton-sdk.out.2025-04-30 +10 -0
- package/opcodes.ts +58 -0
- package/package.json +34 -0
- package/publish.sh +78 -0
- package/sign/buildHash.ts +47 -0
- package/sign/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +15 -0
- package/sign/log/wan-ton-sdk.out.2025-04-14 +3 -0
- package/sign/rawTrans.spec.ts +117 -0
- package/sign/rawTrans.ts +122 -0
- package/sign/tools-secp256k1.js +210 -0
- package/testData/JettonMinter.compile.func.ts +8 -0
- package/testData/JettonWallet.compile.func.ts +8 -0
- package/testData/addressList.json +6 -0
- package/testData/bridge.compile.func.ts +8 -0
- package/testData/bridge.compiled.json +1 -0
- package/testData/contractAddress.json +7 -0
- package/testData/jettonTokenInfo.json +14 -0
- package/testData/prvlist.json +6 -0
- package/testData/smg.json +5 -0
- package/testData/tokenInfo.json +23 -0
- package/transResult/transResult.ts +621 -0
- package/tsconfig.json +19 -0
- package/utils/.compiled.json +1 -0
- package/utils/compileContract.ts +60 -0
- package/utils/log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json +15 -0
- package/utils/log/wan-ton-sdk.out.2025-01-08 +0 -0
- package/utils/logger.spec.ts +14 -0
- package/utils/logger.ts +96 -0
- package/utils/utils.spec.ts +21 -0
- package/utils/utils.ts +295 -0
- package/wallet/balance.ts +29 -0
- package/wallet/jetton.spec.ts +27 -0
- package/wallet/jetton.ts +159 -0
- package/wallet/walletContract.spec.ts +111 -0
- package/wallet/walletContract.ts +105 -0
package/client/client.ts
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
import { TonClient, WalletContractV4, Address } from "@ton/ton";
|
2
|
+
import { getHttpEndpoints , getHttpEndpoint,Network} from "@orbs-network/ton-access";
|
3
|
+
import {getSecureRandomNumber} from "@ton/crypto";
|
4
|
+
import {logger} from '../utils/logger'
|
5
|
+
import {TONCLINET_TIMEOUT} from "../const/const-value";
|
6
|
+
import {DBAccess} from "../db/DbAccess";
|
7
|
+
|
8
|
+
const formatUtil = require('util');
|
9
|
+
|
10
|
+
export interface TonClientConfig {
|
11
|
+
network: Network;
|
12
|
+
tonClientTimeout?:number;
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface TonUrlConfig{
|
16
|
+
url?:string;
|
17
|
+
apiKey?:string;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface TonConfig {
|
21
|
+
network:TonClientConfig;
|
22
|
+
urls?:TonUrlConfig[];
|
23
|
+
usingDbCache?: boolean;
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
let g_tonConfig:TonConfig;
|
28
|
+
|
29
|
+
export function getGlobalTonConfig(){
|
30
|
+
return g_tonConfig;
|
31
|
+
}
|
32
|
+
|
33
|
+
export async function wanTonSdkInit(tcf:TonConfig){
|
34
|
+
if(tcf == null){
|
35
|
+
throw new Error(`invalid ton config ${tcf}`);
|
36
|
+
}
|
37
|
+
g_tonConfig = tcf;
|
38
|
+
|
39
|
+
let dbAccess = await DBAccess.getDBAccess();
|
40
|
+
if(dbAccess){
|
41
|
+
await dbAccess.init();
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
const toncenter_testnet_apikey ="73ee18f6b52a360e9db390f146a8c6af161549495d6e9794ae3efd2e412fa7a2";
|
46
|
+
const toncenter_apikey ="16f38715eb1a0984abf42148d5ed042589f8bf11768141ecb944feae8102913a";
|
47
|
+
|
48
|
+
const default_test_url= "https://testnet.toncenter.com/api/v2/jsonRPC"
|
49
|
+
const default_url= "https://toncenter.com/api/v2/jsonRPC"
|
50
|
+
|
51
|
+
export async function getClient():Promise<TonClient> {
|
52
|
+
logger.info(formatUtil.format("getClient config %s",JSON.stringify(g_tonConfig)));
|
53
|
+
|
54
|
+
// get client by url
|
55
|
+
if(g_tonConfig.urls?.length){
|
56
|
+
let urls = g_tonConfig.urls;
|
57
|
+
const totalUrls = urls.length;
|
58
|
+
const indexUsed = await getSecureRandomNumber(0,totalUrls)
|
59
|
+
return new TonClient({ endpoint:urls[indexUsed].url ?? (g_tonConfig.network.network === 'mainnet' ? default_url:default_test_url),
|
60
|
+
timeout:g_tonConfig.network.tonClientTimeout ?? TONCLINET_TIMEOUT,
|
61
|
+
apiKey: urls[indexUsed].apiKey ?? (g_tonConfig.network.network === 'mainnet' ? toncenter_apikey : toncenter_testnet_apikey) });
|
62
|
+
}
|
63
|
+
|
64
|
+
// get client by orbs access
|
65
|
+
const endpoints = await getHttpEndpoints({ network:g_tonConfig.network.network});
|
66
|
+
const total = endpoints.length;
|
67
|
+
if(!total){
|
68
|
+
throw new Error("no http endpoint found!");
|
69
|
+
}
|
70
|
+
const indexUsed = await getSecureRandomNumber(0,total)
|
71
|
+
logger.info(formatUtil.format("(orbos)http endpoint is =>",endpoints[indexUsed]));
|
72
|
+
return new TonClient({ endpoint:endpoints[indexUsed],timeout:g_tonConfig.network.tonClientTimeout ?? TONCLINET_TIMEOUT});
|
73
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"keep": {
|
3
|
+
"days": true,
|
4
|
+
"amount": 10
|
5
|
+
},
|
6
|
+
"auditLog": "log/.ba8901062aebb86bf525b42c65ff84f9485419e4-audit.json",
|
7
|
+
"files": [
|
8
|
+
{
|
9
|
+
"date": 1734602527770,
|
10
|
+
"name": "log/wan-ton-sdk.out.2024-12-19",
|
11
|
+
"hash": "9ad603c1f13e5f6ce7643cb12ca42af7a906213065bc471dd0012b720f4fd3ba"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"hashType": "sha256"
|
15
|
+
}
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import {Cell, toNano} from "@ton/core";
|
2
|
+
import {codeTable} from "./encode-decode";
|
3
|
+
import {OP_FEE_SetTokenPairFee, OP_TOKENPAIR_Upsert} from "../opcodes"
|
4
|
+
import {BIP44_CHAINID, TON_COIN_ACCOUT} from "../const/const-value";
|
5
|
+
import {getQueryID} from "../utils/utils";
|
6
|
+
import {TON_FEE} from "../fee/fee";
|
7
|
+
|
8
|
+
let rawCellStr = "b5ee9c7201010101005000009c50000003000000000000000100000003000012340000456714833589fcd6edb6e08f4c7c32d4f71b54bda02913200000000000000000000000000000000000000000000000000000000000000000"
|
9
|
+
let rawCellStr1 = 'b5ee9c7241010301006c0002345000000300000000000000010000000300001234000045672a200102005430783833333538396663643665646236653038663463376333326434663731623534626461303239313300400000000000000000000000000000000000000000000000000000000000000000e249552b'
|
10
|
+
|
11
|
+
let tokenInfo = {
|
12
|
+
tokenOrg:{tokenPairId:0x01,srcChainId:0x1234,dstChainId:BIP44_CHAINID,srcTokenAcc:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",dstTokenAcc:'',},
|
13
|
+
tokenWrapped:{tokenPairId:0x02,srcChainId:0x1234,dstChainId:BIP44_CHAINID,srcTokenAcc:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",dstTokenAcc:'',},
|
14
|
+
coin:{tokenPairId:0x03,srcChainId:0x1234,dstChainId:BIP44_CHAINID,srcTokenAcc:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",dstTokenAcc:''},
|
15
|
+
}
|
16
|
+
let queryID;
|
17
|
+
let tokenPairId3 = tokenInfo.coin.tokenPairId;
|
18
|
+
let srcChainId3 = tokenInfo.coin.srcChainId;
|
19
|
+
let dstChainId3 = tokenInfo.coin.dstChainId;
|
20
|
+
let srcTokenAcc3 = tokenInfo.coin.srcTokenAcc;
|
21
|
+
let dstTokenAcc3 = tokenInfo.coin.dstTokenAcc;
|
22
|
+
tokenInfo.coin.dstTokenAcc = TON_COIN_ACCOUT;
|
23
|
+
|
24
|
+
describe('decode', () => {
|
25
|
+
|
26
|
+
beforeAll(async () => {
|
27
|
+
queryID = await getQueryID();
|
28
|
+
});
|
29
|
+
|
30
|
+
it('decode AddTokenPair', async () => {
|
31
|
+
let cell= Cell.fromBoc(Buffer.from(rawCellStr1,'hex'))[0];
|
32
|
+
let opCode = 0x50000003;
|
33
|
+
let decode = codeTable[opCode]["deCode"](cell);
|
34
|
+
console.log(decode);
|
35
|
+
});
|
36
|
+
|
37
|
+
it('decode should be equal code', async () => {
|
38
|
+
let opt = {
|
39
|
+
value: TON_FEE.TRANS_FEE_NORMAL,
|
40
|
+
queryID,
|
41
|
+
tokenPairId: tokenPairId3,
|
42
|
+
fromChainID: srcChainId3,
|
43
|
+
fromAccount: srcTokenAcc3,
|
44
|
+
toChainID: dstChainId3,
|
45
|
+
toAccount: dstTokenAcc3,
|
46
|
+
}
|
47
|
+
|
48
|
+
let encodedCell = codeTable[OP_TOKENPAIR_Upsert].enCode(opt);
|
49
|
+
let bodyCellHex = encodedCell.toBoc().toString('hex');
|
50
|
+
console.log(bodyCellHex);
|
51
|
+
let decoded = codeTable[OP_TOKENPAIR_Upsert].deCode(encodedCell);
|
52
|
+
console.log(decoded);
|
53
|
+
let event = codeTable[OP_TOKENPAIR_Upsert].emitEvent(decoded);
|
54
|
+
console.log(event);
|
55
|
+
});
|
56
|
+
|
57
|
+
it('cell under flow (tonview)',async () =>{
|
58
|
+
let bodyCelStr = "b5ee9c72010103010056000234500000030000000000000001000000030000123400004567142001020028833589fcd6edb6e08f4c7c32d4f71b54bda0291300400000000000000000000000000000000000000000000000000000000000000000";
|
59
|
+
let bodyCell = Cell.fromBoc(Buffer.from(bodyCelStr,'hex'))[0];
|
60
|
+
let opCode = 0x50000003;
|
61
|
+
let decode = codeTable[opCode]["deCode"](bodyCell);
|
62
|
+
console.log(decode);
|
63
|
+
})
|
64
|
+
|
65
|
+
it('cell under flow (sdk)',async () =>{
|
66
|
+
let bodyCelStr = "b5ee9c72410103010056000234500000030000000000000001000000030000123400004567142001020028833589fcd6edb6e08f4c7c32d4f71b54bda02913004000000000000000000000000000000000000000000000000000000000000000008b8d7029";
|
67
|
+
let bodyCell = Cell.fromBoc(Buffer.from(bodyCelStr,'hex'))[0];
|
68
|
+
let opCode = 0x50000003;
|
69
|
+
let decode = codeTable[opCode]["deCode"](bodyCell);
|
70
|
+
console.log(decode);
|
71
|
+
})
|
72
|
+
|
73
|
+
it('decode userlock',async () =>{
|
74
|
+
let bodyCelStr = "b5ee9c720101020100bb0001a2400000010000000043c5bea9000000000000000000000000000000000000000000746573746e65745f303638000003ac0000000000000000000000000000000000000000000000000000000005f5e100000100c98019e2d1908a3b757dc1eb9a4e6cfe5632fa789bcea365ee7ed452693d108b3f97f000a21b8da3f35c1ac4d8745f5d43077e25b2b482a5dbba52b532dd52cad9dda5f600070829dbe0c1c08edaf5f5ba2689cb0a722561e17864183ddc4f8087692ee517c0";
|
75
|
+
let bodyCell = Cell.fromBoc(Buffer.from(bodyCelStr,'hex'))[0];
|
76
|
+
let opCode = 0x40000001;
|
77
|
+
let decode = codeTable[opCode]["deCode"](bodyCell);
|
78
|
+
console.log(decode);
|
79
|
+
})
|
80
|
+
|
81
|
+
});
|