@solana/web3.js 1.75.0 → 1.75.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/lib/index.browser.cjs.js +53 -36
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +53 -36
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +53 -36
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +53 -36
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +53 -36
- 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/index.native.js +53 -36
- package/lib/index.native.js.map +1 -1
- package/package.json +21 -21
- package/src/message/legacy.ts +9 -12
- package/src/message/v0.ts +29 -12
- 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/lib/index.esm.js
CHANGED
|
@@ -609,8 +609,8 @@ class CompiledKeys {
|
|
|
609
609
|
getOrInsertDefault(ix.programId).isInvoked = true;
|
|
610
610
|
for (const accountMeta of ix.keys) {
|
|
611
611
|
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
612
|
-
keyMeta.isSigner
|
|
613
|
-
keyMeta.isWritable
|
|
612
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
613
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -675,6 +675,31 @@ class CompiledKeys {
|
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
+
const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Delegates to `Array#shift`, but throws if the array is zero-length.
|
|
682
|
+
*/
|
|
683
|
+
function guardedShift(byteArray) {
|
|
684
|
+
if (byteArray.length === 0) {
|
|
685
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
686
|
+
}
|
|
687
|
+
return byteArray.shift();
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
|
|
692
|
+
* the array.
|
|
693
|
+
*/
|
|
694
|
+
function guardedSplice(byteArray, ...args) {
|
|
695
|
+
const [start] = args;
|
|
696
|
+
if (args.length === 2 // Implies that `deleteCount` was supplied
|
|
697
|
+
? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {
|
|
698
|
+
throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
|
|
699
|
+
}
|
|
700
|
+
return byteArray.splice(...args);
|
|
701
|
+
}
|
|
702
|
+
|
|
678
703
|
/**
|
|
679
704
|
* An instruction to execute by a program
|
|
680
705
|
*
|
|
@@ -812,32 +837,28 @@ class Message {
|
|
|
812
837
|
static from(buffer) {
|
|
813
838
|
// Slice up wire data
|
|
814
839
|
let byteArray = [...buffer];
|
|
815
|
-
const numRequiredSignatures = byteArray
|
|
840
|
+
const numRequiredSignatures = guardedShift(byteArray);
|
|
816
841
|
if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
|
|
817
842
|
throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
|
|
818
843
|
}
|
|
819
|
-
const numReadonlySignedAccounts = byteArray
|
|
820
|
-
const numReadonlyUnsignedAccounts = byteArray
|
|
844
|
+
const numReadonlySignedAccounts = guardedShift(byteArray);
|
|
845
|
+
const numReadonlyUnsignedAccounts = guardedShift(byteArray);
|
|
821
846
|
const accountCount = decodeLength(byteArray);
|
|
822
847
|
let accountKeys = [];
|
|
823
848
|
for (let i = 0; i < accountCount; i++) {
|
|
824
|
-
const account = byteArray
|
|
825
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
849
|
+
const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
826
850
|
accountKeys.push(new PublicKey(Buffer.from(account)));
|
|
827
851
|
}
|
|
828
|
-
const recentBlockhash = byteArray
|
|
829
|
-
byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
|
|
852
|
+
const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
|
|
830
853
|
const instructionCount = decodeLength(byteArray);
|
|
831
854
|
let instructions = [];
|
|
832
855
|
for (let i = 0; i < instructionCount; i++) {
|
|
833
|
-
const programIdIndex = byteArray
|
|
856
|
+
const programIdIndex = guardedShift(byteArray);
|
|
834
857
|
const accountCount = decodeLength(byteArray);
|
|
835
|
-
const accounts = byteArray
|
|
836
|
-
byteArray = byteArray.slice(accountCount);
|
|
858
|
+
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
837
859
|
const dataLength = decodeLength(byteArray);
|
|
838
|
-
const dataSlice = byteArray
|
|
860
|
+
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
839
861
|
const data = bs58.encode(Buffer.from(dataSlice));
|
|
840
|
-
byteArray = byteArray.slice(dataLength);
|
|
841
862
|
instructions.push({
|
|
842
863
|
programIdIndex,
|
|
843
864
|
accounts,
|
|
@@ -1042,30 +1063,30 @@ class MessageV0 {
|
|
|
1042
1063
|
}
|
|
1043
1064
|
static deserialize(serializedMessage) {
|
|
1044
1065
|
let byteArray = [...serializedMessage];
|
|
1045
|
-
const prefix = byteArray
|
|
1066
|
+
const prefix = guardedShift(byteArray);
|
|
1046
1067
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK;
|
|
1047
1068
|
assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
|
|
1048
1069
|
const version = maskedPrefix;
|
|
1049
1070
|
assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);
|
|
1050
1071
|
const header = {
|
|
1051
|
-
numRequiredSignatures: byteArray
|
|
1052
|
-
numReadonlySignedAccounts: byteArray
|
|
1053
|
-
numReadonlyUnsignedAccounts: byteArray
|
|
1072
|
+
numRequiredSignatures: guardedShift(byteArray),
|
|
1073
|
+
numReadonlySignedAccounts: guardedShift(byteArray),
|
|
1074
|
+
numReadonlyUnsignedAccounts: guardedShift(byteArray)
|
|
1054
1075
|
};
|
|
1055
1076
|
const staticAccountKeys = [];
|
|
1056
1077
|
const staticAccountKeysLength = decodeLength(byteArray);
|
|
1057
1078
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1058
|
-
staticAccountKeys.push(new PublicKey(byteArray
|
|
1079
|
+
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1059
1080
|
}
|
|
1060
|
-
const recentBlockhash = bs58.encode(byteArray
|
|
1081
|
+
const recentBlockhash = bs58.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1061
1082
|
const instructionCount = decodeLength(byteArray);
|
|
1062
1083
|
const compiledInstructions = [];
|
|
1063
1084
|
for (let i = 0; i < instructionCount; i++) {
|
|
1064
|
-
const programIdIndex = byteArray
|
|
1085
|
+
const programIdIndex = guardedShift(byteArray);
|
|
1065
1086
|
const accountKeyIndexesLength = decodeLength(byteArray);
|
|
1066
|
-
const accountKeyIndexes = byteArray
|
|
1087
|
+
const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
|
|
1067
1088
|
const dataLength = decodeLength(byteArray);
|
|
1068
|
-
const data = new Uint8Array(byteArray
|
|
1089
|
+
const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
|
|
1069
1090
|
compiledInstructions.push({
|
|
1070
1091
|
programIdIndex,
|
|
1071
1092
|
accountKeyIndexes,
|
|
@@ -1075,11 +1096,11 @@ class MessageV0 {
|
|
|
1075
1096
|
const addressTableLookupsCount = decodeLength(byteArray);
|
|
1076
1097
|
const addressTableLookups = [];
|
|
1077
1098
|
for (let i = 0; i < addressTableLookupsCount; i++) {
|
|
1078
|
-
const accountKey = new PublicKey(byteArray
|
|
1099
|
+
const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1079
1100
|
const writableIndexesLength = decodeLength(byteArray);
|
|
1080
|
-
const writableIndexes = byteArray
|
|
1101
|
+
const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
|
|
1081
1102
|
const readonlyIndexesLength = decodeLength(byteArray);
|
|
1082
|
-
const readonlyIndexes = byteArray
|
|
1103
|
+
const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
|
|
1083
1104
|
addressTableLookups.push({
|
|
1084
1105
|
accountKey,
|
|
1085
1106
|
writableIndexes,
|
|
@@ -1754,8 +1775,7 @@ class Transaction {
|
|
|
1754
1775
|
const signatureCount = decodeLength(byteArray);
|
|
1755
1776
|
let signatures = [];
|
|
1756
1777
|
for (let i = 0; i < signatureCount; i++) {
|
|
1757
|
-
const signature = byteArray
|
|
1758
|
-
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
1778
|
+
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1759
1779
|
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
1760
1780
|
}
|
|
1761
1781
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -1925,7 +1945,7 @@ class VersionedTransaction {
|
|
|
1925
1945
|
const signatures = [];
|
|
1926
1946
|
const signaturesLength = decodeLength(byteArray);
|
|
1927
1947
|
for (let i = 0; i < signaturesLength; i++) {
|
|
1928
|
-
signatures.push(new Uint8Array(byteArray
|
|
1948
|
+
signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
|
|
1929
1949
|
}
|
|
1930
1950
|
const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
|
|
1931
1951
|
return new VersionedTransaction(message, signatures);
|
|
@@ -6925,7 +6945,7 @@ const LogsNotificationResult = type({
|
|
|
6925
6945
|
|
|
6926
6946
|
/** @internal */
|
|
6927
6947
|
const COMMON_HTTP_HEADERS = {
|
|
6928
|
-
'solana-client': `js/${"
|
|
6948
|
+
'solana-client': `js/${"1.75.1" }`
|
|
6929
6949
|
};
|
|
6930
6950
|
|
|
6931
6951
|
/**
|
|
@@ -9154,12 +9174,11 @@ class Connection {
|
|
|
9154
9174
|
* @internal
|
|
9155
9175
|
*/
|
|
9156
9176
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
9157
|
-
var _this$_subscriptionSt;
|
|
9158
9177
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
9159
9178
|
if (hash == null) {
|
|
9160
9179
|
return () => {};
|
|
9161
9180
|
}
|
|
9162
|
-
const stateChangeCallbacks =
|
|
9181
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
9163
9182
|
stateChangeCallbacks.add(callback);
|
|
9164
9183
|
return () => {
|
|
9165
9184
|
stateChangeCallbacks.delete(callback);
|
|
@@ -11720,10 +11739,8 @@ class ValidatorInfo {
|
|
|
11720
11739
|
if (configKeyCount !== 2) return null;
|
|
11721
11740
|
const configKeys = [];
|
|
11722
11741
|
for (let i = 0; i < 2; i++) {
|
|
11723
|
-
const publicKey = new PublicKey(byteArray
|
|
11724
|
-
|
|
11725
|
-
const isSigner = byteArray.slice(0, 1)[0] === 1;
|
|
11726
|
-
byteArray = byteArray.slice(1);
|
|
11742
|
+
const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
11743
|
+
const isSigner = guardedShift(byteArray) === 1;
|
|
11727
11744
|
configKeys.push({
|
|
11728
11745
|
publicKey,
|
|
11729
11746
|
isSigner
|