@ton-wallet/create 14.0.2 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +5 -2
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@ton/core");
|
|
4
|
+
const WalletV5R1Actions_1 = require("./WalletV5R1Actions");
|
|
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 mockMessageRelaxed2 = {
|
|
17
|
+
info: {
|
|
18
|
+
type: 'internal',
|
|
19
|
+
ihrDisabled: true,
|
|
20
|
+
bounce: false,
|
|
21
|
+
bounced: false,
|
|
22
|
+
dest: core_1.Address.parseRaw('0:' + '2'.repeat(64)),
|
|
23
|
+
value: {
|
|
24
|
+
coins: 1n
|
|
25
|
+
},
|
|
26
|
+
ihrFee: 1n,
|
|
27
|
+
forwardFee: 1n,
|
|
28
|
+
createdLt: 12345n,
|
|
29
|
+
createdAt: 123456
|
|
30
|
+
},
|
|
31
|
+
body: (0, core_1.beginCell)().storeUint(0, 8).endCell(),
|
|
32
|
+
init: null
|
|
33
|
+
};
|
|
34
|
+
const mockAddress = core_1.Address.parseRaw('0:' + '1'.repeat(64));
|
|
35
|
+
describe('Wallet V5R1 actions', () => {
|
|
36
|
+
const outActionSetIsPublicKeyEnabledTag = 0x04;
|
|
37
|
+
const outActionAddExtensionTag = 0x02;
|
|
38
|
+
const outActionRemoveExtensionTag = 0x03;
|
|
39
|
+
const outActionSendMsgTag = 0x0ec3c86d;
|
|
40
|
+
it('Should serialise setIsPublicKeyEnabled action with true flag', () => {
|
|
41
|
+
const action = (0, WalletV5R1Actions_1.storeOutActionExtendedV5R1)({
|
|
42
|
+
type: 'setIsPublicKeyEnabled',
|
|
43
|
+
isEnabled: true
|
|
44
|
+
});
|
|
45
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
46
|
+
const expected = (0, core_1.beginCell)()
|
|
47
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 8)
|
|
48
|
+
.storeBit(1)
|
|
49
|
+
.endCell();
|
|
50
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
it('Should serialise setIsPublicKeyEnabled action with false flag', () => {
|
|
53
|
+
const action = (0, WalletV5R1Actions_1.storeOutActionExtendedV5R1)({
|
|
54
|
+
type: 'setIsPublicKeyEnabled',
|
|
55
|
+
isEnabled: false
|
|
56
|
+
});
|
|
57
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
58
|
+
const expected = (0, core_1.beginCell)()
|
|
59
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 8)
|
|
60
|
+
.storeBit(0)
|
|
61
|
+
.endCell();
|
|
62
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
it('Should serialise add extension action', () => {
|
|
65
|
+
const action = (0, WalletV5R1Actions_1.storeOutActionExtendedV5R1)({
|
|
66
|
+
type: 'addExtension',
|
|
67
|
+
address: mockAddress
|
|
68
|
+
});
|
|
69
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
70
|
+
const expected = (0, core_1.beginCell)()
|
|
71
|
+
.storeUint(outActionAddExtensionTag, 8)
|
|
72
|
+
.storeAddress(mockAddress)
|
|
73
|
+
.endCell();
|
|
74
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
75
|
+
});
|
|
76
|
+
it('Should serialise remove extension action', () => {
|
|
77
|
+
const action = (0, WalletV5R1Actions_1.storeOutActionExtendedV5R1)({
|
|
78
|
+
type: 'removeExtension',
|
|
79
|
+
address: mockAddress
|
|
80
|
+
});
|
|
81
|
+
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
82
|
+
const expected = (0, core_1.beginCell)()
|
|
83
|
+
.storeUint(outActionRemoveExtensionTag, 8)
|
|
84
|
+
.storeAddress(mockAddress)
|
|
85
|
+
.endCell();
|
|
86
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
it('Should serialize extended out list', () => {
|
|
89
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
90
|
+
const isPublicKeyEnabled = false;
|
|
91
|
+
const actions = [
|
|
92
|
+
{
|
|
93
|
+
type: 'addExtension',
|
|
94
|
+
address: mockAddress
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'setIsPublicKeyEnabled',
|
|
98
|
+
isEnabled: isPublicKeyEnabled
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'sendMsg',
|
|
102
|
+
mode: sendMode1,
|
|
103
|
+
outMsg: mockMessageRelaxed1
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5R1Actions_1.storeOutListExtendedV5R1)(actions)).endCell();
|
|
107
|
+
const expected = (0, core_1.beginCell)()
|
|
108
|
+
.storeUint(1, 1)
|
|
109
|
+
.storeRef((0, core_1.beginCell)()
|
|
110
|
+
.storeRef((0, core_1.beginCell)().endCell())
|
|
111
|
+
.storeUint(outActionSendMsgTag, 32)
|
|
112
|
+
.storeUint(sendMode1, 8)
|
|
113
|
+
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
114
|
+
.endCell())
|
|
115
|
+
.storeUint(1, 1)
|
|
116
|
+
.storeUint(outActionAddExtensionTag, 8)
|
|
117
|
+
.storeAddress(mockAddress)
|
|
118
|
+
.storeRef((0, core_1.beginCell)()
|
|
119
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 8)
|
|
120
|
+
.storeBit(isPublicKeyEnabled ? 1 : 0)
|
|
121
|
+
.endCell())
|
|
122
|
+
.endCell();
|
|
123
|
+
expect(actual.equals(expected)).toBeTruthy();
|
|
124
|
+
});
|
|
125
|
+
it('Should serialize extended out list and produce the expected boc', () => {
|
|
126
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS;
|
|
127
|
+
const isPublicKeyEnabled = false;
|
|
128
|
+
const actions = [
|
|
129
|
+
{
|
|
130
|
+
type: 'addExtension',
|
|
131
|
+
address: mockAddress
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'setIsPublicKeyEnabled',
|
|
135
|
+
isEnabled: isPublicKeyEnabled
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'sendMsg',
|
|
139
|
+
mode: sendMode1,
|
|
140
|
+
outMsg: mockMessageRelaxed1
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5R1Actions_1.storeOutListExtendedV5R1)(actions)).endCell();
|
|
144
|
+
const expected = core_1.Cell.fromBoc(Buffer.from('b5ee9c72410105010046000245c0a000888888888888888888888888888888888888888888888888888888888888888c0104020a0ec3c86d0302030000001cc000000000000000000000000000000304409c06218f', 'hex'))[0];
|
|
145
|
+
expect(actual.equals(expected)).toBeTruthy();
|
|
146
|
+
});
|
|
147
|
+
it('Should serialize extended out list and produce the expected boc for complex structures', () => {
|
|
148
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS;
|
|
149
|
+
const sendMode2 = core_1.SendMode.NONE;
|
|
150
|
+
const isPublicKeyEnabled = false;
|
|
151
|
+
const actions = [
|
|
152
|
+
{
|
|
153
|
+
type: 'addExtension',
|
|
154
|
+
address: mockAddress
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'setIsPublicKeyEnabled',
|
|
158
|
+
isEnabled: isPublicKeyEnabled
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'removeExtension',
|
|
162
|
+
address: mockAddress
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'sendMsg',
|
|
166
|
+
mode: sendMode1,
|
|
167
|
+
outMsg: mockMessageRelaxed1
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'sendMsg',
|
|
171
|
+
mode: sendMode2,
|
|
172
|
+
outMsg: mockMessageRelaxed2
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5R1Actions_1.storeOutListExtendedV5R1)(actions)).endCell();
|
|
176
|
+
const expected = core_1.Cell.fromBoc(Buffer.from('b5ee9c724101080100ab000245c0a000888888888888888888888888888888888888888888888888888888888888888c0106020a0ec3c86d030205020a0ec3c86d00030400000068420011111111111111111111111111111111111111111111111111111111111111110808404404000000000000c0e40007890000001cc00000000000000000000000000001030440070045038002222222222222222222222222222222222222222222222222222222222222223037cc71d6', 'hex'))[0];
|
|
177
|
+
expect(actual.equals(expected)).toBeTruthy();
|
|
178
|
+
});
|
|
179
|
+
it('Should deserialize extended out list', () => {
|
|
180
|
+
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
181
|
+
const isPublicKeyEnabled = true;
|
|
182
|
+
const expected = [
|
|
183
|
+
{
|
|
184
|
+
type: 'sendMsg',
|
|
185
|
+
mode: sendMode1,
|
|
186
|
+
outMsg: mockMessageRelaxed1
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: 'addExtension',
|
|
190
|
+
address: mockAddress
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: 'setIsPublicKeyEnabled',
|
|
194
|
+
isEnabled: isPublicKeyEnabled
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
const serialized = (0, core_1.beginCell)()
|
|
198
|
+
.storeUint(1, 1)
|
|
199
|
+
.storeRef((0, core_1.beginCell)()
|
|
200
|
+
.storeRef((0, core_1.beginCell)().endCell())
|
|
201
|
+
.storeUint(outActionSendMsgTag, 32)
|
|
202
|
+
.storeUint(sendMode1, 8)
|
|
203
|
+
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
204
|
+
.endCell())
|
|
205
|
+
.storeUint(1, 1)
|
|
206
|
+
.storeUint(outActionAddExtensionTag, 8)
|
|
207
|
+
.storeAddress(mockAddress)
|
|
208
|
+
.storeRef((0, core_1.beginCell)()
|
|
209
|
+
.storeUint(outActionSetIsPublicKeyEnabledTag, 8)
|
|
210
|
+
.storeBit(isPublicKeyEnabled ? 1 : 0)
|
|
211
|
+
.endCell())
|
|
212
|
+
.endCell();
|
|
213
|
+
const actual = (0, WalletV5R1Actions_1.loadOutListExtendedV5R1)(serialized.beginParse());
|
|
214
|
+
expect(expected.length).toEqual(actual.length);
|
|
215
|
+
expected.forEach((item1, index) => {
|
|
216
|
+
const item2 = actual[index];
|
|
217
|
+
expect(item1.type).toEqual(item2.type);
|
|
218
|
+
if (item1.type === 'sendMsg' && item2.type === 'sendMsg') {
|
|
219
|
+
expect(item1.mode).toEqual(item2.mode);
|
|
220
|
+
expect(item1.outMsg.body.equals(item2.outMsg.body)).toBeTruthy();
|
|
221
|
+
expect(item1.outMsg.info).toEqual(item2.outMsg.info);
|
|
222
|
+
expect(item1.outMsg.init).toEqual(item2.outMsg.init);
|
|
223
|
+
}
|
|
224
|
+
if (item1.type === 'addExtension' && item2.type === 'addExtension') {
|
|
225
|
+
expect(item1.address.equals(item2.address)).toBeTruthy();
|
|
226
|
+
}
|
|
227
|
+
if (item1.type === 'setIsPublicKeyEnabled' && item2.type === 'setIsPublicKeyEnabled') {
|
|
228
|
+
expect(item1.isEnabled).toEqual(item2.isEnabled);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
it('Check toSaveSendMode: add + 2 to externals', () => {
|
|
233
|
+
const notSafeSendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
234
|
+
const authType = 'external';
|
|
235
|
+
const safeSendMode = (0, WalletV5R1Actions_1.toSafeV5R1SendMode)(notSafeSendMode, authType);
|
|
236
|
+
expect(safeSendMode).toEqual(notSafeSendMode + core_1.SendMode.IGNORE_ERRORS);
|
|
237
|
+
});
|
|
238
|
+
it('Check toSaveSendMode: keep mode for internals', () => {
|
|
239
|
+
const notSafeSendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
240
|
+
const authType = 'internal';
|
|
241
|
+
const safeSendMode = (0, WalletV5R1Actions_1.toSafeV5R1SendMode)(notSafeSendMode, authType);
|
|
242
|
+
expect(safeSendMode).toEqual(notSafeSendMode);
|
|
243
|
+
});
|
|
244
|
+
it('Check toSaveSendMode: keep mode for extensions', () => {
|
|
245
|
+
const notSafeSendMode = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
246
|
+
const authType = 'extension';
|
|
247
|
+
const safeSendMode = (0, WalletV5R1Actions_1.toSafeV5R1SendMode)(notSafeSendMode, authType);
|
|
248
|
+
expect(safeSendMode).toEqual(notSafeSendMode);
|
|
249
|
+
});
|
|
250
|
+
it("Check toSaveSendMode: don't add + 2 twice for externals", () => {
|
|
251
|
+
const safeSendMode = core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS;
|
|
252
|
+
const authType = 'external';
|
|
253
|
+
const actualSafeSendMode = (0, WalletV5R1Actions_1.toSafeV5R1SendMode)(safeSendMode, authType);
|
|
254
|
+
expect(actualSafeSendMode).toEqual(safeSendMode);
|
|
255
|
+
});
|
|
256
|
+
it("Check toSaveSendMode: don't add + 2 twice for internals", () => {
|
|
257
|
+
const safeSendMode = core_1.SendMode.PAY_GAS_SEPARATELY + core_1.SendMode.IGNORE_ERRORS;
|
|
258
|
+
const authType = 'internal';
|
|
259
|
+
const actualSafeSendMode = (0, WalletV5R1Actions_1.toSafeV5R1SendMode)(safeSendMode, authType);
|
|
260
|
+
expect(actualSafeSendMode).toEqual(safeSendMode);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Builder, Slice } from '@ton/core';
|
|
3
|
+
/**
|
|
4
|
+
* schema:
|
|
5
|
+
* wallet_id -- int32
|
|
6
|
+
* wallet_id = global_id ^ context_id
|
|
7
|
+
* context_id_client$1 = wc:int8 wallet_version:uint8 counter:uint15
|
|
8
|
+
* context_id_backoffice$0 = counter:uint31
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* calculated default values serialisation:
|
|
12
|
+
*
|
|
13
|
+
* global_id = -239, workchain = 0, wallet_version = 0', subwallet_number = 0 (client context)
|
|
14
|
+
* gives wallet_id = 2147483409
|
|
15
|
+
*
|
|
16
|
+
* global_id = -239, workchain = -1, wallet_version = 0', subwallet_number = 0 (client context)
|
|
17
|
+
* gives wallet_id = 8388369
|
|
18
|
+
*
|
|
19
|
+
* global_id = -3, workchain = 0, wallet_version = 0', subwallet_number = 0 (client context)
|
|
20
|
+
* gives wallet_id = 2147483645
|
|
21
|
+
*
|
|
22
|
+
* global_id = -3, workchain = -1, wallet_version = 0', subwallet_number = 0 (client context)
|
|
23
|
+
* gives wallet_id = 8388605
|
|
24
|
+
*/
|
|
25
|
+
export interface WalletIdV5R1<C extends WalletIdV5R1ClientContext | WalletIdV5R1CustomContext = WalletIdV5R1ClientContext | WalletIdV5R1CustomContext> {
|
|
26
|
+
/**
|
|
27
|
+
* -239 is mainnet, -3 is testnet
|
|
28
|
+
*/
|
|
29
|
+
readonly networkGlobalId: number;
|
|
30
|
+
readonly context: C;
|
|
31
|
+
}
|
|
32
|
+
export interface WalletIdV5R1ClientContext {
|
|
33
|
+
readonly walletVersion: 'v5r1';
|
|
34
|
+
readonly workchain: number;
|
|
35
|
+
readonly subwalletNumber: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 31-bit unsigned integer
|
|
39
|
+
*/
|
|
40
|
+
export type WalletIdV5R1CustomContext = number;
|
|
41
|
+
export declare function isWalletIdV5R1ClientContext(context: WalletIdV5R1ClientContext | WalletIdV5R1CustomContext): context is WalletIdV5R1ClientContext;
|
|
42
|
+
/**
|
|
43
|
+
* @param value serialized wallet id
|
|
44
|
+
* @param networkGlobalId -239 is mainnet, -3 is testnet
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadWalletIdV5R1(value: bigint | Buffer | Slice, networkGlobalId: number): WalletIdV5R1;
|
|
47
|
+
export declare function storeWalletIdV5R1(walletId: WalletIdV5R1): (builder: Builder) => Builder;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storeWalletIdV5R1 = exports.loadWalletIdV5R1 = exports.isWalletIdV5R1ClientContext = void 0;
|
|
4
|
+
const core_1 = require("@ton/core");
|
|
5
|
+
function isWalletIdV5R1ClientContext(context) {
|
|
6
|
+
return typeof context !== 'number';
|
|
7
|
+
}
|
|
8
|
+
exports.isWalletIdV5R1ClientContext = isWalletIdV5R1ClientContext;
|
|
9
|
+
const walletV5R1VersionsSerialisation = {
|
|
10
|
+
v5r1: 0
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @param value serialized wallet id
|
|
14
|
+
* @param networkGlobalId -239 is mainnet, -3 is testnet
|
|
15
|
+
*/
|
|
16
|
+
function loadWalletIdV5R1(value, networkGlobalId) {
|
|
17
|
+
const val = new core_1.BitReader(new core_1.BitString(typeof value === 'bigint' ?
|
|
18
|
+
Buffer.from(value.toString(16), 'hex') :
|
|
19
|
+
value instanceof core_1.Slice ? value.loadBuffer(4) : value, 0, 32)).loadInt(32);
|
|
20
|
+
const context = BigInt(val) ^ BigInt(networkGlobalId);
|
|
21
|
+
const bitReader = (0, core_1.beginCell)().storeInt(context, 32).endCell().beginParse();
|
|
22
|
+
const isClientContext = bitReader.loadUint(1);
|
|
23
|
+
if (isClientContext) {
|
|
24
|
+
const workchain = bitReader.loadInt(8);
|
|
25
|
+
const walletVersionRaw = bitReader.loadUint(8);
|
|
26
|
+
const subwalletNumber = bitReader.loadUint(15);
|
|
27
|
+
const walletVersion = Object.entries(walletV5R1VersionsSerialisation).find(([_, value]) => value === walletVersionRaw)?.[0];
|
|
28
|
+
if (walletVersion === undefined) {
|
|
29
|
+
throw new Error(`Can't deserialize walletId: unknown wallet version ${walletVersionRaw}`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
networkGlobalId,
|
|
33
|
+
context: {
|
|
34
|
+
walletVersion,
|
|
35
|
+
workchain,
|
|
36
|
+
subwalletNumber
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const context = bitReader.loadUint(31);
|
|
42
|
+
return {
|
|
43
|
+
networkGlobalId,
|
|
44
|
+
context
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.loadWalletIdV5R1 = loadWalletIdV5R1;
|
|
49
|
+
function storeWalletIdV5R1(walletId) {
|
|
50
|
+
return (builder) => {
|
|
51
|
+
let context;
|
|
52
|
+
if (isWalletIdV5R1ClientContext(walletId.context)) {
|
|
53
|
+
context = (0, core_1.beginCell)()
|
|
54
|
+
.storeUint(1, 1)
|
|
55
|
+
.storeInt(walletId.context.workchain, 8)
|
|
56
|
+
.storeUint(walletV5R1VersionsSerialisation[walletId.context.walletVersion], 8)
|
|
57
|
+
.storeUint(walletId.context.subwalletNumber, 15)
|
|
58
|
+
.endCell().beginParse().loadInt(32);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
context = (0, core_1.beginCell)()
|
|
62
|
+
.storeUint(0, 1)
|
|
63
|
+
.storeUint(walletId.context, 31)
|
|
64
|
+
.endCell().beginParse().loadInt(32);
|
|
65
|
+
}
|
|
66
|
+
return builder.storeInt(BigInt(walletId.networkGlobalId) ^ BigInt(context), 32);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
exports.storeWalletIdV5R1 = storeWalletIdV5R1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@ton/core");
|
|
4
|
+
const WalletV5R1WalletId_1 = require("./WalletV5R1WalletId");
|
|
5
|
+
describe('Wallet V5R1 wallet id', () => {
|
|
6
|
+
it('Should serialise wallet id', () => {
|
|
7
|
+
const walletId = {
|
|
8
|
+
networkGlobalId: -239,
|
|
9
|
+
context: {
|
|
10
|
+
walletVersion: 'v5r1',
|
|
11
|
+
workchain: 0,
|
|
12
|
+
subwalletNumber: 0
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5R1WalletId_1.storeWalletIdV5R1)(walletId)).endCell();
|
|
16
|
+
const context = (0, core_1.beginCell)()
|
|
17
|
+
.storeUint(1, 1)
|
|
18
|
+
.storeInt(walletId.context.workchain, 8)
|
|
19
|
+
.storeUint(0, 8)
|
|
20
|
+
.storeUint(walletId.context.subwalletNumber, 15)
|
|
21
|
+
.endCell().beginParse().loadInt(32);
|
|
22
|
+
const expected = (0, core_1.beginCell)().storeInt(BigInt(context) ^ BigInt(walletId.networkGlobalId), 32).endCell();
|
|
23
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
it('Should deserialise wallet id', () => {
|
|
26
|
+
const expected = {
|
|
27
|
+
networkGlobalId: -239,
|
|
28
|
+
context: {
|
|
29
|
+
walletVersion: 'v5r1',
|
|
30
|
+
workchain: 0,
|
|
31
|
+
subwalletNumber: 0
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const context = (0, core_1.beginCell)()
|
|
35
|
+
.storeUint(1, 1)
|
|
36
|
+
.storeInt(expected.context.workchain, 8)
|
|
37
|
+
.storeUint(0, 8)
|
|
38
|
+
.storeUint(expected.context.subwalletNumber, 15)
|
|
39
|
+
.endCell().beginParse().loadInt(32);
|
|
40
|
+
const actual = (0, WalletV5R1WalletId_1.loadWalletIdV5R1)((0, core_1.beginCell)().storeInt(BigInt(context) ^ BigInt(expected.networkGlobalId), 32).endCell().beginParse(), expected.networkGlobalId);
|
|
41
|
+
expect(expected).toEqual(actual);
|
|
42
|
+
});
|
|
43
|
+
it('Should serialise wallet id', () => {
|
|
44
|
+
const walletId = {
|
|
45
|
+
networkGlobalId: -3,
|
|
46
|
+
context: 239239239
|
|
47
|
+
};
|
|
48
|
+
const context = (0, core_1.beginCell)()
|
|
49
|
+
.storeUint(0, 1)
|
|
50
|
+
.storeUint(walletId.context, 31)
|
|
51
|
+
.endCell().beginParse().loadInt(32);
|
|
52
|
+
const actual = (0, core_1.beginCell)().store((0, WalletV5R1WalletId_1.storeWalletIdV5R1)(walletId)).endCell();
|
|
53
|
+
const expected = (0, core_1.beginCell)()
|
|
54
|
+
.storeInt(BigInt(context) ^ BigInt(walletId.networkGlobalId), 32)
|
|
55
|
+
.endCell();
|
|
56
|
+
expect(expected.equals(actual)).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
it('Should deserialise wallet id', () => {
|
|
59
|
+
const expected = {
|
|
60
|
+
networkGlobalId: -3,
|
|
61
|
+
context: 239239239
|
|
62
|
+
};
|
|
63
|
+
const context = (0, core_1.beginCell)()
|
|
64
|
+
.storeUint(0, 1)
|
|
65
|
+
.storeUint(expected.context, 31)
|
|
66
|
+
.endCell().beginParse().loadInt(32);
|
|
67
|
+
const actual = (0, WalletV5R1WalletId_1.loadWalletIdV5R1)((0, core_1.beginCell)()
|
|
68
|
+
.storeInt(BigInt(context) ^ BigInt(expected.networkGlobalId), 32)
|
|
69
|
+
.endCell().beginParse(), expected.networkGlobalId);
|
|
70
|
+
expect(expected).toEqual(actual);
|
|
71
|
+
});
|
|
72
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ton-wallet/create",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ton-org/ton.git"
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"@ton/emulator": "^2.1.1",
|
|
25
25
|
"@types/jest": "^27.0.1",
|
|
26
26
|
"@types/node": "^16.7.10",
|
|
27
|
+
"@types/node-telegram-bot-api": "^0.64.7",
|
|
27
28
|
"buffer": "^6.0.3",
|
|
29
|
+
"dotenv": "^16.4.5",
|
|
28
30
|
"expect": "^27.1.0",
|
|
29
31
|
"jest": "^27.1.0",
|
|
30
32
|
"jest-mock": "^27.1.0",
|
|
@@ -76,5 +78,6 @@
|
|
|
76
78
|
"bugs": {
|
|
77
79
|
"url": "https://github.com/ton-org/ton/issues"
|
|
78
80
|
},
|
|
79
|
-
"homepage": "https://github.com/ton-org/ton#readme"
|
|
81
|
+
"homepage": "https://github.com/ton-org/ton#readme",
|
|
82
|
+
"types": "./dist/index.d.ts"
|
|
80
83
|
}
|