@solana/web3.js 1.90.0 → 1.90.2
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.browser.cjs.js +66 -37
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +66 -37
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +66 -37
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.esm.js +66 -37
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +476 -116
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +8 -7
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +66 -37
- package/lib/index.native.js.map +1 -1
- package/package.json +28 -27
- package/src/message/legacy.ts +9 -12
- package/src/message/v0.ts +29 -12
- package/src/programs/stake.ts +22 -5
- package/src/transaction/legacy.ts +2 -2
- package/src/transaction/versioned.ts +2 -1
- package/src/utils/guarded-array-utils.ts +34 -0
- package/src/validator-info.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.90.
|
|
3
|
+
"version": "1.90.2",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -36,27 +36,10 @@
|
|
|
36
36
|
"/lib",
|
|
37
37
|
"/src"
|
|
38
38
|
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"compile:docs": "typedoc --treatWarningsAsErrors",
|
|
41
|
-
"compile:js": "cross-env NODE_ENV=production rollup -c",
|
|
42
|
-
"compile:typedefs": "./scripts/typegen.sh",
|
|
43
|
-
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
|
44
|
-
"clean": "rimraf ./doc ./declarations ./lib",
|
|
45
|
-
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
46
|
-
"publish-packages": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
47
|
-
"test:lint": "eslint src/ test/ --ext .js,.ts",
|
|
48
|
-
"test:lint:fix": "eslint src/ test/ --fix --ext .js,.ts",
|
|
49
|
-
"test:live": "TEST_LIVE=1 pnpm run test:unit:node",
|
|
50
|
-
"test:live-with-test-validator": "start-server-and-test '../../scripts/start-shared-test-validator.sh' http://127.0.0.1:8899/health test:live",
|
|
51
|
-
"test:prettier": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
52
|
-
"test:prettier:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
53
|
-
"test:typecheck": "tsc --noEmit",
|
|
54
|
-
"test:unit:node": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'"
|
|
55
|
-
},
|
|
56
39
|
"dependencies": {
|
|
57
40
|
"@babel/runtime": "^7.23.4",
|
|
58
41
|
"@noble/curves": "^1.2.0",
|
|
59
|
-
"@noble/hashes": "^1.3.
|
|
42
|
+
"@noble/hashes": "^1.3.3",
|
|
60
43
|
"@solana/buffer-layout": "^4.0.1",
|
|
61
44
|
"agentkeepalive": "^4.5.0",
|
|
62
45
|
"bigint-buffer": "^1.1.5",
|
|
@@ -87,7 +70,7 @@
|
|
|
87
70
|
"@rollup/plugin-replace": "^5.0.2",
|
|
88
71
|
"@rollup/plugin-terser": "^0.4.3",
|
|
89
72
|
"@solana/spl-token": "^0.4.0",
|
|
90
|
-
"@types/bn.js": "^5.1.
|
|
73
|
+
"@types/bn.js": "^5.1.5",
|
|
91
74
|
"@types/bs58": "^4.0.1",
|
|
92
75
|
"@types/chai": "^4.3.5",
|
|
93
76
|
"@types/chai-as-promised": "^7.1.8",
|
|
@@ -98,7 +81,7 @@
|
|
|
98
81
|
"@types/node-fetch": "2",
|
|
99
82
|
"@types/sinon": "^10.0.16",
|
|
100
83
|
"@types/sinon-chai": "^3.2.12",
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
102
85
|
"@typescript-eslint/parser": "^6.3.0",
|
|
103
86
|
"chai": "^4.3.7",
|
|
104
87
|
"chai-as-promised": "^7.1.1",
|
|
@@ -109,8 +92,8 @@
|
|
|
109
92
|
"eslint-plugin-mocha": "^10.1.0",
|
|
110
93
|
"eslint-plugin-prettier": "^5.0.1",
|
|
111
94
|
"esm": "^3.2.25",
|
|
112
|
-
"mocha": "^10.
|
|
113
|
-
"mockttp": "^3.10.
|
|
95
|
+
"mocha": "^10.3.0",
|
|
96
|
+
"mockttp": "^3.10.1",
|
|
114
97
|
"mz": "^2.7.0",
|
|
115
98
|
"node-abort-controller": "^3.0.1",
|
|
116
99
|
"prettier": "^3.1",
|
|
@@ -121,12 +104,30 @@
|
|
|
121
104
|
"semantic-release": "^21.0.7",
|
|
122
105
|
"sinon": "^15.2.0",
|
|
123
106
|
"sinon-chai": "^3.7.0",
|
|
124
|
-
"start-server-and-test": "^2.0.
|
|
107
|
+
"start-server-and-test": "^2.0.3",
|
|
125
108
|
"ts-mocha": "^10.0.0",
|
|
126
109
|
"ts-node": "^10.9.1",
|
|
127
|
-
"tsconfig": "workspace:*",
|
|
128
110
|
"tslib": "^2.6.2",
|
|
129
111
|
"typedoc": "^0.25.4",
|
|
130
|
-
"typescript": "^5.1.6"
|
|
112
|
+
"typescript": "^5.1.6",
|
|
113
|
+
"@solana/tsconfig": "0.0.0"
|
|
114
|
+
},
|
|
115
|
+
"scripts": {
|
|
116
|
+
"compile:docs": "typedoc --treatWarningsAsErrors",
|
|
117
|
+
"compile:js": "cross-env NODE_ENV=production rollup -c",
|
|
118
|
+
"compile:typedefs": "./scripts/typegen.sh",
|
|
119
|
+
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
|
120
|
+
"clean": "rimraf ./doc ./declarations ./lib",
|
|
121
|
+
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
122
|
+
"publish-impl": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
123
|
+
"publish-packages": "pnpm publish-impl",
|
|
124
|
+
"test:lint": "eslint src/ test/ --ext .js,.ts",
|
|
125
|
+
"test:lint:fix": "eslint src/ test/ --fix --ext .js,.ts",
|
|
126
|
+
"test:live": "TEST_LIVE=1 pnpm run test:unit:node",
|
|
127
|
+
"test:live-with-test-validator": "start-server-and-test '../../scripts/start-shared-test-validator.sh' http://127.0.0.1:8899/health test:live",
|
|
128
|
+
"test:prettier": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
129
|
+
"test:prettier:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
130
|
+
"test:typecheck": "tsc --noEmit",
|
|
131
|
+
"test:unit:node": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'"
|
|
131
132
|
}
|
|
132
|
-
}
|
|
133
|
+
}
|
package/src/message/legacy.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import {TransactionInstruction} from '../transaction';
|
|
17
17
|
import {CompiledKeys} from './compiled-keys';
|
|
18
18
|
import {MessageAccountKeys} from './account-keys';
|
|
19
|
+
import {guardedShift, guardedSplice} from '../utils/guarded-array-utils';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* An instruction to execute by a program
|
|
@@ -268,7 +269,7 @@ export class Message {
|
|
|
268
269
|
// Slice up wire data
|
|
269
270
|
let byteArray = [...buffer];
|
|
270
271
|
|
|
271
|
-
const numRequiredSignatures = byteArray
|
|
272
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
272
273
|
if (
|
|
273
274
|
numRequiredSignatures !==
|
|
274
275
|
(numRequiredSignatures & VERSION_PREFIX_MASK)
|
|
@@ -278,31 +279,27 @@ export class Message {
|
|
|
278
279
|
);
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
const numReadonlySignedAccounts = byteArray
|
|
282
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
282
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
283
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
283
284
|
|
|
284
285
|
const accountCount = shortvec.decodeLength(byteArray);
|
|
285
286
|
let accountKeys = [];
|
|
286
287
|
for (let i = 0; i < accountCount; i++) {
|
|
287
|
-
const account = byteArray
|
|
288
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
288
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
289
289
|
accountKeys.push(new PublicKey(Buffer.from(account)));
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
const recentBlockhash = byteArray
|
|
293
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
292
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
294
293
|
|
|
295
294
|
const instructionCount = shortvec.decodeLength(byteArray);
|
|
296
295
|
let instructions: CompiledInstruction[] = [];
|
|
297
296
|
for (let i = 0; i < instructionCount; i++) {
|
|
298
|
-
const programIdIndex = byteArray
|
|
297
|
+
const programIdIndex = guardedShift(byteArray);
|
|
299
298
|
const accountCount = shortvec.decodeLength(byteArray);
|
|
300
|
-
const accounts = byteArray
|
|
301
|
-
byteArray = byteArray.slice(accountCount);
|
|
299
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
302
300
|
const dataLength = shortvec.decodeLength(byteArray);
|
|
303
|
-
const dataSlice = byteArray
|
|
301
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
304
302
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
305
|
-
byteArray = byteArray.slice(dataLength);
|
|
306
303
|
instructions.push({
|
|
307
304
|
programIdIndex,
|
|
308
305
|
accounts,
|
package/src/message/v0.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {TransactionInstruction} from '../transaction';
|
|
|
16
16
|
import {AddressLookupTableAccount} from '../programs';
|
|
17
17
|
import {CompiledKeys} from './compiled-keys';
|
|
18
18
|
import {AccountKeysFromLookups, MessageAccountKeys} from './account-keys';
|
|
19
|
+
import {guardedShift, guardedSplice} from '../utils/guarded-array-utils';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Message constructor arguments
|
|
@@ -426,7 +427,7 @@ export class MessageV0 {
|
|
|
426
427
|
static deserialize(serializedMessage: Uint8Array): MessageV0 {
|
|
427
428
|
let byteArray = [...serializedMessage];
|
|
428
429
|
|
|
429
|
-
const prefix = byteArray
|
|
430
|
+
const prefix = guardedShift(byteArray);
|
|
430
431
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
431
432
|
assert(
|
|
432
433
|
prefix !== maskedPrefix,
|
|
@@ -440,29 +441,35 @@ export class MessageV0 {
|
|
|
440
441
|
);
|
|
441
442
|
|
|
442
443
|
const header: MessageHeader = {
|
|
443
|
-
numRequiredSignatures: byteArray
|
|
444
|
-
numReadonlySignedAccounts: byteArray
|
|
445
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
444
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
445
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
446
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray),
|
|
446
447
|
};
|
|
447
448
|
|
|
448
449
|
const staticAccountKeys = [];
|
|
449
450
|
const staticAccountKeysLength = shortvec.decodeLength(byteArray);
|
|
450
451
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
451
452
|
staticAccountKeys.push(
|
|
452
|
-
new PublicKey(byteArray
|
|
453
|
+
new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)),
|
|
453
454
|
);
|
|
454
455
|
}
|
|
455
456
|
|
|
456
|
-
const recentBlockhash = bs58.encode(
|
|
457
|
+
const recentBlockhash = bs58.encode(
|
|
458
|
+
guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),
|
|
459
|
+
);
|
|
457
460
|
|
|
458
461
|
const instructionCount = shortvec.decodeLength(byteArray);
|
|
459
462
|
const compiledInstructions: MessageCompiledInstruction[] = [];
|
|
460
463
|
for (let i = 0; i < instructionCount; i++) {
|
|
461
|
-
const programIdIndex = byteArray
|
|
464
|
+
const programIdIndex = guardedShift(byteArray);
|
|
462
465
|
const accountKeyIndexesLength = shortvec.decodeLength(byteArray);
|
|
463
|
-
const accountKeyIndexes =
|
|
466
|
+
const accountKeyIndexes = guardedSplice(
|
|
467
|
+
byteArray,
|
|
468
|
+
0,
|
|
469
|
+
accountKeyIndexesLength,
|
|
470
|
+
);
|
|
464
471
|
const dataLength = shortvec.decodeLength(byteArray);
|
|
465
|
-
const data = new Uint8Array(byteArray
|
|
472
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
466
473
|
compiledInstructions.push({
|
|
467
474
|
programIdIndex,
|
|
468
475
|
accountKeyIndexes,
|
|
@@ -473,11 +480,21 @@ export class MessageV0 {
|
|
|
473
480
|
const addressTableLookupsCount = shortvec.decodeLength(byteArray);
|
|
474
481
|
const addressTableLookups: MessageAddressTableLookup[] = [];
|
|
475
482
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
476
|
-
const accountKey = new PublicKey(
|
|
483
|
+
const accountKey = new PublicKey(
|
|
484
|
+
guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),
|
|
485
|
+
);
|
|
477
486
|
const writableIndexesLength = shortvec.decodeLength(byteArray);
|
|
478
|
-
const writableIndexes =
|
|
487
|
+
const writableIndexes = guardedSplice(
|
|
488
|
+
byteArray,
|
|
489
|
+
0,
|
|
490
|
+
writableIndexesLength,
|
|
491
|
+
);
|
|
479
492
|
const readonlyIndexesLength = shortvec.decodeLength(byteArray);
|
|
480
|
-
const readonlyIndexes =
|
|
493
|
+
const readonlyIndexes = guardedSplice(
|
|
494
|
+
byteArray,
|
|
495
|
+
0,
|
|
496
|
+
readonlyIndexesLength,
|
|
497
|
+
);
|
|
481
498
|
addressTableLookups.push({
|
|
482
499
|
accountKey,
|
|
483
500
|
writableIndexes,
|
package/src/programs/stake.ts
CHANGED
|
@@ -601,8 +601,8 @@ export class StakeProgram {
|
|
|
601
601
|
* Max space of a Stake account
|
|
602
602
|
*
|
|
603
603
|
* This is generated from the solana-stake-program StakeState struct as
|
|
604
|
-
* `
|
|
605
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
604
|
+
* `StakeStateV2::size_of()`:
|
|
605
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
606
606
|
*/
|
|
607
607
|
static space: number = 200;
|
|
608
608
|
|
|
@@ -808,13 +808,17 @@ export class StakeProgram {
|
|
|
808
808
|
/**
|
|
809
809
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
810
810
|
*/
|
|
811
|
-
static split(
|
|
811
|
+
static split(
|
|
812
|
+
params: SplitStakeParams,
|
|
813
|
+
// Compute the cost of allocating the new stake account in lamports
|
|
814
|
+
rentExemptReserve: number,
|
|
815
|
+
): Transaction {
|
|
812
816
|
const transaction = new Transaction();
|
|
813
817
|
transaction.add(
|
|
814
818
|
SystemProgram.createAccount({
|
|
815
819
|
fromPubkey: params.authorizedPubkey,
|
|
816
820
|
newAccountPubkey: params.splitStakePubkey,
|
|
817
|
-
lamports:
|
|
821
|
+
lamports: rentExemptReserve,
|
|
818
822
|
space: this.space,
|
|
819
823
|
programId: this.programId,
|
|
820
824
|
}),
|
|
@@ -826,7 +830,11 @@ export class StakeProgram {
|
|
|
826
830
|
* Generate a Transaction that splits Stake tokens into another account
|
|
827
831
|
* derived from a base public key and seed
|
|
828
832
|
*/
|
|
829
|
-
static splitWithSeed(
|
|
833
|
+
static splitWithSeed(
|
|
834
|
+
params: SplitStakeWithSeedParams,
|
|
835
|
+
// If this stake account is new, compute the cost of allocating it in lamports
|
|
836
|
+
rentExemptReserve?: number,
|
|
837
|
+
): Transaction {
|
|
830
838
|
const {
|
|
831
839
|
stakePubkey,
|
|
832
840
|
authorizedPubkey,
|
|
@@ -845,6 +853,15 @@ export class StakeProgram {
|
|
|
845
853
|
programId: this.programId,
|
|
846
854
|
}),
|
|
847
855
|
);
|
|
856
|
+
if (rentExemptReserve && rentExemptReserve > 0) {
|
|
857
|
+
transaction.add(
|
|
858
|
+
SystemProgram.transfer({
|
|
859
|
+
fromPubkey: params.authorizedPubkey,
|
|
860
|
+
toPubkey: splitStakePubkey,
|
|
861
|
+
lamports: rentExemptReserve,
|
|
862
|
+
}),
|
|
863
|
+
);
|
|
864
|
+
}
|
|
848
865
|
return transaction.add(
|
|
849
866
|
this.splitInstruction({
|
|
850
867
|
stakePubkey,
|
|
@@ -12,6 +12,7 @@ import type {Signer} from '../keypair';
|
|
|
12
12
|
import type {Blockhash} from '../blockhash';
|
|
13
13
|
import type {CompiledInstruction} from '../message';
|
|
14
14
|
import {sign, verify} from '../utils/ed25519';
|
|
15
|
+
import {guardedSplice} from '../utils/guarded-array-utils';
|
|
15
16
|
|
|
16
17
|
/** @internal */
|
|
17
18
|
type MessageSignednessErrors = {
|
|
@@ -904,8 +905,7 @@ export class Transaction {
|
|
|
904
905
|
const signatureCount = shortvec.decodeLength(byteArray);
|
|
905
906
|
let signatures = [];
|
|
906
907
|
for (let i = 0; i < signatureCount; i++) {
|
|
907
|
-
const signature = byteArray
|
|
908
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
908
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
909
909
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
910
910
|
}
|
|
911
911
|
|
|
@@ -8,6 +8,7 @@ import * as shortvec from '../utils/shortvec-encoding';
|
|
|
8
8
|
import * as Layout from '../layout';
|
|
9
9
|
import {sign} from '../utils/ed25519';
|
|
10
10
|
import {PublicKey} from '../publickey';
|
|
11
|
+
import {guardedSplice} from '../utils/guarded-array-utils';
|
|
11
12
|
|
|
12
13
|
export type TransactionVersion = 'legacy' | 0;
|
|
13
14
|
|
|
@@ -82,7 +83,7 @@ export class VersionedTransaction {
|
|
|
82
83
|
const signaturesLength = shortvec.decodeLength(byteArray);
|
|
83
84
|
for (let i = 0; i < signaturesLength; i++) {
|
|
84
85
|
signatures.push(
|
|
85
|
-
new Uint8Array(byteArray
|
|
86
|
+
new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)),
|
|
86
87
|
);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
5
|
+
*/
|
|
6
|
+
export function guardedShift<T>(byteArray: T[]): T {
|
|
7
|
+
if (byteArray.length === 0) {
|
|
8
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
9
|
+
}
|
|
10
|
+
return byteArray.shift() as T;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
15
|
+
* the array.
|
|
16
|
+
*/
|
|
17
|
+
export function guardedSplice<T>(
|
|
18
|
+
byteArray: T[],
|
|
19
|
+
...args:
|
|
20
|
+
| [start: number, deleteCount?: number]
|
|
21
|
+
| [start: number, deleteCount: number, ...items: T[]]
|
|
22
|
+
): T[] {
|
|
23
|
+
const [start] = args;
|
|
24
|
+
if (
|
|
25
|
+
args.length === 2 // Implies that `deleteCount` was supplied
|
|
26
|
+
? start + (args[1] ?? 0) > byteArray.length
|
|
27
|
+
: start >= byteArray.length
|
|
28
|
+
) {
|
|
29
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
30
|
+
}
|
|
31
|
+
return byteArray.splice(
|
|
32
|
+
...(args as Parameters<typeof Array.prototype.splice>),
|
|
33
|
+
);
|
|
34
|
+
}
|
package/src/validator-info.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import * as Layout from './layout';
|
|
10
10
|
import * as shortvec from './utils/shortvec-encoding';
|
|
11
11
|
import {PublicKey, PUBLIC_KEY_LENGTH} from './publickey';
|
|
12
|
+
import {guardedShift, guardedSplice} from './utils/guarded-array-utils';
|
|
12
13
|
|
|
13
14
|
export const VALIDATOR_INFO_KEY = new PublicKey(
|
|
14
15
|
'Va1idator1nfo111111111111111111111111111111',
|
|
@@ -83,10 +84,10 @@ export class ValidatorInfo {
|
|
|
83
84
|
|
|
84
85
|
const configKeys: Array<ConfigKey> = [];
|
|
85
86
|
for (let i = 0; i < 2; i++) {
|
|
86
|
-
const publicKey = new PublicKey(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const publicKey = new PublicKey(
|
|
88
|
+
guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),
|
|
89
|
+
);
|
|
90
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
90
91
|
configKeys.push({publicKey, isSigner});
|
|
91
92
|
}
|
|
92
93
|
|