@solana/web3.js 1.41.3 → 1.41.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.41.3",
3
+ "version": "1.41.6",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -59,6 +59,7 @@
59
59
  "@babel/runtime": "^7.12.5",
60
60
  "@ethersproject/sha2": "^5.5.0",
61
61
  "@solana/buffer-layout": "^4.0.0",
62
+ "@solana/buffer-layout-utils": "^0.2.0",
62
63
  "bn.js": "^5.0.0",
63
64
  "borsh": "^0.7.0",
64
65
  "bs58": "^4.0.1",
@@ -69,7 +70,6 @@
69
70
  "js-sha3": "^0.8.0",
70
71
  "rpc-websockets": "^7.4.2",
71
72
  "secp256k1": "^4.0.2",
72
- "sinon-chai": "^3.7.0",
73
73
  "superstruct": "^0.14.2",
74
74
  "tweetnacl": "^1.0.0"
75
75
  },
@@ -89,7 +89,7 @@
89
89
  "@rollup/plugin-multi-entry": "^4.0.0",
90
90
  "@rollup/plugin-node-resolve": "^13.0.0",
91
91
  "@rollup/plugin-replace": "^4.0.0",
92
- "@solana/spl-token": "^0.1.2",
92
+ "@solana/spl-token": "^0.2.0",
93
93
  "@types/bn.js": "^5.1.0",
94
94
  "@types/bs58": "^4.0.1",
95
95
  "@types/chai": "^4.2.15",
@@ -127,6 +127,7 @@
127
127
  "rollup-plugin-terser": "^7.0.2",
128
128
  "semantic-release": "^18.0.0",
129
129
  "sinon": "^13.0.2",
130
+ "sinon-chai": "^3.7.0",
130
131
  "start-server-and-test": "^1.12.0",
131
132
  "ts-mocha": "^9.0.2",
132
133
  "ts-node": "^10.0.0",
package/src/connection.ts CHANGED
@@ -4847,7 +4847,7 @@ export class Connection {
4847
4847
  try {
4848
4848
  this.removeSignatureListener(clientSubscriptionId);
4849
4849
  // eslint-disable-next-line no-empty
4850
- } catch {
4850
+ } catch (_err) {
4851
4851
  // Already removed.
4852
4852
  }
4853
4853
  }
@@ -4895,7 +4895,7 @@ export class Connection {
4895
4895
  try {
4896
4896
  this.removeSignatureListener(clientSubscriptionId);
4897
4897
  // eslint-disable-next-line no-empty
4898
- } catch {
4898
+ } catch (_err) {
4899
4899
  // Already removed.
4900
4900
  }
4901
4901
  },
@@ -1,4 +1,5 @@
1
1
  import * as BufferLayout from '@solana/buffer-layout';
2
+ import {u64} from '@solana/buffer-layout-utils';
2
3
 
3
4
  import {
4
5
  encodeData,
@@ -38,7 +39,7 @@ export type TransferParams = {
38
39
  /** Account that will receive transferred lamports */
39
40
  toPubkey: PublicKey;
40
41
  /** Amount of lamports to transfer */
41
- lamports: number;
42
+ lamports: number | bigint;
42
43
  };
43
44
 
44
45
  /**
@@ -200,7 +201,33 @@ export type TransferWithSeedParams = {
200
201
  /** Account that will receive transferred lamports */
201
202
  toPubkey: PublicKey;
202
203
  /** Amount of lamports to transfer */
203
- lamports: number;
204
+ lamports: number | bigint;
205
+ /** Seed to use to derive the funding account address */
206
+ seed: string;
207
+ /** Program id to use to derive the funding account address */
208
+ programId: PublicKey;
209
+ };
210
+
211
+ /** Decoded transfer system transaction instruction */
212
+ export type DecodedTransferInstruction = {
213
+ /** Account that will transfer lamports */
214
+ fromPubkey: PublicKey;
215
+ /** Account that will receive transferred lamports */
216
+ toPubkey: PublicKey;
217
+ /** Amount of lamports to transfer */
218
+ lamports: bigint;
219
+ };
220
+
221
+ /** Decoded transferWithSeed system transaction instruction */
222
+ export type DecodedTransferWithSeedInstruction = {
223
+ /** Account that will transfer lamports */
224
+ fromPubkey: PublicKey;
225
+ /** Base public key to use to derive the funding account address */
226
+ basePubkey: PublicKey;
227
+ /** Account that will receive transferred lamports */
228
+ toPubkey: PublicKey;
229
+ /** Amount of lamports to transfer */
230
+ lamports: bigint;
204
231
  /** Seed to use to derive the funding account address */
205
232
  seed: string;
206
233
  /** Program id to use to derive the funding account address */
@@ -268,7 +295,9 @@ export class SystemInstruction {
268
295
  /**
269
296
  * Decode a transfer system instruction and retrieve the instruction params.
270
297
  */
271
- static decodeTransfer(instruction: TransactionInstruction): TransferParams {
298
+ static decodeTransfer(
299
+ instruction: TransactionInstruction,
300
+ ): DecodedTransferInstruction {
272
301
  this.checkProgramId(instruction.programId);
273
302
  this.checkKeyLength(instruction.keys, 2);
274
303
 
@@ -289,7 +318,7 @@ export class SystemInstruction {
289
318
  */
290
319
  static decodeTransferWithSeed(
291
320
  instruction: TransactionInstruction,
292
- ): TransferWithSeedParams {
321
+ ): DecodedTransferWithSeedInstruction {
293
322
  this.checkProgramId(instruction.programId);
294
323
  this.checkKeyLength(instruction.keys, 3);
295
324
 
@@ -577,10 +606,10 @@ type SystemInstructionInputData = {
577
606
  authorized: Uint8Array;
578
607
  };
579
608
  Transfer: IInstructionInputData & {
580
- lamports: number;
609
+ lamports: bigint;
581
610
  };
582
611
  TransferWithSeed: IInstructionInputData & {
583
- lamports: number;
612
+ lamports: bigint;
584
613
  programId: Uint8Array;
585
614
  seed: string;
586
615
  };
@@ -618,7 +647,7 @@ export const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze<{
618
647
  index: 2,
619
648
  layout: BufferLayout.struct<SystemInstructionInputData['Transfer']>([
620
649
  BufferLayout.u32('instruction'),
621
- BufferLayout.ns64('lamports'),
650
+ u64('lamports'),
622
651
  ]),
623
652
  },
624
653
  CreateWithSeed: {
@@ -689,7 +718,7 @@ export const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze<{
689
718
  layout: BufferLayout.struct<SystemInstructionInputData['TransferWithSeed']>(
690
719
  [
691
720
  BufferLayout.u32('instruction'),
692
- BufferLayout.ns64('lamports'),
721
+ u64('lamports'),
693
722
  Layout.rustString('seed'),
694
723
  Layout.publicKey('programId'),
695
724
  ],
@@ -745,7 +774,7 @@ export class SystemProgram {
745
774
  if ('basePubkey' in params) {
746
775
  const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
747
776
  data = encodeData(type, {
748
- lamports: params.lamports,
777
+ lamports: BigInt(params.lamports),
749
778
  seed: params.seed,
750
779
  programId: toBuffer(params.programId.toBuffer()),
751
780
  });
@@ -756,7 +785,7 @@ export class SystemProgram {
756
785
  ];
757
786
  } else {
758
787
  const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
759
- data = encodeData(type, {lamports: params.lamports});
788
+ data = encodeData(type, {lamports: BigInt(params.lamports)});
760
789
  keys = [
761
790
  {pubkey: params.fromPubkey, isSigner: true, isWritable: true},
762
791
  {pubkey: params.toPubkey, isSigner: false, isWritable: true},
@@ -267,12 +267,10 @@ export class Transaction {
267
267
  * Compile transaction data
268
268
  */
269
269
  compileMessage(): Message {
270
- if (this._message) {
271
- if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
272
- throw new Error(
273
- 'Transaction message mutated after being populated from Message',
274
- );
275
- }
270
+ if (
271
+ this._message &&
272
+ JSON.stringify(this.toJSON()) === JSON.stringify(this._json)
273
+ ) {
276
274
  return this._message;
277
275
  }
278
276