@solana/web3.js 1.76.0 → 1.77.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 +58 -27
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +58 -27
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +58 -27
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +15 -9
- package/lib/index.esm.js +58 -27
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +58 -27
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +58 -27
- package/lib/index.native.js.map +1 -1
- package/package.json +3 -3
- package/src/connection.ts +30 -8
- package/src/loader.ts +34 -3
- package/src/programs/vote.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.77.1",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -108,11 +108,11 @@
|
|
|
108
108
|
"eslint-plugin-prettier": "^4.2.1",
|
|
109
109
|
"esm": "^3.2.25",
|
|
110
110
|
"mocha": "^10.1.0",
|
|
111
|
-
"mockttp": "^3.
|
|
111
|
+
"mockttp": "^3.7.5",
|
|
112
112
|
"mz": "^2.7.0",
|
|
113
113
|
"node-abort-controller": "^3.0.1",
|
|
114
114
|
"prettier": "^2.3.0",
|
|
115
|
-
"rimraf": "
|
|
115
|
+
"rimraf": "5.0.1",
|
|
116
116
|
"rollup": "^3.20.2",
|
|
117
117
|
"rollup-plugin-dts": "^5.3.0",
|
|
118
118
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
package/src/connection.ts
CHANGED
|
@@ -2685,8 +2685,16 @@ export type GetProgramAccountsConfig = {
|
|
|
2685
2685
|
filters?: GetProgramAccountsFilter[];
|
|
2686
2686
|
/** The minimum slot that the request can be evaluated at */
|
|
2687
2687
|
minContextSlot?: number;
|
|
2688
|
+
/** wrap the result in an RpcResponse JSON object */
|
|
2689
|
+
withContext?: boolean;
|
|
2688
2690
|
};
|
|
2689
2691
|
|
|
2692
|
+
export type GetProgramAccountsResponse = readonly Readonly<{
|
|
2693
|
+
account: AccountInfo<Buffer>;
|
|
2694
|
+
/** the account Pubkey as base-58 encoded string */
|
|
2695
|
+
pubkey: PublicKey;
|
|
2696
|
+
}>[];
|
|
2697
|
+
|
|
2690
2698
|
/**
|
|
2691
2699
|
* Configuration object for getParsedProgramAccounts
|
|
2692
2700
|
*/
|
|
@@ -3336,17 +3344,13 @@ export class Connection {
|
|
|
3336
3344
|
/**
|
|
3337
3345
|
* Fetch all the token accounts owned by the specified account
|
|
3338
3346
|
*
|
|
3339
|
-
* @return {Promise<RpcResponseAndContext<
|
|
3347
|
+
* @return {Promise<RpcResponseAndContext<GetProgramAccountsResponse>}
|
|
3340
3348
|
*/
|
|
3341
3349
|
async getTokenAccountsByOwner(
|
|
3342
3350
|
ownerAddress: PublicKey,
|
|
3343
3351
|
filter: TokenAccountsFilter,
|
|
3344
3352
|
commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig,
|
|
3345
|
-
): Promise<
|
|
3346
|
-
RpcResponseAndContext<
|
|
3347
|
-
Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}>
|
|
3348
|
-
>
|
|
3349
|
-
> {
|
|
3353
|
+
): Promise<RpcResponseAndContext<GetProgramAccountsResponse>> {
|
|
3350
3354
|
const {commitment, config} =
|
|
3351
3355
|
extractCommitmentFromConfig(commitmentOrConfig);
|
|
3352
3356
|
let _args: any[] = [ownerAddress.toBase58()];
|
|
@@ -3621,10 +3625,24 @@ export class Connection {
|
|
|
3621
3625
|
*
|
|
3622
3626
|
* @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>}
|
|
3623
3627
|
*/
|
|
3628
|
+
async getProgramAccounts(
|
|
3629
|
+
programId: PublicKey,
|
|
3630
|
+
configOrCommitment?: GetProgramAccountsConfig &
|
|
3631
|
+
Readonly<{withContext: true}>,
|
|
3632
|
+
): Promise<RpcResponseAndContext<GetProgramAccountsResponse>>;
|
|
3633
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
3624
3634
|
async getProgramAccounts(
|
|
3625
3635
|
programId: PublicKey,
|
|
3626
3636
|
configOrCommitment?: GetProgramAccountsConfig | Commitment,
|
|
3627
|
-
): Promise<
|
|
3637
|
+
): Promise<GetProgramAccountsResponse>;
|
|
3638
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
3639
|
+
async getProgramAccounts(
|
|
3640
|
+
programId: PublicKey,
|
|
3641
|
+
configOrCommitment?: GetProgramAccountsConfig | Commitment,
|
|
3642
|
+
): Promise<
|
|
3643
|
+
| GetProgramAccountsResponse
|
|
3644
|
+
| RpcResponseAndContext<GetProgramAccountsResponse>
|
|
3645
|
+
> {
|
|
3628
3646
|
const {commitment, config} =
|
|
3629
3647
|
extractCommitmentFromConfig(configOrCommitment);
|
|
3630
3648
|
const {encoding, ...configWithoutEncoding} = config || {};
|
|
@@ -3635,7 +3653,11 @@ export class Connection {
|
|
|
3635
3653
|
configWithoutEncoding,
|
|
3636
3654
|
);
|
|
3637
3655
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
3638
|
-
const
|
|
3656
|
+
const baseSchema = array(KeyedAccountInfoResult);
|
|
3657
|
+
const res =
|
|
3658
|
+
configWithoutEncoding.withContext === true
|
|
3659
|
+
? create(unsafeRes, jsonRpcResultAndContext(baseSchema))
|
|
3660
|
+
: create(unsafeRes, jsonRpcResult(baseSchema));
|
|
3639
3661
|
if ('error' in res) {
|
|
3640
3662
|
throw new SolanaJSONRPCError(
|
|
3641
3663
|
res.error,
|
package/src/loader.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as BufferLayout from '@solana/buffer-layout';
|
|
|
3
3
|
|
|
4
4
|
import {PublicKey} from './publickey';
|
|
5
5
|
import {Transaction, PACKET_DATA_SIZE} from './transaction';
|
|
6
|
+
import {MS_PER_SLOT} from './timing';
|
|
6
7
|
import {SYSVAR_RENT_PUBKEY} from './sysvar';
|
|
7
8
|
import {sendAndConfirmTransaction} from './utils/send-and-confirm-transaction';
|
|
8
9
|
import {sleep} from './utils/sleep';
|
|
@@ -220,14 +221,44 @@ export class Loader {
|
|
|
220
221
|
programId,
|
|
221
222
|
data,
|
|
222
223
|
});
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
const deployCommitment = 'processed';
|
|
225
|
+
const finalizeSignature = await connection.sendTransaction(
|
|
225
226
|
transaction,
|
|
226
227
|
[payer, program],
|
|
228
|
+
{preflightCommitment: deployCommitment},
|
|
229
|
+
);
|
|
230
|
+
const {context, value} = await connection.confirmTransaction(
|
|
227
231
|
{
|
|
228
|
-
|
|
232
|
+
signature: finalizeSignature,
|
|
233
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight!,
|
|
234
|
+
blockhash: transaction.recentBlockhash!,
|
|
229
235
|
},
|
|
236
|
+
deployCommitment,
|
|
230
237
|
);
|
|
238
|
+
if (value.err) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Transaction ${finalizeSignature} failed (${JSON.stringify(value)})`,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
// We prevent programs from being usable until the slot after their deployment.
|
|
244
|
+
// See https://github.com/solana-labs/solana/pull/29654
|
|
245
|
+
while (
|
|
246
|
+
true // eslint-disable-line no-constant-condition
|
|
247
|
+
) {
|
|
248
|
+
try {
|
|
249
|
+
const currentSlot = await connection.getSlot({
|
|
250
|
+
commitment: deployCommitment,
|
|
251
|
+
});
|
|
252
|
+
if (currentSlot > context.slot) {
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
} catch {
|
|
256
|
+
/* empty */
|
|
257
|
+
}
|
|
258
|
+
await new Promise(resolve =>
|
|
259
|
+
setTimeout(resolve, Math.round(MS_PER_SLOT / 2)),
|
|
260
|
+
);
|
|
261
|
+
}
|
|
231
262
|
}
|
|
232
263
|
|
|
233
264
|
// success
|
package/src/programs/vote.ts
CHANGED
|
@@ -366,8 +366,10 @@ export class VoteProgram {
|
|
|
366
366
|
* This is generated from the solana-vote-program VoteState struct as
|
|
367
367
|
* `VoteState::size_of()`:
|
|
368
368
|
* https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
|
|
369
|
+
*
|
|
370
|
+
* KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342
|
|
369
371
|
*/
|
|
370
|
-
static space: number = 3731;
|
|
372
|
+
static space: number = process.env.TEST_LIVE ? 3762 : 3731;
|
|
371
373
|
|
|
372
374
|
/**
|
|
373
375
|
* Generate an Initialize instruction.
|