@solana/web3.js 1.41.3 → 1.41.4

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.
@@ -3099,6 +3099,92 @@ function sleep(ms) {
3099
3099
  return new Promise(resolve => setTimeout(resolve, ms));
3100
3100
  }
3101
3101
 
3102
+ const encodeDecode = (layout) => {
3103
+ const decode = layout.decode.bind(layout);
3104
+ const encode = layout.encode.bind(layout);
3105
+ return { decode, encode };
3106
+ };
3107
+
3108
+ var browser = {};
3109
+
3110
+ Object.defineProperty(browser, "__esModule", { value: true });
3111
+ /**
3112
+ * Convert a little-endian buffer into a BigInt.
3113
+ * @param buf The little-endian buffer to convert
3114
+ * @returns A BigInt with the little-endian representation of buf.
3115
+ */
3116
+ function toBigIntLE(buf) {
3117
+ {
3118
+ const reversed = Buffer.from(buf);
3119
+ reversed.reverse();
3120
+ const hex = reversed.toString('hex');
3121
+ if (hex.length === 0) {
3122
+ return BigInt(0);
3123
+ }
3124
+ return BigInt(`0x${hex}`);
3125
+ }
3126
+ }
3127
+ var toBigIntLE_1 = browser.toBigIntLE = toBigIntLE;
3128
+ /**
3129
+ * Convert a big-endian buffer into a BigInt
3130
+ * @param buf The big-endian buffer to convert.
3131
+ * @returns A BigInt with the big-endian representation of buf.
3132
+ */
3133
+ function toBigIntBE(buf) {
3134
+ {
3135
+ const hex = buf.toString('hex');
3136
+ if (hex.length === 0) {
3137
+ return BigInt(0);
3138
+ }
3139
+ return BigInt(`0x${hex}`);
3140
+ }
3141
+ }
3142
+ browser.toBigIntBE = toBigIntBE;
3143
+ /**
3144
+ * Convert a BigInt to a little-endian buffer.
3145
+ * @param num The BigInt to convert.
3146
+ * @param width The number of bytes that the resulting buffer should be.
3147
+ * @returns A little-endian buffer representation of num.
3148
+ */
3149
+ function toBufferLE(num, width) {
3150
+ {
3151
+ const hex = num.toString(16);
3152
+ const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
3153
+ buffer.reverse();
3154
+ return buffer;
3155
+ }
3156
+ }
3157
+ var toBufferLE_1 = browser.toBufferLE = toBufferLE;
3158
+ /**
3159
+ * Convert a BigInt to a big-endian buffer.
3160
+ * @param num The BigInt to convert.
3161
+ * @param width The number of bytes that the resulting buffer should be.
3162
+ * @returns A big-endian buffer representation of num.
3163
+ */
3164
+ function toBufferBE(num, width) {
3165
+ {
3166
+ const hex = num.toString(16);
3167
+ return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
3168
+ }
3169
+ }
3170
+ browser.toBufferBE = toBufferBE;
3171
+
3172
+ const bigInt = (length) => (property) => {
3173
+ const layout = BufferLayout.blob(length, property);
3174
+ const { encode, decode } = encodeDecode(layout);
3175
+ const bigIntLayout = layout;
3176
+ bigIntLayout.decode = (buffer, offset) => {
3177
+ const src = decode(buffer, offset);
3178
+ return toBigIntLE_1(Buffer.from(src));
3179
+ };
3180
+ bigIntLayout.encode = (bigInt, buffer, offset) => {
3181
+ const src = toBufferLE_1(bigInt, length);
3182
+ return encode(src, buffer, offset);
3183
+ };
3184
+ return bigIntLayout;
3185
+ };
3186
+ const u64 = bigInt(8);
3187
+
3102
3188
  /**
3103
3189
  * Populate a buffer of instruction data using an InstructionType
3104
3190
  * @internal
@@ -3488,7 +3574,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
3488
3574
  },
3489
3575
  Transfer: {
3490
3576
  index: 2,
3491
- layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
3577
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports')])
3492
3578
  },
3493
3579
  CreateWithSeed: {
3494
3580
  index: 3,
@@ -3524,7 +3610,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
3524
3610
  },
3525
3611
  TransferWithSeed: {
3526
3612
  index: 11,
3527
- layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports'), rustString('seed'), publicKey('programId')])
3613
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
3528
3614
  }
3529
3615
  });
3530
3616
  /**
@@ -3577,7 +3663,7 @@ class SystemProgram {
3577
3663
  if ('basePubkey' in params) {
3578
3664
  const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
3579
3665
  data = encodeData(type, {
3580
- lamports: params.lamports,
3666
+ lamports: BigInt(params.lamports),
3581
3667
  seed: params.seed,
3582
3668
  programId: toBuffer(params.programId.toBuffer())
3583
3669
  });
@@ -3597,7 +3683,7 @@ class SystemProgram {
3597
3683
  } else {
3598
3684
  const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
3599
3685
  data = encodeData(type, {
3600
- lamports: params.lamports
3686
+ lamports: BigInt(params.lamports)
3601
3687
  });
3602
3688
  keys = [{
3603
3689
  pubkey: params.fromPubkey,