@ton/ton 13.8.0 → 13.10.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.
@@ -6,6 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  /// <reference types="node" />
9
+ import { HttpApi } from "./api/HttpApi";
9
10
  import { AxiosAdapter } from 'axios';
10
11
  import { Address, Cell, Contract, ContractProvider, Message, Transaction, TupleItem, TupleReader } from '@ton/core';
11
12
  export declare type TonClientParameters = {
@@ -27,8 +28,8 @@ export declare type TonClientParameters = {
27
28
  httpAdapter?: AxiosAdapter;
28
29
  };
29
30
  export declare class TonClient {
30
- #private;
31
31
  readonly parameters: TonClientParameters;
32
+ protected api: HttpApi;
32
33
  constructor(parameters: TonClientParameters);
33
34
  /**
34
35
  * Get Address Balance
@@ -102,6 +103,22 @@ export declare class TonClient {
102
103
  * @returns transaction or null if not exist
103
104
  */
104
105
  getTransaction(address: Address, lt: string, hash: string): Promise<Transaction | null>;
106
+ /**
107
+ * Locate outcoming transaction of destination address by incoming message
108
+ * @param source message source address
109
+ * @param destination message destination address
110
+ * @param created_lt message's created lt
111
+ * @returns transaction
112
+ */
113
+ tryLocateResultTx(source: Address, destination: Address, created_lt: string): Promise<Transaction>;
114
+ /**
115
+ * Locate incoming transaction of source address by outcoming message
116
+ * @param source message source address
117
+ * @param destination message destination address
118
+ * @param created_lt message's created lt
119
+ * @returns transaction
120
+ */
121
+ tryLocateSourceTx(source: Address, destination: Address, created_lt: string): Promise<Transaction>;
105
122
  /**
106
123
  * Fetch latest masterchain info
107
124
  * @returns masterchain info
@@ -6,33 +6,20 @@
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10
- if (kind === "m") throw new TypeError("Private method is not writable");
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14
- };
15
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
18
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
19
- };
20
- var _TonClient_api;
21
9
  Object.defineProperty(exports, "__esModule", { value: true });
22
10
  exports.TonClient = void 0;
23
11
  const HttpApi_1 = require("./api/HttpApi");
24
12
  const core_1 = require("@ton/core");
25
13
  class TonClient {
26
14
  constructor(parameters) {
27
- _TonClient_api.set(this, void 0);
28
15
  this.parameters = {
29
16
  endpoint: parameters.endpoint
30
17
  };
31
- __classPrivateFieldSet(this, _TonClient_api, new HttpApi_1.HttpApi(this.parameters.endpoint, {
18
+ this.api = new HttpApi_1.HttpApi(this.parameters.endpoint, {
32
19
  timeout: parameters.timeout,
33
20
  apiKey: parameters.apiKey,
34
21
  adapter: parameters.httpAdapter
35
- }), "f");
22
+ });
36
23
  }
37
24
  /**
38
25
  * Get Address Balance
@@ -50,7 +37,7 @@ class TonClient {
50
37
  * @returns stack and gas_used field
51
38
  */
52
39
  async runMethod(address, name, stack = []) {
53
- let res = await __classPrivateFieldGet(this, _TonClient_api, "f").callGetMethod(address, name, stack);
40
+ let res = await this.api.callGetMethod(address, name, stack);
54
41
  if (res.exit_code !== 0) {
55
42
  throw Error('Unable to execute get method. Got exit_code: ' + res.exit_code);
56
43
  }
@@ -75,7 +62,7 @@ class TonClient {
75
62
  * @returns stack and gas_used field
76
63
  */
77
64
  async runMethodWithError(address, name, params = []) {
78
- let res = await __classPrivateFieldGet(this, _TonClient_api, "f").callGetMethod(address, name, params);
65
+ let res = await this.api.callGetMethod(address, name, params);
79
66
  return { gas_used: res.gas_used, stack: parseStack(res.stack), exit_code: res.exit_code };
80
67
  }
81
68
  /**
@@ -95,7 +82,7 @@ class TonClient {
95
82
  */
96
83
  async getTransactions(address, opts) {
97
84
  // Fetch transactions
98
- let tx = await __classPrivateFieldGet(this, _TonClient_api, "f").getTransactions(address, opts);
85
+ let tx = await this.api.getTransactions(address, opts);
99
86
  let res = [];
100
87
  for (let r of tx) {
101
88
  res.push((0, core_1.loadTransaction)(core_1.Cell.fromBoc(Buffer.from(r.data, 'base64'))[0].beginParse()));
@@ -110,7 +97,7 @@ class TonClient {
110
97
  * @returns transaction or null if not exist
111
98
  */
112
99
  async getTransaction(address, lt, hash) {
113
- let res = await __classPrivateFieldGet(this, _TonClient_api, "f").getTransaction(address, lt, hash);
100
+ let res = await this.api.getTransaction(address, lt, hash);
114
101
  if (res) {
115
102
  return (0, core_1.loadTransaction)(core_1.Cell.fromBoc(Buffer.from(res.data, 'base64'))[0].beginParse());
116
103
  }
@@ -118,12 +105,34 @@ class TonClient {
118
105
  return null;
119
106
  }
120
107
  }
108
+ /**
109
+ * Locate outcoming transaction of destination address by incoming message
110
+ * @param source message source address
111
+ * @param destination message destination address
112
+ * @param created_lt message's created lt
113
+ * @returns transaction
114
+ */
115
+ async tryLocateResultTx(source, destination, created_lt) {
116
+ let res = await this.api.tryLocateResultTx(source, destination, created_lt);
117
+ return (0, core_1.loadTransaction)(core_1.Cell.fromBase64(res.data).beginParse());
118
+ }
119
+ /**
120
+ * Locate incoming transaction of source address by outcoming message
121
+ * @param source message source address
122
+ * @param destination message destination address
123
+ * @param created_lt message's created lt
124
+ * @returns transaction
125
+ */
126
+ async tryLocateSourceTx(source, destination, created_lt) {
127
+ let res = await this.api.tryLocateSourceTx(source, destination, created_lt);
128
+ return (0, core_1.loadTransaction)(core_1.Cell.fromBase64(res.data).beginParse());
129
+ }
121
130
  /**
122
131
  * Fetch latest masterchain info
123
132
  * @returns masterchain info
124
133
  */
125
134
  async getMasterchainInfo() {
126
- let r = await __classPrivateFieldGet(this, _TonClient_api, "f").getMasterchainInfo();
135
+ let r = await this.api.getMasterchainInfo();
127
136
  return {
128
137
  workchain: r.init.workchain,
129
138
  shard: r.last.shard,
@@ -136,7 +145,7 @@ class TonClient {
136
145
  * @param seqno masterchain seqno
137
146
  */
138
147
  async getWorkchainShards(seqno) {
139
- let r = await __classPrivateFieldGet(this, _TonClient_api, "f").getShards(seqno);
148
+ let r = await this.api.getShards(seqno);
140
149
  return r.map((m) => ({
141
150
  workchain: m.workchain,
142
151
  shard: m.shard,
@@ -150,7 +159,7 @@ class TonClient {
150
159
  * @param shard
151
160
  */
152
161
  async getShardTransactions(workchain, seqno, shard) {
153
- let tx = await __classPrivateFieldGet(this, _TonClient_api, "f").getBlockTransactions(workchain, seqno, shard);
162
+ let tx = await this.api.getBlockTransactions(workchain, seqno, shard);
154
163
  if (tx.incomplete) {
155
164
  throw Error('Unsupported');
156
165
  }
@@ -169,14 +178,14 @@ class TonClient {
169
178
  .store((0, core_1.storeMessage)(src))
170
179
  .endCell()
171
180
  .toBoc();
172
- await __classPrivateFieldGet(this, _TonClient_api, "f").sendBoc(boc);
181
+ await this.api.sendBoc(boc);
173
182
  }
174
183
  /**
175
184
  * Send file to a network
176
185
  * @param src source file
177
186
  */
178
187
  async sendFile(src) {
179
- await __classPrivateFieldGet(this, _TonClient_api, "f").sendBoc(src);
188
+ await this.api.sendBoc(src);
180
189
  }
181
190
  /**
182
191
  * Estimate fees for external message
@@ -184,7 +193,7 @@ class TonClient {
184
193
  * @returns
185
194
  */
186
195
  async estimateExternalMessageFee(address, args) {
187
- return await __classPrivateFieldGet(this, _TonClient_api, "f").estimateFee(address, { body: args.body, initCode: args.initCode, initData: args.initData, ignoreSignature: args.ignoreSignature });
196
+ return await this.api.estimateFee(address, { body: args.body, initCode: args.initCode, initData: args.initData, ignoreSignature: args.ignoreSignature });
188
197
  }
189
198
  /**
190
199
  * Send external message to contract
@@ -221,7 +230,7 @@ class TonClient {
221
230
  * @param address contract address
222
231
  */
223
232
  async getContractState(address) {
224
- let info = await __classPrivateFieldGet(this, _TonClient_api, "f").getAddressInformation(address);
233
+ let info = await this.api.getAddressInformation(address);
225
234
  let balance = BigInt(info.balance);
226
235
  let state = info.state;
227
236
  return {
@@ -260,7 +269,6 @@ class TonClient {
260
269
  }
261
270
  }
262
271
  exports.TonClient = TonClient;
263
- _TonClient_api = new WeakMap();
264
272
  function parseStackEntry(s) {
265
273
  switch (s["@type"]) {
266
274
  case "tvm.stackEntryNumber":
@@ -34,4 +34,12 @@ describeConditional('TonClient', () => {
34
34
  let wcShards = await client.getWorkchainShards(info.latestSeqno);
35
35
  console.log(info, shardInfo, wcShards);
36
36
  });
37
+ it('should locate source/result tx', async () => {
38
+ let source = core_1.Address.parse('UQDDT0TOC4PMp894jtCo3-d1-8ltSjXMX2EuWww_pCNibsUH');
39
+ let createdLt = '37508996000002';
40
+ let infoSource = await client.tryLocateSourceTx(source, testAddress, createdLt);
41
+ console.log(infoSource);
42
+ let infoResult = await client.tryLocateResultTx(source, testAddress, createdLt);
43
+ console.log(infoResult);
44
+ });
37
45
  });
@@ -644,6 +644,120 @@ export declare class HttpApi {
644
644
  fwd_fee: number;
645
645
  };
646
646
  }>;
647
+ tryLocateResultTx(source: Address, destination: Address, created_lt: string): Promise<{
648
+ data: string;
649
+ storage_fee: string;
650
+ utime: number;
651
+ transaction_id: {
652
+ lt: string;
653
+ hash: string;
654
+ };
655
+ fee: string;
656
+ other_fee: string;
657
+ out_msgs: {
658
+ value: string;
659
+ message: string;
660
+ fwd_fee: string;
661
+ source: string;
662
+ destination: string;
663
+ ihr_fee: string;
664
+ created_lt: string;
665
+ body_hash: string;
666
+ msg_data: {
667
+ '@type': "msg.dataRaw";
668
+ body: string;
669
+ } | {
670
+ '@type': "msg.dataText";
671
+ text: string;
672
+ } | {
673
+ '@type': "msg.dataDecryptedText";
674
+ text: string;
675
+ } | {
676
+ '@type': "msg.dataEncryptedText";
677
+ text: string;
678
+ };
679
+ }[];
680
+ in_msg?: {
681
+ value: string;
682
+ message: string;
683
+ fwd_fee: string;
684
+ source: string;
685
+ destination: string;
686
+ ihr_fee: string;
687
+ created_lt: string;
688
+ body_hash: string;
689
+ msg_data: {
690
+ '@type': "msg.dataRaw";
691
+ body: string;
692
+ } | {
693
+ '@type': "msg.dataText";
694
+ text: string;
695
+ } | {
696
+ '@type': "msg.dataDecryptedText";
697
+ text: string;
698
+ } | {
699
+ '@type': "msg.dataEncryptedText";
700
+ text: string;
701
+ };
702
+ } | undefined;
703
+ }>;
704
+ tryLocateSourceTx(source: Address, destination: Address, created_lt: string): Promise<{
705
+ data: string;
706
+ storage_fee: string;
707
+ utime: number;
708
+ transaction_id: {
709
+ lt: string;
710
+ hash: string;
711
+ };
712
+ fee: string;
713
+ other_fee: string;
714
+ out_msgs: {
715
+ value: string;
716
+ message: string;
717
+ fwd_fee: string;
718
+ source: string;
719
+ destination: string;
720
+ ihr_fee: string;
721
+ created_lt: string;
722
+ body_hash: string;
723
+ msg_data: {
724
+ '@type': "msg.dataRaw";
725
+ body: string;
726
+ } | {
727
+ '@type': "msg.dataText";
728
+ text: string;
729
+ } | {
730
+ '@type': "msg.dataDecryptedText";
731
+ text: string;
732
+ } | {
733
+ '@type': "msg.dataEncryptedText";
734
+ text: string;
735
+ };
736
+ }[];
737
+ in_msg?: {
738
+ value: string;
739
+ message: string;
740
+ fwd_fee: string;
741
+ source: string;
742
+ destination: string;
743
+ ihr_fee: string;
744
+ created_lt: string;
745
+ body_hash: string;
746
+ msg_data: {
747
+ '@type': "msg.dataRaw";
748
+ body: string;
749
+ } | {
750
+ '@type': "msg.dataText";
751
+ text: string;
752
+ } | {
753
+ '@type': "msg.dataDecryptedText";
754
+ text: string;
755
+ } | {
756
+ '@type': "msg.dataEncryptedText";
757
+ text: string;
758
+ };
759
+ } | undefined;
760
+ }>;
647
761
  private doCall;
648
762
  }
649
763
  export {};
@@ -246,6 +246,12 @@ class HttpApi {
246
246
  ignore_chksig: args.ignoreSignature
247
247
  }, feeResponse);
248
248
  }
249
+ async tryLocateResultTx(source, destination, created_lt) {
250
+ return await this.doCall('tryLocateResultTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
251
+ }
252
+ async tryLocateSourceTx(source, destination, created_lt) {
253
+ return await this.doCall('tryLocateSourceTx', { source: source.toString(), destination: destination.toString(), created_lt }, transaction);
254
+ }
249
255
  async doCall(method, body, codec) {
250
256
  let headers = {
251
257
  'Content-Type': 'application/json',
@@ -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, OutAction, Builder } from "@ton/core";
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.createWalletTransferV5 = exports.createWalletTransferV4 = exports.createWalletTransferV3 = exports.createWalletTransferV2 = exports.createWalletTransferV1 = void 0;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton/ton",
3
- "version": "13.8.0",
3
+ "version": "13.10.0",
4
4
  "repository": "https://github.com/ton-org/ton.git",
5
5
  "author": "Whales Corp. <developers@whalescorp.com>",
6
6
  "license": "MIT",
@@ -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,8 +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
- export {};
@@ -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
- });