@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.cjs.js CHANGED
@@ -7,7 +7,7 @@ var bs58 = require('bs58');
7
7
  var sha256 = require('@noble/hashes/sha256');
8
8
  var borsh = require('borsh');
9
9
  var BufferLayout = require('@solana/buffer-layout');
10
- var bigintBuffer = require('bigint-buffer');
10
+ var codecsNumbers = require('@solana/codecs-numbers');
11
11
  var require$$0 = require('util');
12
12
  var require$$0$1 = require('http');
13
13
  var require$$0$2 = require('https');
@@ -2407,32 +2407,22 @@ class NonceAccount {
2407
2407
  }
2408
2408
  }
2409
2409
 
2410
- const encodeDecode = layout => {
2410
+ function u64(property) {
2411
+ const layout = BufferLayout.blob(8 /* bytes */, property);
2411
2412
  const decode = layout.decode.bind(layout);
2412
2413
  const encode = layout.encode.bind(layout);
2413
- return {
2414
- decode,
2415
- encode
2416
- };
2417
- };
2418
- const bigInt = length => property => {
2419
- const layout = BufferLayout.blob(length, property);
2420
- const {
2421
- encode,
2422
- decode
2423
- } = encodeDecode(layout);
2424
2414
  const bigIntLayout = layout;
2425
- bigIntLayout.decode = (buffer$1, offset) => {
2426
- const src = decode(buffer$1, offset);
2427
- return bigintBuffer.toBigIntLE(buffer.Buffer.from(src));
2415
+ const codec = codecsNumbers.getU64Codec();
2416
+ bigIntLayout.decode = (buffer, offset) => {
2417
+ const src = decode(buffer, offset);
2418
+ return codec.decode(src);
2428
2419
  };
2429
2420
  bigIntLayout.encode = (bigInt, buffer, offset) => {
2430
- const src = bigintBuffer.toBufferLE(bigInt, length);
2421
+ const src = codec.encode(bigInt);
2431
2422
  return encode(src, buffer, offset);
2432
2423
  };
2433
2424
  return bigIntLayout;
2434
- };
2435
- const u64 = bigInt(8);
2425
+ }
2436
2426
 
2437
2427
  /**
2438
2428
  * Create account system transaction params
@@ -5754,18 +5744,6 @@ const GetParsedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superst
5754
5744
  version: superstruct.optional(TransactionVersionStruct)
5755
5745
  })));
5756
5746
 
5757
- /**
5758
- * Expected JSON RPC response for the "getRecentBlockhash" message
5759
- *
5760
- * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetLatestBlockhashRpcResult} instead.
5761
- */
5762
- const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(superstruct.type({
5763
- blockhash: superstruct.string(),
5764
- feeCalculator: superstruct.type({
5765
- lamportsPerSignature: superstruct.number()
5766
- })
5767
- }));
5768
-
5769
5747
  /**
5770
5748
  * Expected JSON RPC response for the "getLatestBlockhash" message
5771
5749
  */
@@ -7143,13 +7121,27 @@ class Connection {
7143
7121
  * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.
7144
7122
  */
7145
7123
  async getRecentBlockhashAndContext(commitment) {
7146
- const args = this._buildArgs([], commitment);
7147
- const unsafeRes = await this._rpcRequest('getRecentBlockhash', args);
7148
- const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
7149
- if ('error' in res) {
7150
- throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
7151
- }
7152
- return res.result;
7124
+ const {
7125
+ context,
7126
+ value: {
7127
+ blockhash
7128
+ }
7129
+ } = await this.getLatestBlockhashAndContext(commitment);
7130
+ const feeCalculator = {
7131
+ get lamportsPerSignature() {
7132
+ 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.');
7133
+ },
7134
+ toJSON() {
7135
+ return {};
7136
+ }
7137
+ };
7138
+ return {
7139
+ context,
7140
+ value: {
7141
+ blockhash,
7142
+ feeCalculator
7143
+ }
7144
+ };
7153
7145
  }
7154
7146
 
7155
7147
  /**
@@ -9170,7 +9162,7 @@ class AddressLookupTableProgram {
9170
9162
  */
9171
9163
  constructor() {}
9172
9164
  static createLookupTable(params) {
9173
- const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), bigintBuffer.toBufferLE(BigInt(params.recentSlot), 8)], this.programId);
9165
+ const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), codecsNumbers.getU64Encoder().encode(params.recentSlot)], this.programId);
9174
9166
  const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
9175
9167
  const data = encodeData(type, {
9176
9168
  recentSlot: BigInt(params.recentSlot),