@ledgerhq/coin-ton 0.9.1-nightly.1 → 0.10.0-nightly.2

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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/jest.config.js +1 -0
  4. package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
  5. package/lib/__tests__/fixtures/common.fixtures.js +1 -2
  6. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -1
  7. package/lib/transaction.d.ts +1 -0
  8. package/lib/transaction.d.ts.map +1 -1
  9. package/lib/transaction.js +240 -2
  10. package/lib/transaction.js.map +1 -1
  11. package/lib/transaction.unit.test.d.ts +2 -0
  12. package/lib/transaction.unit.test.d.ts.map +1 -0
  13. package/lib/transaction.unit.test.js +600 -0
  14. package/lib/transaction.unit.test.js.map +1 -0
  15. package/lib/types.d.ts +92 -2
  16. package/lib/types.d.ts.map +1 -1
  17. package/lib/utils.d.ts.map +1 -1
  18. package/lib/utils.js +2 -1
  19. package/lib/utils.js.map +1 -1
  20. package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -1
  21. package/lib-es/__tests__/fixtures/common.fixtures.js +1 -2
  22. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -1
  23. package/lib-es/transaction.d.ts +1 -0
  24. package/lib-es/transaction.d.ts.map +1 -1
  25. package/lib-es/transaction.js +238 -1
  26. package/lib-es/transaction.js.map +1 -1
  27. package/lib-es/transaction.unit.test.d.ts +2 -0
  28. package/lib-es/transaction.unit.test.d.ts.map +1 -0
  29. package/lib-es/transaction.unit.test.js +595 -0
  30. package/lib-es/transaction.unit.test.js.map +1 -0
  31. package/lib-es/types.d.ts +92 -2
  32. package/lib-es/types.d.ts.map +1 -1
  33. package/lib-es/utils.d.ts.map +1 -1
  34. package/lib-es/utils.js +2 -1
  35. package/lib-es/utils.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/__tests__/fixtures/common.fixtures.ts +5 -6
  38. package/src/transaction.ts +262 -2
  39. package/src/transaction.unit.test.ts +614 -0
  40. package/src/types.ts +119 -2
  41. package/src/utils.ts +9 -1
package/src/types.ts CHANGED
@@ -7,8 +7,7 @@ import {
7
7
  TransactionStatusCommon,
8
8
  TransactionStatusCommonRaw,
9
9
  } from "@ledgerhq/types-live";
10
- import { Address, SendMode, StateInit } from "@ton/core";
11
- import { Cell } from "@ton/ton";
10
+ import { Address, SendMode, StateInit, Cell } from "@ton/core";
12
11
  import BigNumber from "bignumber.js";
13
12
 
14
13
  type FamilyType = "ton";
@@ -24,11 +23,13 @@ export type Transaction = TransactionCommon & {
24
23
  family: FamilyType;
25
24
  fees: BigNumber;
26
25
  comment: TonComment;
26
+ payload?: TonPayloadFormat;
27
27
  };
28
28
  export type TransactionRaw = TransactionCommonRaw & {
29
29
  family: FamilyType;
30
30
  fees: string;
31
31
  comment: TonComment;
32
+ payload?: TonPayloadFormatRaw;
32
33
  };
33
34
 
34
35
  export type TransactionStatus = TransactionStatusCommon;
@@ -51,6 +52,21 @@ export type TonPayloadJettonTransfer = {
51
52
  } | null;
52
53
  };
53
54
 
55
+ export type TonPayloadJettonTransferRaw = {
56
+ type: "jetton-transfer";
57
+ queryId: string | null;
58
+ amount: string;
59
+ destination: string;
60
+ responseDestination: string;
61
+ customPayload: string | null;
62
+ forwardAmount: string;
63
+ forwardPayload: string | null;
64
+ knownJetton: {
65
+ jettonId: number;
66
+ workchain: number;
67
+ } | null;
68
+ };
69
+
54
70
  export type TonPayloadNftTransfer = {
55
71
  type: "nft-transfer";
56
72
  queryId: bigint | null;
@@ -61,16 +77,36 @@ export type TonPayloadNftTransfer = {
61
77
  forwardPayload: TonCell | null;
62
78
  };
63
79
 
80
+ export type TonPayloadNftTransferRaw = {
81
+ type: "nft-transfer";
82
+ queryId: string | null;
83
+ newOwner: string;
84
+ responseDestination: string;
85
+ customPayload: string | null;
86
+ forwardAmount: string;
87
+ forwardPayload: string | null;
88
+ };
89
+
64
90
  export type TonPayloadComment = {
65
91
  type: "comment";
66
92
  text: string;
67
93
  };
68
94
 
95
+ export type TonPayloadCommentRaw = {
96
+ type: "comment";
97
+ text: string;
98
+ };
99
+
69
100
  export type TonPayloadUnsafe = {
70
101
  type: "unsafe";
71
102
  message: TonCell;
72
103
  };
73
104
 
105
+ export type TonPayloadUnsafeRaw = {
106
+ type: "unsafe";
107
+ message: string;
108
+ };
109
+
74
110
  export type TonPayloadJettonBurn = {
75
111
  type: "jetton-burn";
76
112
  queryId: bigint | null;
@@ -79,30 +115,62 @@ export type TonPayloadJettonBurn = {
79
115
  customPayload: TonCell | Buffer | null;
80
116
  };
81
117
 
118
+ export type TonPayloadJettonBurnRaw = {
119
+ type: "jetton-burn";
120
+ queryId: string | null;
121
+ amount: string;
122
+ responseDestination: string;
123
+ customPayload: string | null;
124
+ };
125
+
82
126
  export type TonPayloadAddWhitelist = {
83
127
  type: "add-whitelist";
84
128
  queryId: bigint | null;
85
129
  address: Address;
86
130
  };
87
131
 
132
+ export type TonPayloadAddWhitelistRaw = {
133
+ type: "add-whitelist";
134
+ queryId: string | null;
135
+ address: string;
136
+ };
137
+
88
138
  export type TonPayloadSingleNominatorWithdraw = {
89
139
  type: "single-nominator-withdraw";
90
140
  queryId: bigint | null;
91
141
  amount: bigint;
92
142
  };
93
143
 
144
+ export type TonPayloadSingleNominatorWithdrawRaw = {
145
+ type: "single-nominator-withdraw";
146
+ queryId: string | null;
147
+ amount: string;
148
+ };
149
+
94
150
  export type TonPayloadSingleNominatorChangeValidator = {
95
151
  type: "single-nominator-change-validator";
96
152
  queryId: bigint | null;
97
153
  address: Address;
98
154
  };
99
155
 
156
+ export type TonPayloadSingleNominatorChangeValidatorRaw = {
157
+ type: "single-nominator-change-validator";
158
+ queryId: string | null;
159
+ address: string;
160
+ };
161
+
100
162
  export type TonPayloadTonStakersDeposit = {
101
163
  type: "tonstakers-deposit";
102
164
  queryId: bigint | null;
103
165
  appId: bigint | null;
104
166
  };
105
167
 
168
+ export type TonPayloadTonStakersDepositRaw = {
169
+ type: "tonstakers-deposit";
170
+ queryId: string | null;
171
+ appId: string | null;
172
+ };
173
+
106
174
  export type TonPayloadVoteForProposal = {
107
175
  type: "vote-for-proposal";
108
176
  queryId: bigint | null;
@@ -112,6 +180,15 @@ export type TonPayloadVoteForProposal = {
112
180
  needConfirmation: boolean;
113
181
  };
114
182
 
183
+ export type TonPayloadVoteForProposalRaw = {
184
+ type: "vote-for-proposal";
185
+ queryId: string | null;
186
+ votingAddress: string;
187
+ expirationDate: number;
188
+ vote: boolean;
189
+ needConfirmation: boolean;
190
+ };
191
+
115
192
  export type TonPayloadChangeDnsRecord = {
116
193
  type: "change-dns-record";
117
194
  queryId: bigint | null;
@@ -132,12 +209,38 @@ export type TonPayloadChangeDnsRecord = {
132
209
  };
133
210
  };
134
211
 
212
+ export type TonPayloadChangeDnsRecordRaw = {
213
+ type: "change-dns-record";
214
+ queryId: string | null;
215
+ record:
216
+ | {
217
+ type: "wallet";
218
+ value: {
219
+ address: string;
220
+ capabilities: {
221
+ isWallet: boolean;
222
+ } | null;
223
+ } | null;
224
+ }
225
+ | {
226
+ type: "unknown";
227
+ key: string;
228
+ value: string | null;
229
+ };
230
+ };
231
+
135
232
  export type TonPayloadTokenBridgePaySwap = {
136
233
  type: "token-bridge-pay-swap";
137
234
  queryId: bigint | null;
138
235
  swapId: Buffer;
139
236
  };
140
237
 
238
+ export type TonPayloadTokenBridgePaySwapRaw = {
239
+ type: "token-bridge-pay-swap";
240
+ queryId: string | null;
241
+ swapId: string;
242
+ };
243
+
141
244
  export type TonPayloadFormat =
142
245
  | TonPayloadComment
143
246
  | TonPayloadJettonTransfer
@@ -152,6 +255,20 @@ export type TonPayloadFormat =
152
255
  | TonPayloadChangeDnsRecord
153
256
  | TonPayloadTokenBridgePaySwap;
154
257
 
258
+ export type TonPayloadFormatRaw =
259
+ | TonPayloadCommentRaw
260
+ | TonPayloadJettonTransferRaw
261
+ | TonPayloadNftTransferRaw
262
+ | TonPayloadUnsafeRaw
263
+ | TonPayloadJettonBurnRaw
264
+ | TonPayloadAddWhitelistRaw
265
+ | TonPayloadSingleNominatorWithdrawRaw
266
+ | TonPayloadSingleNominatorChangeValidatorRaw
267
+ | TonPayloadTonStakersDepositRaw
268
+ | TonPayloadVoteForProposalRaw
269
+ | TonPayloadChangeDnsRecordRaw
270
+ | TonPayloadTokenBridgePaySwapRaw;
271
+
155
272
  export interface TonTransaction {
156
273
  to: Address;
157
274
  sendMode: SendMode;
package/src/utils.ts CHANGED
@@ -84,7 +84,14 @@ export function buildTonTransaction(
84
84
  seqno: number,
85
85
  account: TonAccount,
86
86
  ): TonTransaction {
87
- const { subAccountId, useAllAmount, amount, comment: commentTx, recipient } = transaction;
87
+ const {
88
+ subAccountId,
89
+ useAllAmount,
90
+ amount,
91
+ comment: commentTx,
92
+ recipient,
93
+ payload,
94
+ } = transaction;
88
95
  let recipientParsed = recipient;
89
96
  // if recipient is not valid calculate fees with empty address
90
97
  // we handle invalid addresses in account bridge
@@ -118,6 +125,7 @@ export function buildTonTransaction(
118
125
  useAllAmount && !subAccount
119
126
  ? SendMode.CARRY_ALL_REMAINING_BALANCE
120
127
  : SendMode.IGNORE_ERRORS + SendMode.PAY_GAS_SEPARATELY,
128
+ payload,
121
129
  };
122
130
 
123
131
  if (commentTx.text.length) {