@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.61.1",
3
+ "version": "1.62.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -130,14 +130,18 @@ export class Message {
130
130
  }
131
131
 
132
132
  isAccountWritable(index: number): boolean {
133
- return (
134
- index <
135
- this.header.numRequiredSignatures -
136
- this.header.numReadonlySignedAccounts ||
137
- (index >= this.header.numRequiredSignatures &&
138
- index <
139
- this.accountKeys.length - this.header.numReadonlyUnsignedAccounts)
140
- );
133
+ const numSignedAccounts = this.header.numRequiredSignatures;
134
+ if (index >= this.header.numRequiredSignatures) {
135
+ const unsignedAccountIndex = index - numSignedAccounts;
136
+ const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;
137
+ const numWritableUnsignedAccounts =
138
+ numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
139
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
140
+ } else {
141
+ const numWritableSignedAccounts =
142
+ numSignedAccounts - this.header.numReadonlySignedAccounts;
143
+ return index < numWritableSignedAccounts;
144
+ }
141
145
  }
142
146
 
143
147
  isProgramId(index: number): boolean {
package/src/message/v0.ts CHANGED
@@ -103,6 +103,33 @@ export class MessageV0 {
103
103
  );
104
104
  }
105
105
 
106
+ isAccountSigner(index: number): boolean {
107
+ return index < this.header.numRequiredSignatures;
108
+ }
109
+
110
+ isAccountWritable(index: number): boolean {
111
+ const numSignedAccounts = this.header.numRequiredSignatures;
112
+ const numStaticAccountKeys = this.staticAccountKeys.length;
113
+ if (index >= numStaticAccountKeys) {
114
+ const lookupAccountKeysIndex = index - numStaticAccountKeys;
115
+ const numWritableLookupAccountKeys = this.addressTableLookups.reduce(
116
+ (count, lookup) => count + lookup.writableIndexes.length,
117
+ 0,
118
+ );
119
+ return lookupAccountKeysIndex < numWritableLookupAccountKeys;
120
+ } else if (index >= this.header.numRequiredSignatures) {
121
+ const unsignedAccountIndex = index - numSignedAccounts;
122
+ const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;
123
+ const numWritableUnsignedAccounts =
124
+ numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;
125
+ return unsignedAccountIndex < numWritableUnsignedAccounts;
126
+ } else {
127
+ const numWritableSignedAccounts =
128
+ numSignedAccounts - this.header.numReadonlySignedAccounts;
129
+ return index < numWritableSignedAccounts;
130
+ }
131
+ }
132
+
106
133
  resolveAddressTableLookups(
107
134
  addressLookupTableAccounts: AddressLookupTableAccount[],
108
135
  ): AccountKeysFromLookups {