@solana/web3.js 1.61.1 → 1.62.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.d.ts CHANGED
@@ -29,7 +29,6 @@ declare module '@solana/web3.js' {
29
29
  export type PublicKeyInitData =
30
30
  | number
31
31
  | string
32
- | Buffer
33
32
  | Uint8Array
34
33
  | Array<number>
35
34
  | PublicKeyData;
@@ -1578,6 +1577,8 @@ declare module '@solana/web3.js' {
1578
1577
  get version(): 0;
1579
1578
  get numAccountKeysFromLookups(): number;
1580
1579
  getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys;
1580
+ isAccountSigner(index: number): boolean;
1581
+ isAccountWritable(index: number): boolean;
1581
1582
  resolveAddressTableLookups(
1582
1583
  addressLookupTableAccounts: AddressLookupTableAccount[],
1583
1584
  ): 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: [],
@@ -3529,7 +3562,7 @@ class AddressLookupTableAccount {
3529
3562
  }
3530
3563
 
3531
3564
  isActive() {
3532
- const U64_MAX = 18446744073709551615n;
3565
+ const U64_MAX = BigInt('0xffffffffffffffff');
3533
3566
  return this.state.deactivationSlot === U64_MAX;
3534
3567
  }
3535
3568