@ledgerhq/coin-solana 0.28.0 → 0.29.0-nightly.1

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 (101) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/lib/__tests__/fixtures/helpers.fixture.d.ts +36 -1
  4. package/lib/__tests__/fixtures/helpers.fixture.d.ts.map +1 -1
  5. package/lib/__tests__/fixtures/helpers.fixture.js +2 -1
  6. package/lib/__tests__/fixtures/helpers.fixture.js.map +1 -1
  7. package/lib/__tests__/scan-accounts.test.js +5 -1
  8. package/lib/__tests__/scan-accounts.test.js.map +1 -1
  9. package/lib/bridge.integration.test.js +1 -0
  10. package/lib/bridge.integration.test.js.map +1 -1
  11. package/lib/buildTransaction.d.ts.map +1 -1
  12. package/lib/buildTransaction.js +5 -0
  13. package/lib/buildTransaction.js.map +1 -1
  14. package/lib/getTransactionStatus.d.ts.map +1 -1
  15. package/lib/getTransactionStatus.js +2 -0
  16. package/lib/getTransactionStatus.js.map +1 -1
  17. package/lib/network/chain/account/token.d.ts +9 -0
  18. package/lib/network/chain/account/token.d.ts.map +1 -1
  19. package/lib/network/chain/account/tokenExtensions.d.ts +6 -0
  20. package/lib/network/chain/account/tokenExtensions.d.ts.map +1 -1
  21. package/lib/network/chain/account/tokenExtensions.js +1 -0
  22. package/lib/network/chain/account/tokenExtensions.js.map +1 -1
  23. package/lib/prepareTransaction.d.ts.map +1 -1
  24. package/lib/prepareTransaction.js +4 -61
  25. package/lib/prepareTransaction.js.map +1 -1
  26. package/lib/prepareTransaction.test.js +37 -52
  27. package/lib/prepareTransaction.test.js.map +1 -1
  28. package/lib/rawTransaction.d.ts +5 -0
  29. package/lib/rawTransaction.d.ts.map +1 -0
  30. package/lib/rawTransaction.js +52 -0
  31. package/lib/rawTransaction.js.map +1 -0
  32. package/lib/signOperation.d.ts.map +1 -1
  33. package/lib/signOperation.js +16 -0
  34. package/lib/signOperation.js.map +1 -1
  35. package/lib/specs.d.ts.map +1 -1
  36. package/lib/specs.js +1 -0
  37. package/lib/specs.js.map +1 -1
  38. package/lib/transaction.d.ts.map +1 -1
  39. package/lib/transaction.js +14 -20
  40. package/lib/transaction.js.map +1 -1
  41. package/lib/tx-fees.js +1 -0
  42. package/lib/tx-fees.js.map +1 -1
  43. package/lib/types.d.ts +10 -2
  44. package/lib/types.d.ts.map +1 -1
  45. package/lib-es/__tests__/fixtures/helpers.fixture.d.ts +36 -1
  46. package/lib-es/__tests__/fixtures/helpers.fixture.d.ts.map +1 -1
  47. package/lib-es/__tests__/fixtures/helpers.fixture.js +2 -1
  48. package/lib-es/__tests__/fixtures/helpers.fixture.js.map +1 -1
  49. package/lib-es/__tests__/scan-accounts.test.js +5 -1
  50. package/lib-es/__tests__/scan-accounts.test.js.map +1 -1
  51. package/lib-es/bridge.integration.test.js +1 -0
  52. package/lib-es/bridge.integration.test.js.map +1 -1
  53. package/lib-es/buildTransaction.d.ts.map +1 -1
  54. package/lib-es/buildTransaction.js +5 -0
  55. package/lib-es/buildTransaction.js.map +1 -1
  56. package/lib-es/getTransactionStatus.d.ts.map +1 -1
  57. package/lib-es/getTransactionStatus.js +2 -0
  58. package/lib-es/getTransactionStatus.js.map +1 -1
  59. package/lib-es/network/chain/account/token.d.ts +9 -0
  60. package/lib-es/network/chain/account/token.d.ts.map +1 -1
  61. package/lib-es/network/chain/account/tokenExtensions.d.ts +6 -0
  62. package/lib-es/network/chain/account/tokenExtensions.d.ts.map +1 -1
  63. package/lib-es/network/chain/account/tokenExtensions.js +1 -0
  64. package/lib-es/network/chain/account/tokenExtensions.js.map +1 -1
  65. package/lib-es/prepareTransaction.d.ts.map +1 -1
  66. package/lib-es/prepareTransaction.js +3 -60
  67. package/lib-es/prepareTransaction.js.map +1 -1
  68. package/lib-es/prepareTransaction.test.js +37 -52
  69. package/lib-es/prepareTransaction.test.js.map +1 -1
  70. package/lib-es/rawTransaction.d.ts +5 -0
  71. package/lib-es/rawTransaction.d.ts.map +1 -0
  72. package/lib-es/rawTransaction.js +44 -0
  73. package/lib-es/rawTransaction.js.map +1 -0
  74. package/lib-es/signOperation.d.ts.map +1 -1
  75. package/lib-es/signOperation.js +16 -0
  76. package/lib-es/signOperation.js.map +1 -1
  77. package/lib-es/specs.d.ts.map +1 -1
  78. package/lib-es/specs.js +1 -0
  79. package/lib-es/specs.js.map +1 -1
  80. package/lib-es/transaction.d.ts.map +1 -1
  81. package/lib-es/transaction.js +14 -20
  82. package/lib-es/transaction.js.map +1 -1
  83. package/lib-es/tx-fees.js +1 -0
  84. package/lib-es/tx-fees.js.map +1 -1
  85. package/lib-es/types.d.ts +10 -2
  86. package/lib-es/types.d.ts.map +1 -1
  87. package/package.json +7 -7
  88. package/src/__tests__/fixtures/helpers.fixture.ts +4 -0
  89. package/src/__tests__/scan-accounts.test.ts +5 -1
  90. package/src/bridge.integration.test.ts +1 -0
  91. package/src/buildTransaction.ts +5 -0
  92. package/src/getTransactionStatus.ts +2 -0
  93. package/src/network/chain/account/tokenExtensions.ts +1 -0
  94. package/src/prepareTransaction.test.ts +31 -71
  95. package/src/prepareTransaction.ts +3 -100
  96. package/src/rawTransaction.ts +59 -0
  97. package/src/signOperation.ts +24 -0
  98. package/src/specs.ts +1 -0
  99. package/src/transaction.ts +17 -20
  100. package/src/tx-fees.ts +1 -0
  101. package/src/types.ts +13 -1
@@ -88,6 +88,8 @@ function formatCommand(mainAccount: Account, tx: Transaction, command: Command)
88
88
  return formatStakeWithdraw(mainAccount, tx, command);
89
89
  case "stake.split":
90
90
  return formatStakeSplit(mainAccount, tx, command);
91
+ case "raw":
92
+ return formatRaw(tx);
91
93
  default:
92
94
  return assertUnreachable(command);
93
95
  }
@@ -105,9 +107,7 @@ function formatStakeCreateAccount(
105
107
  ` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
106
108
  ` SEED: ${command.seed}`,
107
109
  ` VALIDATOR: ${command.delegate.voteAccAddress}`,
108
- ]
109
- .filter(Boolean)
110
- .join("\n");
110
+ ].join("\n");
111
111
 
112
112
  return "\n" + str;
113
113
  }
@@ -157,7 +157,7 @@ function formatCreateATA(mainAccount: Account, command: TokenCreateATACommand) {
157
157
  if (!token) {
158
158
  throw new Error(`token for mint "${command.mint}" not found`);
159
159
  }
160
- const str = [` OPT IN TOKEN: ${token.ticker}`].filter(Boolean).join("\n");
160
+ const str = [` OPT IN TOKEN: ${token.ticker}`].join("\n");
161
161
  return "\n" + str;
162
162
  }
163
163
 
@@ -186,9 +186,7 @@ function formatCreateApprove(
186
186
  ` APPROVE: ${command.account}`,
187
187
  ` DELEGATE: ${command.recipientDescriptor.walletAddress}`,
188
188
  ` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
189
- ]
190
- .filter(Boolean)
191
- .join("\n");
189
+ ].join("\n");
192
190
  return "\n" + str;
193
191
  }
194
192
 
@@ -205,21 +203,17 @@ function formatCreateRevoke(
205
203
  throw new Error("token subaccount expected");
206
204
  }
207
205
 
208
- const str = [` OWNER: ${command.owner}`, ` REVOKE: ${command.account}`]
209
- .filter(Boolean)
210
- .join("\n");
206
+ const str = [` OWNER: ${command.owner}`, ` REVOKE: ${command.account}`].join("\n");
211
207
  return "\n" + str;
212
208
  }
213
209
 
214
210
  function formatStakeDelegate(command: StakeDelegateCommand) {
215
- const str = [` DELEGATE: ${command.stakeAccAddr}`, ` TO: ${command.voteAccAddr}`]
216
- .filter(Boolean)
217
- .join("\n");
211
+ const str = [` DELEGATE: ${command.stakeAccAddr}`, ` TO: ${command.voteAccAddr}`].join("\n");
218
212
  return "\n" + str;
219
213
  }
220
214
 
221
215
  function formatStakeUndelegate(command: StakeUndelegateCommand) {
222
- const str = [` UNDELEGATE: ${command.stakeAccAddr}`].filter(Boolean).join("\n");
216
+ const str = [` UNDELEGATE: ${command.stakeAccAddr}`].join("\n");
223
217
  return "\n" + str;
224
218
  }
225
219
 
@@ -229,9 +223,7 @@ function formatStakeWithdraw(mainAccount: Account, tx: Transaction, command: Sta
229
223
  ` WITHDRAW FROM: ${command.stakeAccAddr}`,
230
224
  ` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
231
225
  ` TO: ${command.toAccAddr}`,
232
- ]
233
- .filter(Boolean)
234
- .join("\n");
226
+ ].join("\n");
235
227
  return "\n" + str;
236
228
  }
237
229
 
@@ -241,9 +233,14 @@ function formatStakeSplit(mainAccount: Account, tx: Transaction, command: StakeS
241
233
  ` SPLIT: ${command.stakeAccAddr}`,
242
234
  ` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
243
235
  ` TO: ${command.splitStakeAccAddr}`,
244
- ]
245
- .filter(Boolean)
246
- .join("\n");
236
+ ].join("\n");
237
+ return "\n" + str;
238
+ }
239
+
240
+ function formatRaw(tx: Transaction) {
241
+ const str = [` SEND RAW: ${tx.useAllAmount ? " (ALL)" : ""}`, ` TO: ${tx.recipient}`].join(
242
+ "\n",
243
+ );
247
244
  return "\n" + str;
248
245
  }
249
246
 
package/src/tx-fees.ts CHANGED
@@ -58,6 +58,7 @@ const createDummyTx = (address: string, kind: TransactionModel["kind"]) => {
58
58
  return createDummyTokenRevokeTx(address);
59
59
  case "stake.split":
60
60
  case "token.createATA":
61
+ case "raw":
61
62
  throw new Error(`not implemented for <${kind}>`);
62
63
  default:
63
64
  return assertUnreachable(kind);
package/src/types.ts CHANGED
@@ -121,6 +121,11 @@ export type TokenTransferCommand = {
121
121
  };
122
122
  };
123
123
 
124
+ export type RawCommand = {
125
+ kind: "raw";
126
+ raw: string;
127
+ };
128
+
124
129
  export type Command =
125
130
  | TransferCommand
126
131
  | TokenTransferCommand
@@ -131,7 +136,8 @@ export type Command =
131
136
  | StakeDelegateCommand
132
137
  | StakeUndelegateCommand
133
138
  | StakeWithdrawCommand
134
- | StakeSplitCommand;
139
+ | StakeSplitCommand
140
+ | RawCommand;
135
141
 
136
142
  export type CommandDescriptor = {
137
143
  command: Command;
@@ -214,6 +220,11 @@ export type StakeSplitTransaction = {
214
220
  };
215
221
  };
216
222
 
223
+ export type RawTransaction = {
224
+ kind: "raw";
225
+ uiState: object;
226
+ };
227
+
217
228
  export type TransactionModel = { commandDescriptor?: CommandDescriptor } & (
218
229
  | TransferTransaction
219
230
  | TokenTransferTransaction
@@ -225,6 +236,7 @@ export type TransactionModel = { commandDescriptor?: CommandDescriptor } & (
225
236
  | StakeUndelegateTransaction
226
237
  | StakeWithdrawTransaction
227
238
  | StakeSplitTransaction
239
+ | RawTransaction
228
240
  );
229
241
 
230
242
  export type Transaction = TransactionCommon & {