@solana/transaction-messages 3.0.0-canary-20250826072555 → 3.0.0-canary-20250826100240

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/README.md CHANGED
@@ -119,30 +119,20 @@ const txMessageWithBlockhashLifetime = setTransactionMessageLifetimeUsingBlockha
119
119
  Given a nonce, the account where the value of the nonce is stored, and the address of the account authorized to consume that nonce, this method will return a new transaction having the same type as the one supplied plus the `TransactionMessageWithDurableNonceLifetime` type. In particular, this method _prepends_ an instruction to the transaction message designed to consume (or ‘advance’) the nonce in the same transaction whose lifetime is defined by it.
120
120
 
121
121
  ```ts
122
- import { setTransactionMessageLifetimeUsingDurableNonce } from '@solana/transactions';
123
-
124
- const NONCE_VALUE_OFFSET =
125
- 4 + // version(u32)
126
- 4 + // state(u32)
127
- 32; // nonce authority(pubkey)
128
- // Then comes the nonce value.
122
+ import { Nonce, setTransactionMessageLifetimeUsingDurableNonce } from '@solana/transaction-messages';
123
+ import { fetchNonce } from '@solana-program/system';
129
124
 
130
125
  const nonceAccountAddress = address('EGtMh4yvXswwHhwVhyPxGrVV2TkLTgUqGodbATEPvojZ');
131
126
  const nonceAuthorityAddress = address('4KD1Rdrd89NG7XbzW3xsX9Aqnx2EExJvExiNme6g9iAT');
132
- const { value: nonceAccount } = await rpc
133
- .getAccountInfo(nonceAccountAddress, {
134
- dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
135
- encoding: 'base58',
136
- })
137
- .send();
138
- const nonce =
139
- // This works because we asked for the exact slice of data representing the nonce
140
- // value, and furthermore asked for it in `base58` encoding.
141
- nonceAccount!.data[0] as unknown as Nonce;
127
+
128
+ const {
129
+ data: { blockhash },
130
+ } = await fetchNonce(rpc, nonceAccountAddress);
131
+ const nonce = blockhash as string as Nonce;
142
132
 
143
133
  const durableNonceTransactionMessage = setTransactionMessageLifetimeUsingDurableNonce(
144
134
  { nonce, nonceAccountAddress, nonceAuthorityAddress },
145
- tx,
135
+ transactionMessage,
146
136
  );
147
137
  ```
148
138
 
@@ -201,14 +191,15 @@ Given an instruction, this method will return a new transaction message with tha
201
191
 
202
192
  ```ts
203
193
  import { address } from '@solana/addresses';
194
+ import { getUtf8Encoder } from '@solana/codecs-strings';
204
195
  import { appendTransactionMessageInstruction } from '@solana/transaction-messages';
205
196
 
206
- const memoTransaction = appendTransactionMessageInstruction(
197
+ const memoTransactionMessage = appendTransactionMessageInstruction(
207
198
  {
208
- data: new TextEncoder().encode('Hello world!'),
199
+ data: getUtf8Encoder().encode('Hello world!'),
209
200
  programAddress: address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
210
201
  },
211
- tx,
202
+ transactionMessage,
212
203
  );
213
204
  ```
214
205
 
@@ -240,16 +231,22 @@ This means that these accounts will take up less space in the compiled transacti
240
231
 
241
232
  ```ts
242
233
  import { address } from '@solana/addresses';
243
- import { compressTransactionMessageUsingAddressLookupTables } from '@solana/transaction-messages';
234
+ import {
235
+ AddressesByLookupTableAddressm,
236
+ compressTransactionMessageUsingAddressLookupTables,
237
+ } from '@solana/transaction-messages';
238
+ import { fetchAddressLookupTable } from '@solana-program/address-lookup-table';
244
239
 
245
240
  const lookupTableAddress = address('4QwSwNriKPrz8DLW4ju5uxC2TN5cksJx6tPUPj7DGLAW');
246
- const accountAddress = address('5n2ADjHPsqB4EVUNEX48xRqtnmuLu5XSHDwkJRR98qpM');
247
- const lookupTableAddresses: AddressesByLookupTableAddress = {
248
- [lookupTableAddress]: [accountAddress],
241
+ const {
242
+ data: { addresses },
243
+ } = await fetchAddressLookupTable(rpc, lookupTableAddress);
244
+ const addressesByAddressLookupTable: AddressesByLookupTableAddress = {
245
+ [lookupTableAddress]: addresses,
249
246
  };
250
247
 
251
248
  const compressedTransactionMessage = compressTransactionMessageUsingAddressLookupTables(
252
249
  transactionMessage,
253
- lookupTableAddresses,
250
+ addressesByAddressLookupTable,
254
251
  );
255
252
  ```