@solana/web3.js 0.98.0 → 1.0.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.
Files changed (81) hide show
  1. package/README.md +10 -55
  2. package/lib/index.browser.esm.js +48 -24
  3. package/lib/index.browser.esm.js.map +1 -1
  4. package/lib/index.cjs.js +101 -56
  5. package/lib/index.cjs.js.map +1 -1
  6. package/lib/index.esm.js +88 -64
  7. package/lib/index.esm.js.map +1 -1
  8. package/lib/index.iife.js +42 -25
  9. package/lib/index.iife.js.map +1 -1
  10. package/lib/index.iife.min.js +2 -2
  11. package/lib/index.iife.min.js.map +1 -1
  12. package/lib/types/index.d.ts.map +1 -1
  13. package/package.json +27 -45
  14. package/src/message.ts +9 -12
  15. package/src/transaction.ts +2 -2
  16. package/src/util/guarded-array-utils.ts +37 -0
  17. package/src/validator-info.ts +5 -4
  18. package/bin/bpf-sdk-install.sh +0 -38
  19. package/bin/localnet.sh +0 -161
  20. package/bpf-sdk/LICENSE +0 -13
  21. package/bpf-sdk/c/README.md +0 -44
  22. package/bpf-sdk/c/bpf.ld +0 -20
  23. package/bpf-sdk/c/bpf.mk +0 -249
  24. package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
  25. package/bpf-sdk/c/inc/solana_sdk.h +0 -669
  26. package/bpf-sdk/c/inc/stdio.h +0 -4
  27. package/bpf-sdk/c/inc/stdlib.h +0 -2
  28. package/bpf-sdk/c/inc/string.h +0 -7
  29. package/bpf-sdk/c/inc/sys/param.h +0 -1
  30. package/bpf-sdk/c/inc/wchar.h +0 -1
  31. package/bpf-sdk/env.sh +0 -39
  32. package/bpf-sdk/rust/bpf.ld +0 -20
  33. package/bpf-sdk/rust/build.sh +0 -21
  34. package/bpf-sdk/rust/clean.sh +0 -17
  35. package/bpf-sdk/rust/xargo-build.sh +0 -29
  36. package/bpf-sdk/scripts/dump.sh +0 -45
  37. package/bpf-sdk/scripts/install.sh +0 -178
  38. package/bpf-sdk/scripts/objcopy.sh +0 -6
  39. package/bpf-sdk/scripts/package.sh +0 -19
  40. package/bpf-sdk/scripts/strip.sh +0 -23
  41. package/bpf-sdk/version.txt +0 -2
  42. package/doc/assets/css/main.css +0 -2660
  43. package/doc/assets/images/icons.png +0 -0
  44. package/doc/assets/images/icons@2x.png +0 -0
  45. package/doc/assets/images/widgets.png +0 -0
  46. package/doc/assets/images/widgets@2x.png +0 -0
  47. package/doc/assets/js/main.js +0 -248
  48. package/doc/assets/js/search.js +0 -1
  49. package/doc/classes/account.html +0 -244
  50. package/doc/classes/authorized.html +0 -234
  51. package/doc/classes/bpfloader.html +0 -267
  52. package/doc/classes/connection.html +0 -2354
  53. package/doc/classes/loader.html +0 -275
  54. package/doc/classes/lockup.html +0 -250
  55. package/doc/classes/message.html +0 -326
  56. package/doc/classes/nonceaccount.html +0 -233
  57. package/doc/classes/publickey.html +0 -411
  58. package/doc/classes/secp256k1program.html +0 -308
  59. package/doc/classes/stakeinstruction.html +0 -403
  60. package/doc/classes/stakeprogram.html +0 -503
  61. package/doc/classes/systeminstruction.html +0 -563
  62. package/doc/classes/systemprogram.html +0 -503
  63. package/doc/classes/transaction.html +0 -688
  64. package/doc/classes/transactioninstruction.html +0 -240
  65. package/doc/classes/validatorinfo.html +0 -279
  66. package/doc/classes/voteaccount.html +0 -331
  67. package/doc/index.html +0 -640
  68. package/doc/interfaces/feecalculator.html +0 -166
  69. package/doc/modules.html +0 -4682
  70. package/examples/README.md +0 -10
  71. package/examples/account.html +0 -24
  72. package/examples/account.js +0 -10
  73. package/examples/bpf-c-noop/.gitignore +0 -1
  74. package/examples/bpf-c-noop/makefile +0 -1
  75. package/examples/bpf-c-noop/src/noop/noop.c +0 -19
  76. package/examples/bpf-rust-noop/.gitignore +0 -3
  77. package/examples/bpf-rust-noop/Cargo.toml +0 -23
  78. package/examples/bpf-rust-noop/Xargo.toml +0 -2
  79. package/examples/bpf-rust-noop/src/lib.rs +0 -70
  80. package/examples/get-balance.html +0 -37
  81. package/examples/get-balance.js +0 -18
package/lib/index.cjs.js CHANGED
@@ -22,10 +22,32 @@ var jsSha3 = require('js-sha3');
22
22
 
23
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
24
 
25
+ function _interopNamespace(e) {
26
+ if (e && e.__esModule) return e;
27
+ var n = Object.create(null);
28
+ if (e) {
29
+ Object.keys(e).forEach(function (k) {
30
+ if (k !== 'default') {
31
+ var d = Object.getOwnPropertyDescriptor(e, k);
32
+ Object.defineProperty(n, k, d.get ? d : {
33
+ enumerable: true,
34
+ get: function () {
35
+ return e[k];
36
+ }
37
+ });
38
+ }
39
+ });
40
+ }
41
+ n['default'] = e;
42
+ return Object.freeze(n);
43
+ }
44
+
25
45
  var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
26
46
  var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
47
+ var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
27
48
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
28
49
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
50
+ var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
29
51
  var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
30
52
  var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
31
53
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
@@ -251,9 +273,9 @@ class Account {
251
273
  _defineProperty__default['default'](this, "_keypair", void 0);
252
274
 
253
275
  if (secretKey) {
254
- this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
276
+ this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
255
277
  } else {
256
- this._keypair = nacl.sign.keyPair();
278
+ this._keypair = nacl__namespace.sign.keyPair();
257
279
  }
258
280
  }
259
281
  /**
@@ -282,14 +304,14 @@ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader111111111111111
282
304
  */
283
305
 
284
306
  const publicKey = (property = 'publicKey') => {
285
- return BufferLayout.blob(32, property);
307
+ return BufferLayout__namespace.blob(32, property);
286
308
  };
287
309
  /**
288
310
  * Layout for a Rust String type
289
311
  */
290
312
 
291
313
  const rustString = (property = 'string') => {
292
- const rsl = BufferLayout.struct([BufferLayout.u32('length'), BufferLayout.u32('lengthPadding'), BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars')], property);
314
+ const rsl = BufferLayout__namespace.struct([BufferLayout__namespace.u32('length'), BufferLayout__namespace.u32('lengthPadding'), BufferLayout__namespace.blob(BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'chars')], property);
293
315
 
294
316
  const _decode = rsl.decode.bind(rsl);
295
317
 
@@ -309,7 +331,7 @@ const rustString = (property = 'string') => {
309
331
  };
310
332
 
311
333
  rsl.alloc = str => {
312
- return BufferLayout.u32().span + BufferLayout.u32().span + buffer.Buffer.from(str, 'utf8').length;
334
+ return BufferLayout__namespace.u32().span + BufferLayout__namespace.u32().span + buffer.Buffer.from(str, 'utf8').length;
313
335
  };
314
336
 
315
337
  return rsl;
@@ -319,14 +341,14 @@ const rustString = (property = 'string') => {
319
341
  */
320
342
 
321
343
  const authorized = (property = 'authorized') => {
322
- return BufferLayout.struct([publicKey('staker'), publicKey('withdrawer')], property);
344
+ return BufferLayout__namespace.struct([publicKey('staker'), publicKey('withdrawer')], property);
323
345
  };
324
346
  /**
325
347
  * Layout for a Lockup object
326
348
  */
327
349
 
328
350
  const lockup = (property = 'lockup') => {
329
- return BufferLayout.struct([BufferLayout.ns64('unixTimestamp'), BufferLayout.ns64('epoch'), publicKey('custodian')], property);
351
+ return BufferLayout__namespace.struct([BufferLayout__namespace.ns64('unixTimestamp'), BufferLayout__namespace.ns64('epoch'), publicKey('custodian')], property);
330
352
  };
331
353
  function getAlloc(type, fields) {
332
354
  let alloc = 0;
@@ -373,6 +395,36 @@ function encodeLength(bytes, len) {
373
395
  }
374
396
  }
375
397
 
398
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
399
+ /**
400
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
401
+ */
402
+
403
+ function guardedShift(byteArray) {
404
+ if (byteArray.length === 0) {
405
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
406
+ }
407
+
408
+ return byteArray.shift();
409
+ }
410
+ /**
411
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
412
+ * the array.
413
+ */
414
+
415
+ function guardedSplice(byteArray, ...args) {
416
+ var _args$;
417
+
418
+ const [start] = args;
419
+
420
+ if (args.length === 2 // Implies that `deleteCount` was supplied
421
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
422
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
423
+ }
424
+
425
+ return byteArray.splice(...args);
426
+ }
427
+
376
428
  /**
377
429
  * The message header, identifying signed and read-only account
378
430
  *
@@ -436,12 +488,12 @@ class Message {
436
488
  buffer.Buffer.from(instructionCount).copy(instructionBuffer);
437
489
  let instructionBufferLength = instructionCount.length;
438
490
  instructions.forEach(instruction => {
439
- const instructionLayout = BufferLayout.struct([BufferLayout.u8('programIdIndex'), BufferLayout.blob(instruction.keyIndicesCount.length, 'keyIndicesCount'), BufferLayout.seq(BufferLayout.u8('keyIndex'), instruction.keyIndices.length, 'keyIndices'), BufferLayout.blob(instruction.dataLength.length, 'dataLength'), BufferLayout.seq(BufferLayout.u8('userdatum'), instruction.data.length, 'data')]);
491
+ const instructionLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u8('programIdIndex'), BufferLayout__namespace.blob(instruction.keyIndicesCount.length, 'keyIndicesCount'), BufferLayout__namespace.seq(BufferLayout__namespace.u8('keyIndex'), instruction.keyIndices.length, 'keyIndices'), BufferLayout__namespace.blob(instruction.dataLength.length, 'dataLength'), BufferLayout__namespace.seq(BufferLayout__namespace.u8('userdatum'), instruction.data.length, 'data')]);
440
492
  const length = instructionLayout.encode(instruction, instructionBuffer, instructionBufferLength);
441
493
  instructionBufferLength += length;
442
494
  });
443
495
  instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
444
- const signDataLayout = BufferLayout.struct([BufferLayout.blob(1, 'numRequiredSignatures'), BufferLayout.blob(1, 'numReadonlySignedAccounts'), BufferLayout.blob(1, 'numReadonlyUnsignedAccounts'), BufferLayout.blob(keyCount.length, 'keyCount'), BufferLayout.seq(publicKey('key'), numKeys, 'keys'), publicKey('recentBlockhash')]);
496
+ const signDataLayout = BufferLayout__namespace.struct([BufferLayout__namespace.blob(1, 'numRequiredSignatures'), BufferLayout__namespace.blob(1, 'numReadonlySignedAccounts'), BufferLayout__namespace.blob(1, 'numReadonlyUnsignedAccounts'), BufferLayout__namespace.blob(keyCount.length, 'keyCount'), BufferLayout__namespace.seq(publicKey('key'), numKeys, 'keys'), publicKey('recentBlockhash')]);
445
497
  const transaction = {
446
498
  numRequiredSignatures: buffer.Buffer.from([this.header.numRequiredSignatures]),
447
499
  numReadonlySignedAccounts: buffer.Buffer.from([this.header.numReadonlySignedAccounts]),
@@ -463,32 +515,28 @@ class Message {
463
515
  static from(buffer$1) {
464
516
  // Slice up wire data
465
517
  let byteArray = [...buffer$1];
466
- const numRequiredSignatures = byteArray.shift();
467
- const numReadonlySignedAccounts = byteArray.shift();
468
- const numReadonlyUnsignedAccounts = byteArray.shift();
518
+ const numRequiredSignatures = guardedShift(byteArray);
519
+ const numReadonlySignedAccounts = guardedShift(byteArray);
520
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
469
521
  const accountCount = decodeLength(byteArray);
470
522
  let accountKeys = [];
471
523
 
472
524
  for (let i = 0; i < accountCount; i++) {
473
- const account = byteArray.slice(0, PUBKEY_LENGTH);
474
- byteArray = byteArray.slice(PUBKEY_LENGTH);
525
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
475
526
  accountKeys.push(bs58__default['default'].encode(buffer.Buffer.from(account)));
476
527
  }
477
528
 
478
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
479
- byteArray = byteArray.slice(PUBKEY_LENGTH);
529
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
480
530
  const instructionCount = decodeLength(byteArray);
481
531
  let instructions = [];
482
532
 
483
533
  for (let i = 0; i < instructionCount; i++) {
484
- const programIdIndex = byteArray.shift();
534
+ const programIdIndex = guardedShift(byteArray);
485
535
  const accountCount = decodeLength(byteArray);
486
- const accounts = byteArray.slice(0, accountCount);
487
- byteArray = byteArray.slice(accountCount);
536
+ const accounts = guardedSplice(byteArray, 0, accountCount);
488
537
  const dataLength = decodeLength(byteArray);
489
- const dataSlice = byteArray.slice(0, dataLength);
538
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
490
539
  const data = bs58__default['default'].encode(buffer.Buffer.from(dataSlice));
491
- byteArray = byteArray.slice(dataLength);
492
540
  instructions.push({
493
541
  programIdIndex,
494
542
  accounts,
@@ -1113,8 +1161,7 @@ class Transaction {
1113
1161
  let signatures = [];
1114
1162
 
1115
1163
  for (let i = 0; i < signatureCount; i++) {
1116
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
1117
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
1164
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
1118
1165
  signatures.push(bs58__default['default'].encode(buffer.Buffer.from(signature)));
1119
1166
  }
1120
1167
 
@@ -1246,7 +1293,7 @@ function decodeData(type, buffer) {
1246
1293
  * @internal
1247
1294
  */
1248
1295
 
1249
- const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
1296
+ const FeeCalculatorLayout = BufferLayout__namespace.nu64('lamportsPerSignature');
1250
1297
  /**
1251
1298
  * Calculator for transaction fees.
1252
1299
  */
@@ -1257,7 +1304,7 @@ const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
1257
1304
  * @internal
1258
1305
  */
1259
1306
 
1260
- const NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);
1307
+ const NonceAccountLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u32('version'), BufferLayout__namespace.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout__namespace.struct([FeeCalculatorLayout], 'feeCalculator')]);
1261
1308
  const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
1262
1309
 
1263
1310
  /**
@@ -1322,7 +1369,7 @@ class SystemInstruction {
1322
1369
 
1323
1370
  static decodeInstructionType(instruction) {
1324
1371
  this.checkProgramId(instruction.programId);
1325
- const instructionTypeLayout = BufferLayout.u32('instruction');
1372
+ const instructionTypeLayout = BufferLayout__namespace.u32('instruction');
1326
1373
  const typeIndex = instructionTypeLayout.decode(instruction.data);
1327
1374
  let type;
1328
1375
 
@@ -1595,51 +1642,51 @@ class SystemInstruction {
1595
1642
  const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
1596
1643
  Create: {
1597
1644
  index: 0,
1598
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports'), BufferLayout.ns64('space'), publicKey('programId')])
1645
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports'), BufferLayout__namespace.ns64('space'), publicKey('programId')])
1599
1646
  },
1600
1647
  Assign: {
1601
1648
  index: 1,
1602
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('programId')])
1649
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('programId')])
1603
1650
  },
1604
1651
  Transfer: {
1605
1652
  index: 2,
1606
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
1653
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
1607
1654
  },
1608
1655
  CreateWithSeed: {
1609
1656
  index: 3,
1610
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout.ns64('lamports'), BufferLayout.ns64('space'), publicKey('programId')])
1657
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout__namespace.ns64('lamports'), BufferLayout__namespace.ns64('space'), publicKey('programId')])
1611
1658
  },
1612
1659
  AdvanceNonceAccount: {
1613
1660
  index: 4,
1614
- layout: BufferLayout.struct([BufferLayout.u32('instruction')])
1661
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
1615
1662
  },
1616
1663
  WithdrawNonceAccount: {
1617
1664
  index: 5,
1618
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
1665
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
1619
1666
  },
1620
1667
  InitializeNonceAccount: {
1621
1668
  index: 6,
1622
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('authorized')])
1669
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('authorized')])
1623
1670
  },
1624
1671
  AuthorizeNonceAccount: {
1625
1672
  index: 7,
1626
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('authorized')])
1673
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('authorized')])
1627
1674
  },
1628
1675
  Allocate: {
1629
1676
  index: 8,
1630
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('space')])
1677
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('space')])
1631
1678
  },
1632
1679
  AllocateWithSeed: {
1633
1680
  index: 9,
1634
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout.ns64('space'), publicKey('programId')])
1681
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout__namespace.ns64('space'), publicKey('programId')])
1635
1682
  },
1636
1683
  AssignWithSeed: {
1637
1684
  index: 10,
1638
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), publicKey('programId')])
1685
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('base'), rustString('seed'), publicKey('programId')])
1639
1686
  },
1640
1687
  TransferWithSeed: {
1641
1688
  index: 11,
1642
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports'), rustString('seed'), publicKey('programId')])
1689
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports'), rustString('seed'), publicKey('programId')])
1643
1690
  }
1644
1691
  });
1645
1692
  /**
@@ -2120,7 +2167,7 @@ class Loader {
2120
2167
  });
2121
2168
  }
2122
2169
  }
2123
- const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.u32('offset'), BufferLayout.u32('bytesLength'), BufferLayout.u32('bytesLengthPadding'), BufferLayout.seq(BufferLayout.u8('byte'), BufferLayout.offset(BufferLayout.u32(), -8), 'bytes')]);
2170
+ const dataLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.u32('offset'), BufferLayout__namespace.u32('bytesLength'), BufferLayout__namespace.u32('bytesLengthPadding'), BufferLayout__namespace.seq(BufferLayout__namespace.u8('byte'), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'bytes')]);
2124
2171
  const chunkSize = Loader.chunkSize;
2125
2172
  let offset = 0;
2126
2173
  let array = data;
@@ -2160,7 +2207,7 @@ class Loader {
2160
2207
  await Promise.all(transactions); // Finalize the account loaded with program data for execution
2161
2208
 
2162
2209
  {
2163
- const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
2210
+ const dataLayout = BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')]);
2164
2211
  const data = buffer.Buffer.alloc(dataLayout.span);
2165
2212
  dataLayout.encode({
2166
2213
  instruction: 1 // Finalize instruction
@@ -4837,7 +4884,7 @@ class StakeInstruction {
4837
4884
 
4838
4885
  static decodeInstructionType(instruction) {
4839
4886
  this.checkProgramId(instruction.programId);
4840
- const instructionTypeLayout = BufferLayout.u32('instruction');
4887
+ const instructionTypeLayout = BufferLayout__namespace.u32('instruction');
4841
4888
  const typeIndex = instructionTypeLayout.decode(instruction.data);
4842
4889
  let type;
4843
4890
 
@@ -5033,31 +5080,31 @@ class StakeInstruction {
5033
5080
  const STAKE_INSTRUCTION_LAYOUTS = Object.freeze({
5034
5081
  Initialize: {
5035
5082
  index: 0,
5036
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), authorized(), lockup()])
5083
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), authorized(), lockup()])
5037
5084
  },
5038
5085
  Authorize: {
5039
5086
  index: 1,
5040
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('stakeAuthorizationType')])
5087
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('newAuthorized'), BufferLayout__namespace.u32('stakeAuthorizationType')])
5041
5088
  },
5042
5089
  Delegate: {
5043
5090
  index: 2,
5044
- layout: BufferLayout.struct([BufferLayout.u32('instruction')])
5091
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
5045
5092
  },
5046
5093
  Split: {
5047
5094
  index: 3,
5048
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
5095
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
5049
5096
  },
5050
5097
  Withdraw: {
5051
5098
  index: 4,
5052
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
5099
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
5053
5100
  },
5054
5101
  Deactivate: {
5055
5102
  index: 5,
5056
- layout: BufferLayout.struct([BufferLayout.u32('instruction')])
5103
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
5057
5104
  },
5058
5105
  AuthorizeWithSeed: {
5059
5106
  index: 8,
5060
- layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('stakeAuthorizationType'), rustString('authoritySeed'), publicKey('authorityOwner')])
5107
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('newAuthorized'), BufferLayout__namespace.u32('stakeAuthorizationType'), rustString('authoritySeed'), publicKey('authorityOwner')])
5061
5108
  }
5062
5109
  });
5063
5110
  /**
@@ -5484,7 +5531,7 @@ const SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11;
5484
5531
  * @property {number} recoveryId
5485
5532
  */
5486
5533
 
5487
- const SECP256K1_INSTRUCTION_LAYOUT = BufferLayout.struct([BufferLayout.u8('numSignatures'), BufferLayout.u16('signatureOffset'), BufferLayout.u8('signatureInstructionIndex'), BufferLayout.u16('ethAddressOffset'), BufferLayout.u8('ethAddressInstructionIndex'), BufferLayout.u16('messageDataOffset'), BufferLayout.u16('messageDataSize'), BufferLayout.u8('messageInstructionIndex'), BufferLayout.blob(20, 'ethAddress'), BufferLayout.blob(64, 'signature'), BufferLayout.u8('recoveryId')]);
5534
+ const SECP256K1_INSTRUCTION_LAYOUT = BufferLayout__namespace.struct([BufferLayout__namespace.u8('numSignatures'), BufferLayout__namespace.u16('signatureOffset'), BufferLayout__namespace.u8('signatureInstructionIndex'), BufferLayout__namespace.u16('ethAddressOffset'), BufferLayout__namespace.u8('ethAddressInstructionIndex'), BufferLayout__namespace.u16('messageDataOffset'), BufferLayout__namespace.u16('messageDataSize'), BufferLayout__namespace.u8('messageInstructionIndex'), BufferLayout__namespace.blob(20, 'ethAddress'), BufferLayout__namespace.blob(64, 'signature'), BufferLayout__namespace.u8('recoveryId')]);
5488
5535
  class Secp256k1Program {
5489
5536
  /**
5490
5537
  * @internal
@@ -5681,10 +5728,8 @@ class ValidatorInfo {
5681
5728
  const configKeys = [];
5682
5729
 
5683
5730
  for (let i = 0; i < 2; i++) {
5684
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
5685
- byteArray = byteArray.slice(PUBKEY_LENGTH);
5686
- const isSigner = byteArray.slice(0, 1)[0] === 1;
5687
- byteArray = byteArray.slice(1);
5731
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
5732
+ const isSigner = guardedShift(byteArray) === 1;
5688
5733
  configKeys.push({
5689
5734
  publicKey,
5690
5735
  isSigner
@@ -5712,9 +5757,9 @@ const VOTE_PROGRAM_ID = new PublicKey('Vote1111111111111111111111111111111111111
5712
5757
  *
5713
5758
  * @internal
5714
5759
  */
5715
- const VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout.u8('commission'), BufferLayout.nu64(), // votes.length
5716
- BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.u32('confirmationCount')]), BufferLayout.offset(BufferLayout.u32(), -8), 'votes'), BufferLayout.u8('rootSlotValid'), BufferLayout.nu64('rootSlot'), BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('lastEpochCredits'), BufferLayout.nu64(), // epochCredits.length
5717
- BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('prevCredits')]), BufferLayout.offset(BufferLayout.u32(), -8), 'epochCredits')]);
5760
+ const VoteAccountLayout = BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout__namespace.u8('commission'), BufferLayout__namespace.nu64(), // votes.length
5761
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.u32('confirmationCount')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'votes'), BufferLayout__namespace.u8('rootSlotValid'), BufferLayout__namespace.nu64('rootSlot'), BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('lastEpochCredits'), BufferLayout__namespace.nu64(), // epochCredits.length
5762
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('prevCredits')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'epochCredits')]);
5718
5763
 
5719
5764
  /**
5720
5765
  * VoteAccount class