@solana/web3.js 1.67.1 → 1.68.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/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 +128 -2
- 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 +325 -65
package/lib/index.native.js
CHANGED
|
@@ -4355,6 +4355,16 @@ const ConfirmedTransactionResult = superstruct.type({
|
|
|
4355
4355
|
addressTableLookups: superstruct.optional(superstruct.array(AddressTableLookupStruct))
|
|
4356
4356
|
})
|
|
4357
4357
|
});
|
|
4358
|
+
const AnnotatedAccountKey = superstruct.type({
|
|
4359
|
+
pubkey: PublicKeyFromString,
|
|
4360
|
+
signer: superstruct.boolean(),
|
|
4361
|
+
writable: superstruct.boolean(),
|
|
4362
|
+
source: superstruct.optional(superstruct.union([superstruct.literal('transaction'), superstruct.literal('lookupTable')]))
|
|
4363
|
+
});
|
|
4364
|
+
const ConfirmedTransactionAccountsModeResult = superstruct.type({
|
|
4365
|
+
accountKeys: superstruct.array(AnnotatedAccountKey),
|
|
4366
|
+
signatures: superstruct.array(superstruct.string())
|
|
4367
|
+
});
|
|
4358
4368
|
const ParsedInstructionResult = superstruct.type({
|
|
4359
4369
|
parsed: superstruct.unknown(),
|
|
4360
4370
|
program: superstruct.string(),
|
|
@@ -4389,12 +4399,7 @@ const ParsedOrRawInstruction = superstruct.coerce(InstructionResult, UnknownInst
|
|
|
4389
4399
|
const ParsedConfirmedTransactionResult = superstruct.type({
|
|
4390
4400
|
signatures: superstruct.array(superstruct.string()),
|
|
4391
4401
|
message: superstruct.type({
|
|
4392
|
-
accountKeys: superstruct.array(
|
|
4393
|
-
pubkey: PublicKeyFromString,
|
|
4394
|
-
signer: superstruct.boolean(),
|
|
4395
|
-
writable: superstruct.boolean(),
|
|
4396
|
-
source: superstruct.optional(superstruct.union([superstruct.literal('transaction'), superstruct.literal('lookupTable')]))
|
|
4397
|
-
})),
|
|
4402
|
+
accountKeys: superstruct.array(AnnotatedAccountKey),
|
|
4398
4403
|
instructions: superstruct.array(ParsedOrRawInstruction),
|
|
4399
4404
|
recentBlockhash: superstruct.string(),
|
|
4400
4405
|
addressTableLookups: superstruct.optional(superstruct.nullable(superstruct.array(AddressTableLookupStruct)))
|
|
@@ -4453,6 +4458,14 @@ const ParsedConfirmedTransactionMetaResult = superstruct.type({
|
|
|
4453
4458
|
computeUnitsConsumed: superstruct.optional(superstruct.number())
|
|
4454
4459
|
});
|
|
4455
4460
|
const TransactionVersionStruct = superstruct.union([superstruct.literal(0), superstruct.literal('legacy')]);
|
|
4461
|
+
/** @internal */
|
|
4462
|
+
|
|
4463
|
+
const RewardsResult = superstruct.type({
|
|
4464
|
+
pubkey: superstruct.string(),
|
|
4465
|
+
lamports: superstruct.number(),
|
|
4466
|
+
postBalance: superstruct.nullable(superstruct.number()),
|
|
4467
|
+
rewardType: superstruct.nullable(superstruct.string())
|
|
4468
|
+
});
|
|
4456
4469
|
/**
|
|
4457
4470
|
* Expected JSON RPC response for the "getBlock" message
|
|
4458
4471
|
*/
|
|
@@ -4466,12 +4479,36 @@ const GetBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
|
4466
4479
|
meta: superstruct.nullable(ConfirmedTransactionMetaResult),
|
|
4467
4480
|
version: superstruct.optional(TransactionVersionStruct)
|
|
4468
4481
|
})),
|
|
4469
|
-
rewards: superstruct.optional(superstruct.array(
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4482
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4483
|
+
blockTime: superstruct.nullable(superstruct.number()),
|
|
4484
|
+
blockHeight: superstruct.nullable(superstruct.number())
|
|
4485
|
+
})));
|
|
4486
|
+
/**
|
|
4487
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
4488
|
+
*/
|
|
4489
|
+
|
|
4490
|
+
const GetNoneModeBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
4491
|
+
blockhash: superstruct.string(),
|
|
4492
|
+
previousBlockhash: superstruct.string(),
|
|
4493
|
+
parentSlot: superstruct.number(),
|
|
4494
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4495
|
+
blockTime: superstruct.nullable(superstruct.number()),
|
|
4496
|
+
blockHeight: superstruct.nullable(superstruct.number())
|
|
4497
|
+
})));
|
|
4498
|
+
/**
|
|
4499
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
4500
|
+
*/
|
|
4501
|
+
|
|
4502
|
+
const GetAccountsModeBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
4503
|
+
blockhash: superstruct.string(),
|
|
4504
|
+
previousBlockhash: superstruct.string(),
|
|
4505
|
+
parentSlot: superstruct.number(),
|
|
4506
|
+
transactions: superstruct.array(superstruct.type({
|
|
4507
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
4508
|
+
meta: superstruct.nullable(ConfirmedTransactionMetaResult),
|
|
4509
|
+
version: superstruct.optional(TransactionVersionStruct)
|
|
4510
|
+
})),
|
|
4511
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4475
4512
|
blockTime: superstruct.nullable(superstruct.number()),
|
|
4476
4513
|
blockHeight: superstruct.nullable(superstruct.number())
|
|
4477
4514
|
})));
|
|
@@ -4488,12 +4525,36 @@ const GetParsedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.t
|
|
|
4488
4525
|
meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
|
|
4489
4526
|
version: superstruct.optional(TransactionVersionStruct)
|
|
4490
4527
|
})),
|
|
4491
|
-
rewards: superstruct.optional(superstruct.array(
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4528
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4529
|
+
blockTime: superstruct.nullable(superstruct.number()),
|
|
4530
|
+
blockHeight: superstruct.nullable(superstruct.number())
|
|
4531
|
+
})));
|
|
4532
|
+
/**
|
|
4533
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
4534
|
+
*/
|
|
4535
|
+
|
|
4536
|
+
const GetParsedAccountsModeBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
4537
|
+
blockhash: superstruct.string(),
|
|
4538
|
+
previousBlockhash: superstruct.string(),
|
|
4539
|
+
parentSlot: superstruct.number(),
|
|
4540
|
+
transactions: superstruct.array(superstruct.type({
|
|
4541
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
4542
|
+
meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
|
|
4543
|
+
version: superstruct.optional(TransactionVersionStruct)
|
|
4544
|
+
})),
|
|
4545
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4546
|
+
blockTime: superstruct.nullable(superstruct.number()),
|
|
4547
|
+
blockHeight: superstruct.nullable(superstruct.number())
|
|
4548
|
+
})));
|
|
4549
|
+
/**
|
|
4550
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
4551
|
+
*/
|
|
4552
|
+
|
|
4553
|
+
const GetParsedNoneModeBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
4554
|
+
blockhash: superstruct.string(),
|
|
4555
|
+
previousBlockhash: superstruct.string(),
|
|
4556
|
+
parentSlot: superstruct.number(),
|
|
4557
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4497
4558
|
blockTime: superstruct.nullable(superstruct.number()),
|
|
4498
4559
|
blockHeight: superstruct.nullable(superstruct.number())
|
|
4499
4560
|
})));
|
|
@@ -4511,12 +4572,7 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruc
|
|
|
4511
4572
|
transaction: ConfirmedTransactionResult,
|
|
4512
4573
|
meta: superstruct.nullable(ConfirmedTransactionMetaResult)
|
|
4513
4574
|
})),
|
|
4514
|
-
rewards: superstruct.optional(superstruct.array(
|
|
4515
|
-
pubkey: superstruct.string(),
|
|
4516
|
-
lamports: superstruct.number(),
|
|
4517
|
-
postBalance: superstruct.nullable(superstruct.number()),
|
|
4518
|
-
rewardType: superstruct.nullable(superstruct.string())
|
|
4519
|
-
}))),
|
|
4575
|
+
rewards: superstruct.optional(superstruct.array(RewardsResult)),
|
|
4520
4576
|
blockTime: superstruct.nullable(superstruct.number())
|
|
4521
4577
|
})));
|
|
4522
4578
|
/**
|
|
@@ -6013,7 +6069,7 @@ class Connection {
|
|
|
6013
6069
|
|
|
6014
6070
|
|
|
6015
6071
|
async getFeeForMessage(message, commitment) {
|
|
6016
|
-
const wireMessage = message.serialize().toString('base64');
|
|
6072
|
+
const wireMessage = toBuffer(message.serialize()).toString('base64');
|
|
6017
6073
|
|
|
6018
6074
|
const args = this._buildArgs([wireMessage], commitment);
|
|
6019
6075
|
|
|
@@ -6138,33 +6194,67 @@ class Connection {
|
|
|
6138
6194
|
, config);
|
|
6139
6195
|
|
|
6140
6196
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
6141
|
-
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6142
6197
|
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6198
|
+
try {
|
|
6199
|
+
switch (config === null || config === void 0 ? void 0 : config.transactionDetails) {
|
|
6200
|
+
case 'accounts':
|
|
6201
|
+
{
|
|
6202
|
+
const res = superstruct.create(unsafeRes, GetAccountsModeBlockRpcResult);
|
|
6146
6203
|
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6204
|
+
if ('error' in res) {
|
|
6205
|
+
throw res.error;
|
|
6206
|
+
}
|
|
6207
|
+
|
|
6208
|
+
return res.result;
|
|
6209
|
+
}
|
|
6210
|
+
|
|
6211
|
+
case 'none':
|
|
6212
|
+
{
|
|
6213
|
+
const res = superstruct.create(unsafeRes, GetNoneModeBlockRpcResult);
|
|
6214
|
+
|
|
6215
|
+
if ('error' in res) {
|
|
6216
|
+
throw res.error;
|
|
6217
|
+
}
|
|
6218
|
+
|
|
6219
|
+
return res.result;
|
|
6220
|
+
}
|
|
6221
|
+
|
|
6222
|
+
default:
|
|
6223
|
+
{
|
|
6224
|
+
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6225
|
+
|
|
6226
|
+
if ('error' in res) {
|
|
6227
|
+
throw res.error;
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
const {
|
|
6231
|
+
result
|
|
6232
|
+
} = res;
|
|
6233
|
+
return result ? { ...result,
|
|
6234
|
+
transactions: result.transactions.map(({
|
|
6235
|
+
transaction,
|
|
6236
|
+
meta,
|
|
6237
|
+
version
|
|
6238
|
+
}) => ({
|
|
6239
|
+
meta,
|
|
6240
|
+
transaction: { ...transaction,
|
|
6241
|
+
message: versionedMessageFromResponse(version, transaction.message)
|
|
6242
|
+
},
|
|
6243
|
+
version
|
|
6244
|
+
}))
|
|
6245
|
+
} : null;
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6248
|
+
} catch (e) {
|
|
6249
|
+
throw new SolanaJSONRPCError(e, 'failed to get confirmed block');
|
|
6250
|
+
}
|
|
6162
6251
|
}
|
|
6163
6252
|
/**
|
|
6164
6253
|
* Fetch parsed transaction details for a confirmed or finalized block
|
|
6165
6254
|
*/
|
|
6166
6255
|
|
|
6167
6256
|
|
|
6257
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
6168
6258
|
async getParsedBlock(slot, rawConfig) {
|
|
6169
6259
|
const {
|
|
6170
6260
|
commitment,
|
|
@@ -6174,13 +6264,45 @@ class Connection {
|
|
|
6174
6264
|
const args = this._buildArgsAtLeastConfirmed([slot], commitment, 'jsonParsed', config);
|
|
6175
6265
|
|
|
6176
6266
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
6177
|
-
const res = superstruct.create(unsafeRes, GetParsedBlockRpcResult);
|
|
6178
6267
|
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6268
|
+
try {
|
|
6269
|
+
switch (config === null || config === void 0 ? void 0 : config.transactionDetails) {
|
|
6270
|
+
case 'accounts':
|
|
6271
|
+
{
|
|
6272
|
+
const res = superstruct.create(unsafeRes, GetParsedAccountsModeBlockRpcResult);
|
|
6182
6273
|
|
|
6183
|
-
|
|
6274
|
+
if ('error' in res) {
|
|
6275
|
+
throw res.error;
|
|
6276
|
+
}
|
|
6277
|
+
|
|
6278
|
+
return res.result;
|
|
6279
|
+
}
|
|
6280
|
+
|
|
6281
|
+
case 'none':
|
|
6282
|
+
{
|
|
6283
|
+
const res = superstruct.create(unsafeRes, GetParsedNoneModeBlockRpcResult);
|
|
6284
|
+
|
|
6285
|
+
if ('error' in res) {
|
|
6286
|
+
throw res.error;
|
|
6287
|
+
}
|
|
6288
|
+
|
|
6289
|
+
return res.result;
|
|
6290
|
+
}
|
|
6291
|
+
|
|
6292
|
+
default:
|
|
6293
|
+
{
|
|
6294
|
+
const res = superstruct.create(unsafeRes, GetParsedBlockRpcResult);
|
|
6295
|
+
|
|
6296
|
+
if ('error' in res) {
|
|
6297
|
+
throw res.error;
|
|
6298
|
+
}
|
|
6299
|
+
|
|
6300
|
+
return res.result;
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
} catch (e) {
|
|
6304
|
+
throw new SolanaJSONRPCError(e, 'failed to get block');
|
|
6305
|
+
}
|
|
6184
6306
|
}
|
|
6185
6307
|
/*
|
|
6186
6308
|
* Returns the current block height of the node
|