@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.
- package/README.md +10 -55
- package/lib/index.browser.esm.js +48 -24
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +101 -56
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +88 -64
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +42 -25
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +27 -45
- package/src/message.ts +9 -12
- package/src/transaction.ts +2 -2
- package/src/util/guarded-array-utils.ts +37 -0
- package/src/validator-info.ts +5 -4
- package/bin/bpf-sdk-install.sh +0 -38
- package/bin/localnet.sh +0 -161
- package/bpf-sdk/LICENSE +0 -13
- package/bpf-sdk/c/README.md +0 -44
- package/bpf-sdk/c/bpf.ld +0 -20
- package/bpf-sdk/c/bpf.mk +0 -249
- package/bpf-sdk/c/inc/deserialize_deprecated.h +0 -115
- package/bpf-sdk/c/inc/solana_sdk.h +0 -669
- package/bpf-sdk/c/inc/stdio.h +0 -4
- package/bpf-sdk/c/inc/stdlib.h +0 -2
- package/bpf-sdk/c/inc/string.h +0 -7
- package/bpf-sdk/c/inc/sys/param.h +0 -1
- package/bpf-sdk/c/inc/wchar.h +0 -1
- package/bpf-sdk/env.sh +0 -39
- package/bpf-sdk/rust/bpf.ld +0 -20
- package/bpf-sdk/rust/build.sh +0 -21
- package/bpf-sdk/rust/clean.sh +0 -17
- package/bpf-sdk/rust/xargo-build.sh +0 -29
- package/bpf-sdk/scripts/dump.sh +0 -45
- package/bpf-sdk/scripts/install.sh +0 -178
- package/bpf-sdk/scripts/objcopy.sh +0 -6
- package/bpf-sdk/scripts/package.sh +0 -19
- package/bpf-sdk/scripts/strip.sh +0 -23
- package/bpf-sdk/version.txt +0 -2
- package/doc/assets/css/main.css +0 -2660
- package/doc/assets/images/icons.png +0 -0
- package/doc/assets/images/icons@2x.png +0 -0
- package/doc/assets/images/widgets.png +0 -0
- package/doc/assets/images/widgets@2x.png +0 -0
- package/doc/assets/js/main.js +0 -248
- package/doc/assets/js/search.js +0 -1
- package/doc/classes/account.html +0 -244
- package/doc/classes/authorized.html +0 -234
- package/doc/classes/bpfloader.html +0 -267
- package/doc/classes/connection.html +0 -2354
- package/doc/classes/loader.html +0 -275
- package/doc/classes/lockup.html +0 -250
- package/doc/classes/message.html +0 -326
- package/doc/classes/nonceaccount.html +0 -233
- package/doc/classes/publickey.html +0 -411
- package/doc/classes/secp256k1program.html +0 -308
- package/doc/classes/stakeinstruction.html +0 -403
- package/doc/classes/stakeprogram.html +0 -503
- package/doc/classes/systeminstruction.html +0 -563
- package/doc/classes/systemprogram.html +0 -503
- package/doc/classes/transaction.html +0 -688
- package/doc/classes/transactioninstruction.html +0 -240
- package/doc/classes/validatorinfo.html +0 -279
- package/doc/classes/voteaccount.html +0 -331
- package/doc/index.html +0 -640
- package/doc/interfaces/feecalculator.html +0 -166
- package/doc/modules.html +0 -4682
- package/examples/README.md +0 -10
- package/examples/account.html +0 -24
- package/examples/account.js +0 -10
- package/examples/bpf-c-noop/.gitignore +0 -1
- package/examples/bpf-c-noop/makefile +0 -1
- package/examples/bpf-c-noop/src/noop/noop.c +0 -19
- package/examples/bpf-rust-noop/.gitignore +0 -3
- package/examples/bpf-rust-noop/Cargo.toml +0 -23
- package/examples/bpf-rust-noop/Xargo.toml +0 -2
- package/examples/bpf-rust-noop/src/lib.rs +0 -70
- package/examples/get-balance.html +0 -37
- 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 =
|
|
276
|
+
this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
|
|
255
277
|
} else {
|
|
256
|
-
this._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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
467
|
-
const numReadonlySignedAccounts = byteArray
|
|
468
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
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
|
|
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
|
|
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
|
|
534
|
+
const programIdIndex = guardedShift(byteArray);
|
|
485
535
|
const accountCount = decodeLength(byteArray);
|
|
486
|
-
const accounts = byteArray
|
|
487
|
-
byteArray = byteArray.slice(accountCount);
|
|
536
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
488
537
|
const dataLength = decodeLength(byteArray);
|
|
489
|
-
const dataSlice = byteArray
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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:
|
|
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:
|
|
1649
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('programId')])
|
|
1603
1650
|
},
|
|
1604
1651
|
Transfer: {
|
|
1605
1652
|
index: 2,
|
|
1606
|
-
layout:
|
|
1653
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
|
|
1607
1654
|
},
|
|
1608
1655
|
CreateWithSeed: {
|
|
1609
1656
|
index: 3,
|
|
1610
|
-
layout:
|
|
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:
|
|
1661
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
|
|
1615
1662
|
},
|
|
1616
1663
|
WithdrawNonceAccount: {
|
|
1617
1664
|
index: 5,
|
|
1618
|
-
layout:
|
|
1665
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
|
|
1619
1666
|
},
|
|
1620
1667
|
InitializeNonceAccount: {
|
|
1621
1668
|
index: 6,
|
|
1622
|
-
layout:
|
|
1669
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('authorized')])
|
|
1623
1670
|
},
|
|
1624
1671
|
AuthorizeNonceAccount: {
|
|
1625
1672
|
index: 7,
|
|
1626
|
-
layout:
|
|
1673
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('authorized')])
|
|
1627
1674
|
},
|
|
1628
1675
|
Allocate: {
|
|
1629
1676
|
index: 8,
|
|
1630
|
-
layout:
|
|
1677
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('space')])
|
|
1631
1678
|
},
|
|
1632
1679
|
AllocateWithSeed: {
|
|
1633
1680
|
index: 9,
|
|
1634
|
-
layout:
|
|
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:
|
|
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:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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:
|
|
5083
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), authorized(), lockup()])
|
|
5037
5084
|
},
|
|
5038
5085
|
Authorize: {
|
|
5039
5086
|
index: 1,
|
|
5040
|
-
layout:
|
|
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:
|
|
5091
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
|
|
5045
5092
|
},
|
|
5046
5093
|
Split: {
|
|
5047
5094
|
index: 3,
|
|
5048
|
-
layout:
|
|
5095
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
|
|
5049
5096
|
},
|
|
5050
5097
|
Withdraw: {
|
|
5051
5098
|
index: 4,
|
|
5052
|
-
layout:
|
|
5099
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
|
|
5053
5100
|
},
|
|
5054
5101
|
Deactivate: {
|
|
5055
5102
|
index: 5,
|
|
5056
|
-
layout:
|
|
5103
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
|
|
5057
5104
|
},
|
|
5058
5105
|
AuthorizeWithSeed: {
|
|
5059
5106
|
index: 8,
|
|
5060
|
-
layout:
|
|
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 =
|
|
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
|
|
5685
|
-
|
|
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 =
|
|
5716
|
-
|
|
5717
|
-
|
|
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
|