@ton/ton 16.1.0 → 16.2.0
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/README.md +47 -11
- package/dist/client/TonClient.d.ts +6 -6
- package/dist/client/TonClient.js +105 -80
- package/dist/client/TonClient4.d.ts +1 -1
- package/dist/client/TonClient4.js +227 -138
- package/dist/client/api/HttpApi.d.ts +122 -122
- package/dist/client/api/HttpApi.js +103 -72
- package/dist/client/api/TonCache.js +3 -3
- package/dist/config/ConfigParser.js +133 -112
- package/dist/elector/ElectorContract.js +46 -20
- package/dist/index.d.ts +22 -22
- package/dist/jetton/JettonMaster.js +5 -3
- package/dist/jetton/JettonWallet.js +2 -2
- package/dist/multisig/MultisigOrder.d.ts +2 -2
- package/dist/multisig/MultisigOrder.js +1 -1
- package/dist/multisig/MultisigOrderBuilder.d.ts +2 -2
- package/dist/multisig/MultisigOrderBuilder.js +1 -1
- package/dist/multisig/MultisigWallet.d.ts +3 -3
- package/dist/multisig/MultisigWallet.js +8 -8
- package/dist/utils/createTestClient.d.ts +1 -1
- package/dist/utils/createTestClient.js +6 -2
- package/dist/utils/createTestClient4.d.ts +1 -1
- package/dist/utils/createTestClient4.js +5 -1
- package/dist/utils/fees.d.ts +2 -2
- package/dist/utils/fees.js +21 -6
- package/dist/utils/{randomTestKey.d.ts → testUtils.d.ts} +2 -0
- package/dist/utils/testUtils.js +21 -0
- package/dist/utils/testWallets.d.ts +10 -10
- package/dist/utils/time.js +5 -3
- package/dist/utils/toUrlSafe.js +6 -6
- package/dist/wallets/WalletContractV1R1.d.ts +1 -57
- package/dist/wallets/WalletContractV1R1.js +15 -99
- package/dist/wallets/WalletContractV1R2.d.ts +1 -57
- package/dist/wallets/WalletContractV1R2.js +15 -100
- package/dist/wallets/WalletContractV1R3.d.ts +1 -57
- package/dist/wallets/WalletContractV1R3.js +15 -99
- package/dist/wallets/WalletContractV2R1.d.ts +1 -59
- package/dist/wallets/WalletContractV2R1.js +15 -101
- package/dist/wallets/WalletContractV2R2.d.ts +1 -59
- package/dist/wallets/WalletContractV2R2.js +15 -101
- package/dist/wallets/WalletContractV3R1.d.ts +1 -56
- package/dist/wallets/WalletContractV3R1.js +15 -103
- package/dist/wallets/WalletContractV3R2.d.ts +1 -56
- package/dist/wallets/WalletContractV3R2.js +15 -103
- package/dist/wallets/WalletContractV4.d.ts +2 -2
- package/dist/wallets/WalletContractV5Beta.d.ts +3 -3
- package/dist/wallets/WalletContractV5R1.d.ts +3 -3
- package/dist/wallets/signing/createWalletTransfer.d.ts +11 -3
- package/dist/wallets/signing/createWalletTransfer.js +18 -15
- package/dist/wallets/signing/singer.d.ts +2 -1
- package/dist/wallets/signing/singer.js +11 -5
- package/dist/wallets/v1/r1.d.ts +59 -0
- package/dist/wallets/v1/r1.js +103 -0
- package/dist/wallets/v1/r2.d.ts +59 -0
- package/dist/wallets/v1/r2.js +104 -0
- package/dist/wallets/v1/r3.d.ts +59 -0
- package/dist/wallets/v1/r3.js +103 -0
- package/dist/wallets/v2/r1.d.ts +61 -0
- package/dist/wallets/v2/r1.js +107 -0
- package/dist/wallets/v2/r2.d.ts +61 -0
- package/dist/wallets/v2/r2.js +107 -0
- package/dist/wallets/v3/r1.d.ts +58 -0
- package/dist/wallets/v3/r1.js +109 -0
- package/dist/wallets/v3/r2.d.ts +58 -0
- package/dist/wallets/v3/r2.js +109 -0
- package/dist/wallets/v4/WalletContractV4.d.ts +4 -2
- package/dist/wallets/v4/WalletContractV4.js +36 -32
- package/dist/wallets/v4/WalletContractV4Actions.d.ts +4 -4
- package/dist/wallets/v4/WalletContractV4Actions.js +10 -10
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +7 -5
- package/dist/wallets/v5beta/WalletContractV5Beta.js +44 -28
- package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +1 -1
- package/dist/wallets/v5beta/WalletV5BetaActions.js +25 -18
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +2 -2
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +6 -4
- package/dist/wallets/v5beta/WalletV5OutActions.d.ts +4 -4
- package/dist/wallets/v5beta/WalletV5OutActions.js +3 -1
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +10 -6
- package/dist/wallets/v5r1/WalletContractV5R1.js +55 -36
- package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +3 -3
- package/dist/wallets/v5r1/WalletV5R1Actions.js +32 -25
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +2 -2
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +16 -10
- package/package.json +62 -65
- package/dist/client/TonClient.spec.d.ts +0 -1
- package/dist/client/TonClient.spec.js +0 -59
- package/dist/client/TonClient4.spec.d.ts +0 -1
- package/dist/client/TonClient4.spec.js +0 -67
- package/dist/config/ConfigParser.spec.d.ts +0 -8
- package/dist/config/ConfigParser.spec.js +0 -247
- package/dist/elector/ElectorContract.spec.d.ts +0 -8
- package/dist/elector/ElectorContract.spec.js +0 -104
- package/dist/jetton/JettonMaster.spec.d.ts +0 -8
- package/dist/jetton/JettonMaster.spec.js +0 -27
- package/dist/multisig/MultisigOrder.spec.d.ts +0 -1
- package/dist/multisig/MultisigOrder.spec.js +0 -139
- package/dist/multisig/MultisigWallet.spec.d.ts +0 -1
- package/dist/multisig/MultisigWallet.spec.js +0 -248
- package/dist/utils/fees.spec.d.ts +0 -1
- package/dist/utils/fees.spec.js +0 -83
- package/dist/utils/randomTestKey.js +0 -23
- package/dist/wallets/WalletContractV1R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R1.spec.js +0 -67
- package/dist/wallets/WalletContractV1R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R2.spec.js +0 -67
- package/dist/wallets/WalletContractV1R3.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV1R3.spec.js +0 -44
- package/dist/wallets/WalletContractV2R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R1.spec.js +0 -67
- package/dist/wallets/WalletContractV2R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV2R2.spec.js +0 -67
- package/dist/wallets/WalletContractV3R1.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R1.spec.js +0 -67
- package/dist/wallets/WalletContractV3R2.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV3R2.spec.js +0 -67
- package/dist/wallets/v4/WalletContractV4.spec.d.ts +0 -8
- package/dist/wallets/v4/WalletContractV4.spec.js +0 -157
- package/dist/wallets/v4/WalletContractV4Actions.spec.d.ts +0 -1
- package/dist/wallets/v4/WalletContractV4Actions.spec.js +0 -74
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +0 -8
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +0 -317
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +0 -166
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +0 -68
- package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +0 -8
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +0 -340
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +0 -262
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +0 -103
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isOutActionExtended = isOutActionExtended;
|
|
4
4
|
exports.isOutActionBasic = isOutActionBasic;
|
|
5
5
|
function isOutActionExtended(action) {
|
|
6
|
-
return (action.type ===
|
|
6
|
+
return (action.type === "setIsPublicKeyEnabled" ||
|
|
7
|
+
action.type === "addExtension" ||
|
|
8
|
+
action.type === "removeExtension");
|
|
7
9
|
}
|
|
8
10
|
function isOutActionBasic(action) {
|
|
9
11
|
return !isOutActionExtended(action);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
8
|
+
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode, SignatureDomain } from "@ton/core";
|
|
9
9
|
import { Maybe } from "../../utils/maybe";
|
|
10
10
|
import { SendArgsSignable, SendArgsSigned } from "../signing/singer";
|
|
11
11
|
import { OutActionWalletV5 } from "../v5beta/WalletV5OutActions";
|
|
@@ -15,13 +15,13 @@ export type WalletV5R1BasicSendArgs = {
|
|
|
15
15
|
timeout?: Maybe<number>;
|
|
16
16
|
};
|
|
17
17
|
export type WalletV5R1SendArgsSinged = WalletV5R1BasicSendArgs & SendArgsSigned & {
|
|
18
|
-
authType?:
|
|
18
|
+
authType?: "external" | "internal";
|
|
19
19
|
};
|
|
20
20
|
export type WalletV5R1SendArgsSignable = WalletV5R1BasicSendArgs & SendArgsSignable & {
|
|
21
|
-
authType?:
|
|
21
|
+
authType?: "external" | "internal";
|
|
22
22
|
};
|
|
23
23
|
export type Wallet5VR1SendArgsExtensionAuth = WalletV5R1BasicSendArgs & {
|
|
24
|
-
authType:
|
|
24
|
+
authType: "extension";
|
|
25
25
|
queryId?: bigint;
|
|
26
26
|
};
|
|
27
27
|
export type WalletV5R1SendArgs = WalletV5R1SendArgsSinged | WalletV5R1SendArgsSignable | Wallet5VR1SendArgsExtensionAuth;
|
|
@@ -29,25 +29,29 @@ export type WalletV5R1PackedCell<T> = T extends WalletV5R1SendArgsSignable ? Pro
|
|
|
29
29
|
export declare class WalletContractV5R1 implements Contract {
|
|
30
30
|
readonly publicKey: Buffer;
|
|
31
31
|
readonly walletId: WalletIdV5R1<WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>;
|
|
32
|
+
readonly globalId?: number | undefined;
|
|
32
33
|
static OpCodes: {
|
|
33
34
|
auth_extension: number;
|
|
34
35
|
auth_signed_external: number;
|
|
35
36
|
auth_signed_internal: number;
|
|
36
37
|
};
|
|
37
|
-
static create<C extends WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>(args: C extends WalletIdV5R1ClientContext ? {
|
|
38
|
+
static create<C extends WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>(args: (C extends WalletIdV5R1ClientContext ? {
|
|
38
39
|
walletId?: Maybe<WalletIdV5R1<C>>;
|
|
39
40
|
publicKey: Buffer;
|
|
40
41
|
} : {
|
|
41
42
|
workchain?: number;
|
|
42
43
|
publicKey: Buffer;
|
|
43
44
|
walletId?: Maybe<Partial<WalletIdV5R1<C>>>;
|
|
45
|
+
}) & {
|
|
46
|
+
domain?: SignatureDomain;
|
|
44
47
|
}): WalletContractV5R1;
|
|
45
48
|
readonly address: Address;
|
|
46
49
|
readonly init: {
|
|
47
50
|
data: Cell;
|
|
48
51
|
code: Cell;
|
|
49
52
|
};
|
|
50
|
-
|
|
53
|
+
domain?: SignatureDomain;
|
|
54
|
+
constructor(workchain: number, publicKey: Buffer, walletId: WalletIdV5R1<WalletIdV5R1ClientContext | WalletIdV5R1CustomContext>, domain?: SignatureDomain, globalId?: number | undefined);
|
|
51
55
|
/**
|
|
52
56
|
* Get Wallet Balance
|
|
53
57
|
*/
|
|
@@ -14,27 +14,31 @@ const WalletV5R1WalletId_1 = require("./WalletV5R1WalletId");
|
|
|
14
14
|
class WalletContractV5R1 {
|
|
15
15
|
static create(args) {
|
|
16
16
|
let workchain = 0;
|
|
17
|
-
if (
|
|
17
|
+
if ("workchain" in args && args.workchain != undefined) {
|
|
18
18
|
workchain = args.workchain;
|
|
19
19
|
}
|
|
20
|
-
if (args.walletId?.context &&
|
|
20
|
+
if (args.walletId?.context &&
|
|
21
|
+
(0, WalletV5R1WalletId_1.isWalletIdV5R1ClientContext)(args.walletId.context) &&
|
|
22
|
+
args.walletId.context.workchain != undefined) {
|
|
21
23
|
workchain = args.walletId.context.workchain;
|
|
22
24
|
}
|
|
23
25
|
return new WalletContractV5R1(workchain, args.publicKey, {
|
|
24
26
|
networkGlobalId: args.walletId?.networkGlobalId ?? -239,
|
|
25
27
|
context: args.walletId?.context ?? {
|
|
26
28
|
workchain: 0,
|
|
27
|
-
walletVersion:
|
|
28
|
-
subwalletNumber: 0
|
|
29
|
-
}
|
|
30
|
-
});
|
|
29
|
+
walletVersion: "v5r1",
|
|
30
|
+
subwalletNumber: 0,
|
|
31
|
+
},
|
|
32
|
+
}, args.domain);
|
|
31
33
|
}
|
|
32
|
-
constructor(workchain, publicKey, walletId) {
|
|
34
|
+
constructor(workchain, publicKey, walletId, domain, globalId) {
|
|
33
35
|
this.publicKey = publicKey;
|
|
34
36
|
this.walletId = walletId;
|
|
37
|
+
this.globalId = globalId;
|
|
35
38
|
this.walletId = walletId;
|
|
39
|
+
this.domain = domain;
|
|
36
40
|
// https://github.com/ton-blockchain/wallet-contract-v5/blob/4fab977f4fae3a37c1aac216ed2b7e611a9bc2af/build/wallet_v5.compiled.json
|
|
37
|
-
let code = core_1.Cell.fromBoc(Buffer.from(
|
|
41
|
+
let code = core_1.Cell.fromBoc(Buffer.from("b5ee9c7241021401000281000114ff00f4a413f4bcf2c80b01020120020d020148030402dcd020d749c120915b8f6320d70b1f2082106578746ebd21821073696e74bdb0925f03e082106578746eba8eb48020d72101d074d721fa4030fa44f828fa443058bd915be0ed44d0810141d721f4058307f40e6fa1319130e18040d721707fdb3ce03120d749810280b99130e070e2100f020120050c020120060902016e07080019adce76a2684020eb90eb85ffc00019af1df6a2684010eb90eb858fc00201480a0b0017b325fb51341c75c875c2c7e00011b262fb513435c280200019be5f0f6a2684080a0eb90fa02c0102f20e011e20d70b1f82107369676ebaf2e08a7f0f01e68ef0eda2edfb218308d722028308d723208020d721d31fd31fd31fed44d0d200d31f20d31fd3ffd70a000af90140ccf9109a28945f0adb31e1f2c087df02b35007b0f2d0845125baf2e0855036baf2e086f823bbf2d0882292f800de01a47fc8ca00cb1f01cf16c9ed542092f80fde70db3cd81003f6eda2edfb02f404216e926c218e4c0221d73930709421c700b38e2d01d72820761e436c20d749c008f2e09320d74ac002f2e09320d71d06c712c2005230b0f2d089d74cd7393001a4e86c128407bbf2e093d74ac000f2e093ed55e2d20001c000915be0ebd72c08142091709601d72c081c12e25210b1e30f20d74a111213009601fa4001fa44f828fa443058baf2e091ed44d0810141d718f405049d7fc8ca0040048307f453f2e08b8e14038307f45bf2e08c22d70a00216e01b3b0f2d090e2c85003cf1612f400c9ed54007230d72c08248e2d21f2e092d200ed44d0d2005113baf2d08f54503091319c01810140d721d70a00f2e08ee2c8ca0058cf16c9ed5493f2c08de20010935bdb31e1d74cd0b4d6c35e", "hex"))[0];
|
|
38
42
|
let data = (0, core_1.beginCell)()
|
|
39
43
|
.storeUint(1, 1) // is signature auth allowed
|
|
40
44
|
.storeUint(0, 32) // Seqno
|
|
@@ -57,8 +61,8 @@ class WalletContractV5R1 {
|
|
|
57
61
|
*/
|
|
58
62
|
async getSeqno(provider) {
|
|
59
63
|
let state = await provider.getState();
|
|
60
|
-
if (state.state.type ===
|
|
61
|
-
let res = await provider.get(
|
|
64
|
+
if (state.state.type === "active") {
|
|
65
|
+
let res = await provider.get("seqno", []);
|
|
62
66
|
return res.stack.readNumber();
|
|
63
67
|
}
|
|
64
68
|
else {
|
|
@@ -70,8 +74,8 @@ class WalletContractV5R1 {
|
|
|
70
74
|
*/
|
|
71
75
|
async getExtensions(provider) {
|
|
72
76
|
let state = await provider.getState();
|
|
73
|
-
if (state.state.type ===
|
|
74
|
-
const result = await provider.get(
|
|
77
|
+
if (state.state.type === "active") {
|
|
78
|
+
const result = await provider.get("get_extensions", []);
|
|
75
79
|
return result.stack.readCellOpt();
|
|
76
80
|
}
|
|
77
81
|
else {
|
|
@@ -87,16 +91,16 @@ class WalletContractV5R1 {
|
|
|
87
91
|
return [];
|
|
88
92
|
}
|
|
89
93
|
const dict = core_1.Dictionary.loadDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(1), extensions);
|
|
90
|
-
return dict.keys().map(addressHex => {
|
|
94
|
+
return dict.keys().map((addressHex) => {
|
|
91
95
|
const wc = this.address.workChain;
|
|
92
|
-
return core_1.Address.parseRaw(`${wc}:${addressHex.toString(16).padStart(64,
|
|
96
|
+
return core_1.Address.parseRaw(`${wc}:${addressHex.toString(16).padStart(64, "0")}`);
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
99
|
/**
|
|
96
100
|
* Get is secret-key authentication enabled
|
|
97
101
|
*/
|
|
98
102
|
async getIsSecretKeyAuthEnabled(provider) {
|
|
99
|
-
let res = await provider.get(
|
|
103
|
+
let res = await provider.get("is_signature_allowed", []);
|
|
100
104
|
return res.stack.readBoolean();
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
@@ -127,7 +131,11 @@ class WalletContractV5R1 {
|
|
|
127
131
|
await this.send(provider, request);
|
|
128
132
|
}
|
|
129
133
|
createActions(args) {
|
|
130
|
-
const actions = args.messages.map(message => ({
|
|
134
|
+
const actions = args.messages.map((message) => ({
|
|
135
|
+
type: "sendMsg",
|
|
136
|
+
mode: args.sendMode,
|
|
137
|
+
outMsg: message,
|
|
138
|
+
}));
|
|
131
139
|
return actions;
|
|
132
140
|
}
|
|
133
141
|
/**
|
|
@@ -135,8 +143,11 @@ class WalletContractV5R1 {
|
|
|
135
143
|
*/
|
|
136
144
|
createTransfer(args) {
|
|
137
145
|
return this.createRequest({
|
|
138
|
-
actions: this.createActions({
|
|
139
|
-
|
|
146
|
+
actions: this.createActions({
|
|
147
|
+
messages: args.messages,
|
|
148
|
+
sendMode: args.sendMode,
|
|
149
|
+
}),
|
|
150
|
+
...args,
|
|
140
151
|
});
|
|
141
152
|
}
|
|
142
153
|
/**
|
|
@@ -144,11 +155,13 @@ class WalletContractV5R1 {
|
|
|
144
155
|
*/
|
|
145
156
|
createAddExtension(args) {
|
|
146
157
|
return this.createRequest({
|
|
147
|
-
actions: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
actions: [
|
|
159
|
+
{
|
|
160
|
+
type: "addExtension",
|
|
161
|
+
address: args.extensionAddress,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
...args,
|
|
152
165
|
});
|
|
153
166
|
}
|
|
154
167
|
/**
|
|
@@ -156,23 +169,26 @@ class WalletContractV5R1 {
|
|
|
156
169
|
*/
|
|
157
170
|
createRemoveExtension(args) {
|
|
158
171
|
return this.createRequest({
|
|
159
|
-
actions: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
actions: [
|
|
173
|
+
{
|
|
174
|
+
type: "removeExtension",
|
|
175
|
+
address: args.extensionAddress,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
...args,
|
|
164
179
|
});
|
|
165
180
|
}
|
|
166
181
|
/**
|
|
167
182
|
* Create signed request or extension auth request
|
|
168
183
|
*/
|
|
169
184
|
createRequest(args) {
|
|
170
|
-
if (args.authType ===
|
|
185
|
+
if (args.authType === "extension") {
|
|
171
186
|
return (0, createWalletTransfer_1.createWalletTransferV5R1)(args);
|
|
172
187
|
}
|
|
173
188
|
return (0, createWalletTransfer_1.createWalletTransferV5R1)({
|
|
174
189
|
...args,
|
|
175
|
-
walletId: (0, WalletV5R1WalletId_1.storeWalletIdV5R1)(this.walletId)
|
|
190
|
+
walletId: (0, WalletV5R1WalletId_1.storeWalletIdV5R1)(this.walletId),
|
|
191
|
+
domain: this.domain,
|
|
176
192
|
});
|
|
177
193
|
}
|
|
178
194
|
/**
|
|
@@ -185,18 +201,21 @@ class WalletContractV5R1 {
|
|
|
185
201
|
let transfer = this.createTransfer({
|
|
186
202
|
seqno,
|
|
187
203
|
secretKey,
|
|
188
|
-
sendMode: args.sendMode ??
|
|
189
|
-
|
|
204
|
+
sendMode: args.sendMode ??
|
|
205
|
+
core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
206
|
+
messages: [
|
|
207
|
+
(0, core_1.internal)({
|
|
190
208
|
to: args.to,
|
|
191
209
|
value: args.value,
|
|
192
210
|
extracurrency: args.extracurrency,
|
|
193
211
|
init: args.init,
|
|
194
212
|
body: args.body,
|
|
195
|
-
bounce: args.bounce
|
|
196
|
-
})
|
|
213
|
+
bounce: args.bounce,
|
|
214
|
+
}),
|
|
215
|
+
],
|
|
197
216
|
});
|
|
198
217
|
await this.send(provider, transfer);
|
|
199
|
-
}
|
|
218
|
+
},
|
|
200
219
|
};
|
|
201
220
|
}
|
|
202
221
|
}
|
|
@@ -204,5 +223,5 @@ exports.WalletContractV5R1 = WalletContractV5R1;
|
|
|
204
223
|
WalletContractV5R1.OpCodes = {
|
|
205
224
|
auth_extension: 0x6578746e,
|
|
206
225
|
auth_signed_external: 0x7369676e,
|
|
207
|
-
auth_signed_internal: 0x73696e74
|
|
226
|
+
auth_signed_internal: 0x73696e74,
|
|
208
227
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Builder, OutActionSendMsg, SendMode, Slice } from
|
|
1
|
+
import { Builder, OutActionSendMsg, SendMode, Slice } from "@ton/core";
|
|
2
2
|
import { OutActionExtended, OutActionWalletV5 } from "../v5beta/WalletV5OutActions";
|
|
3
3
|
import { WalletV5R1SendArgs } from "./WalletContractV5R1";
|
|
4
4
|
export declare function storeOutActionExtendedV5R1(action: OutActionExtended): (builder: Builder) => void;
|
|
@@ -8,5 +8,5 @@ export declare function loadOutListExtendedV5R1(slice: Slice): (OutActionExtende
|
|
|
8
8
|
/**
|
|
9
9
|
* Safety rules -- actions of external messages must have +2 in the SendMode. Internal messages actions may have arbitrary SendMode.
|
|
10
10
|
*/
|
|
11
|
-
export declare function toSafeV5R1SendMode(sendMode: SendMode, authType: WalletV5R1SendArgs[
|
|
12
|
-
export declare function patchV5R1ActionsSendMode(actions: OutActionWalletV5[], authType: WalletV5R1SendArgs[
|
|
11
|
+
export declare function toSafeV5R1SendMode(sendMode: SendMode, authType: WalletV5R1SendArgs["authType"]): number;
|
|
12
|
+
export declare function patchV5R1ActionsSendMode(actions: OutActionWalletV5[], authType: WalletV5R1SendArgs["authType"]): OutActionWalletV5[];
|
|
@@ -11,31 +11,37 @@ const WalletV5OutActions_1 = require("../v5beta/WalletV5OutActions");
|
|
|
11
11
|
const outActionSetIsPublicKeyEnabledTag = 0x04;
|
|
12
12
|
function storeOutActionSetIsPublicKeyEnabled(action) {
|
|
13
13
|
return (builder) => {
|
|
14
|
-
builder
|
|
14
|
+
builder
|
|
15
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 8)
|
|
16
|
+
.storeUint(action.isEnabled ? 1 : 0, 1);
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
const outActionAddExtensionTag = 0x02;
|
|
18
20
|
function storeOutActionAddExtension(action) {
|
|
19
21
|
return (builder) => {
|
|
20
|
-
builder
|
|
22
|
+
builder
|
|
23
|
+
.storeUint(outActionAddExtensionTag, 8)
|
|
24
|
+
.storeAddress(action.address);
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
const outActionRemoveExtensionTag = 0x03;
|
|
24
28
|
function storeOutActionRemoveExtension(action) {
|
|
25
29
|
return (builder) => {
|
|
26
|
-
builder
|
|
30
|
+
builder
|
|
31
|
+
.storeUint(outActionRemoveExtensionTag, 8)
|
|
32
|
+
.storeAddress(action.address);
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
35
|
function storeOutActionExtendedV5R1(action) {
|
|
30
36
|
switch (action.type) {
|
|
31
|
-
case
|
|
37
|
+
case "setIsPublicKeyEnabled":
|
|
32
38
|
return storeOutActionSetIsPublicKeyEnabled(action);
|
|
33
|
-
case
|
|
39
|
+
case "addExtension":
|
|
34
40
|
return storeOutActionAddExtension(action);
|
|
35
|
-
case
|
|
41
|
+
case "removeExtension":
|
|
36
42
|
return storeOutActionRemoveExtension(action);
|
|
37
43
|
default:
|
|
38
|
-
throw new Error(
|
|
44
|
+
throw new Error("Unknown action type" + action?.type);
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
function loadOutActionExtendedV5R1(slice) {
|
|
@@ -43,18 +49,18 @@ function loadOutActionExtendedV5R1(slice) {
|
|
|
43
49
|
switch (tag) {
|
|
44
50
|
case outActionSetIsPublicKeyEnabledTag:
|
|
45
51
|
return {
|
|
46
|
-
type:
|
|
47
|
-
isEnabled: !!slice.loadUint(1)
|
|
52
|
+
type: "setIsPublicKeyEnabled",
|
|
53
|
+
isEnabled: !!slice.loadUint(1),
|
|
48
54
|
};
|
|
49
55
|
case outActionAddExtensionTag:
|
|
50
56
|
return {
|
|
51
|
-
type:
|
|
52
|
-
address: slice.loadAddress()
|
|
57
|
+
type: "addExtension",
|
|
58
|
+
address: slice.loadAddress(),
|
|
53
59
|
};
|
|
54
60
|
case outActionRemoveExtensionTag:
|
|
55
61
|
return {
|
|
56
|
-
type:
|
|
57
|
-
address: slice.loadAddress()
|
|
62
|
+
type: "removeExtension",
|
|
63
|
+
address: slice.loadAddress(),
|
|
58
64
|
};
|
|
59
65
|
default:
|
|
60
66
|
throw new Error(`Unknown extended out action tag 0x${tag.toString(16)}`);
|
|
@@ -64,16 +70,16 @@ function storeOutListExtendedV5R1(actions) {
|
|
|
64
70
|
const extendedActions = actions.filter(WalletV5OutActions_1.isOutActionExtended);
|
|
65
71
|
const basicActions = actions.filter(WalletV5OutActions_1.isOutActionBasic);
|
|
66
72
|
return (builder) => {
|
|
67
|
-
const outListPacked = basicActions.length
|
|
73
|
+
const outListPacked = basicActions.length
|
|
74
|
+
? (0, core_1.beginCell)().store((0, core_1.storeOutList)(basicActions))
|
|
75
|
+
: null;
|
|
68
76
|
builder.storeMaybeRef(outListPacked);
|
|
69
77
|
if (extendedActions.length === 0) {
|
|
70
78
|
builder.storeUint(0, 1);
|
|
71
79
|
}
|
|
72
80
|
else {
|
|
73
81
|
const [first, ...rest] = extendedActions;
|
|
74
|
-
builder
|
|
75
|
-
.storeUint(1, 1)
|
|
76
|
-
.store(storeOutActionExtendedV5R1(first));
|
|
82
|
+
builder.storeUint(1, 1).store(storeOutActionExtendedV5R1(first));
|
|
77
83
|
if (rest.length > 0) {
|
|
78
84
|
builder.storeRef(packExtendedActionsRec(rest));
|
|
79
85
|
}
|
|
@@ -82,8 +88,7 @@ function storeOutListExtendedV5R1(actions) {
|
|
|
82
88
|
}
|
|
83
89
|
function packExtendedActionsRec(extendedActions) {
|
|
84
90
|
const [first, ...rest] = extendedActions;
|
|
85
|
-
let builder = (0, core_1.beginCell)()
|
|
86
|
-
.store(storeOutActionExtendedV5R1(first));
|
|
91
|
+
let builder = (0, core_1.beginCell)().store(storeOutActionExtendedV5R1(first));
|
|
87
92
|
if (rest.length > 0) {
|
|
88
93
|
builder = builder.storeRef(packExtendedActionsRec(rest));
|
|
89
94
|
}
|
|
@@ -94,7 +99,7 @@ function loadOutListExtendedV5R1(slice) {
|
|
|
94
99
|
const outListPacked = slice.loadMaybeRef();
|
|
95
100
|
if (outListPacked) {
|
|
96
101
|
const loadedActions = (0, core_1.loadOutList)(outListPacked.beginParse());
|
|
97
|
-
if (loadedActions.some(a => a.type !==
|
|
102
|
+
if (loadedActions.some((a) => a.type !== "sendMsg")) {
|
|
98
103
|
throw new Error("Can't deserialize actions list: only sendMsg actions are allowed for wallet v5r1");
|
|
99
104
|
}
|
|
100
105
|
actions.push(...loadedActions);
|
|
@@ -114,14 +119,16 @@ function loadOutListExtendedV5R1(slice) {
|
|
|
114
119
|
* Safety rules -- actions of external messages must have +2 in the SendMode. Internal messages actions may have arbitrary SendMode.
|
|
115
120
|
*/
|
|
116
121
|
function toSafeV5R1SendMode(sendMode, authType) {
|
|
117
|
-
if (authType ===
|
|
122
|
+
if (authType === "internal" || authType === "extension") {
|
|
118
123
|
return sendMode;
|
|
119
124
|
}
|
|
120
125
|
return sendMode | core_1.SendMode.IGNORE_ERRORS;
|
|
121
126
|
}
|
|
122
127
|
function patchV5R1ActionsSendMode(actions, authType) {
|
|
123
|
-
return actions.map(action => action.type ===
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
return actions.map((action) => action.type === "sendMsg"
|
|
129
|
+
? {
|
|
130
|
+
...action,
|
|
131
|
+
mode: toSafeV5R1SendMode(action.mode, authType),
|
|
132
|
+
}
|
|
133
|
+
: action);
|
|
127
134
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Builder, Slice } from
|
|
1
|
+
import { Builder, Slice } from "@ton/core";
|
|
2
2
|
/**
|
|
3
3
|
* schema:
|
|
4
4
|
* wallet_id -- int32
|
|
@@ -29,7 +29,7 @@ export interface WalletIdV5R1<C extends WalletIdV5R1ClientContext | WalletIdV5R1
|
|
|
29
29
|
readonly context: C;
|
|
30
30
|
}
|
|
31
31
|
export interface WalletIdV5R1ClientContext {
|
|
32
|
-
readonly walletVersion:
|
|
32
|
+
readonly walletVersion: "v5r1";
|
|
33
33
|
readonly workchain: number;
|
|
34
34
|
readonly subwalletNumber: number;
|
|
35
35
|
}
|
|
@@ -5,19 +5,21 @@ exports.loadWalletIdV5R1 = loadWalletIdV5R1;
|
|
|
5
5
|
exports.storeWalletIdV5R1 = storeWalletIdV5R1;
|
|
6
6
|
const core_1 = require("@ton/core");
|
|
7
7
|
function isWalletIdV5R1ClientContext(context) {
|
|
8
|
-
return typeof context !==
|
|
8
|
+
return typeof context !== "number";
|
|
9
9
|
}
|
|
10
10
|
const walletV5R1VersionsSerialisation = {
|
|
11
|
-
v5r1: 0
|
|
11
|
+
v5r1: 0,
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* @param value serialized wallet id
|
|
15
15
|
* @param networkGlobalId -239 is mainnet, -3 is testnet
|
|
16
16
|
*/
|
|
17
17
|
function loadWalletIdV5R1(value, networkGlobalId) {
|
|
18
|
-
const val = new core_1.BitReader(new core_1.BitString(typeof value ===
|
|
19
|
-
Buffer.from(value.toString(16).padStart(8,
|
|
20
|
-
value instanceof core_1.Slice
|
|
18
|
+
const val = new core_1.BitReader(new core_1.BitString(typeof value === "bigint"
|
|
19
|
+
? Buffer.from(value.toString(16).padStart(8, "0"), "hex")
|
|
20
|
+
: value instanceof core_1.Slice
|
|
21
|
+
? value.loadBuffer(4)
|
|
22
|
+
: value, 0, 32)).loadInt(32);
|
|
21
23
|
const context = BigInt(val) ^ BigInt(networkGlobalId);
|
|
22
24
|
const bitReader = (0, core_1.beginCell)().storeInt(context, 32).endCell().beginParse();
|
|
23
25
|
const isClientContext = bitReader.loadUint(1);
|
|
@@ -34,15 +36,15 @@ function loadWalletIdV5R1(value, networkGlobalId) {
|
|
|
34
36
|
context: {
|
|
35
37
|
walletVersion,
|
|
36
38
|
workchain,
|
|
37
|
-
subwalletNumber
|
|
38
|
-
}
|
|
39
|
+
subwalletNumber,
|
|
40
|
+
},
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
const context = bitReader.loadUint(31);
|
|
43
45
|
return {
|
|
44
46
|
networkGlobalId,
|
|
45
|
-
context
|
|
47
|
+
context,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
}
|
|
@@ -55,13 +57,17 @@ function storeWalletIdV5R1(walletId) {
|
|
|
55
57
|
.storeInt(walletId.context.workchain, 8)
|
|
56
58
|
.storeUint(walletV5R1VersionsSerialisation[walletId.context.walletVersion], 8)
|
|
57
59
|
.storeUint(walletId.context.subwalletNumber, 15)
|
|
58
|
-
.endCell()
|
|
60
|
+
.endCell()
|
|
61
|
+
.beginParse()
|
|
62
|
+
.loadInt(32);
|
|
59
63
|
}
|
|
60
64
|
else {
|
|
61
65
|
context = (0, core_1.beginCell)()
|
|
62
66
|
.storeUint(0, 1)
|
|
63
67
|
.storeUint(walletId.context, 31)
|
|
64
|
-
.endCell()
|
|
68
|
+
.endCell()
|
|
69
|
+
.beginParse()
|
|
70
|
+
.loadInt(32);
|
|
65
71
|
}
|
|
66
72
|
return builder.storeInt(BigInt(walletId.networkGlobalId) ^ BigInt(context), 32);
|
|
67
73
|
};
|
package/package.json
CHANGED
|
@@ -1,68 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"expect": "^27.1.0",
|
|
26
|
-
"jest": "^27.1.0",
|
|
27
|
-
"jest-mock": "^27.1.0",
|
|
28
|
-
"karma": "^6.3.4",
|
|
29
|
-
"karma-chrome-launcher": "^3.1.0",
|
|
30
|
-
"karma-jasmine": "^4.0.1",
|
|
31
|
-
"karma-typescript": "^5.5.2",
|
|
32
|
-
"karma-webpack": "^5.0.0",
|
|
33
|
-
"prando": "^6.0.1",
|
|
34
|
-
"release-it": "^17.1.1",
|
|
35
|
-
"ts-jest": "^27.0.5",
|
|
36
|
-
"ts-loader": "^9.2.5",
|
|
37
|
-
"ts-node": "^10.7.0",
|
|
38
|
-
"typedoc": "^0.23.24",
|
|
39
|
-
"typescript": "^5.6.3",
|
|
40
|
-
"webpack": "^5.51.2"
|
|
41
|
-
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"axios": "^1.6.7",
|
|
44
|
-
"dataloader": "^2.0.0",
|
|
45
|
-
"symbol.inspect": "1.0.1",
|
|
46
|
-
"teslabot": "^1.3.0",
|
|
47
|
-
"zod": "^3.21.4"
|
|
48
|
-
},
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"@ton/core": ">=0.62.0 <1.0.0",
|
|
51
|
-
"@ton/crypto": ">=3.2.0"
|
|
52
|
-
},
|
|
53
|
-
"publishConfig": {
|
|
54
|
-
"access": "public",
|
|
55
|
-
"registry": "https://registry.npmjs.org/"
|
|
56
|
-
},
|
|
57
|
-
"release-it": {
|
|
58
|
-
"github": {
|
|
59
|
-
"release": true
|
|
2
|
+
"name": "@ton/ton",
|
|
3
|
+
"version": "16.2.0",
|
|
4
|
+
"repository": "https://github.com/ton-org/ton.git",
|
|
5
|
+
"author": "Whales Corp. <developers@whalescorp.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"!*.test.*",
|
|
11
|
+
"!*.spec.*",
|
|
12
|
+
"!*.trait.*",
|
|
13
|
+
"!__snapshots__",
|
|
14
|
+
"!__testdata__",
|
|
15
|
+
"!__tests__"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -fr dist && tsc -p ./tsconfig.build.json",
|
|
19
|
+
"typecheck": "tsc",
|
|
20
|
+
"test": "jest --verbose",
|
|
21
|
+
"format": "biome format --write .",
|
|
22
|
+
"format:check": "biome format .",
|
|
23
|
+
"coverage": "jest -c ./jest-coverage.config.js",
|
|
24
|
+
"release": "yarn build && yarn release-it --npm.yarn1"
|
|
60
25
|
},
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@biomejs/biome": "2.3.8",
|
|
28
|
+
"@release-it/keep-a-changelog": "^5.0.0",
|
|
29
|
+
"@swc/core": "^1.15.3",
|
|
30
|
+
"@swc/jest": "^0.2.39",
|
|
31
|
+
"@ton/core": "^0.63.0",
|
|
32
|
+
"@ton/crypto": "3.2.0",
|
|
33
|
+
"@ton/sandbox": "^0.40.0",
|
|
34
|
+
"@ton/test-utils": "^0.12.0",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/node": "^20.11.30",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"release-it": "^17.1.1",
|
|
39
|
+
"typescript": "^5.6.3"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"axios": "^1.6.7",
|
|
43
|
+
"dataloader": "^2.0.0",
|
|
44
|
+
"zod": "^3.21.4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@ton/core": ">=0.63.0 <1.0.0",
|
|
48
|
+
"@ton/crypto": ">=3.2.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"release-it": {
|
|
55
|
+
"github": {
|
|
56
|
+
"release": true
|
|
57
|
+
},
|
|
58
|
+
"plugins": {
|
|
59
|
+
"@release-it/keep-a-changelog": {
|
|
60
|
+
"filename": "CHANGELOG.md"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"packageManager": "yarn@3.4.1"
|
|
68
65
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|