@solana/web3.js 1.67.2 → 1.68.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 +171 -49
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +171 -49
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +171 -49
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +127 -1
- package/lib/index.esm.js +171 -49
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +171 -49
- 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 +171 -49
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +324 -64
package/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import type {Struct} from 'superstruct';
|
|
24
24
|
import {Client as RpcWebSocketClient} from 'rpc-websockets';
|
|
25
25
|
import RpcClient from 'jayson/lib/client/browser';
|
|
26
|
+
import {JSONRPCError} from 'jayson';
|
|
26
27
|
|
|
27
28
|
import {AgentManager} from './agent-manager';
|
|
28
29
|
import {EpochSchedule} from './epoch-schedule';
|
|
@@ -517,6 +518,18 @@ export type GetBalanceConfig = {
|
|
|
517
518
|
export type GetBlockConfig = {
|
|
518
519
|
/** The level of finality desired */
|
|
519
520
|
commitment?: Finality;
|
|
521
|
+
/**
|
|
522
|
+
* Whether to populate the rewards array. If parameter not provided, the default includes rewards.
|
|
523
|
+
*/
|
|
524
|
+
rewards?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
|
|
527
|
+
* parameter not provided, the default detail level is "full". If "accounts" are requested,
|
|
528
|
+
* transaction details only include signatures and an annotated list of accounts in each
|
|
529
|
+
* transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
|
|
530
|
+
* pre_token_balances, and post_token_balances.
|
|
531
|
+
*/
|
|
532
|
+
transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
|
|
520
533
|
};
|
|
521
534
|
|
|
522
535
|
/**
|
|
@@ -527,6 +540,18 @@ export type GetVersionedBlockConfig = {
|
|
|
527
540
|
commitment?: Finality;
|
|
528
541
|
/** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
|
|
529
542
|
maxSupportedTransactionVersion?: number;
|
|
543
|
+
/**
|
|
544
|
+
* Whether to populate the rewards array. If parameter not provided, the default includes rewards.
|
|
545
|
+
*/
|
|
546
|
+
rewards?: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
|
|
549
|
+
* parameter not provided, the default detail level is "full". If "accounts" are requested,
|
|
550
|
+
* transaction details only include signatures and an annotated list of accounts in each
|
|
551
|
+
* transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
|
|
552
|
+
* pre_token_balances, and post_token_balances.
|
|
553
|
+
*/
|
|
554
|
+
transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
|
|
530
555
|
};
|
|
531
556
|
|
|
532
557
|
/**
|
|
@@ -1172,6 +1197,16 @@ export type BlockResponse = {
|
|
|
1172
1197
|
blockTime: number | null;
|
|
1173
1198
|
};
|
|
1174
1199
|
|
|
1200
|
+
/**
|
|
1201
|
+
* A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
|
|
1202
|
+
*/
|
|
1203
|
+
export type AccountsModeBlockResponse = VersionedAccountsModeBlockResponse;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
|
|
1207
|
+
*/
|
|
1208
|
+
export type NoneModeBlockResponse = VersionedNoneModeBlockResponse;
|
|
1209
|
+
|
|
1175
1210
|
/**
|
|
1176
1211
|
* A block with parsed transactions
|
|
1177
1212
|
*/
|
|
@@ -1208,6 +1243,33 @@ export type ParsedBlockResponse = {
|
|
|
1208
1243
|
blockHeight: number | null;
|
|
1209
1244
|
};
|
|
1210
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* A block with parsed transactions where the `transactionDetails` mode is `accounts`
|
|
1248
|
+
*/
|
|
1249
|
+
export type ParsedAccountsModeBlockResponse = Omit<
|
|
1250
|
+
ParsedBlockResponse,
|
|
1251
|
+
'transactions'
|
|
1252
|
+
> & {
|
|
1253
|
+
transactions: Array<
|
|
1254
|
+
Omit<ParsedBlockResponse['transactions'][number], 'transaction'> & {
|
|
1255
|
+
transaction: Pick<
|
|
1256
|
+
ParsedBlockResponse['transactions'][number]['transaction'],
|
|
1257
|
+
'signatures'
|
|
1258
|
+
> & {
|
|
1259
|
+
accountKeys: ParsedMessageAccount[];
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
>;
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* A block with parsed transactions where the `transactionDetails` mode is `none`
|
|
1267
|
+
*/
|
|
1268
|
+
export type ParsedNoneModeBlockResponse = Omit<
|
|
1269
|
+
ParsedBlockResponse,
|
|
1270
|
+
'transactions'
|
|
1271
|
+
>;
|
|
1272
|
+
|
|
1211
1273
|
/**
|
|
1212
1274
|
* A processed block fetched from the RPC API
|
|
1213
1275
|
*/
|
|
@@ -1247,6 +1309,33 @@ export type VersionedBlockResponse = {
|
|
|
1247
1309
|
blockTime: number | null;
|
|
1248
1310
|
};
|
|
1249
1311
|
|
|
1312
|
+
/**
|
|
1313
|
+
* A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
|
|
1314
|
+
*/
|
|
1315
|
+
export type VersionedAccountsModeBlockResponse = Omit<
|
|
1316
|
+
VersionedBlockResponse,
|
|
1317
|
+
'transactions'
|
|
1318
|
+
> & {
|
|
1319
|
+
transactions: Array<
|
|
1320
|
+
Omit<VersionedBlockResponse['transactions'][number], 'transaction'> & {
|
|
1321
|
+
transaction: Pick<
|
|
1322
|
+
VersionedBlockResponse['transactions'][number]['transaction'],
|
|
1323
|
+
'signatures'
|
|
1324
|
+
> & {
|
|
1325
|
+
accountKeys: ParsedMessageAccount[];
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
>;
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
|
|
1333
|
+
*/
|
|
1334
|
+
export type VersionedNoneModeBlockResponse = Omit<
|
|
1335
|
+
VersionedBlockResponse,
|
|
1336
|
+
'transactions'
|
|
1337
|
+
>;
|
|
1338
|
+
|
|
1250
1339
|
/**
|
|
1251
1340
|
* A confirmed block on the ledger
|
|
1252
1341
|
*
|
|
@@ -1980,6 +2069,18 @@ const ConfirmedTransactionResult = pick({
|
|
|
1980
2069
|
}),
|
|
1981
2070
|
});
|
|
1982
2071
|
|
|
2072
|
+
const AnnotatedAccountKey = pick({
|
|
2073
|
+
pubkey: PublicKeyFromString,
|
|
2074
|
+
signer: boolean(),
|
|
2075
|
+
writable: boolean(),
|
|
2076
|
+
source: optional(union([literal('transaction'), literal('lookupTable')])),
|
|
2077
|
+
});
|
|
2078
|
+
|
|
2079
|
+
const ConfirmedTransactionAccountsModeResult = pick({
|
|
2080
|
+
accountKeys: array(AnnotatedAccountKey),
|
|
2081
|
+
signatures: array(string()),
|
|
2082
|
+
});
|
|
2083
|
+
|
|
1983
2084
|
const ParsedInstructionResult = pick({
|
|
1984
2085
|
parsed: unknown(),
|
|
1985
2086
|
program: string(),
|
|
@@ -2028,16 +2129,7 @@ const ParsedOrRawInstruction = coerce(
|
|
|
2028
2129
|
const ParsedConfirmedTransactionResult = pick({
|
|
2029
2130
|
signatures: array(string()),
|
|
2030
2131
|
message: pick({
|
|
2031
|
-
accountKeys: array(
|
|
2032
|
-
pick({
|
|
2033
|
-
pubkey: PublicKeyFromString,
|
|
2034
|
-
signer: boolean(),
|
|
2035
|
-
writable: boolean(),
|
|
2036
|
-
source: optional(
|
|
2037
|
-
union([literal('transaction'), literal('lookupTable')]),
|
|
2038
|
-
),
|
|
2039
|
-
}),
|
|
2040
|
-
),
|
|
2132
|
+
accountKeys: array(AnnotatedAccountKey),
|
|
2041
2133
|
instructions: array(ParsedOrRawInstruction),
|
|
2042
2134
|
recentBlockhash: string(),
|
|
2043
2135
|
addressTableLookups: optional(nullable(array(AddressTableLookupStruct))),
|
|
@@ -2114,6 +2206,14 @@ const ParsedConfirmedTransactionMetaResult = pick({
|
|
|
2114
2206
|
|
|
2115
2207
|
const TransactionVersionStruct = union([literal(0), literal('legacy')]);
|
|
2116
2208
|
|
|
2209
|
+
/** @internal */
|
|
2210
|
+
const RewardsResult = pick({
|
|
2211
|
+
pubkey: string(),
|
|
2212
|
+
lamports: number(),
|
|
2213
|
+
postBalance: nullable(number()),
|
|
2214
|
+
rewardType: nullable(string()),
|
|
2215
|
+
});
|
|
2216
|
+
|
|
2117
2217
|
/**
|
|
2118
2218
|
* Expected JSON RPC response for the "getBlock" message
|
|
2119
2219
|
*/
|
|
@@ -2130,16 +2230,46 @@ const GetBlockRpcResult = jsonRpcResult(
|
|
|
2130
2230
|
version: optional(TransactionVersionStruct),
|
|
2131
2231
|
}),
|
|
2132
2232
|
),
|
|
2133
|
-
rewards: optional(
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2233
|
+
rewards: optional(array(RewardsResult)),
|
|
2234
|
+
blockTime: nullable(number()),
|
|
2235
|
+
blockHeight: nullable(number()),
|
|
2236
|
+
}),
|
|
2237
|
+
),
|
|
2238
|
+
);
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
2242
|
+
*/
|
|
2243
|
+
const GetNoneModeBlockRpcResult = jsonRpcResult(
|
|
2244
|
+
nullable(
|
|
2245
|
+
pick({
|
|
2246
|
+
blockhash: string(),
|
|
2247
|
+
previousBlockhash: string(),
|
|
2248
|
+
parentSlot: number(),
|
|
2249
|
+
rewards: optional(array(RewardsResult)),
|
|
2250
|
+
blockTime: nullable(number()),
|
|
2251
|
+
blockHeight: nullable(number()),
|
|
2252
|
+
}),
|
|
2253
|
+
),
|
|
2254
|
+
);
|
|
2255
|
+
|
|
2256
|
+
/**
|
|
2257
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
2258
|
+
*/
|
|
2259
|
+
const GetAccountsModeBlockRpcResult = jsonRpcResult(
|
|
2260
|
+
nullable(
|
|
2261
|
+
pick({
|
|
2262
|
+
blockhash: string(),
|
|
2263
|
+
previousBlockhash: string(),
|
|
2264
|
+
parentSlot: number(),
|
|
2265
|
+
transactions: array(
|
|
2266
|
+
pick({
|
|
2267
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
2268
|
+
meta: nullable(ConfirmedTransactionMetaResult),
|
|
2269
|
+
version: optional(TransactionVersionStruct),
|
|
2270
|
+
}),
|
|
2142
2271
|
),
|
|
2272
|
+
rewards: optional(array(RewardsResult)),
|
|
2143
2273
|
blockTime: nullable(number()),
|
|
2144
2274
|
blockHeight: nullable(number()),
|
|
2145
2275
|
}),
|
|
@@ -2162,16 +2292,46 @@ const GetParsedBlockRpcResult = jsonRpcResult(
|
|
|
2162
2292
|
version: optional(TransactionVersionStruct),
|
|
2163
2293
|
}),
|
|
2164
2294
|
),
|
|
2165
|
-
rewards: optional(
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2295
|
+
rewards: optional(array(RewardsResult)),
|
|
2296
|
+
blockTime: nullable(number()),
|
|
2297
|
+
blockHeight: nullable(number()),
|
|
2298
|
+
}),
|
|
2299
|
+
),
|
|
2300
|
+
);
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
2304
|
+
*/
|
|
2305
|
+
const GetParsedAccountsModeBlockRpcResult = jsonRpcResult(
|
|
2306
|
+
nullable(
|
|
2307
|
+
pick({
|
|
2308
|
+
blockhash: string(),
|
|
2309
|
+
previousBlockhash: string(),
|
|
2310
|
+
parentSlot: number(),
|
|
2311
|
+
transactions: array(
|
|
2312
|
+
pick({
|
|
2313
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
2314
|
+
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
2315
|
+
version: optional(TransactionVersionStruct),
|
|
2316
|
+
}),
|
|
2174
2317
|
),
|
|
2318
|
+
rewards: optional(array(RewardsResult)),
|
|
2319
|
+
blockTime: nullable(number()),
|
|
2320
|
+
blockHeight: nullable(number()),
|
|
2321
|
+
}),
|
|
2322
|
+
),
|
|
2323
|
+
);
|
|
2324
|
+
|
|
2325
|
+
/**
|
|
2326
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
2327
|
+
*/
|
|
2328
|
+
const GetParsedNoneModeBlockRpcResult = jsonRpcResult(
|
|
2329
|
+
nullable(
|
|
2330
|
+
pick({
|
|
2331
|
+
blockhash: string(),
|
|
2332
|
+
previousBlockhash: string(),
|
|
2333
|
+
parentSlot: number(),
|
|
2334
|
+
rewards: optional(array(RewardsResult)),
|
|
2175
2335
|
blockTime: nullable(number()),
|
|
2176
2336
|
blockHeight: nullable(number()),
|
|
2177
2337
|
}),
|
|
@@ -2195,16 +2355,7 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(
|
|
|
2195
2355
|
meta: nullable(ConfirmedTransactionMetaResult),
|
|
2196
2356
|
}),
|
|
2197
2357
|
),
|
|
2198
|
-
rewards: optional(
|
|
2199
|
-
array(
|
|
2200
|
-
pick({
|
|
2201
|
-
pubkey: string(),
|
|
2202
|
-
lamports: number(),
|
|
2203
|
-
postBalance: nullable(number()),
|
|
2204
|
-
rewardType: nullable(string()),
|
|
2205
|
-
}),
|
|
2206
|
-
),
|
|
2207
|
-
),
|
|
2358
|
+
rewards: optional(array(RewardsResult)),
|
|
2208
2359
|
blockTime: nullable(number()),
|
|
2209
2360
|
}),
|
|
2210
2361
|
),
|
|
@@ -3561,7 +3712,7 @@ export class Connection {
|
|
|
3561
3712
|
disposeSignatureSubscriptionStateChangeObserver();
|
|
3562
3713
|
disposeSignatureSubscriptionStateChangeObserver = undefined;
|
|
3563
3714
|
}
|
|
3564
|
-
if (signatureSubscriptionId) {
|
|
3715
|
+
if (signatureSubscriptionId != null) {
|
|
3565
3716
|
this.removeSignatureListener(signatureSubscriptionId);
|
|
3566
3717
|
signatureSubscriptionId = undefined;
|
|
3567
3718
|
}
|
|
@@ -4261,6 +4412,26 @@ export class Connection {
|
|
|
4261
4412
|
rawConfig?: GetBlockConfig,
|
|
4262
4413
|
): Promise<BlockResponse | null>;
|
|
4263
4414
|
|
|
4415
|
+
/**
|
|
4416
|
+
* @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
|
|
4417
|
+
* setting the `maxSupportedTransactionVersion` property.
|
|
4418
|
+
*/
|
|
4419
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4420
|
+
async getBlock(
|
|
4421
|
+
slot: number,
|
|
4422
|
+
rawConfig: GetBlockConfig & {transactionDetails: 'accounts'},
|
|
4423
|
+
): Promise<AccountsModeBlockResponse | null>;
|
|
4424
|
+
|
|
4425
|
+
/**
|
|
4426
|
+
* @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
|
|
4427
|
+
* setting the `maxSupportedTransactionVersion` property.
|
|
4428
|
+
*/
|
|
4429
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4430
|
+
async getBlock(
|
|
4431
|
+
slot: number,
|
|
4432
|
+
rawConfig: GetBlockConfig & {transactionDetails: 'none'},
|
|
4433
|
+
): Promise<NoneModeBlockResponse | null>;
|
|
4434
|
+
|
|
4264
4435
|
/**
|
|
4265
4436
|
* Fetch a processed block from the cluster.
|
|
4266
4437
|
*/
|
|
@@ -4270,6 +4441,18 @@ export class Connection {
|
|
|
4270
4441
|
rawConfig?: GetVersionedBlockConfig,
|
|
4271
4442
|
): Promise<VersionedBlockResponse | null>;
|
|
4272
4443
|
|
|
4444
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4445
|
+
async getBlock(
|
|
4446
|
+
slot: number,
|
|
4447
|
+
rawConfig: GetVersionedBlockConfig & {transactionDetails: 'accounts'},
|
|
4448
|
+
): Promise<VersionedAccountsModeBlockResponse | null>;
|
|
4449
|
+
|
|
4450
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4451
|
+
async getBlock(
|
|
4452
|
+
slot: number,
|
|
4453
|
+
rawConfig: GetVersionedBlockConfig & {transactionDetails: 'none'},
|
|
4454
|
+
): Promise<VersionedNoneModeBlockResponse | null>;
|
|
4455
|
+
|
|
4273
4456
|
/**
|
|
4274
4457
|
* Fetch a processed block from the cluster.
|
|
4275
4458
|
*/
|
|
@@ -4277,7 +4460,12 @@ export class Connection {
|
|
|
4277
4460
|
async getBlock(
|
|
4278
4461
|
slot: number,
|
|
4279
4462
|
rawConfig?: GetVersionedBlockConfig,
|
|
4280
|
-
): Promise<
|
|
4463
|
+
): Promise<
|
|
4464
|
+
| VersionedBlockResponse
|
|
4465
|
+
| VersionedAccountsModeBlockResponse
|
|
4466
|
+
| VersionedNoneModeBlockResponse
|
|
4467
|
+
| null
|
|
4468
|
+
> {
|
|
4281
4469
|
const {commitment, config} = extractCommitmentFromConfig(rawConfig);
|
|
4282
4470
|
const args = this._buildArgsAtLeastConfirmed(
|
|
4283
4471
|
[slot],
|
|
@@ -4286,26 +4474,54 @@ export class Connection {
|
|
|
4286
4474
|
config,
|
|
4287
4475
|
);
|
|
4288
4476
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4477
|
+
try {
|
|
4478
|
+
switch (config?.transactionDetails) {
|
|
4479
|
+
case 'accounts': {
|
|
4480
|
+
const res = create(unsafeRes, GetAccountsModeBlockRpcResult);
|
|
4481
|
+
if ('error' in res) {
|
|
4482
|
+
throw res.error;
|
|
4483
|
+
}
|
|
4484
|
+
return res.result;
|
|
4485
|
+
}
|
|
4486
|
+
case 'none': {
|
|
4487
|
+
const res = create(unsafeRes, GetNoneModeBlockRpcResult);
|
|
4488
|
+
if ('error' in res) {
|
|
4489
|
+
throw res.error;
|
|
4490
|
+
}
|
|
4491
|
+
return res.result;
|
|
4492
|
+
}
|
|
4493
|
+
default: {
|
|
4494
|
+
const res = create(unsafeRes, GetBlockRpcResult);
|
|
4495
|
+
if ('error' in res) {
|
|
4496
|
+
throw res.error;
|
|
4497
|
+
}
|
|
4498
|
+
const {result} = res;
|
|
4499
|
+
return result
|
|
4500
|
+
? {
|
|
4501
|
+
...result,
|
|
4502
|
+
transactions: result.transactions.map(
|
|
4503
|
+
({transaction, meta, version}) => ({
|
|
4504
|
+
meta,
|
|
4505
|
+
transaction: {
|
|
4506
|
+
...transaction,
|
|
4507
|
+
message: versionedMessageFromResponse(
|
|
4508
|
+
version,
|
|
4509
|
+
transaction.message,
|
|
4510
|
+
),
|
|
4511
|
+
},
|
|
4512
|
+
version,
|
|
4513
|
+
}),
|
|
4514
|
+
),
|
|
4515
|
+
}
|
|
4516
|
+
: null;
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
} catch (e) {
|
|
4520
|
+
throw new SolanaJSONRPCError(
|
|
4521
|
+
e as JSONRPCError,
|
|
4522
|
+
'failed to get confirmed block',
|
|
4523
|
+
);
|
|
4293
4524
|
}
|
|
4294
|
-
|
|
4295
|
-
const result = res.result;
|
|
4296
|
-
if (!result) return result;
|
|
4297
|
-
|
|
4298
|
-
return {
|
|
4299
|
-
...result,
|
|
4300
|
-
transactions: result.transactions.map(({transaction, meta, version}) => ({
|
|
4301
|
-
meta,
|
|
4302
|
-
transaction: {
|
|
4303
|
-
...transaction,
|
|
4304
|
-
message: versionedMessageFromResponse(version, transaction.message),
|
|
4305
|
-
},
|
|
4306
|
-
version,
|
|
4307
|
-
})),
|
|
4308
|
-
};
|
|
4309
4525
|
}
|
|
4310
4526
|
|
|
4311
4527
|
/**
|
|
@@ -4314,7 +4530,29 @@ export class Connection {
|
|
|
4314
4530
|
async getParsedBlock(
|
|
4315
4531
|
slot: number,
|
|
4316
4532
|
rawConfig?: GetVersionedBlockConfig,
|
|
4317
|
-
): Promise<
|
|
4533
|
+
): Promise<ParsedAccountsModeBlockResponse>;
|
|
4534
|
+
|
|
4535
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4536
|
+
async getParsedBlock(
|
|
4537
|
+
slot: number,
|
|
4538
|
+
rawConfig: GetVersionedBlockConfig & {transactionDetails: 'accounts'},
|
|
4539
|
+
): Promise<ParsedAccountsModeBlockResponse>;
|
|
4540
|
+
|
|
4541
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4542
|
+
async getParsedBlock(
|
|
4543
|
+
slot: number,
|
|
4544
|
+
rawConfig: GetVersionedBlockConfig & {transactionDetails: 'none'},
|
|
4545
|
+
): Promise<ParsedNoneModeBlockResponse>;
|
|
4546
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
4547
|
+
async getParsedBlock(
|
|
4548
|
+
slot: number,
|
|
4549
|
+
rawConfig?: GetVersionedBlockConfig,
|
|
4550
|
+
): Promise<
|
|
4551
|
+
| ParsedBlockResponse
|
|
4552
|
+
| ParsedAccountsModeBlockResponse
|
|
4553
|
+
| ParsedNoneModeBlockResponse
|
|
4554
|
+
| null
|
|
4555
|
+
> {
|
|
4318
4556
|
const {commitment, config} = extractCommitmentFromConfig(rawConfig);
|
|
4319
4557
|
const args = this._buildArgsAtLeastConfirmed(
|
|
4320
4558
|
[slot],
|
|
@@ -4323,11 +4561,33 @@ export class Connection {
|
|
|
4323
4561
|
config,
|
|
4324
4562
|
);
|
|
4325
4563
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4564
|
+
try {
|
|
4565
|
+
switch (config?.transactionDetails) {
|
|
4566
|
+
case 'accounts': {
|
|
4567
|
+
const res = create(unsafeRes, GetParsedAccountsModeBlockRpcResult);
|
|
4568
|
+
if ('error' in res) {
|
|
4569
|
+
throw res.error;
|
|
4570
|
+
}
|
|
4571
|
+
return res.result;
|
|
4572
|
+
}
|
|
4573
|
+
case 'none': {
|
|
4574
|
+
const res = create(unsafeRes, GetParsedNoneModeBlockRpcResult);
|
|
4575
|
+
if ('error' in res) {
|
|
4576
|
+
throw res.error;
|
|
4577
|
+
}
|
|
4578
|
+
return res.result;
|
|
4579
|
+
}
|
|
4580
|
+
default: {
|
|
4581
|
+
const res = create(unsafeRes, GetParsedBlockRpcResult);
|
|
4582
|
+
if ('error' in res) {
|
|
4583
|
+
throw res.error;
|
|
4584
|
+
}
|
|
4585
|
+
return res.result;
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
} catch (e) {
|
|
4589
|
+
throw new SolanaJSONRPCError(e as JSONRPCError, 'failed to get block');
|
|
4329
4590
|
}
|
|
4330
|
-
return res.result;
|
|
4331
4591
|
}
|
|
4332
4592
|
|
|
4333
4593
|
/*
|