@ton-wallet/create 14.0.1 → 14.0.3
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/client/TonClient.d.ts +228 -0
- package/dist/client/TonClient.js +441 -0
- package/dist/client/TonClient.spec.d.ts +1 -0
- package/dist/client/TonClient.spec.js +45 -0
- package/dist/client/TonClient4.d.ts +1130 -0
- package/dist/client/TonClient4.js +687 -0
- package/dist/client/TonClient4.spec.d.ts +1 -0
- package/dist/client/TonClient4.spec.js +42 -0
- package/dist/client/api/HttpApi.d.ts +764 -0
- package/dist/client/api/HttpApi.js +306 -0
- package/dist/client/api/TonCache.d.ts +16 -0
- package/dist/client/api/TonCache.js +33 -0
- package/dist/config/ConfigParser.d.ts +622 -0
- package/dist/config/ConfigParser.js +711 -0
- package/dist/config/ConfigParser.spec.d.ts +8 -0
- package/dist/config/ConfigParser.spec.js +97 -0
- package/dist/elector/ElectorContract.d.ts +51 -0
- package/dist/elector/ElectorContract.js +192 -0
- package/dist/elector/ElectorContract.spec.d.ts +8 -0
- package/dist/elector/ElectorContract.spec.js +104 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +129 -0
- package/dist/jetton/JettonMaster.d.ts +21 -0
- package/dist/jetton/JettonMaster.js +39 -0
- package/dist/jetton/JettonMaster.spec.d.ts +8 -0
- package/dist/jetton/JettonMaster.spec.js +27 -0
- package/dist/jetton/JettonWallet.d.ts +14 -0
- package/dist/jetton/JettonWallet.js +27 -0
- package/dist/multisig/MultisigOrder.d.ts +17 -0
- package/dist/multisig/MultisigOrder.js +73 -0
- package/dist/multisig/MultisigOrder.spec.d.ts +1 -0
- package/dist/multisig/MultisigOrder.spec.js +139 -0
- package/dist/multisig/MultisigOrderBuilder.d.ts +13 -0
- package/dist/multisig/MultisigOrderBuilder.js +37 -0
- package/dist/multisig/MultisigWallet.d.ts +27 -0
- package/dist/multisig/MultisigWallet.js +134 -0
- package/dist/multisig/MultisigWallet.spec.d.ts +1 -0
- package/dist/multisig/MultisigWallet.spec.js +248 -0
- package/dist/utils/createTestClient.d.ts +9 -0
- package/dist/utils/createTestClient.js +18 -0
- package/dist/utils/createTestClient4.d.ts +9 -0
- package/dist/utils/createTestClient4.js +15 -0
- package/dist/utils/fees.d.ts +25 -0
- package/dist/utils/fees.js +105 -0
- package/dist/utils/fees.spec.d.ts +1 -0
- package/dist/utils/fees.spec.js +83 -0
- package/dist/utils/maybe.d.ts +8 -0
- package/dist/utils/maybe.js +9 -0
- package/dist/utils/randomTestKey.d.ts +8 -0
- package/dist/utils/randomTestKey.js +24 -0
- package/dist/utils/time.d.ts +15 -0
- package/dist/utils/time.js +63 -0
- package/dist/utils/toUrlSafe.d.ts +8 -0
- package/dist/utils/toUrlSafe.js +23 -0
- package/dist/wallets/WalletContractV1R1.d.ts +58 -0
- package/dist/wallets/WalletContractV1R1.js +100 -0
- package/dist/wallets/WalletContractV1R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R1.spec.js +44 -0
- package/dist/wallets/WalletContractV1R2.d.ts +58 -0
- package/dist/wallets/WalletContractV1R2.js +101 -0
- package/dist/wallets/WalletContractV1R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R2.spec.js +44 -0
- package/dist/wallets/WalletContractV1R3.d.ts +58 -0
- package/dist/wallets/WalletContractV1R3.js +101 -0
- package/dist/wallets/WalletContractV1R3.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV1R3.spec.js +44 -0
- package/dist/wallets/WalletContractV2R1.d.ts +60 -0
- package/dist/wallets/WalletContractV2R1.js +102 -0
- package/dist/wallets/WalletContractV2R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R1.spec.js +44 -0
- package/dist/wallets/WalletContractV2R2.d.ts +60 -0
- package/dist/wallets/WalletContractV2R2.js +102 -0
- package/dist/wallets/WalletContractV2R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV2R2.spec.js +44 -0
- package/dist/wallets/WalletContractV3R1.d.ts +57 -0
- package/dist/wallets/WalletContractV3R1.js +104 -0
- package/dist/wallets/WalletContractV3R1.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R1.spec.js +44 -0
- package/dist/wallets/WalletContractV3R2.d.ts +57 -0
- package/dist/wallets/WalletContractV3R2.js +104 -0
- package/dist/wallets/WalletContractV3R2.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV3R2.spec.js +44 -0
- package/dist/wallets/WalletContractV3Types.d.ts +12 -0
- package/dist/wallets/WalletContractV3Types.js +2 -0
- package/dist/wallets/WalletContractV4.d.ts +65 -0
- package/dist/wallets/WalletContractV4.js +105 -0
- package/dist/wallets/WalletContractV4.spec.d.ts +8 -0
- package/dist/wallets/WalletContractV4.spec.js +48 -0
- package/dist/wallets/WalletContractV5Beta.d.ts +3 -0
- package/dist/wallets/WalletContractV5Beta.js +19 -0
- package/dist/wallets/WalletContractV5R1.d.ts +3 -0
- package/dist/wallets/WalletContractV5R1.js +19 -0
- package/dist/wallets/signing/createWalletTransfer.d.ts +48 -0
- package/dist/wallets/signing/createWalletTransfer.js +190 -0
- package/dist/wallets/signing/singer.d.ts +9 -0
- package/dist/wallets/signing/singer.js +21 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +130 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.js +211 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.d.ts +8 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +298 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.d.ts +6 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.js +92 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.d.ts +1 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.spec.js +166 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +13 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +31 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.d.ts +1 -0
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +68 -0
- package/dist/wallets/v5beta/WalletV5OutActions.d.ts +17 -0
- package/dist/wallets/v5beta/WalletV5OutActions.js +11 -0
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +125 -0
- package/dist/wallets/v5r1/WalletContractV5R1.js +207 -0
- package/dist/wallets/v5r1/WalletContractV5R1.spec.d.ts +8 -0
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +321 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.d.ts +12 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.js +128 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.d.ts +1 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.spec.js +262 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +47 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +69 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.d.ts +1 -0
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +72 -0
- package/package.json +6 -3
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Whales Corp.
|
|
4
|
+
* All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const randomTestKey_1 = require("../../utils/randomTestKey");
|
|
11
|
+
const core_1 = require("@ton/core");
|
|
12
|
+
const WalletContractV5Beta_1 = require("./WalletContractV5Beta");
|
|
13
|
+
const crypto_1 = require("@ton/crypto");
|
|
14
|
+
const createTestClient4_1 = require("../../utils/createTestClient4");
|
|
15
|
+
const getExtensionsArray = async (wallet) => {
|
|
16
|
+
try {
|
|
17
|
+
return await wallet.getExtensionsArray();
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
// Handle toncenter bug. Toncenter incorrectly returns 'list' in the stack in case of empty extensions dict
|
|
21
|
+
if (e && typeof e === 'object' && 'message' in e && e.message === 'Unsupported stack item type: list') {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
throw e;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
describe('WalletContractV5Beta', () => {
|
|
28
|
+
let client;
|
|
29
|
+
let walletKey;
|
|
30
|
+
let wallet;
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
client = (0, createTestClient4_1.createTestClient4)();
|
|
33
|
+
walletKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-1');
|
|
34
|
+
wallet = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { networkGlobalId: -3 }, publicKey: walletKey.publicKey }));
|
|
35
|
+
});
|
|
36
|
+
it('should has balance and correct address', async () => {
|
|
37
|
+
const balance = await wallet.getBalance();
|
|
38
|
+
expect(wallet.address.equals(core_1.Address.parse('EQAb3OyXDQyjOGf3HOXPXELTF8dhZP0onqMPz6fNQbleRqtY'))).toBeTruthy();
|
|
39
|
+
expect(balance > 0n).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it('should perform single transfer', async () => {
|
|
42
|
+
const seqno = await wallet.getSeqno();
|
|
43
|
+
const transfer = wallet.createTransfer({
|
|
44
|
+
seqno,
|
|
45
|
+
secretKey: walletKey.secretKey,
|
|
46
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
47
|
+
messages: [(0, core_1.internal)({
|
|
48
|
+
bounce: false,
|
|
49
|
+
to: 'UQB-2r0kM28L4lmq-4V8ppQGcnO1tXC7FZmbnDzWZVBkp6jE',
|
|
50
|
+
value: '0.01',
|
|
51
|
+
body: 'Hello world single transfer!'
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
await wallet.send(transfer);
|
|
55
|
+
});
|
|
56
|
+
it('should perform single transfer with async signing', async () => {
|
|
57
|
+
const seqno = await wallet.getSeqno();
|
|
58
|
+
const signer = (payload) => new Promise(r => setTimeout(() => {
|
|
59
|
+
const signature = (0, crypto_1.sign)(payload.hash(), walletKey.secretKey);
|
|
60
|
+
r(signature);
|
|
61
|
+
}, 100));
|
|
62
|
+
const transfer = await wallet.createTransfer({
|
|
63
|
+
seqno,
|
|
64
|
+
signer,
|
|
65
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
66
|
+
messages: [(0, core_1.internal)({
|
|
67
|
+
bounce: false,
|
|
68
|
+
to: 'UQB-2r0kM28L4lmq-4V8ppQGcnO1tXC7FZmbnDzWZVBkp6jE',
|
|
69
|
+
value: '0.01',
|
|
70
|
+
body: 'Hello world single transfer signed async!'
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
await wallet.send(transfer);
|
|
74
|
+
});
|
|
75
|
+
it('should perform double transfer', async () => {
|
|
76
|
+
const seqno = await wallet.getSeqno();
|
|
77
|
+
const transfer = wallet.createTransfer({
|
|
78
|
+
seqno,
|
|
79
|
+
secretKey: walletKey.secretKey,
|
|
80
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
81
|
+
messages: [(0, core_1.internal)({
|
|
82
|
+
bounce: false,
|
|
83
|
+
to: 'UQB-2r0kM28L4lmq-4V8ppQGcnO1tXC7FZmbnDzWZVBkp6jE',
|
|
84
|
+
value: '0.01',
|
|
85
|
+
body: 'Hello world to extension'
|
|
86
|
+
}), (0, core_1.internal)({
|
|
87
|
+
bounce: false,
|
|
88
|
+
to: 'UQDUyIkKoOR5iZ1Gz60JwKc7wPr3LcdHxOJpVDb9jAKY_pfk',
|
|
89
|
+
value: '0.02',
|
|
90
|
+
body: 'Hello world to relayer'
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
await wallet.send(transfer);
|
|
94
|
+
});
|
|
95
|
+
it('should add extension', async () => {
|
|
96
|
+
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
97
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
98
|
+
let seqno = await wallet.getSeqno();
|
|
99
|
+
const extensions = await getExtensionsArray(wallet);
|
|
100
|
+
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
101
|
+
if (!extensionAlreadyAdded) {
|
|
102
|
+
await wallet.sendAddExtension({
|
|
103
|
+
seqno,
|
|
104
|
+
secretKey: walletKey.secretKey,
|
|
105
|
+
extensionAddress: extensionContract.address
|
|
106
|
+
});
|
|
107
|
+
const waitUntilExtensionAdded = async (attempt = 0) => {
|
|
108
|
+
if (attempt >= 20) {
|
|
109
|
+
throw new Error('Extension was not added in 20 blocks');
|
|
110
|
+
}
|
|
111
|
+
const extensions = await getExtensionsArray(wallet);
|
|
112
|
+
const extensionAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
113
|
+
if (extensionAdded) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
117
|
+
return waitUntilExtensionAdded(attempt + 1);
|
|
118
|
+
};
|
|
119
|
+
await waitUntilExtensionAdded();
|
|
120
|
+
}
|
|
121
|
+
seqno = await wallet.getSeqno();
|
|
122
|
+
const extensionsSeqno = await extensionContract.getSeqno();
|
|
123
|
+
await extensionContract.sendTransfer({
|
|
124
|
+
seqno: extensionsSeqno,
|
|
125
|
+
secretKey: extensionKey.secretKey,
|
|
126
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
127
|
+
messages: [(0, core_1.internal)({
|
|
128
|
+
to: wallet.address,
|
|
129
|
+
value: '0.02',
|
|
130
|
+
body: wallet.createTransfer({
|
|
131
|
+
seqno: seqno,
|
|
132
|
+
authType: 'extension',
|
|
133
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
134
|
+
messages: [(0, core_1.internal)({
|
|
135
|
+
bounce: false,
|
|
136
|
+
to: '0QD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgoHo',
|
|
137
|
+
value: '0.03',
|
|
138
|
+
body: 'Hello world from plugin'
|
|
139
|
+
})]
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
}, 60000);
|
|
144
|
+
it('should remove extension', async () => {
|
|
145
|
+
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
146
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
147
|
+
const seqno = await wallet.getSeqno();
|
|
148
|
+
const extensions = await getExtensionsArray(wallet);
|
|
149
|
+
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
150
|
+
if (extensionAlreadyAdded) {
|
|
151
|
+
await wallet.sendRemoveExtension({
|
|
152
|
+
seqno,
|
|
153
|
+
secretKey: walletKey.secretKey,
|
|
154
|
+
extensionAddress: extensionContract.address
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
it('should send internal transfer via relayer', async () => {
|
|
159
|
+
const relaerKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-relayer');
|
|
160
|
+
const relayerContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: relaerKey.publicKey }));
|
|
161
|
+
const seqno = await wallet.getSeqno();
|
|
162
|
+
const relayerSeqno = await relayerContract.getSeqno();
|
|
163
|
+
await relayerContract.sendTransfer({
|
|
164
|
+
seqno: relayerSeqno,
|
|
165
|
+
secretKey: relaerKey.secretKey,
|
|
166
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
167
|
+
messages: [(0, core_1.internal)({
|
|
168
|
+
to: wallet.address,
|
|
169
|
+
value: '0.03',
|
|
170
|
+
body: wallet.createTransfer({
|
|
171
|
+
seqno: seqno,
|
|
172
|
+
secretKey: walletKey.secretKey,
|
|
173
|
+
authType: 'internal',
|
|
174
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
175
|
+
messages: [(0, core_1.internal)({
|
|
176
|
+
bounce: false,
|
|
177
|
+
to: '0QD2NmD_lH5f5u1Kj3KfGyTvhZSX0Eg6qp2a5IQUKXxOG4so',
|
|
178
|
+
value: '0.04',
|
|
179
|
+
body: 'Hello world from relayer'
|
|
180
|
+
})]
|
|
181
|
+
})
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
it('should disable secret key auth, send extension-auth tx, and enable it again', async () => {
|
|
186
|
+
/* firstly add an extension that will take the control over the wallet */
|
|
187
|
+
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
188
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
189
|
+
let seqno = await wallet.getSeqno();
|
|
190
|
+
const extensions = await getExtensionsArray(wallet);
|
|
191
|
+
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
192
|
+
if (!extensionAlreadyAdded) {
|
|
193
|
+
await wallet.sendAddExtension({
|
|
194
|
+
seqno,
|
|
195
|
+
secretKey: walletKey.secretKey,
|
|
196
|
+
extensionAddress: extensionContract.address
|
|
197
|
+
});
|
|
198
|
+
const waitUntilExtensionAdded = async (attempt = 0) => {
|
|
199
|
+
if (attempt >= 20) {
|
|
200
|
+
throw new Error('Extension was not added in 20 blocks');
|
|
201
|
+
}
|
|
202
|
+
const extensions = await getExtensionsArray(wallet);
|
|
203
|
+
const extensionAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
204
|
+
if (extensionAdded) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
208
|
+
return waitUntilExtensionAdded(attempt + 1);
|
|
209
|
+
};
|
|
210
|
+
await waitUntilExtensionAdded();
|
|
211
|
+
}
|
|
212
|
+
/* disable secret key auth */
|
|
213
|
+
seqno = await wallet.getSeqno();
|
|
214
|
+
const isInitiallyEnabled = await wallet.getIsSecretKeyAuthEnabled();
|
|
215
|
+
const waitUntilAuthValue = async (target, attempt = 0) => {
|
|
216
|
+
if (attempt >= 20) {
|
|
217
|
+
throw new Error('Auth permissions were not changed in 20 blocks');
|
|
218
|
+
}
|
|
219
|
+
const isEnabledNow = await wallet.getIsSecretKeyAuthEnabled();
|
|
220
|
+
if ((target === 'enabled' && isEnabledNow) || (target === 'disabled' && !isEnabledNow)) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
224
|
+
return waitUntilAuthValue(target, attempt + 1);
|
|
225
|
+
};
|
|
226
|
+
if (isInitiallyEnabled) {
|
|
227
|
+
await wallet.sendActionsBatch({
|
|
228
|
+
seqno,
|
|
229
|
+
secretKey: walletKey.secretKey,
|
|
230
|
+
actions: [
|
|
231
|
+
{
|
|
232
|
+
type: 'setIsPublicKeyEnabled',
|
|
233
|
+
isEnabled: false
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
await waitUntilAuthValue('disabled');
|
|
238
|
+
}
|
|
239
|
+
/* should fail direct secret-key auth transfer from the wallet */
|
|
240
|
+
seqno = await wallet.getSeqno();
|
|
241
|
+
const transfer = wallet.createTransfer({
|
|
242
|
+
seqno: seqno,
|
|
243
|
+
secretKey: walletKey.secretKey,
|
|
244
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
245
|
+
messages: [(0, core_1.internal)({
|
|
246
|
+
bounce: false,
|
|
247
|
+
to: 'UQB-2r0kM28L4lmq-4V8ppQGcnO1tXC7FZmbnDzWZVBkp6jE',
|
|
248
|
+
value: '0.01',
|
|
249
|
+
body: 'Hello world single transfer that SHOULD FAIL!'
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
await expect(wallet.send(transfer)).rejects.toThrow();
|
|
253
|
+
/* should perform transfer from the extension and enable auth by secret key */
|
|
254
|
+
const extensionsSeqno = await extensionContract.getSeqno();
|
|
255
|
+
await extensionContract.sendTransfer({
|
|
256
|
+
seqno: extensionsSeqno,
|
|
257
|
+
secretKey: extensionKey.secretKey,
|
|
258
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
259
|
+
messages: [(0, core_1.internal)({
|
|
260
|
+
to: wallet.address,
|
|
261
|
+
value: '0.03',
|
|
262
|
+
body: wallet.createRequest({
|
|
263
|
+
seqno,
|
|
264
|
+
authType: 'extension',
|
|
265
|
+
actions: [
|
|
266
|
+
{
|
|
267
|
+
type: 'setIsPublicKeyEnabled',
|
|
268
|
+
isEnabled: true
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: "sendMsg",
|
|
272
|
+
mode: core_1.SendMode.IGNORE_ERRORS + core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
273
|
+
outMsg: (0, core_1.internal)({
|
|
274
|
+
bounce: false,
|
|
275
|
+
to: '0QD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgoHo',
|
|
276
|
+
value: '0.03',
|
|
277
|
+
body: 'Hello world from plugin that controls the wallet!'
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
})
|
|
282
|
+
})]
|
|
283
|
+
});
|
|
284
|
+
await waitUntilAuthValue('enabled');
|
|
285
|
+
/* should fail direct secret-key auth transfer from the wallet */
|
|
286
|
+
await wallet.sendTransfer({
|
|
287
|
+
seqno: seqno + 1,
|
|
288
|
+
secretKey: walletKey.secretKey,
|
|
289
|
+
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS,
|
|
290
|
+
messages: [(0, core_1.internal)({
|
|
291
|
+
bounce: false,
|
|
292
|
+
to: 'UQB-2r0kM28L4lmq-4V8ppQGcnO1tXC7FZmbnDzWZVBkp6jE',
|
|
293
|
+
value: '0.01',
|
|
294
|
+
body: 'Hello world single transfer after sk auth enabled!'
|
|
295
|
+
})]
|
|
296
|
+
});
|
|
297
|
+
}, 120000);
|
|
298
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Builder, OutActionSendMsg, Slice } from '@ton/core';
|
|
2
|
+
import { OutActionExtended } from "./WalletV5OutActions";
|
|
3
|
+
export declare function storeOutActionExtendedV5Beta(action: OutActionExtended): (builder: Builder) => void;
|
|
4
|
+
export declare function loadOutActionV5BetaExtended(slice: Slice): OutActionExtended;
|
|
5
|
+
export declare function storeOutListExtendedV5Beta(actions: (OutActionExtended | OutActionSendMsg)[]): (builder: Builder) => void;
|
|
6
|
+
export declare function loadOutListExtendedV5Beta(slice: Slice): (OutActionExtended | OutActionSendMsg)[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadOutListExtendedV5Beta = exports.storeOutListExtendedV5Beta = exports.loadOutActionV5BetaExtended = exports.storeOutActionExtendedV5Beta = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
const WalletV5OutActions_1 = require("./WalletV5OutActions");
|
|
6
|
+
const outActionSetIsPublicKeyEnabledTag = 0x20cbb95a;
|
|
7
|
+
function storeOutActionSetIsPublicKeyEnabled(action) {
|
|
8
|
+
return (builder) => {
|
|
9
|
+
builder.storeUint(outActionSetIsPublicKeyEnabledTag, 32).storeUint(action.isEnabled ? 1 : 0, 1);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const outActionAddExtensionTag = 0x1c40db9f;
|
|
13
|
+
function storeOutActionAddExtension(action) {
|
|
14
|
+
return (builder) => {
|
|
15
|
+
builder.storeUint(outActionAddExtensionTag, 32).storeAddress(action.address);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const outActionRemoveExtensionTag = 0x5eaef4a4;
|
|
19
|
+
function storeOutActionRemoveExtension(action) {
|
|
20
|
+
return (builder) => {
|
|
21
|
+
builder.storeUint(outActionRemoveExtensionTag, 32).storeAddress(action.address);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function storeOutActionExtendedV5Beta(action) {
|
|
25
|
+
switch (action.type) {
|
|
26
|
+
case 'setIsPublicKeyEnabled':
|
|
27
|
+
return storeOutActionSetIsPublicKeyEnabled(action);
|
|
28
|
+
case 'addExtension':
|
|
29
|
+
return storeOutActionAddExtension(action);
|
|
30
|
+
case 'removeExtension':
|
|
31
|
+
return storeOutActionRemoveExtension(action);
|
|
32
|
+
default:
|
|
33
|
+
throw new Error('Unknown action type' + action?.type);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.storeOutActionExtendedV5Beta = storeOutActionExtendedV5Beta;
|
|
37
|
+
function loadOutActionV5BetaExtended(slice) {
|
|
38
|
+
const tag = slice.loadUint(32);
|
|
39
|
+
switch (tag) {
|
|
40
|
+
case outActionSetIsPublicKeyEnabledTag:
|
|
41
|
+
return {
|
|
42
|
+
type: 'setIsPublicKeyEnabled',
|
|
43
|
+
isEnabled: !!slice.loadUint(1)
|
|
44
|
+
};
|
|
45
|
+
case outActionAddExtensionTag:
|
|
46
|
+
return {
|
|
47
|
+
type: 'addExtension',
|
|
48
|
+
address: slice.loadAddress()
|
|
49
|
+
};
|
|
50
|
+
case outActionRemoveExtensionTag:
|
|
51
|
+
return {
|
|
52
|
+
type: 'removeExtension',
|
|
53
|
+
address: slice.loadAddress()
|
|
54
|
+
};
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unknown extended out action tag 0x${tag.toString(16)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.loadOutActionV5BetaExtended = loadOutActionV5BetaExtended;
|
|
60
|
+
function storeOutListExtendedV5Beta(actions) {
|
|
61
|
+
const [action, ...rest] = actions;
|
|
62
|
+
if (!action || !(0, WalletV5OutActions_1.isOutActionExtended)(action)) {
|
|
63
|
+
if (actions.some(WalletV5OutActions_1.isOutActionExtended)) {
|
|
64
|
+
throw new Error("Can't serialize actions list: all extended actions must be placed before out actions");
|
|
65
|
+
}
|
|
66
|
+
return (builder) => {
|
|
67
|
+
builder
|
|
68
|
+
.storeUint(0, 1)
|
|
69
|
+
.storeRef((0, core_1.beginCell)().store((0, core_1.storeOutList)(actions)).endCell());
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return (builder) => {
|
|
73
|
+
builder.storeUint(1, 1)
|
|
74
|
+
.store(storeOutActionExtendedV5Beta(action))
|
|
75
|
+
.storeRef((0, core_1.beginCell)().store(storeOutListExtendedV5Beta(rest)).endCell());
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.storeOutListExtendedV5Beta = storeOutListExtendedV5Beta;
|
|
79
|
+
function loadOutListExtendedV5Beta(slice) {
|
|
80
|
+
const actions = [];
|
|
81
|
+
while (slice.loadUint(1)) {
|
|
82
|
+
const action = loadOutActionV5BetaExtended(slice);
|
|
83
|
+
actions.push(action);
|
|
84
|
+
slice = slice.loadRef().beginParse();
|
|
85
|
+
}
|
|
86
|
+
const commonAction = (0, core_1.loadOutList)(slice.loadRef().beginParse());
|
|
87
|
+
if (commonAction.some(i => i.type === 'setCode')) {
|
|
88
|
+
throw new Error("Can't deserialize actions list: only sendMsg actions are allowed for wallet v5");
|
|
89
|
+
}
|
|
90
|
+
return actions.concat(commonAction);
|
|
91
|
+
}
|
|
92
|
+
exports.loadOutListExtendedV5Beta = loadOutListExtendedV5Beta;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@ton/core");
|
|
4
|
+
const WalletV5BetaActions_1 = require("./WalletV5BetaActions");
|
|
5
|
+
const mockMessageRelaxed1 = {
|
|
6
|
+
info: {
|
|
7
|
+
type: 'external-out',
|
|
8
|
+
createdLt: 0n,
|
|
9
|
+
createdAt: 0,
|
|
10
|
+
dest: null,
|
|
11
|
+
src: null
|
|
12
|
+
},
|
|
13
|
+
body: (0, core_1.beginCell)().storeUint(0, 8).endCell(),
|
|
14
|
+
init: null
|
|
15
|
+
};
|
|
16
|
+
const mockAddress = core_1.Address.parseRaw('0:' + '1'.repeat(64));
|
|
17
|
+
describe('Wallet V5Beta actions', () => {
|
|
18
|
+
const outActionSetIsPublicKeyEnabledTag = 0x20cbb95a;
|
|
19
|
+
const outActionAddExtensionTag = 0x1c40db9f;
|
|
20
|
+
const outActionRemoveExtensionTag = 0x5eaef4a4;
|
|
21
|
+
const outActionSendMsgTag = 0x0ec3c86d;
|
|
22
|
+
it('Should serialise setIsPublicKeyEnabled action with true flag', () => {
|
|
23
|
+
const action = (0, WalletV5BetaActions_1.storeOutActionExtendedV5Beta)({
|
|
24
|
+
type: 'setIsPublicKeyEnabled',
|
|
25
|
+
isEnabled: true
|
|
26
|
+
});
|
|
27
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
28
|
+
const expected = (0, core_1.beginCell)()
|
|
29
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 32)
|
|
30
|
+
.storeBit(1)
|
|
31
|
+
.endCell();
|
|
32
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
it('Should serialise setIsPublicKeyEnabled action with false flag', () => {
|
|
35
|
+
const action = (0, WalletV5BetaActions_1.storeOutActionExtendedV5Beta)({
|
|
36
|
+
type: 'setIsPublicKeyEnabled',
|
|
37
|
+
isEnabled: false
|
|
38
|
+
});
|
|
39
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
40
|
+
const expected = (0, core_1.beginCell)()
|
|
41
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 32)
|
|
42
|
+
.storeBit(0)
|
|
43
|
+
.endCell();
|
|
44
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
it('Should serialise add extension action', () => {
|
|
47
|
+
const action = (0, WalletV5BetaActions_1.storeOutActionExtendedV5Beta)({
|
|
48
|
+
type: 'addExtension',
|
|
49
|
+
address: mockAddress
|
|
50
|
+
});
|
|
51
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
52
|
+
const expected = (0, core_1.beginCell)()
|
|
53
|
+
.storeUint(outActionAddExtensionTag, 32)
|
|
54
|
+
.storeAddress(mockAddress)
|
|
55
|
+
.endCell();
|
|
56
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
it('Should serialise remove extension action', () => {
|
|
59
|
+
const action = (0, WalletV5BetaActions_1.storeOutActionExtendedV5Beta)({
|
|
60
|
+
type: 'removeExtension',
|
|
61
|
+
address: mockAddress
|
|
62
|
+
});
|
|
63
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
64
|
+
const expected = (0, core_1.beginCell)()
|
|
65
|
+
.storeUint(outActionRemoveExtensionTag, 32)
|
|
66
|
+
.storeAddress(mockAddress)
|
|
67
|
+
.endCell();
|
|
68
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
69
|
+
});
|
|
70
|
+
it('Should serialize extended out list', () => {
|
|
71
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
72
|
+
const isPublicKeyEnabled = false;
|
|
73
|
+
const actions = [
|
|
74
|
+
{
|
|
75
|
+
type: 'addExtension',
|
|
76
|
+
address: mockAddress
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'setIsPublicKeyEnabled',
|
|
80
|
+
isEnabled: isPublicKeyEnabled
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'sendMsg',
|
|
84
|
+
mode: sendMode1,
|
|
85
|
+
outMsg: mockMessageRelaxed1
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5BetaActions_1.storeOutListExtendedV5Beta)(actions)).endCell();
|
|
89
|
+
const expected = (0, core_1.beginCell)()
|
|
90
|
+
.storeUint(1, 1)
|
|
91
|
+
.storeUint(outActionAddExtensionTag, 32)
|
|
92
|
+
.storeAddress(mockAddress)
|
|
93
|
+
.storeRef((0, core_1.beginCell)()
|
|
94
|
+
.storeUint(1, 1)
|
|
95
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 32)
|
|
96
|
+
.storeBit(isPublicKeyEnabled ? 1 : 0)
|
|
97
|
+
.storeRef((0, core_1.beginCell)()
|
|
98
|
+
.storeUint(0, 1)
|
|
99
|
+
.storeRef((0, core_1.beginCell)()
|
|
100
|
+
.storeRef((0, core_1.beginCell)().endCell())
|
|
101
|
+
.storeUint(outActionSendMsgTag, 32)
|
|
102
|
+
.storeUint(sendMode1, 8)
|
|
103
|
+
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
104
|
+
.endCell())
|
|
105
|
+
.endCell())
|
|
106
|
+
.endCell())
|
|
107
|
+
.endCell();
|
|
108
|
+
expect(actual.equals(expected)).toBeTruthy();
|
|
109
|
+
});
|
|
110
|
+
it('Should deserialize extended out list', () => {
|
|
111
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
112
|
+
const isPublicKeyEnabled = true;
|
|
113
|
+
const expected = [
|
|
114
|
+
{
|
|
115
|
+
type: 'addExtension',
|
|
116
|
+
address: mockAddress
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'setIsPublicKeyEnabled',
|
|
120
|
+
isEnabled: isPublicKeyEnabled
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'sendMsg',
|
|
124
|
+
mode: sendMode1,
|
|
125
|
+
outMsg: mockMessageRelaxed1
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
const serialized = (0, core_1.beginCell)()
|
|
129
|
+
.storeUint(1, 1)
|
|
130
|
+
.storeUint(outActionAddExtensionTag, 32)
|
|
131
|
+
.storeAddress(mockAddress)
|
|
132
|
+
.storeRef((0, core_1.beginCell)()
|
|
133
|
+
.storeUint(1, 1)
|
|
134
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 32)
|
|
135
|
+
.storeBit(isPublicKeyEnabled ? 1 : 0)
|
|
136
|
+
.storeRef((0, core_1.beginCell)()
|
|
137
|
+
.storeUint(0, 1)
|
|
138
|
+
.storeRef((0, core_1.beginCell)()
|
|
139
|
+
.storeRef((0, core_1.beginCell)().endCell())
|
|
140
|
+
.storeUint(outActionSendMsgTag, 32)
|
|
141
|
+
.storeUint(sendMode1, 8)
|
|
142
|
+
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
143
|
+
.endCell())
|
|
144
|
+
.endCell())
|
|
145
|
+
.endCell())
|
|
146
|
+
.endCell();
|
|
147
|
+
const actual = (0, WalletV5BetaActions_1.loadOutListExtendedV5Beta)(serialized.beginParse());
|
|
148
|
+
expect(expected.length).toEqual(actual.length);
|
|
149
|
+
expected.forEach((item1, index) => {
|
|
150
|
+
const item2 = actual[index];
|
|
151
|
+
expect(item1.type).toEqual(item2.type);
|
|
152
|
+
if (item1.type === 'sendMsg' && item2.type === 'sendMsg') {
|
|
153
|
+
expect(item1.mode).toEqual(item2.mode);
|
|
154
|
+
expect(item1.outMsg.body.equals(item2.outMsg.body)).toBeTruthy();
|
|
155
|
+
expect(item1.outMsg.info).toEqual(item2.outMsg.info);
|
|
156
|
+
expect(item1.outMsg.init).toEqual(item2.outMsg.init);
|
|
157
|
+
}
|
|
158
|
+
if (item1.type === 'addExtension' && item2.type === 'addExtension') {
|
|
159
|
+
expect(item1.address.equals(item2.address)).toBeTruthy();
|
|
160
|
+
}
|
|
161
|
+
if (item1.type === 'setIsPublicKeyEnabled' && item2.type === 'setIsPublicKeyEnabled') {
|
|
162
|
+
expect(item1.isEnabled).toEqual(item2.isEnabled);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Builder, Slice } from '@ton/core';
|
|
3
|
+
export interface WalletIdV5Beta {
|
|
4
|
+
readonly walletVersion: 'v5';
|
|
5
|
+
/**
|
|
6
|
+
* -239 is mainnet, -3 is testnet
|
|
7
|
+
*/
|
|
8
|
+
readonly networkGlobalId: number;
|
|
9
|
+
readonly workchain: number;
|
|
10
|
+
readonly subwalletNumber: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function loadWalletIdV5Beta(value: bigint | Buffer | Slice): WalletIdV5Beta;
|
|
13
|
+
export declare function storeWalletIdV5Beta(walletId: WalletIdV5Beta): (builder: Builder) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storeWalletIdV5Beta = exports.loadWalletIdV5Beta = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
const walletV5BetaVersionsSerialisation = {
|
|
6
|
+
v5: 0
|
|
7
|
+
};
|
|
8
|
+
function loadWalletIdV5Beta(value) {
|
|
9
|
+
const bitReader = new core_1.BitReader(new core_1.BitString(typeof value === 'bigint' ?
|
|
10
|
+
Buffer.from(value.toString(16), 'hex') :
|
|
11
|
+
value instanceof core_1.Slice ? value.loadBuffer(10) : value, 0, 80));
|
|
12
|
+
const networkGlobalId = bitReader.loadInt(32);
|
|
13
|
+
const workchain = bitReader.loadInt(8);
|
|
14
|
+
const walletVersionRaw = bitReader.loadUint(8);
|
|
15
|
+
const subwalletNumber = bitReader.loadUint(32);
|
|
16
|
+
const walletVersion = Object.entries(walletV5BetaVersionsSerialisation).find(([_, value]) => value === walletVersionRaw)?.[0];
|
|
17
|
+
if (walletVersion === undefined) {
|
|
18
|
+
throw new Error(`Can't deserialize walletId: unknown wallet version ${walletVersionRaw}`);
|
|
19
|
+
}
|
|
20
|
+
return { networkGlobalId, workchain, walletVersion, subwalletNumber };
|
|
21
|
+
}
|
|
22
|
+
exports.loadWalletIdV5Beta = loadWalletIdV5Beta;
|
|
23
|
+
function storeWalletIdV5Beta(walletId) {
|
|
24
|
+
return (builder) => {
|
|
25
|
+
builder.storeInt(walletId.networkGlobalId, 32);
|
|
26
|
+
builder.storeInt(walletId.workchain, 8);
|
|
27
|
+
builder.storeUint(walletV5BetaVersionsSerialisation[walletId.walletVersion], 8);
|
|
28
|
+
builder.storeUint(walletId.subwalletNumber, 32);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.storeWalletIdV5Beta = storeWalletIdV5Beta;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|