@solana/web3.js 1.97.0 → 1.98.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.
package/lib/index.esm.js CHANGED
@@ -6,7 +6,7 @@ import { sha256 } from '@noble/hashes/sha256';
6
6
  import { serialize, deserialize, deserializeUnchecked } from 'borsh';
7
7
  import * as BufferLayout from '@solana/buffer-layout';
8
8
  import { blob } from '@solana/buffer-layout';
9
- import { toBigIntLE, toBufferLE } from 'bigint-buffer';
9
+ import { getU64Codec, getU64Encoder } from '@solana/codecs-numbers';
10
10
  import require$$0 from 'util';
11
11
  import require$$0$1 from 'http';
12
12
  import require$$0$2, { Agent } from 'https';
@@ -2377,32 +2377,22 @@ class NonceAccount {
2377
2377
  }
2378
2378
  }
2379
2379
 
2380
- const encodeDecode = layout => {
2380
+ function u64(property) {
2381
+ const layout = blob(8 /* bytes */, property);
2381
2382
  const decode = layout.decode.bind(layout);
2382
2383
  const encode = layout.encode.bind(layout);
2383
- return {
2384
- decode,
2385
- encode
2386
- };
2387
- };
2388
- const bigInt = length => property => {
2389
- const layout = blob(length, property);
2390
- const {
2391
- encode,
2392
- decode
2393
- } = encodeDecode(layout);
2394
2384
  const bigIntLayout = layout;
2385
+ const codec = getU64Codec();
2395
2386
  bigIntLayout.decode = (buffer, offset) => {
2396
2387
  const src = decode(buffer, offset);
2397
- return toBigIntLE(Buffer.from(src));
2388
+ return codec.decode(src);
2398
2389
  };
2399
2390
  bigIntLayout.encode = (bigInt, buffer, offset) => {
2400
- const src = toBufferLE(bigInt, length);
2391
+ const src = codec.encode(bigInt);
2401
2392
  return encode(src, buffer, offset);
2402
2393
  };
2403
2394
  return bigIntLayout;
2404
- };
2405
- const u64 = bigInt(8);
2395
+ }
2406
2396
 
2407
2397
  /**
2408
2398
  * Create account system transaction params
@@ -5724,18 +5714,6 @@ const GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({
5724
5714
  version: optional(TransactionVersionStruct)
5725
5715
  })));
5726
5716
 
5727
- /**
5728
- * Expected JSON RPC response for the "getRecentBlockhash" message
5729
- *
5730
- * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetLatestBlockhashRpcResult} instead.
5731
- */
5732
- const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(type({
5733
- blockhash: string(),
5734
- feeCalculator: type({
5735
- lamportsPerSignature: number()
5736
- })
5737
- }));
5738
-
5739
5717
  /**
5740
5718
  * Expected JSON RPC response for the "getLatestBlockhash" message
5741
5719
  */
@@ -7113,13 +7091,27 @@ class Connection {
7113
7091
  * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.
7114
7092
  */
7115
7093
  async getRecentBlockhashAndContext(commitment) {
7116
- const args = this._buildArgs([], commitment);
7117
- const unsafeRes = await this._rpcRequest('getRecentBlockhash', args);
7118
- const res = create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
7119
- if ('error' in res) {
7120
- throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
7121
- }
7122
- return res.result;
7094
+ const {
7095
+ context,
7096
+ value: {
7097
+ blockhash
7098
+ }
7099
+ } = await this.getLatestBlockhashAndContext(commitment);
7100
+ const feeCalculator = {
7101
+ get lamportsPerSignature() {
7102
+ throw new Error('The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is ' + 'no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee ' + 'for a given message.');
7103
+ },
7104
+ toJSON() {
7105
+ return {};
7106
+ }
7107
+ };
7108
+ return {
7109
+ context,
7110
+ value: {
7111
+ blockhash,
7112
+ feeCalculator
7113
+ }
7114
+ };
7123
7115
  }
7124
7116
 
7125
7117
  /**
@@ -9140,7 +9132,7 @@ class AddressLookupTableProgram {
9140
9132
  */
9141
9133
  constructor() {}
9142
9134
  static createLookupTable(params) {
9143
- const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
9135
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), getU64Encoder().encode(params.recentSlot)], this.programId);
9144
9136
  const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
9145
9137
  const data = encodeData(type, {
9146
9138
  recentSlot: BigInt(params.recentSlot),