@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.
@@ -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 { coerce, instance, string, tuple, literal, unknown, type, number, array, nullable, optional, boolean, record, union, create, any, assert as assert$1 } from 'superstruct';
11
11
  import RpcClient from 'jayson/lib/client/browser';
12
12
  import { CommonClient, WebSocket } from 'rpc-websockets';
@@ -2373,32 +2373,22 @@ class NonceAccount {
2373
2373
  }
2374
2374
  }
2375
2375
 
2376
- const encodeDecode = layout => {
2376
+ function u64(property) {
2377
+ const layout = blob(8 /* bytes */, property);
2377
2378
  const decode = layout.decode.bind(layout);
2378
2379
  const encode = layout.encode.bind(layout);
2379
- return {
2380
- decode,
2381
- encode
2382
- };
2383
- };
2384
- const bigInt = length => property => {
2385
- const layout = blob(length, property);
2386
- const {
2387
- encode,
2388
- decode
2389
- } = encodeDecode(layout);
2390
2380
  const bigIntLayout = layout;
2381
+ const codec = getU64Codec();
2391
2382
  bigIntLayout.decode = (buffer, offset) => {
2392
2383
  const src = decode(buffer, offset);
2393
- return toBigIntLE(Buffer.from(src));
2384
+ return codec.decode(src);
2394
2385
  };
2395
2386
  bigIntLayout.encode = (bigInt, buffer, offset) => {
2396
- const src = toBufferLE(bigInt, length);
2387
+ const src = codec.encode(bigInt);
2397
2388
  return encode(src, buffer, offset);
2398
2389
  };
2399
2390
  return bigIntLayout;
2400
- };
2401
- const u64 = bigInt(8);
2391
+ }
2402
2392
 
2403
2393
  /**
2404
2394
  * Create account system transaction params
@@ -4979,18 +4969,6 @@ const GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({
4979
4969
  version: optional(TransactionVersionStruct)
4980
4970
  })));
4981
4971
 
4982
- /**
4983
- * Expected JSON RPC response for the "getRecentBlockhash" message
4984
- *
4985
- * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetLatestBlockhashRpcResult} instead.
4986
- */
4987
- const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(type({
4988
- blockhash: string(),
4989
- feeCalculator: type({
4990
- lamportsPerSignature: number()
4991
- })
4992
- }));
4993
-
4994
4972
  /**
4995
4973
  * Expected JSON RPC response for the "getLatestBlockhash" message
4996
4974
  */
@@ -6368,13 +6346,27 @@ class Connection {
6368
6346
  * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.
6369
6347
  */
6370
6348
  async getRecentBlockhashAndContext(commitment) {
6371
- const args = this._buildArgs([], commitment);
6372
- const unsafeRes = await this._rpcRequest('getRecentBlockhash', args);
6373
- const res = create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
6374
- if ('error' in res) {
6375
- throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
6376
- }
6377
- return res.result;
6349
+ const {
6350
+ context,
6351
+ value: {
6352
+ blockhash
6353
+ }
6354
+ } = await this.getLatestBlockhashAndContext(commitment);
6355
+ const feeCalculator = {
6356
+ get lamportsPerSignature() {
6357
+ 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.');
6358
+ },
6359
+ toJSON() {
6360
+ return {};
6361
+ }
6362
+ };
6363
+ return {
6364
+ context,
6365
+ value: {
6366
+ blockhash,
6367
+ feeCalculator
6368
+ }
6369
+ };
6378
6370
  }
6379
6371
 
6380
6372
  /**
@@ -8395,7 +8387,7 @@ class AddressLookupTableProgram {
8395
8387
  */
8396
8388
  constructor() {}
8397
8389
  static createLookupTable(params) {
8398
- const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
8390
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), getU64Encoder().encode(params.recentSlot)], this.programId);
8399
8391
  const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
8400
8392
  const data = encodeData(type, {
8401
8393
  recentSlot: BigInt(params.recentSlot),