@ton/ton 13.8.0 → 13.9.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/dist/wallets/signing/createWalletTransfer.d.ts +1 -7
- package/dist/wallets/signing/createWalletTransfer.js +1 -33
- package/package.json +1 -1
- package/dist/wallets/WalletContractV5.d.ts +0 -111
- package/dist/wallets/WalletContractV5.js +0 -197
- package/dist/wallets/WalletContractV5.spec.d.ts +0 -8
- package/dist/wallets/WalletContractV5.spec.js +0 -151
- package/dist/wallets/WalletV5Utils.d.ts +0 -31
- package/dist/wallets/WalletV5Utils.js +0 -115
- package/dist/wallets/WalletV5Utils.spec.d.ts +0 -1
- package/dist/wallets/WalletV5Utils.spec.js +0 -192
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
|
-
import { MessageRelaxed
|
|
9
|
+
import { MessageRelaxed } from "@ton/core";
|
|
10
10
|
import { Maybe } from "../../utils/maybe";
|
|
11
|
-
import { Wallet5SendArgs } from "../WalletContractV5";
|
|
12
|
-
import { OutActionExtended } from "../WalletV5Utils";
|
|
13
11
|
export declare function createWalletTransferV1(args: {
|
|
14
12
|
seqno: number;
|
|
15
13
|
sendMode: number;
|
|
@@ -39,7 +37,3 @@ export declare function createWalletTransferV4(args: {
|
|
|
39
37
|
secretKey: Buffer;
|
|
40
38
|
timeout?: Maybe<number>;
|
|
41
39
|
}): import("@ton/core").Cell;
|
|
42
|
-
export declare function createWalletTransferV5(args: Wallet5SendArgs & {
|
|
43
|
-
actions: (OutAction | OutActionExtended)[];
|
|
44
|
-
walletId: (builder: Builder) => void;
|
|
45
|
-
}): import("@ton/core").Cell;
|
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.createWalletTransferV4 = exports.createWalletTransferV3 = exports.createWalletTransferV2 = exports.createWalletTransferV1 = void 0;
|
|
11
11
|
const core_1 = require("@ton/core");
|
|
12
12
|
const crypto_1 = require("@ton/crypto");
|
|
13
|
-
const WalletContractV5_1 = require("../WalletContractV5");
|
|
14
|
-
const WalletV5Utils_1 = require("../WalletV5Utils");
|
|
15
13
|
function createWalletTransferV1(args) {
|
|
16
14
|
// Create message
|
|
17
15
|
let signingMessage = (0, core_1.beginCell)()
|
|
@@ -122,33 +120,3 @@ function createWalletTransferV4(args) {
|
|
|
122
120
|
return body;
|
|
123
121
|
}
|
|
124
122
|
exports.createWalletTransferV4 = createWalletTransferV4;
|
|
125
|
-
function createWalletTransferV5(args) {
|
|
126
|
-
// Check number of actions
|
|
127
|
-
if (args.actions.length > 255) {
|
|
128
|
-
throw Error("Maximum number of OutActions in a single request is 255");
|
|
129
|
-
}
|
|
130
|
-
if (!('secretKey' in args) || !args.secretKey) {
|
|
131
|
-
return (0, core_1.beginCell)()
|
|
132
|
-
.storeUint(WalletContractV5_1.WalletContractV5.opCodes.auth_extension, 32)
|
|
133
|
-
.store((0, WalletV5Utils_1.storeOutListExtended)(args.actions))
|
|
134
|
-
.endCell();
|
|
135
|
-
}
|
|
136
|
-
const message = (0, core_1.beginCell)().store(args.walletId);
|
|
137
|
-
if (args.seqno === 0) {
|
|
138
|
-
for (let i = 0; i < 32; i++) {
|
|
139
|
-
message.storeBit(1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
message.storeUint(args.timeout || Math.floor(Date.now() / 1e3) + 60, 32); // Default timeout: 60 seconds
|
|
144
|
-
}
|
|
145
|
-
message.storeUint(args.seqno, 32).store((0, WalletV5Utils_1.storeOutListExtended)(args.actions));
|
|
146
|
-
// Sign message
|
|
147
|
-
const signature = (0, crypto_1.sign)(message.endCell().hash(), args.secretKey);
|
|
148
|
-
return (0, core_1.beginCell)()
|
|
149
|
-
.storeUint(WalletContractV5_1.WalletContractV5.opCodes.auth_signed, 32)
|
|
150
|
-
.storeBuffer(signature)
|
|
151
|
-
.storeBuilder(message)
|
|
152
|
-
.endCell();
|
|
153
|
-
}
|
|
154
|
-
exports.createWalletTransferV5 = createWalletTransferV5;
|
package/package.json
CHANGED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Whales Corp.
|
|
3
|
-
* All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
/// <reference types="node" />
|
|
9
|
-
import { Address, Cell, Contract, ContractProvider, MessageRelaxed, OutAction, Sender, SendMode } from "@ton/core";
|
|
10
|
-
import { Maybe } from "../utils/maybe";
|
|
11
|
-
import { OutActionExtended, WalletId } from "./WalletV5Utils";
|
|
12
|
-
export declare type Wallet5BasicSendArgs = {
|
|
13
|
-
seqno: number;
|
|
14
|
-
sendMode?: Maybe<SendMode>;
|
|
15
|
-
timeout?: Maybe<number>;
|
|
16
|
-
};
|
|
17
|
-
export declare type SingedAuthWallet5SendArgs = Wallet5BasicSendArgs & {
|
|
18
|
-
secretKey: Buffer;
|
|
19
|
-
};
|
|
20
|
-
export declare type ExtensionAuthWallet5SendArgs = Wallet5BasicSendArgs & {};
|
|
21
|
-
export declare type Wallet5SendArgs = SingedAuthWallet5SendArgs | ExtensionAuthWallet5SendArgs;
|
|
22
|
-
export declare class WalletContractV5 implements Contract {
|
|
23
|
-
readonly walletId: WalletId;
|
|
24
|
-
readonly publicKey: Buffer;
|
|
25
|
-
static opCodes: {
|
|
26
|
-
auth_extension: number;
|
|
27
|
-
auth_signed: number;
|
|
28
|
-
};
|
|
29
|
-
static create(args: {
|
|
30
|
-
walletId?: Partial<WalletId>;
|
|
31
|
-
publicKey: Buffer;
|
|
32
|
-
}): WalletContractV5;
|
|
33
|
-
readonly address: Address;
|
|
34
|
-
readonly init: {
|
|
35
|
-
data: Cell;
|
|
36
|
-
code: Cell;
|
|
37
|
-
};
|
|
38
|
-
private constructor();
|
|
39
|
-
/**
|
|
40
|
-
* Get Wallet Balance
|
|
41
|
-
*/
|
|
42
|
-
getBalance(provider: ContractProvider): Promise<bigint>;
|
|
43
|
-
/**
|
|
44
|
-
* Get Wallet Seqno
|
|
45
|
-
*/
|
|
46
|
-
getSeqno(provider: ContractProvider): Promise<number>;
|
|
47
|
-
/**
|
|
48
|
-
* Get Wallet Extensions
|
|
49
|
-
*/
|
|
50
|
-
getExtensions(provider: ContractProvider): Promise<Cell | null>;
|
|
51
|
-
/**
|
|
52
|
-
* Get Wallet Extensions
|
|
53
|
-
*/
|
|
54
|
-
getExtensionsArray(provider: ContractProvider): Promise<Address[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Send signed transfer
|
|
57
|
-
*/
|
|
58
|
-
send(provider: ContractProvider, message: Cell): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Sign and send transfer
|
|
61
|
-
*/
|
|
62
|
-
sendTransfer(provider: ContractProvider, args: Wallet5SendArgs & {
|
|
63
|
-
messages: MessageRelaxed[];
|
|
64
|
-
}): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Sign and send add extension request
|
|
67
|
-
*/
|
|
68
|
-
sendAddExtension(provider: ContractProvider, args: Wallet5SendArgs & {
|
|
69
|
-
extensionAddress: Address;
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Sign and send remove extension request
|
|
73
|
-
*/
|
|
74
|
-
sendRemoveExtension(provider: ContractProvider, args: Wallet5SendArgs & {
|
|
75
|
-
extensionAddress: Address;
|
|
76
|
-
}): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Sign and send request
|
|
79
|
-
*/
|
|
80
|
-
sendRequest(provider: ContractProvider, args: Wallet5SendArgs & {
|
|
81
|
-
actions: (OutAction | OutActionExtended)[];
|
|
82
|
-
}): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Create signed transfer
|
|
85
|
-
*/
|
|
86
|
-
createTransfer(args: Wallet5SendArgs & {
|
|
87
|
-
messages: MessageRelaxed[];
|
|
88
|
-
}): Cell;
|
|
89
|
-
/**
|
|
90
|
-
* Create signed add extension request
|
|
91
|
-
*/
|
|
92
|
-
createAddExtension(args: Wallet5SendArgs & {
|
|
93
|
-
extensionAddress: Address;
|
|
94
|
-
}): Cell;
|
|
95
|
-
/**
|
|
96
|
-
* Create signed remove extension request
|
|
97
|
-
*/
|
|
98
|
-
createRemoveExtension(args: Wallet5SendArgs & {
|
|
99
|
-
extensionAddress: Address;
|
|
100
|
-
}): Cell;
|
|
101
|
-
/**
|
|
102
|
-
* Create signed request
|
|
103
|
-
*/
|
|
104
|
-
createRequest(args: Wallet5SendArgs & {
|
|
105
|
-
actions: (OutAction | OutActionExtended)[];
|
|
106
|
-
}): Cell;
|
|
107
|
-
/**
|
|
108
|
-
* Create sender
|
|
109
|
-
*/
|
|
110
|
-
sender(provider: ContractProvider, secretKey: Buffer): Sender;
|
|
111
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
exports.WalletContractV5 = void 0;
|
|
11
|
-
const core_1 = require("@ton/core");
|
|
12
|
-
const createWalletTransfer_1 = require("./signing/createWalletTransfer");
|
|
13
|
-
const WalletV5Utils_1 = require("./WalletV5Utils");
|
|
14
|
-
class WalletContractV5 {
|
|
15
|
-
constructor(walletId, publicKey) {
|
|
16
|
-
this.walletId = walletId;
|
|
17
|
-
this.publicKey = publicKey;
|
|
18
|
-
this.walletId = walletId;
|
|
19
|
-
// Build initial code and data
|
|
20
|
-
let code = core_1.Cell.fromBoc(Buffer.from('te6cckEBAQEAIwAIQgLND3fEdsoVqej99mmdJbaOAOcmH9K3vkNG64R7FPAsl9kimVw=', 'base64'))[0];
|
|
21
|
-
let data = (0, core_1.beginCell)()
|
|
22
|
-
.storeUint(0, 32) // Seqno
|
|
23
|
-
.store((0, WalletV5Utils_1.storeWalletId)(this.walletId))
|
|
24
|
-
.storeBuffer(this.publicKey)
|
|
25
|
-
.storeBit(0) // Empty plugins dict
|
|
26
|
-
.endCell();
|
|
27
|
-
this.init = { code, data };
|
|
28
|
-
this.address = (0, core_1.contractAddress)(this.walletId.workChain, { code, data });
|
|
29
|
-
}
|
|
30
|
-
static create(args) {
|
|
31
|
-
const walletId = {
|
|
32
|
-
networkGlobalId: args.walletId?.networkGlobalId ?? -239,
|
|
33
|
-
workChain: args?.walletId?.workChain ?? 0,
|
|
34
|
-
subwalletNumber: args?.walletId?.subwalletNumber ?? 0,
|
|
35
|
-
walletVersion: args?.walletId?.walletVersion ?? 'v5'
|
|
36
|
-
};
|
|
37
|
-
return new WalletContractV5(walletId, args.publicKey);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get Wallet Balance
|
|
41
|
-
*/
|
|
42
|
-
async getBalance(provider) {
|
|
43
|
-
let state = await provider.getState();
|
|
44
|
-
return state.balance;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get Wallet Seqno
|
|
48
|
-
*/
|
|
49
|
-
async getSeqno(provider) {
|
|
50
|
-
let state = await provider.getState();
|
|
51
|
-
if (state.state.type === 'active') {
|
|
52
|
-
let res = await provider.get('seqno', []);
|
|
53
|
-
return res.stack.readNumber();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get Wallet Extensions
|
|
61
|
-
*/
|
|
62
|
-
async getExtensions(provider) {
|
|
63
|
-
let state = await provider.getState();
|
|
64
|
-
if (state.state.type === 'active') {
|
|
65
|
-
const result = await provider.get('get_extensions', []);
|
|
66
|
-
return result.stack.readCellOpt();
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get Wallet Extensions
|
|
74
|
-
*/
|
|
75
|
-
async getExtensionsArray(provider) {
|
|
76
|
-
const extensions = await this.getExtensions(provider);
|
|
77
|
-
if (!extensions) {
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
const dict = core_1.Dictionary.loadDirect(core_1.Dictionary.Keys.BigUint(256), core_1.Dictionary.Values.BigInt(8), extensions);
|
|
81
|
-
return dict.keys().map(key => {
|
|
82
|
-
const wc = dict.get(key);
|
|
83
|
-
const addressHex = key ^ (wc + 1n);
|
|
84
|
-
return core_1.Address.parseRaw(`${wc}:${addressHex.toString(16)}`);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Send signed transfer
|
|
89
|
-
*/
|
|
90
|
-
async send(provider, message) {
|
|
91
|
-
await provider.external(message);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Sign and send transfer
|
|
95
|
-
*/
|
|
96
|
-
async sendTransfer(provider, args) {
|
|
97
|
-
const transfer = this.createTransfer(args);
|
|
98
|
-
await this.send(provider, transfer);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Sign and send add extension request
|
|
102
|
-
*/
|
|
103
|
-
async sendAddExtension(provider, args) {
|
|
104
|
-
const request = this.createAddExtension(args);
|
|
105
|
-
await this.send(provider, request);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Sign and send remove extension request
|
|
109
|
-
*/
|
|
110
|
-
async sendRemoveExtension(provider, args) {
|
|
111
|
-
const request = this.createRemoveExtension(args);
|
|
112
|
-
await this.send(provider, request);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Sign and send request
|
|
116
|
-
*/
|
|
117
|
-
async sendRequest(provider, args) {
|
|
118
|
-
const request = this.createRequest(args);
|
|
119
|
-
await this.send(provider, request);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Create signed transfer
|
|
123
|
-
*/
|
|
124
|
-
createTransfer(args) {
|
|
125
|
-
const { messages, ...rest } = args;
|
|
126
|
-
const sendMode = args.sendMode ?? core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
127
|
-
const actions = messages.map(message => ({ type: 'sendMsg', mode: sendMode, outMsg: message }));
|
|
128
|
-
return this.createRequest({
|
|
129
|
-
...rest,
|
|
130
|
-
actions
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Create signed add extension request
|
|
135
|
-
*/
|
|
136
|
-
createAddExtension(args) {
|
|
137
|
-
const { extensionAddress, ...rest } = args;
|
|
138
|
-
return this.createRequest({
|
|
139
|
-
actions: [{
|
|
140
|
-
type: 'addExtension',
|
|
141
|
-
address: extensionAddress
|
|
142
|
-
}],
|
|
143
|
-
...rest
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Create signed remove extension request
|
|
148
|
-
*/
|
|
149
|
-
createRemoveExtension(args) {
|
|
150
|
-
const { extensionAddress, ...rest } = args;
|
|
151
|
-
return this.createRequest({
|
|
152
|
-
actions: [{
|
|
153
|
-
type: 'removeExtension',
|
|
154
|
-
address: extensionAddress
|
|
155
|
-
}],
|
|
156
|
-
...rest
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Create signed request
|
|
161
|
-
*/
|
|
162
|
-
createRequest(args) {
|
|
163
|
-
return (0, createWalletTransfer_1.createWalletTransferV5)({
|
|
164
|
-
...args,
|
|
165
|
-
sendMode: args.sendMode ?? core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
166
|
-
walletId: (0, WalletV5Utils_1.storeWalletId)(this.walletId)
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Create sender
|
|
171
|
-
*/
|
|
172
|
-
sender(provider, secretKey) {
|
|
173
|
-
return {
|
|
174
|
-
send: async (args) => {
|
|
175
|
-
let seqno = await this.getSeqno(provider);
|
|
176
|
-
let transfer = this.createTransfer({
|
|
177
|
-
seqno,
|
|
178
|
-
secretKey,
|
|
179
|
-
sendMode: args.sendMode,
|
|
180
|
-
messages: [(0, core_1.internal)({
|
|
181
|
-
to: args.to,
|
|
182
|
-
value: args.value,
|
|
183
|
-
init: args.init,
|
|
184
|
-
body: args.body,
|
|
185
|
-
bounce: args.bounce
|
|
186
|
-
})]
|
|
187
|
-
});
|
|
188
|
-
await this.send(provider, transfer);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
exports.WalletContractV5 = WalletContractV5;
|
|
194
|
-
WalletContractV5.opCodes = {
|
|
195
|
-
auth_extension: 0x6578746e,
|
|
196
|
-
auth_signed: 0x7369676e
|
|
197
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
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 WalletContractV5_1 = require("./WalletContractV5");
|
|
13
|
-
const createTestClient_1 = require("../utils/createTestClient");
|
|
14
|
-
const getExtensionsArray = async (wallet) => {
|
|
15
|
-
try {
|
|
16
|
-
return await wallet.getExtensionsArray();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
// Handle toncenter bug. Toncenter incorrectly returns 'list' in the stack in case of empty extensions dict
|
|
20
|
-
if (e instanceof Error && e.message === 'Unsupported stack item type: list') {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
describe('WalletContractV5', () => {
|
|
27
|
-
let client;
|
|
28
|
-
let walletKey;
|
|
29
|
-
let wallet;
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
client = (0, createTestClient_1.createTestClient)();
|
|
32
|
-
walletKey = (0, randomTestKey_1.randomTestKey)('v5-treasure');
|
|
33
|
-
wallet = client.open(WalletContractV5_1.WalletContractV5.create({ walletId: { networkGlobalId: -3 }, publicKey: walletKey.publicKey }));
|
|
34
|
-
});
|
|
35
|
-
it('should has balance and correct address', async () => {
|
|
36
|
-
const balance = await wallet.getBalance();
|
|
37
|
-
expect(wallet.address.equals(core_1.Address.parse('EQDv2B0jPmJZ1j-ne3Ko64eGqfYZRHGQbfSE5pUWVvUdQmDH'))).toBeTruthy();
|
|
38
|
-
expect(balance > 0n).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it('should perform single transfer', async () => {
|
|
41
|
-
const seqno = await wallet.getSeqno();
|
|
42
|
-
const transfer = wallet.createTransfer({
|
|
43
|
-
seqno,
|
|
44
|
-
secretKey: walletKey.secretKey,
|
|
45
|
-
messages: [(0, core_1.internal)({
|
|
46
|
-
to: 'EQDQ0PRYSWmW-v6LVHNYq5Uelpr5f7Ct7awG7Lao2HImrCzn',
|
|
47
|
-
value: '0.01',
|
|
48
|
-
body: 'Hello world single transfer!'
|
|
49
|
-
})]
|
|
50
|
-
});
|
|
51
|
-
await wallet.send(transfer);
|
|
52
|
-
});
|
|
53
|
-
it('should perform double transfer', async () => {
|
|
54
|
-
const seqno = await wallet.getSeqno();
|
|
55
|
-
const transfer = wallet.createTransfer({
|
|
56
|
-
seqno,
|
|
57
|
-
secretKey: walletKey.secretKey,
|
|
58
|
-
messages: [(0, core_1.internal)({
|
|
59
|
-
to: 'EQDQ0PRYSWmW-v6LVHNYq5Uelpr5f7Ct7awG7Lao2HImrCzn',
|
|
60
|
-
value: '0.01',
|
|
61
|
-
body: 'Hello world to extension'
|
|
62
|
-
}), (0, core_1.internal)({
|
|
63
|
-
to: 'EQAtHiE_vEyAogU1rHcz3uzp64h-yqeFJ2S2ChkKNwygLMk3',
|
|
64
|
-
value: '0.02',
|
|
65
|
-
body: 'Hello world to relayer'
|
|
66
|
-
})]
|
|
67
|
-
});
|
|
68
|
-
await wallet.send(transfer);
|
|
69
|
-
});
|
|
70
|
-
it('should add extension', async () => {
|
|
71
|
-
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
72
|
-
const extensionContract = client.open(WalletContractV5_1.WalletContractV5.create({ walletId: { workChain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
73
|
-
const seqno = await wallet.getSeqno();
|
|
74
|
-
const extensions = await getExtensionsArray(wallet);
|
|
75
|
-
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
76
|
-
if (!extensionAlreadyAdded) {
|
|
77
|
-
await wallet.sendAddExtension({
|
|
78
|
-
seqno,
|
|
79
|
-
secretKey: walletKey.secretKey,
|
|
80
|
-
extensionAddress: extensionContract.address
|
|
81
|
-
});
|
|
82
|
-
const waitUntilExtensionAdded = async (attempt = 0) => {
|
|
83
|
-
if (attempt >= 10) {
|
|
84
|
-
throw new Error('Extension was not added in 10 blocks');
|
|
85
|
-
}
|
|
86
|
-
const extensions = await getExtensionsArray(wallet);
|
|
87
|
-
const extensionAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
88
|
-
if (extensionAdded) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
await new Promise(r => setTimeout(r, 1500));
|
|
92
|
-
return waitUntilExtensionAdded(attempt + 1);
|
|
93
|
-
};
|
|
94
|
-
await waitUntilExtensionAdded();
|
|
95
|
-
}
|
|
96
|
-
const extensionsSeqno = await extensionContract.getSeqno();
|
|
97
|
-
await extensionContract.sendTransfer({
|
|
98
|
-
seqno: extensionsSeqno,
|
|
99
|
-
secretKey: extensionKey.secretKey,
|
|
100
|
-
messages: [(0, core_1.internal)({
|
|
101
|
-
to: wallet.address,
|
|
102
|
-
value: '0.1',
|
|
103
|
-
body: wallet.createTransfer({
|
|
104
|
-
seqno: seqno + 1,
|
|
105
|
-
messages: [(0, core_1.internal)({
|
|
106
|
-
to: 'kQD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgtwt',
|
|
107
|
-
value: '0.03',
|
|
108
|
-
body: 'Hello world from plugin'
|
|
109
|
-
})]
|
|
110
|
-
})
|
|
111
|
-
})]
|
|
112
|
-
});
|
|
113
|
-
}, 60000);
|
|
114
|
-
it('should remove extension', async () => {
|
|
115
|
-
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
116
|
-
const extensionContract = client.open(WalletContractV5_1.WalletContractV5.create({ walletId: { workChain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
117
|
-
const seqno = await wallet.getSeqno();
|
|
118
|
-
const extensions = await getExtensionsArray(wallet);
|
|
119
|
-
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
120
|
-
if (extensionAlreadyAdded) {
|
|
121
|
-
await wallet.sendRemoveExtension({
|
|
122
|
-
seqno,
|
|
123
|
-
secretKey: walletKey.secretKey,
|
|
124
|
-
extensionAddress: extensionContract.address
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
it('should send internal transfer via relayer', async () => {
|
|
129
|
-
const relaerKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-relayer');
|
|
130
|
-
const relayerContract = client.open(WalletContractV5_1.WalletContractV5.create({ walletId: { workChain: 0, networkGlobalId: -3 }, publicKey: relaerKey.publicKey }));
|
|
131
|
-
const seqno = await wallet.getSeqno();
|
|
132
|
-
const relayerSeqno = await relayerContract.getSeqno();
|
|
133
|
-
await relayerContract.sendTransfer({
|
|
134
|
-
seqno: relayerSeqno,
|
|
135
|
-
secretKey: relaerKey.secretKey,
|
|
136
|
-
messages: [(0, core_1.internal)({
|
|
137
|
-
to: wallet.address,
|
|
138
|
-
value: '0.1',
|
|
139
|
-
body: wallet.createTransfer({
|
|
140
|
-
seqno: seqno,
|
|
141
|
-
secretKey: walletKey.secretKey,
|
|
142
|
-
messages: [(0, core_1.internal)({
|
|
143
|
-
to: 'kQD6oPnzaaAMRW24R8F0_nlSsJQni0cGHntR027eT9_sgtwt',
|
|
144
|
-
value: '0.04',
|
|
145
|
-
body: 'Hello world from relayer'
|
|
146
|
-
})]
|
|
147
|
-
})
|
|
148
|
-
})]
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Address, Builder, Cell, OutAction, Slice } from '@ton/core';
|
|
3
|
-
export interface OutActionSetData {
|
|
4
|
-
type: 'setData';
|
|
5
|
-
newData: Cell;
|
|
6
|
-
}
|
|
7
|
-
export interface OutActionAddExtension {
|
|
8
|
-
type: 'addExtension';
|
|
9
|
-
address: Address;
|
|
10
|
-
}
|
|
11
|
-
export interface OutActionRemoveExtension {
|
|
12
|
-
type: 'removeExtension';
|
|
13
|
-
address: Address;
|
|
14
|
-
}
|
|
15
|
-
export declare type OutActionExtended = OutActionSetData | OutActionAddExtension | OutActionRemoveExtension;
|
|
16
|
-
export declare function storeOutActionExtended(action: OutActionExtended): (builder: Builder) => void;
|
|
17
|
-
export declare function loadOutActionExtended(slice: Slice): OutActionExtended;
|
|
18
|
-
export declare function isOutActionExtended(action: OutAction | OutActionExtended): action is OutActionExtended;
|
|
19
|
-
export declare function storeOutListExtended(actions: (OutActionExtended | OutAction)[]): (builder: Builder) => void;
|
|
20
|
-
export declare function loadOutListExtended(slice: Slice): (OutActionExtended | OutAction)[];
|
|
21
|
-
export interface WalletId {
|
|
22
|
-
readonly walletVersion: 'v5';
|
|
23
|
-
/**
|
|
24
|
-
* -239 is mainnet, -3 is testnet
|
|
25
|
-
*/
|
|
26
|
-
readonly networkGlobalId: number;
|
|
27
|
-
readonly workChain: number;
|
|
28
|
-
readonly subwalletNumber: number;
|
|
29
|
-
}
|
|
30
|
-
export declare function loadWalletId(value: bigint | Buffer | Slice): WalletId;
|
|
31
|
-
export declare function storeWalletId(walletId: WalletId): (builder: Builder) => void;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeWalletId = exports.loadWalletId = exports.loadOutListExtended = exports.storeOutListExtended = exports.isOutActionExtended = exports.loadOutActionExtended = exports.storeOutActionExtended = void 0;
|
|
4
|
-
const core_1 = require("@ton/core");
|
|
5
|
-
const outActionSetDataTag = 0x1ff8ea0b;
|
|
6
|
-
function storeOutActionSetData(action) {
|
|
7
|
-
return (builder) => {
|
|
8
|
-
builder.storeUint(outActionSetDataTag, 32).storeRef(action.newData);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const outActionAddExtensionTag = 0x1c40db9f;
|
|
12
|
-
function storeOutActionAddExtension(action) {
|
|
13
|
-
return (builder) => {
|
|
14
|
-
builder.storeUint(outActionAddExtensionTag, 32).storeAddress(action.address);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const outActionRemoveExtensionTag = 0x5eaef4a4;
|
|
18
|
-
function storeOutActionRemoveExtension(action) {
|
|
19
|
-
return (builder) => {
|
|
20
|
-
builder.storeUint(outActionRemoveExtensionTag, 32).storeAddress(action.address);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function storeOutActionExtended(action) {
|
|
24
|
-
if (action.type === 'setData') {
|
|
25
|
-
return storeOutActionSetData(action);
|
|
26
|
-
}
|
|
27
|
-
if (action.type === 'addExtension') {
|
|
28
|
-
return storeOutActionAddExtension(action);
|
|
29
|
-
}
|
|
30
|
-
return storeOutActionRemoveExtension(action);
|
|
31
|
-
}
|
|
32
|
-
exports.storeOutActionExtended = storeOutActionExtended;
|
|
33
|
-
function loadOutActionExtended(slice) {
|
|
34
|
-
const tag = slice.loadUint(32);
|
|
35
|
-
switch (tag) {
|
|
36
|
-
case outActionSetDataTag:
|
|
37
|
-
return {
|
|
38
|
-
type: 'setData',
|
|
39
|
-
newData: slice.loadRef()
|
|
40
|
-
};
|
|
41
|
-
case outActionAddExtensionTag:
|
|
42
|
-
return {
|
|
43
|
-
type: 'addExtension',
|
|
44
|
-
address: slice.loadAddress()
|
|
45
|
-
};
|
|
46
|
-
case outActionRemoveExtensionTag:
|
|
47
|
-
return {
|
|
48
|
-
type: 'removeExtension',
|
|
49
|
-
address: slice.loadAddress()
|
|
50
|
-
};
|
|
51
|
-
default:
|
|
52
|
-
throw new Error(`Unknown extended out action tag 0x${tag.toString(16)}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.loadOutActionExtended = loadOutActionExtended;
|
|
56
|
-
function isOutActionExtended(action) {
|
|
57
|
-
return (action.type === 'setData' || action.type === 'addExtension' || action.type === 'removeExtension');
|
|
58
|
-
}
|
|
59
|
-
exports.isOutActionExtended = isOutActionExtended;
|
|
60
|
-
function storeOutListExtended(actions) {
|
|
61
|
-
const [action, ...rest] = actions;
|
|
62
|
-
if (!action || !isOutActionExtended(action)) {
|
|
63
|
-
if (actions.some(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(storeOutActionExtended(action))
|
|
75
|
-
.storeRef((0, core_1.beginCell)().store(storeOutListExtended(rest)).endCell());
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
exports.storeOutListExtended = storeOutListExtended;
|
|
79
|
-
function loadOutListExtended(slice) {
|
|
80
|
-
const actions = [];
|
|
81
|
-
while (slice.loadUint(1)) {
|
|
82
|
-
const action = loadOutActionExtended(slice);
|
|
83
|
-
actions.push(action);
|
|
84
|
-
slice = slice.loadRef().beginParse();
|
|
85
|
-
}
|
|
86
|
-
return actions.concat((0, core_1.loadOutList)(slice.loadRef().beginParse()));
|
|
87
|
-
}
|
|
88
|
-
exports.loadOutListExtended = loadOutListExtended;
|
|
89
|
-
const walletVersionsSerialisation = {
|
|
90
|
-
v5: 0
|
|
91
|
-
};
|
|
92
|
-
function loadWalletId(value) {
|
|
93
|
-
const bitReader = new core_1.BitReader(new core_1.BitString(typeof value === 'bigint' ?
|
|
94
|
-
Buffer.from(value.toString(16), 'hex') :
|
|
95
|
-
value instanceof core_1.Slice ? value.loadBuffer(10) : value, 0, 80));
|
|
96
|
-
const networkGlobalId = bitReader.loadInt(32);
|
|
97
|
-
const workChain = bitReader.loadInt(8);
|
|
98
|
-
const walletVersionRaw = bitReader.loadUint(8);
|
|
99
|
-
const subwalletNumber = bitReader.loadUint(32);
|
|
100
|
-
const walletVersion = Object.entries(walletVersionsSerialisation).find(([_, value]) => value === walletVersionRaw)?.[0];
|
|
101
|
-
if (walletVersion === undefined) {
|
|
102
|
-
throw new Error(`Can't deserialize walletId: unknown wallet version ${walletVersionRaw}`);
|
|
103
|
-
}
|
|
104
|
-
return { networkGlobalId, workChain, walletVersion, subwalletNumber };
|
|
105
|
-
}
|
|
106
|
-
exports.loadWalletId = loadWalletId;
|
|
107
|
-
function storeWalletId(walletId) {
|
|
108
|
-
return (builder) => {
|
|
109
|
-
builder.storeInt(walletId.networkGlobalId, 32);
|
|
110
|
-
builder.storeInt(walletId.workChain, 8);
|
|
111
|
-
builder.storeUint(walletVersionsSerialisation[walletId.walletVersion], 8);
|
|
112
|
-
builder.storeUint(walletId.subwalletNumber, 32);
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
exports.storeWalletId = storeWalletId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@ton/core");
|
|
4
|
-
const WalletV5Utils_1 = require("./WalletV5Utils");
|
|
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 mockData = (0, core_1.beginCell)().storeUint(123, 32).endCell();
|
|
17
|
-
const mockAddress = core_1.Address.parseRaw('0:' + '1'.repeat(64));
|
|
18
|
-
describe('Wallet V5 utils', () => {
|
|
19
|
-
const outActionSetDataTag = 0x1ff8ea0b;
|
|
20
|
-
const outActionAddExtensionTag = 0x1c40db9f;
|
|
21
|
-
const outActionRemoveExtensionTag = 0x5eaef4a4;
|
|
22
|
-
const outActionSendMsgTag = 0x0ec3c86d;
|
|
23
|
-
it('Should serialise set data action', () => {
|
|
24
|
-
const action = (0, WalletV5Utils_1.storeOutActionExtended)({
|
|
25
|
-
type: 'setData',
|
|
26
|
-
newData: mockData
|
|
27
|
-
});
|
|
28
|
-
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
29
|
-
const expected = (0, core_1.beginCell)()
|
|
30
|
-
.storeUint(outActionSetDataTag, 32)
|
|
31
|
-
.storeRef(mockData)
|
|
32
|
-
.endCell();
|
|
33
|
-
expect(expected.equals(actual)).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
it('Should serialise add extension action', () => {
|
|
36
|
-
const action = (0, WalletV5Utils_1.storeOutActionExtended)({
|
|
37
|
-
type: 'addExtension',
|
|
38
|
-
address: mockAddress
|
|
39
|
-
});
|
|
40
|
-
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
41
|
-
const expected = (0, core_1.beginCell)()
|
|
42
|
-
.storeUint(outActionAddExtensionTag, 32)
|
|
43
|
-
.storeAddress(mockAddress)
|
|
44
|
-
.endCell();
|
|
45
|
-
expect(expected.equals(actual)).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
it('Should serialise remove extension action', () => {
|
|
48
|
-
const action = (0, WalletV5Utils_1.storeOutActionExtended)({
|
|
49
|
-
type: 'removeExtension',
|
|
50
|
-
address: mockAddress
|
|
51
|
-
});
|
|
52
|
-
const actual = (0, core_1.beginCell)().store(action).endCell();
|
|
53
|
-
const expected = (0, core_1.beginCell)()
|
|
54
|
-
.storeUint(outActionRemoveExtensionTag, 32)
|
|
55
|
-
.storeAddress(mockAddress)
|
|
56
|
-
.endCell();
|
|
57
|
-
expect(expected.equals(actual)).toBeTruthy();
|
|
58
|
-
});
|
|
59
|
-
it('Should serialise wallet id', () => {
|
|
60
|
-
const walletId = {
|
|
61
|
-
walletVersion: 'v5',
|
|
62
|
-
networkGlobalId: -239,
|
|
63
|
-
workChain: 0,
|
|
64
|
-
subwalletNumber: 0
|
|
65
|
-
};
|
|
66
|
-
const actual = (0, core_1.beginCell)().store((0, WalletV5Utils_1.storeWalletId)(walletId)).endCell();
|
|
67
|
-
const expected = (0, core_1.beginCell)()
|
|
68
|
-
.storeInt(walletId.networkGlobalId, 32)
|
|
69
|
-
.storeInt(walletId.workChain, 8)
|
|
70
|
-
.storeUint(0, 8)
|
|
71
|
-
.storeUint(walletId.subwalletNumber, 32)
|
|
72
|
-
.endCell();
|
|
73
|
-
expect(expected.equals(actual)).toBeTruthy();
|
|
74
|
-
});
|
|
75
|
-
it('Should deserialise wallet id', () => {
|
|
76
|
-
const expected = {
|
|
77
|
-
walletVersion: 'v5',
|
|
78
|
-
networkGlobalId: -239,
|
|
79
|
-
workChain: 0,
|
|
80
|
-
subwalletNumber: 0
|
|
81
|
-
};
|
|
82
|
-
const actual = (0, WalletV5Utils_1.loadWalletId)((0, core_1.beginCell)()
|
|
83
|
-
.storeInt(expected.networkGlobalId, 32)
|
|
84
|
-
.storeInt(expected.workChain, 8)
|
|
85
|
-
.storeUint(0, 8)
|
|
86
|
-
.storeUint(expected.subwalletNumber, 32)
|
|
87
|
-
.endCell().beginParse());
|
|
88
|
-
expect(expected).toEqual(actual);
|
|
89
|
-
});
|
|
90
|
-
it('Should serialise wallet id', () => {
|
|
91
|
-
const walletId = {
|
|
92
|
-
walletVersion: 'v5',
|
|
93
|
-
networkGlobalId: -3,
|
|
94
|
-
workChain: -1,
|
|
95
|
-
subwalletNumber: 1234
|
|
96
|
-
};
|
|
97
|
-
const actual = (0, core_1.beginCell)().store((0, WalletV5Utils_1.storeWalletId)(walletId)).endCell();
|
|
98
|
-
const expected = (0, core_1.beginCell)()
|
|
99
|
-
.storeInt(walletId.networkGlobalId, 32)
|
|
100
|
-
.storeInt(walletId.workChain, 8)
|
|
101
|
-
.storeUint(0, 8)
|
|
102
|
-
.storeUint(walletId.subwalletNumber, 32)
|
|
103
|
-
.endCell();
|
|
104
|
-
expect(expected.equals(actual)).toBeTruthy();
|
|
105
|
-
});
|
|
106
|
-
it('Should deserialise wallet id', () => {
|
|
107
|
-
const expected = {
|
|
108
|
-
walletVersion: 'v5',
|
|
109
|
-
networkGlobalId: -239,
|
|
110
|
-
workChain: -1,
|
|
111
|
-
subwalletNumber: 1
|
|
112
|
-
};
|
|
113
|
-
const actual = (0, WalletV5Utils_1.loadWalletId)((0, core_1.beginCell)()
|
|
114
|
-
.storeInt(expected.networkGlobalId, 32)
|
|
115
|
-
.storeInt(expected.workChain, 8)
|
|
116
|
-
.storeUint(0, 8)
|
|
117
|
-
.storeUint(expected.subwalletNumber, 32)
|
|
118
|
-
.endCell().beginParse());
|
|
119
|
-
expect(expected).toEqual(actual);
|
|
120
|
-
});
|
|
121
|
-
it('Should serialize extended out list', () => {
|
|
122
|
-
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
123
|
-
const actions = [
|
|
124
|
-
{
|
|
125
|
-
type: 'addExtension',
|
|
126
|
-
address: mockAddress
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
type: 'sendMsg',
|
|
130
|
-
mode: sendMode1,
|
|
131
|
-
outMsg: mockMessageRelaxed1
|
|
132
|
-
}
|
|
133
|
-
];
|
|
134
|
-
const actual = (0, core_1.beginCell)().store((0, WalletV5Utils_1.storeOutListExtended)(actions)).endCell();
|
|
135
|
-
const expected = (0, core_1.beginCell)()
|
|
136
|
-
.storeUint(1, 1)
|
|
137
|
-
.store((0, WalletV5Utils_1.storeOutActionExtended)(actions[0]))
|
|
138
|
-
.storeRef((0, core_1.beginCell)()
|
|
139
|
-
.storeUint(0, 1)
|
|
140
|
-
.storeRef((0, core_1.beginCell)()
|
|
141
|
-
.storeRef((0, core_1.beginCell)().endCell())
|
|
142
|
-
.storeUint(outActionSendMsgTag, 32)
|
|
143
|
-
.storeUint(sendMode1, 8)
|
|
144
|
-
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
145
|
-
.endCell())
|
|
146
|
-
.endCell())
|
|
147
|
-
.endCell();
|
|
148
|
-
expect(actual.equals(expected)).toBeTruthy();
|
|
149
|
-
});
|
|
150
|
-
it('Should deserialize extended out list', () => {
|
|
151
|
-
const sendMode1 = core_1.SendMode.PAY_GAS_SEPARATELY;
|
|
152
|
-
const expected = [
|
|
153
|
-
{
|
|
154
|
-
type: 'addExtension',
|
|
155
|
-
address: mockAddress
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
type: 'sendMsg',
|
|
159
|
-
mode: sendMode1,
|
|
160
|
-
outMsg: mockMessageRelaxed1
|
|
161
|
-
}
|
|
162
|
-
];
|
|
163
|
-
const serialized = (0, core_1.beginCell)()
|
|
164
|
-
.storeUint(1, 1)
|
|
165
|
-
.store((0, WalletV5Utils_1.storeOutActionExtended)(expected[0]))
|
|
166
|
-
.storeRef((0, core_1.beginCell)()
|
|
167
|
-
.storeUint(0, 1)
|
|
168
|
-
.storeRef((0, core_1.beginCell)()
|
|
169
|
-
.storeRef((0, core_1.beginCell)().endCell())
|
|
170
|
-
.storeUint(outActionSendMsgTag, 32)
|
|
171
|
-
.storeUint(sendMode1, 8)
|
|
172
|
-
.storeRef((0, core_1.beginCell)().store((0, core_1.storeMessageRelaxed)(mockMessageRelaxed1)).endCell())
|
|
173
|
-
.endCell())
|
|
174
|
-
.endCell())
|
|
175
|
-
.endCell();
|
|
176
|
-
const actual = (0, WalletV5Utils_1.loadOutListExtended)(serialized.beginParse());
|
|
177
|
-
expect(expected.length).toEqual(actual.length);
|
|
178
|
-
expected.forEach((item1, index) => {
|
|
179
|
-
const item2 = actual[index];
|
|
180
|
-
expect(item1.type).toEqual(item2.type);
|
|
181
|
-
if (item1.type === 'sendMsg' && item2.type === 'sendMsg') {
|
|
182
|
-
expect(item1.mode).toEqual(item2.mode);
|
|
183
|
-
expect(item1.outMsg.body.equals(item2.outMsg.body)).toBeTruthy();
|
|
184
|
-
expect(item1.outMsg.info).toEqual(item2.outMsg.info);
|
|
185
|
-
expect(item1.outMsg.init).toEqual(item2.outMsg.init);
|
|
186
|
-
}
|
|
187
|
-
if (item1.type === 'addExtension' && item2.type === 'addExtension') {
|
|
188
|
-
expect(item1.address.equals(item2.address)).toBeTruthy();
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
});
|