@solana/web3.js 1.61.1 → 1.62.0

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.d.ts CHANGED
@@ -1578,6 +1578,8 @@ declare module '@solana/web3.js' {
1578
1578
  get version(): 0;
1579
1579
  get numAccountKeysFromLookups(): number;
1580
1580
  getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys;
1581
+ isAccountSigner(index: number): boolean;
1582
+ isAccountWritable(index: number): boolean;
1581
1583
  resolveAddressTableLookups(
1582
1584
  addressLookupTableAccounts: AddressLookupTableAccount[],
1583
1585
  ): AccountKeysFromLookups;
package/lib/index.esm.js CHANGED
@@ -808,7 +808,17 @@ class Message {
808
808
  }
809
809
 
810
810
  isAccountWritable(index) {
811
- return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
811
+ const numSignedAccounts = this.header.numRequiredSignatures;
812
+
813
+ if (index >= this.header.numRequiredSignatures) {
814
+ const unsignedAccountIndex = index - numSignedAccounts;
815
+ const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;
816
+ const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
817
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
818
+ } else {
819
+ const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;
820
+ return index < numWritableSignedAccounts;
821
+ }
812
822
  }
813
823
 
814
824
  isProgramId(index) {
@@ -981,6 +991,29 @@ class MessageV0 {
981
991
  return new MessageAccountKeys(this.staticAccountKeys, accountKeysFromLookups);
982
992
  }
983
993
 
994
+ isAccountSigner(index) {
995
+ return index < this.header.numRequiredSignatures;
996
+ }
997
+
998
+ isAccountWritable(index) {
999
+ const numSignedAccounts = this.header.numRequiredSignatures;
1000
+ const numStaticAccountKeys = this.staticAccountKeys.length;
1001
+
1002
+ if (index >= numStaticAccountKeys) {
1003
+ const lookupAccountKeysIndex = index - numStaticAccountKeys;
1004
+ const numWritableLookupAccountKeys = this.addressTableLookups.reduce((count, lookup) => count + lookup.writableIndexes.length, 0);
1005
+ return lookupAccountKeysIndex < numWritableLookupAccountKeys;
1006
+ } else if (index >= this.header.numRequiredSignatures) {
1007
+ const unsignedAccountIndex = index - numSignedAccounts;
1008
+ const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;
1009
+ const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
1010
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
1011
+ } else {
1012
+ const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;
1013
+ return index < numWritableSignedAccounts;
1014
+ }
1015
+ }
1016
+
984
1017
  resolveAddressTableLookups(addressLookupTableAccounts) {
985
1018
  const accountKeysFromLookups = {
986
1019
  writable: [],