wan-ton-sdk 0.0.17 → 0.0.19
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/Bridge.d.ts +1 -1
- package/dist/Bridge.js +22 -21
- package/dist/client/client.js +13 -5
- package/dist/code/encode-decode.d.ts +28 -0
- package/dist/code/encode-decode.js +84 -15
- package/dist/code/exports.d.ts +1 -0
- package/dist/code/exports.js +1 -0
- package/dist/code/smgRelease.d.ts +23 -0
- package/dist/code/smgRelease.js +74 -0
- package/dist/code/userLock.js +2 -0
- package/dist/config/config-ex.d.ts +1 -0
- package/dist/config/config-ex.js +13 -1
- package/dist/config/config-mainnet.d.ts +5 -0
- package/dist/config/config-mainnet.js +6 -0
- package/dist/config/config-testnet.d.ts +5 -0
- package/dist/config/config-testnet.js +6 -0
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +16 -0
- package/dist/db/DbAccess.d.ts +1 -1
- package/dist/db/DbAccess.js +16 -16
- package/dist/example/event/getAllEvents-ex.js +46 -14
- package/dist/example/event/getEventByHash-ex.js +37 -15
- package/dist/example/event/getEventsByRange-ex.js +37 -11
- package/dist/example/lock-release/userLock-ex.js +1 -1
- package/dist/example/token/addToken-ex.js +94 -0
- package/dist/example/token/addTokenPair-ex.js +39 -22
- package/dist/example/token/changeAdmin-ex.js +27 -8
- package/dist/example/token/delTokenPair-ex.js +28 -17
- package/dist/example/token/getAdmin-ex.js +18 -9
- package/dist/example/token/getTokenPair-ex.js +29 -12
- package/dist/example/token/mintToken-ex.js +33 -15
- package/dist/sign/exports.d.ts +0 -1
- package/dist/sign/exports.js +1 -2
- package/package.json +1 -1
- package/dist/example/db/createDb-ex.d.ts +0 -1
- package/dist/example/db/createDb-ex.js +0 -7
- package/dist/example/db/dbFeedTrans-ex.js +0 -18
- package/dist/example/event/getAllSlimEvents-ex.d.ts +0 -1
- package/dist/example/event/getAllSlimEvents-ex.js +0 -73
- package/dist/example/token/AddToken-ex.d.ts +0 -1
- package/dist/example/token/AddToken-ex.js +0 -122
- /package/dist/example/{db/dbFeedTrans-ex.d.ts → token/addToken-ex.d.ts} +0 -0
package/dist/Bridge.d.ts
CHANGED
@@ -130,9 +130,9 @@ export declare class Bridge implements Contract {
|
|
130
130
|
toChainID: number;
|
131
131
|
fromAccount: string;
|
132
132
|
toAccount: string;
|
133
|
-
jettonAdminAddr: string;
|
134
133
|
walletCodeBase64: string;
|
135
134
|
exist: string;
|
135
|
+
tokenAccount: string;
|
136
136
|
}>;
|
137
137
|
getFirstTokenPairID(provider: ContractProvider): Promise<number>;
|
138
138
|
getNextTokenPairID(provider: ContractProvider, id: number): Promise<number>;
|
package/dist/Bridge.js
CHANGED
@@ -36,13 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Bridge = void 0;
|
37
37
|
exports.bridgeConfigToCell = bridgeConfigToCell;
|
38
38
|
const logger_1 = require("./utils/logger");
|
39
|
-
const formatUtil = require('util');
|
40
39
|
const userLock_1 = require("./code/userLock");
|
41
40
|
const core_1 = require("@ton/core");
|
42
41
|
const JettonMinter_1 = require("./JettonMinter");
|
43
42
|
const opcodes = __importStar(require("./opcodes"));
|
44
43
|
const encode_decode_1 = require("./code/encode-decode");
|
45
44
|
const const_value_1 = require("./const/const-value");
|
45
|
+
const formatUtil = require('util');
|
46
46
|
function bridgeConfigToCell(config) {
|
47
47
|
return (0, core_1.beginCell)()
|
48
48
|
.storeAddress(config.owner)
|
@@ -147,22 +147,9 @@ class Bridge {
|
|
147
147
|
}
|
148
148
|
async getTokenAccount(provider, tokenPairID) {
|
149
149
|
// 1. get tokenpair from bridge
|
150
|
-
let
|
151
|
-
logger_1.logger.info(formatUtil.format("
|
152
|
-
|
153
|
-
let tokenAccount = "";
|
154
|
-
if (tokePairInfo.fromChainID == const_value_1.BIP44_CHAINID) {
|
155
|
-
tokenAccount = tokePairInfo.fromAccount;
|
156
|
-
}
|
157
|
-
else {
|
158
|
-
if (tokePairInfo.toChainID == const_value_1.BIP44_CHAINID) {
|
159
|
-
tokenAccount = tokePairInfo.toAccount;
|
160
|
-
}
|
161
|
-
else {
|
162
|
-
throw "TokenPair not support";
|
163
|
-
}
|
164
|
-
}
|
165
|
-
return tokenAccount;
|
150
|
+
let tokenPairInfo = await this.getTokenPair(provider, tokenPairID);
|
151
|
+
logger_1.logger.info(formatUtil.format("tokenPairInfo", tokenPairInfo));
|
152
|
+
return tokenPairInfo.tokenAccount;
|
166
153
|
}
|
167
154
|
async sendUserLock(provider, via, opts, differentQueryID) {
|
168
155
|
let ret = await (0, userLock_1.buildUserLockMessages)({
|
@@ -259,8 +246,8 @@ class Bridge {
|
|
259
246
|
let fromAccount = result.stack.readBuffer();
|
260
247
|
let toChainID = result.stack.readNumber();
|
261
248
|
let toAccount = result.stack.readBuffer();
|
262
|
-
let jettonAdminAddr = result.stack.readBuffer();
|
263
249
|
let exist = 1;
|
250
|
+
let tokenAccount;
|
264
251
|
if (result.stack.remaining) {
|
265
252
|
exist = result.stack.readNumber();
|
266
253
|
}
|
@@ -268,7 +255,18 @@ class Bridge {
|
|
268
255
|
if (result.stack.remaining) {
|
269
256
|
walletCode = result.stack.readCellOpt();
|
270
257
|
}
|
271
|
-
|
258
|
+
if (result.stack.remaining) {
|
259
|
+
tokenAccount = result.stack.readBuffer();
|
260
|
+
}
|
261
|
+
let pair = {
|
262
|
+
fromChainID,
|
263
|
+
toChainID,
|
264
|
+
fromAccount: "",
|
265
|
+
toAccount: "",
|
266
|
+
walletCodeBase64: "",
|
267
|
+
exist: "",
|
268
|
+
tokenAccount: ""
|
269
|
+
};
|
272
270
|
if (pair.fromChainID == 0 || pair.toChainID == 0) {
|
273
271
|
return pair;
|
274
272
|
}
|
@@ -283,8 +281,8 @@ class Bridge {
|
|
283
281
|
pair['fromAccount'] = "0x" + fromAccount.toString('hex');
|
284
282
|
}
|
285
283
|
pair['exist'] = exist.toString();
|
286
|
-
pair['jettonAdminAddr'] = (new core_1.Address(0, jettonAdminAddr)).toString();
|
287
284
|
pair['walletCodeBase64'] = walletCode.toBoc().toString('base64');
|
285
|
+
pair['tokenAccount'] = (new core_1.Address(0, tokenAccount)).toString();
|
288
286
|
return pair;
|
289
287
|
}
|
290
288
|
async getFirstTokenPairID(provider) {
|
@@ -428,7 +426,10 @@ class Bridge {
|
|
428
426
|
return addr.toString();
|
429
427
|
}
|
430
428
|
async getNextAdmin(provider, adminAddr) {
|
431
|
-
const { stack } = await provider.get("get_next_crossAdmin", [{
|
429
|
+
const { stack } = await provider.get("get_next_crossAdmin", [{
|
430
|
+
type: 'slice',
|
431
|
+
cell: (0, core_1.beginCell)().storeAddress(adminAddr).endCell()
|
432
|
+
}]);
|
432
433
|
let s = stack.readBuffer();
|
433
434
|
if (s.toString('hex') == '0000000000000000000000000000000000000000000000000000000000000000') {
|
434
435
|
return "";
|
package/dist/client/client.js
CHANGED
@@ -56,22 +56,30 @@ const toncenter_testnet_apikey = "73ee18f6b52a360e9db390f146a8c6af161549495d6e97
|
|
56
56
|
const toncenter_apikey = "16f38715eb1a0984abf42148d5ed042589f8bf11768141ecb944feae8102913a";
|
57
57
|
const default_test_url = "https://testnet.toncenter.com/api/v2/jsonRPC";
|
58
58
|
const default_url = "https://toncenter.com/api/v2/jsonRPC";
|
59
|
+
const tonapi_apikey = "AH4MNTSJ5HBH4KAAAAAJQ2O2QNEXAKZWGAMTFLFJC4BMWNGDNFYXSKUOPQ4KRJSXJDSL65I";
|
60
|
+
const tonapi_testnet_apikey = "AH4MNTSJ5HBH4KAAAAAJQ2O2QNEXAKZWGAMTFLFJC4BMWNGDNFYXSKUOPQ4KRJSXJDSL65I";
|
59
61
|
async function getClient() {
|
60
62
|
logger_1.logger.info(formatUtil.format("getClient config %s", JSON.stringify(g_tonConfig)));
|
63
|
+
let finalClientConfig = null;
|
61
64
|
// get client by url
|
62
65
|
if (g_tonConfig.urls?.length) {
|
63
66
|
let urls = g_tonConfig.urls;
|
64
67
|
const totalUrls = urls.length;
|
65
68
|
const indexUsed = await (0, crypto_1.getSecureRandomNumber)(0, totalUrls);
|
66
69
|
if (urls[indexUsed].vendor?.toLowerCase() == 'tonapi') {
|
67
|
-
|
68
|
-
baseUrl: urls[indexUsed].url
|
69
|
-
|
70
|
+
finalClientConfig = {
|
71
|
+
baseUrl: urls[indexUsed].url,
|
72
|
+
apiKey: urls[indexUsed].apiKey ?? (g_tonConfig.network.network === 'mainnet' ? tonapi_apikey : tonapi_testnet_apikey)
|
73
|
+
};
|
74
|
+
logger_1.logger.info(formatUtil.format("getClient final config %s", JSON.stringify(finalClientConfig)));
|
75
|
+
return new tonapi_client_1.TonApiClient(finalClientConfig);
|
70
76
|
}
|
71
77
|
else {
|
72
|
-
|
78
|
+
finalClientConfig = { endpoint: urls[indexUsed].url ?? (g_tonConfig.network.network === 'mainnet' ? default_url : default_test_url),
|
73
79
|
timeout: g_tonConfig.network.tonClientTimeout ?? const_value_1.TONCLINET_TIMEOUT,
|
74
|
-
apiKey: urls[indexUsed].apiKey ?? (g_tonConfig.network.network === 'mainnet' ? toncenter_apikey : toncenter_testnet_apikey) }
|
80
|
+
apiKey: urls[indexUsed].apiKey ?? (g_tonConfig.network.network === 'mainnet' ? toncenter_apikey : toncenter_testnet_apikey) };
|
81
|
+
logger_1.logger.info(formatUtil.format("getClient final config %s", JSON.stringify(finalClientConfig)));
|
82
|
+
return new ton_1.TonClient(finalClientConfig);
|
75
83
|
}
|
76
84
|
}
|
77
85
|
// get client by orbs access
|
@@ -38,10 +38,27 @@ export declare const codeTable: {
|
|
38
38
|
805306373: {
|
39
39
|
enCode: (opts: any) => Cell;
|
40
40
|
deCode: (cell: Cell) => any;
|
41
|
+
emitEvent: (opts: any) => {
|
42
|
+
eventName: string;
|
43
|
+
tokenPairID: any;
|
44
|
+
fee: any;
|
45
|
+
userAccount: any;
|
46
|
+
txHashBase64: any;
|
47
|
+
txHash: any;
|
48
|
+
lt: any;
|
49
|
+
};
|
41
50
|
};
|
42
51
|
805306371: {
|
43
52
|
enCode: (opts: any) => Cell;
|
44
53
|
deCode: (cell: Cell) => any;
|
54
|
+
emitEvent: (opts: any) => {
|
55
|
+
eventName: string;
|
56
|
+
smgFeeProxyAddr: any;
|
57
|
+
userAccount: any;
|
58
|
+
txHashBase64: any;
|
59
|
+
txHash: any;
|
60
|
+
lt: any;
|
61
|
+
};
|
45
62
|
};
|
46
63
|
2684354576: {
|
47
64
|
enCode: (opts: any) => Cell;
|
@@ -98,6 +115,17 @@ export declare const codeTable: {
|
|
98
115
|
805306369: {
|
99
116
|
enCode: (opts: any) => Cell;
|
100
117
|
deCode: (cell: Cell) => any;
|
118
|
+
emitEvent: (opts: any) => {
|
119
|
+
eventName: string;
|
120
|
+
srcChainId: any;
|
121
|
+
dstChainId: any;
|
122
|
+
contractFee: any;
|
123
|
+
agentFee: any;
|
124
|
+
userAccount: any;
|
125
|
+
txHashBase64: any;
|
126
|
+
txHash: any;
|
127
|
+
lt: any;
|
128
|
+
};
|
101
129
|
};
|
102
130
|
805306370: {
|
103
131
|
enCode: (opts: any) => Cell;
|
@@ -39,7 +39,6 @@ const opcodes = __importStar(require("../opcodes"));
|
|
39
39
|
const const_value_1 = require("../const/const-value");
|
40
40
|
const logger_1 = require("../utils/logger");
|
41
41
|
const utils_1 = require("../utils/utils");
|
42
|
-
const utils_2 = require("../utils/utils");
|
43
42
|
const formatUtil = require('util');
|
44
43
|
exports.codeTable = {
|
45
44
|
[opcodes.OP_CROSS_UserLock]: {
|
@@ -107,7 +106,7 @@ exports.codeTable = {
|
|
107
106
|
[opcodes.OP_CROSS_SmgRelease]: {
|
108
107
|
"enCode": function (opts) {
|
109
108
|
logger_1.logger.info(formatUtil.format("Entering enCode Function OP_CROSS_SmgRelease"));
|
110
|
-
logger_1.logger.info(formatUtil.format("op_cross_smgRelease opts %s", JSON.stringify(opts,
|
109
|
+
logger_1.logger.info(formatUtil.format("op_cross_smgRelease opts %s", JSON.stringify(opts, utils_1.bigIntReplacer)));
|
111
110
|
let part2Cell = (0, core_1.beginCell)()
|
112
111
|
.storeUint(opts.fee, 256)
|
113
112
|
.storeAddress(opts.userAccount)
|
@@ -200,7 +199,30 @@ exports.codeTable = {
|
|
200
199
|
.endCell();
|
201
200
|
},
|
202
201
|
"deCode": function (cell) {
|
203
|
-
|
202
|
+
logger_1.logger.info(formatUtil.format("Entering deCode Function OP_FEE_SetTokenPairFee"));
|
203
|
+
let slice = cell.beginParse();
|
204
|
+
let opCode = slice.loadUint(32);
|
205
|
+
let queryID = slice.loadUint(64);
|
206
|
+
let tokenPairID = slice.loadUint(32);
|
207
|
+
let fee = slice.loadUint(32);
|
208
|
+
slice.endParse();
|
209
|
+
return {
|
210
|
+
opCode,
|
211
|
+
queryID,
|
212
|
+
tokenPairID,
|
213
|
+
fee
|
214
|
+
};
|
215
|
+
},
|
216
|
+
"emitEvent": function (opts) {
|
217
|
+
return {
|
218
|
+
eventName: "SetTokenPairFeeLogger",
|
219
|
+
tokenPairID: opts.tokenPairID,
|
220
|
+
fee: opts.fee,
|
221
|
+
userAccount: opts.userAccount,
|
222
|
+
txHashBase64: opts.txHashBase64,
|
223
|
+
txHash: opts.txHash,
|
224
|
+
lt: opts?.lt
|
225
|
+
};
|
204
226
|
}
|
205
227
|
},
|
206
228
|
[opcodes.OP_FEE_SetSmgFeeProxy]: {
|
@@ -213,7 +235,27 @@ exports.codeTable = {
|
|
213
235
|
.endCell();
|
214
236
|
},
|
215
237
|
"deCode": function (cell) {
|
216
|
-
|
238
|
+
logger_1.logger.info(formatUtil.format("Entering deCode Function OP_FEE_SetSmgFeeProxy"));
|
239
|
+
let slice = cell.beginParse();
|
240
|
+
let opCode = slice.loadUint(32);
|
241
|
+
let queryID = slice.loadUint(64);
|
242
|
+
let smgFeeProxyAddr = slice.loadAddress();
|
243
|
+
slice.endParse();
|
244
|
+
return {
|
245
|
+
opCode,
|
246
|
+
queryID,
|
247
|
+
smgFeeProxyAddr
|
248
|
+
};
|
249
|
+
},
|
250
|
+
"emitEvent": function (opts) {
|
251
|
+
return {
|
252
|
+
eventName: "SetSmgFeeProxyLogger",
|
253
|
+
smgFeeProxyAddr: opts.smgFeeProxyAddr.toString(),
|
254
|
+
userAccount: opts.userAccount,
|
255
|
+
txHashBase64: opts.txHashBase64,
|
256
|
+
txHash: opts.txHash,
|
257
|
+
lt: opts?.lt,
|
258
|
+
};
|
217
259
|
}
|
218
260
|
},
|
219
261
|
[opcodes.OP_GROUPAPPROVE_Proposol_SetSmgFeeProxy]: {
|
@@ -500,7 +542,36 @@ exports.codeTable = {
|
|
500
542
|
.endCell();
|
501
543
|
},
|
502
544
|
"deCode": function (cell) {
|
503
|
-
|
545
|
+
logger_1.logger.info(formatUtil.format("Entering deCode Function OP_FEE_SetChainFee"));
|
546
|
+
let slice = cell.beginParse();
|
547
|
+
let opCode = slice.loadUint(32);
|
548
|
+
let queryID = slice.loadUint(64);
|
549
|
+
let srcChainId = slice.loadUint(32);
|
550
|
+
let dstChainId = slice.loadUint(32);
|
551
|
+
let contractFee = slice.loadUint(32);
|
552
|
+
let agentFee = slice.loadUint(32);
|
553
|
+
slice.endParse();
|
554
|
+
return {
|
555
|
+
opCode,
|
556
|
+
queryID,
|
557
|
+
srcChainId,
|
558
|
+
dstChainId,
|
559
|
+
contractFee,
|
560
|
+
agentFee
|
561
|
+
};
|
562
|
+
},
|
563
|
+
"emitEvent": function (opts) {
|
564
|
+
return {
|
565
|
+
eventName: "SetChainFeeLogger",
|
566
|
+
srcChainId: opts.srcChainId,
|
567
|
+
dstChainId: opts.dstChainId,
|
568
|
+
contractFee: opts.contractFee,
|
569
|
+
agentFee: opts.agentFee,
|
570
|
+
userAccount: opts.userAccount,
|
571
|
+
txHashBase64: opts.txHashBase64,
|
572
|
+
txHash: opts.txHash,
|
573
|
+
lt: opts?.lt,
|
574
|
+
};
|
504
575
|
}
|
505
576
|
},
|
506
577
|
[opcodes.OP_FEE_SetChainFees]: {
|
@@ -550,13 +621,6 @@ exports.codeTable = {
|
|
550
621
|
else {
|
551
622
|
throw ("Error chain ID.");
|
552
623
|
}
|
553
|
-
let jettonAdminBuffer;
|
554
|
-
if (opts.jettonAdminAddr == "") {
|
555
|
-
jettonAdminBuffer = Buffer.from(const_value_1.TON_COIN_ACCOUT.slice(2), 'hex');
|
556
|
-
}
|
557
|
-
else {
|
558
|
-
jettonAdminBuffer = core_1.Address.parseFriendly(opts.jettonAdminAddr).address.hash;
|
559
|
-
}
|
560
624
|
let walletCodeCell = core_1.Cell.EMPTY;
|
561
625
|
if (!!opts.walletCodeBase64) {
|
562
626
|
walletCodeCell = core_1.Cell.fromBase64(opts.walletCodeBase64);
|
@@ -572,7 +636,6 @@ exports.codeTable = {
|
|
572
636
|
.storeUint(toBuffer.length, 8)
|
573
637
|
.storeRef((0, core_1.beginCell)().storeBuffer(fromBuffer).endCell())
|
574
638
|
.storeRef((0, core_1.beginCell)().storeBuffer(toBuffer).endCell())
|
575
|
-
.storeBuffer(jettonAdminBuffer)
|
576
639
|
.storeMaybeRef(walletCodeCell)
|
577
640
|
.endCell();
|
578
641
|
},
|
@@ -593,13 +656,19 @@ exports.codeTable = {
|
|
593
656
|
let toBuffer = sliceTo.loadBits(8 * toLength);
|
594
657
|
sliceTo.endParse();
|
595
658
|
logger_1.logger.info(formatUtil.format("toBuffer=>", toBuffer));
|
596
|
-
let jettonAdmin = slice.loadBits(256);
|
597
659
|
logger_1.logger.info("OP_TOKENPAIR_Upsert before loadMybeRef begin");
|
598
660
|
let walletCodeCell = slice.loadMaybeRef();
|
599
661
|
logger_1.logger.info("OP_TOKENPAIR_Upsert before loadMybeRef end");
|
600
662
|
slice.endParse();
|
601
663
|
return {
|
602
|
-
opCode,
|
664
|
+
opCode,
|
665
|
+
queryID,
|
666
|
+
tokenPairID,
|
667
|
+
fromChainID,
|
668
|
+
toChainID,
|
669
|
+
fromAccount: fromBuffer,
|
670
|
+
toAccount: toBuffer,
|
671
|
+
walletCodeBase64: walletCodeCell.toBoc().toString('base64'),
|
603
672
|
};
|
604
673
|
},
|
605
674
|
"emitEvent": function (opts) {
|
package/dist/code/exports.d.ts
CHANGED
package/dist/code/exports.js
CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./encode-decode"), exports);
|
18
18
|
__exportStar(require("./userLock"), exports);
|
19
|
+
__exportStar(require("./smgRelease"), exports);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Address } from "@ton/core";
|
2
|
+
export declare function buildSmgReleaseMessage(opts: {
|
3
|
+
value: bigint;
|
4
|
+
uniqueID: bigint;
|
5
|
+
smgID: string;
|
6
|
+
tokenPairID: number;
|
7
|
+
releaseValue: bigint;
|
8
|
+
fee: bigint;
|
9
|
+
userAccount: Address;
|
10
|
+
fwTonAmount: bigint;
|
11
|
+
totalTonAmount: bigint;
|
12
|
+
bridgeJettonWalletAddr: Address;
|
13
|
+
e: bigint;
|
14
|
+
p: bigint;
|
15
|
+
s: bigint;
|
16
|
+
queryID?: bigint;
|
17
|
+
bridgeScAddr: string;
|
18
|
+
}): Promise<{
|
19
|
+
internalMsg: import("@ton/core").MessageRelaxed;
|
20
|
+
body: import("@ton/core").Cell;
|
21
|
+
to: string;
|
22
|
+
value: bigint;
|
23
|
+
}>;
|
@@ -0,0 +1,74 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.buildSmgReleaseMessage = buildSmgReleaseMessage;
|
37
|
+
const core_1 = require("@ton/core");
|
38
|
+
const opcodes = __importStar(require("../opcodes"));
|
39
|
+
const logger_1 = require("../utils/logger");
|
40
|
+
const encode_decode_1 = require("./encode-decode");
|
41
|
+
const utils_1 = require("../utils/utils");
|
42
|
+
const userLock_1 = require("./userLock");
|
43
|
+
async function buildSmgReleaseMessage(opts) {
|
44
|
+
try {
|
45
|
+
if (!(0, utils_1.isValidHexString)(opts.smgID)) {
|
46
|
+
throw Error("smgId is not valid hex string");
|
47
|
+
}
|
48
|
+
if (!core_1.Address.isAddress(opts.userAccount)) {
|
49
|
+
throw Error("userAccount is not valid address");
|
50
|
+
}
|
51
|
+
if (!core_1.Address.isAddress(opts.bridgeJettonWalletAddr)) {
|
52
|
+
throw Error("bridgeJettonWalletAddr is not valid address");
|
53
|
+
}
|
54
|
+
if (!core_1.Address.isAddress(core_1.Address.parse(opts.bridgeScAddr))) {
|
55
|
+
throw Error("bridgeScAddr is not valid address");
|
56
|
+
}
|
57
|
+
logger_1.logger.info("buildSmgReleaseMessage", "opts", JSON.stringify(opts, utils_1.bigIntReplacer));
|
58
|
+
if (!opts.queryID) {
|
59
|
+
opts.queryID = BigInt(await (0, utils_1.getQueryID)());
|
60
|
+
}
|
61
|
+
let body = encode_decode_1.codeTable[opcodes.OP_CROSS_SmgRelease].enCode(opts);
|
62
|
+
let msg = await (0, userLock_1.buildInternalMessage)({ to: opts.bridgeScAddr, value: opts.value, body: body, bounce: true });
|
63
|
+
return {
|
64
|
+
internalMsg: msg,
|
65
|
+
body: body,
|
66
|
+
to: opts.bridgeScAddr,
|
67
|
+
value: opts.value,
|
68
|
+
};
|
69
|
+
}
|
70
|
+
catch (e) {
|
71
|
+
logger_1.logger.error((0, utils_1.formatError)(e));
|
72
|
+
throw (0, utils_1.formatError)(e);
|
73
|
+
}
|
74
|
+
}
|
package/dist/code/userLock.js
CHANGED
@@ -123,6 +123,7 @@ async function buildLockCoinMessages(opts, jwAddrBridgeSc, jwAddrSrc, addrTokenA
|
|
123
123
|
let extraCell2 = (0, core_1.beginCell)()
|
124
124
|
.storeAddress(core_1.Address.parse(opts.senderAccount))
|
125
125
|
.storeUint(lockFee, 256)
|
126
|
+
//.storeUint(1, 256) //todo should delete
|
126
127
|
.endCell();
|
127
128
|
let body = (0, core_1.beginCell)()
|
128
129
|
.storeUint(opcodes.OP_CROSS_UserLock, 32)
|
@@ -151,6 +152,7 @@ async function buildLockOriginalTokenMessages(opts, jwAddrBridgeSc, jwAddrSrc, a
|
|
151
152
|
}
|
152
153
|
// forward payLoad
|
153
154
|
let queryId = await (0, utils_1.getQueryID)();
|
155
|
+
//differentQueryID = BigInt(1); //todo should delete
|
154
156
|
let dstUserAccountBuffer = Buffer.from((0, utils_1.remove0x)(opts.dstUserAccount), 'hex');
|
155
157
|
let dstUserAccountBufferLen = dstUserAccountBuffer.length;
|
156
158
|
let extraCell = (0, core_1.beginCell)()
|
@@ -3,6 +3,7 @@ export declare const configTestnet: TonConfig;
|
|
3
3
|
export declare const configTestnetObs: TonConfig;
|
4
4
|
export declare const configTestnetNoDb: TonConfig;
|
5
5
|
export declare const configMainnet: TonConfig;
|
6
|
+
export declare const configMainnetNoDb: TonConfig;
|
6
7
|
export declare const configTestTonApi: TonConfig;
|
7
8
|
export declare const configTestTonApiNoDb: TonConfig;
|
8
9
|
export declare const configMainTonApi: TonConfig;
|
package/dist/config/config-ex.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.configMainTonApi = exports.configTestTonApiNoDb = exports.configTestTonApi = exports.configMainnet = exports.configTestnetNoDb = exports.configTestnetObs = exports.configTestnet = void 0;
|
3
|
+
exports.configMainTonApi = exports.configTestTonApiNoDb = exports.configTestTonApi = exports.configMainnetNoDb = exports.configMainnet = exports.configTestnetNoDb = exports.configTestnetObs = exports.configTestnet = void 0;
|
4
4
|
exports.configTestnet = {
|
5
5
|
network: {
|
6
6
|
network: "testnet", // testnet|mainnet
|
@@ -43,6 +43,18 @@ exports.configMainnet = {
|
|
43
43
|
}
|
44
44
|
]
|
45
45
|
};
|
46
|
+
exports.configMainnetNoDb = {
|
47
|
+
network: {
|
48
|
+
network: "mainnet", // testnet|mainnet
|
49
|
+
},
|
50
|
+
usingDbCache: false,
|
51
|
+
urls: [
|
52
|
+
{
|
53
|
+
//url:'',
|
54
|
+
//apiKey:''
|
55
|
+
}
|
56
|
+
]
|
57
|
+
};
|
46
58
|
exports.configTestTonApi = {
|
47
59
|
network: {
|
48
60
|
network: "testnet", // testnet|mainnet
|
@@ -0,0 +1,6 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
exports.tokenInput = path.join(__dirname, '../deploy-info/input/mainnet/tokenInput-mainnet.json');
|
3
|
+
exports.tokenpairInput = path.join(__dirname, '../deploy-info/input/mainnet/tokenpairInput-mainnet.json');
|
4
|
+
exports.tokenOutput = path.join(__dirname, '../deploy-info/output/mainnet/token-mainnet.json');
|
5
|
+
exports.tokenpairOutput = path.join(__dirname, '../deploy-info/output/mainnet/tokenpair-mainnet.json');
|
6
|
+
exports.contractOutput = path.join(__dirname, '../deploy-info/output/mainnet/contract-mainnet.json');
|
@@ -0,0 +1,6 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
exports.tokenInput = path.join(__dirname, '../deploy-info/input/testnet/tokenInput-testnet.json');
|
3
|
+
exports.tokenpairInput = path.join(__dirname, '../deploy-info/input/testnet/tokenpairInput-testnet.json');
|
4
|
+
exports.tokenOutput = path.join(__dirname, '../deploy-info/output/testnet/token-testnet.json');
|
5
|
+
exports.tokenpairOutput = path.join(__dirname, '../deploy-info/output/testnet/tokenpair-testnet.json');
|
6
|
+
exports.contractOutput = path.join(__dirname, '../deploy-info/output/testnet/contract-testnet.json');
|
package/dist/config/config.d.ts
CHANGED
package/dist/config/config.js
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
let config = {};
|
2
|
+
const path = require('path');
|
3
|
+
(function () {
|
4
|
+
if (global.network === "testnet") {
|
5
|
+
console.log("use testnet config");
|
6
|
+
config = require('./config-testnet');
|
7
|
+
}
|
8
|
+
if (global.network === "mainnet") {
|
9
|
+
console.log("use mainnet config");
|
10
|
+
config = require('./config-mainnet');
|
11
|
+
}
|
12
|
+
// config.dryRun = true; // only for test
|
13
|
+
config.dryRun = false; // for product
|
14
|
+
console.log("@@@@@@The flag of dryRun is %s@@@@@\n", config.dryRun);
|
15
|
+
})();
|
16
|
+
module.exports = config;
|
package/dist/db/DbAccess.d.ts
CHANGED
@@ -4,9 +4,9 @@ export declare class DBAccess {
|
|
4
4
|
private inited;
|
5
5
|
private scanTran;
|
6
6
|
constructor();
|
7
|
+
static getDBAccess(): DBAccess;
|
7
8
|
init(scanTran: boolean): Promise<void>;
|
8
9
|
clear(): Promise<void>;
|
9
|
-
static getDBAccess(): DBAccess;
|
10
10
|
addDbByName(dbName: string): Promise<void>;
|
11
11
|
removeDbByName(dbName: string): Promise<void>;
|
12
12
|
setTranHandleFlag(dbName: string, tran: TonTransaction, finishOrNot: boolean): Promise<void>;
|
package/dist/db/DbAccess.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.DBAccess = void 0;
|
4
|
-
const DB = require("../db/Db").DB;
|
5
|
-
const RangeOpen = require("../db/Db").RangeOpen;
|
6
4
|
const common_1 = require("./common");
|
7
|
-
const common_2 = require("./common");
|
8
5
|
const core_1 = require("@ton/core");
|
9
6
|
const client_1 = require("../client/client");
|
10
7
|
const utils_1 = require("../utils/utils");
|
11
8
|
const logger_1 = require("../utils/logger");
|
9
|
+
const DB = require("../db/Db").DB;
|
10
|
+
const RangeOpen = require("../db/Db").RangeOpen;
|
12
11
|
let dbAccess = null;
|
13
12
|
async function runAsyncTask(db, scanTran = true) {
|
14
13
|
logger_1.logger.info("DbAccess runAsyncTask......", "dbName", db.getDbName(), "scanTran", scanTran);
|
@@ -22,6 +21,19 @@ class DBAccess {
|
|
22
21
|
this.inited = false;
|
23
22
|
this.scanTran = true;
|
24
23
|
}
|
24
|
+
static getDBAccess() {
|
25
|
+
let isUsing = (0, client_1.getGlobalTonConfig)().usingDbCache ?? false;
|
26
|
+
if (!isUsing) {
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
if (dbAccess == null) {
|
30
|
+
dbAccess = new DBAccess();
|
31
|
+
return dbAccess;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
return dbAccess;
|
35
|
+
}
|
36
|
+
}
|
25
37
|
async init(scanTran) {
|
26
38
|
logger_1.logger.info("begin DbAccess init", "scanTran", scanTran);
|
27
39
|
if (this.inited) {
|
@@ -29,7 +41,7 @@ class DBAccess {
|
|
29
41
|
}
|
30
42
|
let dbNames = [];
|
31
43
|
await (0, utils_1.ensureDirectoryExists)((0, client_1.getDBDataDir)());
|
32
|
-
(0,
|
44
|
+
(0, common_1.listJsonFiles)((0, client_1.getDBDataDir)(), dbNames);
|
33
45
|
for (let dbName of dbNames) {
|
34
46
|
let db = new DB(dbName);
|
35
47
|
await db.init(dbName);
|
@@ -49,18 +61,6 @@ class DBAccess {
|
|
49
61
|
}
|
50
62
|
this.dbs.clear();
|
51
63
|
}
|
52
|
-
static getDBAccess() {
|
53
|
-
if (!(0, client_1.getGlobalTonConfig)().usingDbCache) {
|
54
|
-
return null;
|
55
|
-
}
|
56
|
-
if (dbAccess == null) {
|
57
|
-
dbAccess = new DBAccess();
|
58
|
-
return dbAccess;
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
return dbAccess;
|
62
|
-
}
|
63
|
-
}
|
64
64
|
async addDbByName(dbName) {
|
65
65
|
logger_1.logger.info("before addDbByName", "dbName", dbName, "dbs.length", this.dbs.size);
|
66
66
|
if (this.has(dbName)) {
|