@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.
@@ -805,7 +805,17 @@ class Message {
805
805
  }
806
806
 
807
807
  isAccountWritable(index) {
808
- return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
808
+ const numSignedAccounts = this.header.numRequiredSignatures;
809
+
810
+ if (index >= this.header.numRequiredSignatures) {
811
+ const unsignedAccountIndex = index - numSignedAccounts;
812
+ const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;
813
+ const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
814
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
815
+ } else {
816
+ const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;
817
+ return index < numWritableSignedAccounts;
818
+ }
809
819
  }
810
820
 
811
821
  isProgramId(index) {
@@ -978,6 +988,29 @@ class MessageV0 {
978
988
  return new MessageAccountKeys(this.staticAccountKeys, accountKeysFromLookups);
979
989
  }
980
990
 
991
+ isAccountSigner(index) {
992
+ return index < this.header.numRequiredSignatures;
993
+ }
994
+
995
+ isAccountWritable(index) {
996
+ const numSignedAccounts = this.header.numRequiredSignatures;
997
+ const numStaticAccountKeys = this.staticAccountKeys.length;
998
+
999
+ if (index >= numStaticAccountKeys) {
1000
+ const lookupAccountKeysIndex = index - numStaticAccountKeys;
1001
+ const numWritableLookupAccountKeys = this.addressTableLookups.reduce((count, lookup) => count + lookup.writableIndexes.length, 0);
1002
+ return lookupAccountKeysIndex < numWritableLookupAccountKeys;
1003
+ } else if (index >= this.header.numRequiredSignatures) {
1004
+ const unsignedAccountIndex = index - numSignedAccounts;
1005
+ const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;
1006
+ const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
1007
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
1008
+ } else {
1009
+ const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;
1010
+ return index < numWritableSignedAccounts;
1011
+ }
1012
+ }
1013
+
981
1014
  resolveAddressTableLookups(addressLookupTableAccounts) {
982
1015
  const accountKeysFromLookups = {
983
1016
  writable: [],