@solana/transactions 2.0.0-experimental.ffeddf6 → 2.0.0-preview.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 (69) hide show
  1. package/README.md +8 -46
  2. package/dist/index.browser.cjs +360 -470
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +355 -470
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.native.js +353 -470
  7. package/dist/index.native.js.map +1 -1
  8. package/dist/index.node.cjs +360 -470
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.js +353 -470
  11. package/dist/index.node.js.map +1 -1
  12. package/dist/types/accounts.d.ts +3 -3
  13. package/dist/types/accounts.d.ts.map +1 -0
  14. package/dist/types/blockhash.d.ts +7 -9
  15. package/dist/types/blockhash.d.ts.map +1 -0
  16. package/dist/types/compilable-transaction.d.ts +6 -5
  17. package/dist/types/compilable-transaction.d.ts.map +1 -0
  18. package/dist/types/compile-address-table-lookups.d.ts +3 -3
  19. package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
  20. package/dist/types/compile-header.d.ts +1 -1
  21. package/dist/types/compile-header.d.ts.map +1 -0
  22. package/dist/types/compile-instructions.d.ts +1 -1
  23. package/dist/types/compile-instructions.d.ts.map +1 -0
  24. package/dist/types/compile-lifetime-token.d.ts +2 -2
  25. package/dist/types/compile-lifetime-token.d.ts.map +1 -0
  26. package/dist/types/compile-static-accounts.d.ts +3 -3
  27. package/dist/types/compile-static-accounts.d.ts.map +1 -0
  28. package/dist/types/compile-transaction.d.ts +5 -5
  29. package/dist/types/compile-transaction.d.ts.map +1 -0
  30. package/dist/types/create-transaction.d.ts +1 -1
  31. package/dist/types/create-transaction.d.ts.map +1 -0
  32. package/dist/types/decompile-transaction.d.ts +12 -4
  33. package/dist/types/decompile-transaction.d.ts.map +1 -0
  34. package/dist/types/durable-nonce.d.ts +6 -6
  35. package/dist/types/durable-nonce.d.ts.map +1 -0
  36. package/dist/types/fee-payer.d.ts +6 -6
  37. package/dist/types/fee-payer.d.ts.map +1 -0
  38. package/dist/types/index.d.ts +13 -10
  39. package/dist/types/index.d.ts.map +1 -0
  40. package/dist/types/instructions.d.ts +6 -4
  41. package/dist/types/instructions.d.ts.map +1 -0
  42. package/dist/types/message.d.ts +6 -6
  43. package/dist/types/message.d.ts.map +1 -0
  44. package/dist/types/serializers/address-table-lookup.d.ts +5 -5
  45. package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
  46. package/dist/types/serializers/header.d.ts +5 -5
  47. package/dist/types/serializers/header.d.ts.map +1 -0
  48. package/dist/types/serializers/index.d.ts +2 -1
  49. package/dist/types/serializers/index.d.ts.map +1 -0
  50. package/dist/types/serializers/instruction.d.ts +5 -5
  51. package/dist/types/serializers/instruction.d.ts.map +1 -0
  52. package/dist/types/serializers/message.d.ts +5 -5
  53. package/dist/types/serializers/message.d.ts.map +1 -0
  54. package/dist/types/serializers/transaction-version.d.ts +5 -5
  55. package/dist/types/serializers/transaction-version.d.ts.map +1 -0
  56. package/dist/types/serializers/transaction.d.ts +9 -6
  57. package/dist/types/serializers/transaction.d.ts.map +1 -0
  58. package/dist/types/signatures.d.ts +9 -14
  59. package/dist/types/signatures.d.ts.map +1 -0
  60. package/dist/types/types.d.ts +6 -13
  61. package/dist/types/types.d.ts.map +1 -0
  62. package/dist/types/unsigned-transaction.d.ts +2 -2
  63. package/dist/types/unsigned-transaction.d.ts.map +1 -0
  64. package/dist/types/wire-transaction.d.ts +1 -1
  65. package/dist/types/wire-transaction.d.ts.map +1 -0
  66. package/package.json +18 -39
  67. package/dist/index.development.js +0 -1778
  68. package/dist/index.development.js.map +0 -1
  69. package/dist/index.production.min.js +0 -29
package/README.md CHANGED
@@ -30,7 +30,7 @@ const transferTransaction = pipe(
30
30
  createTransaction({ version: 0 }),
31
31
  tx => setTransactionFeePayer(myAddress, tx),
32
32
  tx => setTransactionLifetimeUsingBlockhash(latestBlockhash, tx),
33
- tx => appendTransactionInstruction(createTransferInstruction(myAddress, toAddress, amountInLamports), tx)
33
+ tx => appendTransactionInstruction(createTransferInstruction(myAddress, toAddress, amountInLamports), tx),
34
34
  );
35
35
  ```
36
36
 
@@ -144,7 +144,7 @@ const nonce =
144
144
 
145
145
  const durableNonceTransaction = setTransactionLifetimeUsingDurableNonce(
146
146
  { nonce, nonceAccountAddress, nonceAuthorityAddress },
147
- tx
147
+ tx,
148
148
  );
149
149
  ```
150
150
 
@@ -210,14 +210,18 @@ const memoTransaction = appendTransactionInstruction(
210
210
  data: new TextEncoder().encode('Hello world!'),
211
211
  programAddress: address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
212
212
  },
213
- tx
213
+ tx,
214
214
  );
215
215
  ```
216
216
 
217
+ If you'd like to add multiple instructions to a transaction at once, you may use the `appendTransactionInstructions` function instead which accepts an array of instructions.
218
+
217
219
  #### `prependTransactionInstruction()`
218
220
 
219
221
  Given an instruction, this method will return a new transaction with that instruction having been added to the beginning of the list of existing instructions.
220
222
 
223
+ If you'd like to prepend multiple instructions to a transaction at once, you may use the `prependTransactionInstructions` function instead which accepts an array of instructions.
224
+
221
225
  See [`appendTransactionInstruction()`](#appendtransactioninstruction) for an example of how to use this function.
222
226
 
223
227
  ## Signing transactions
@@ -244,21 +248,11 @@ This type represents a transaction that is signed by all of its required signers
244
248
 
245
249
  Expect any function that modifies a transaction (eg. `setTransactionFeePayer`, `appendTransactionInstruction`, et cetera) to delete a transaction's `signatures` property and unset this type.
246
250
 
247
- #### `TransactionSignature`
248
-
249
- This type represents the base58-encoded signature of a transactions fee payer. This value uniquely identifies the transaction on the network.
250
-
251
251
  ### Functions
252
252
 
253
- #### `assertIsTransactionSignature()`
254
-
255
- From time to time you might acquire a string that you expect to be the base58-encoded signature of a transaction, from an untrusted network API or user input. To assert that such an arbitrary string is in fact a transaction signature, use the `assertIsTransactionSignature` function.
256
-
257
- See [`assertIsBlockhash()`](#assertisblockhash) for an example of how to use an assertion function.
258
-
259
253
  #### `getSignatureFromTransaction()`
260
254
 
261
- Given a transaction signed by its fee payer, this method will return the `TransactionSignature` that uniquely identifies it. This string can be used to look up transactions at a later date, for example on a Solana block explorer.
255
+ Given a transaction signed by its fee payer, this method will return the `Signature` that uniquely identifies it. This string can be used to look up transactions at a later date, for example on a Solana block explorer.
262
256
 
263
257
  ```ts
264
258
  import { getSignatureFromTransaction } from '@solana/transactions';
@@ -267,25 +261,6 @@ const signature = getSignatureFromTransaction(tx);
267
261
  console.debug(`Inspect this transaction at https://explorer.solana.com/tx/${signature}`);
268
262
  ```
269
263
 
270
- #### `isTransactionSignature()`
271
-
272
- This is a type guard that accepts a string as input. It will both return `true` if the string conforms to the `TransactionSignature` type and will refine the type for use in your program.
273
-
274
- ```ts
275
- import { isTransactionSignature } from '@solana/transactions';
276
-
277
- if (isTransactionSignature(signature)) {
278
- // At this point, `signature` has been refined to a
279
- // `TransactionSignature` that can be used with the RPC.
280
- const {
281
- value: [status],
282
- } = await rpc.getSignatureStatuses([signature]).send();
283
- setSignatureStatus(status);
284
- } else {
285
- setError(`${signature} is not a transaction signature`);
286
- }
287
- ```
288
-
289
264
  #### `signTransaction()`
290
265
 
291
266
  Given an array of `CryptoKey` objects which are private keys pertaining to addresses that are required to sign a transaction, this method will return a new signed transaction having the same type as the one supplied plus the `ITransactionWithSignatures` type.
@@ -297,19 +272,6 @@ import { signTransaction } from '@solana/transactions';
297
272
  const signedTransaction = await signTransaction([myPrivateKey], tx);
298
273
  ```
299
274
 
300
- #### `transactionSignature()`
301
-
302
- This helper combines _asserting_ that a string is a transaction signature with _coercing_ it to the `TransactionSignature` type. It's best used with untrusted input.
303
-
304
- ```ts
305
- import { transactionSignature } from '@solana/transactions';
306
-
307
- const signature = transactionSignature(userSuppliedSignature);
308
- const {
309
- value: [status],
310
- } = await rpc.getSignatureStatuses([signature]).send();
311
- ```
312
-
313
275
  ## Serializing transactions
314
276
 
315
277
  Before sending a transaction to be landed on the network, you must serialize it in a particular way. You can use these types and functions to serialize a signed transaction into a binary format suitable for transit over the wire.