@solana/web3.js 1.63.0 → 1.64.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 +46 -2
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +46 -2
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +46 -2
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +44 -2
- package/lib/index.esm.js +46 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +46 -2
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +46 -2
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +90 -0
- package/src/message/v0.ts +12 -4
package/lib/index.d.ts
CHANGED
|
@@ -1562,10 +1562,10 @@ declare module '@solana/web3.js' {
|
|
|
1562
1562
|
};
|
|
1563
1563
|
export type GetAccountKeysArgs =
|
|
1564
1564
|
| {
|
|
1565
|
-
accountKeysFromLookups
|
|
1565
|
+
accountKeysFromLookups?: AccountKeysFromLookups | null;
|
|
1566
1566
|
}
|
|
1567
1567
|
| {
|
|
1568
|
-
addressLookupTableAccounts
|
|
1568
|
+
addressLookupTableAccounts?: AddressLookupTableAccount[] | null;
|
|
1569
1569
|
};
|
|
1570
1570
|
export class MessageV0 {
|
|
1571
1571
|
header: MessageHeader;
|
|
@@ -2544,6 +2544,41 @@ declare module '@solana/web3.js' {
|
|
|
2544
2544
|
/** The unix timestamp of when the block was processed */
|
|
2545
2545
|
blockTime: number | null;
|
|
2546
2546
|
};
|
|
2547
|
+
/**
|
|
2548
|
+
* A block with parsed transactions
|
|
2549
|
+
*/
|
|
2550
|
+
export type ParsedBlockResponse = {
|
|
2551
|
+
/** Blockhash of this block */
|
|
2552
|
+
blockhash: Blockhash;
|
|
2553
|
+
/** Blockhash of this block's parent */
|
|
2554
|
+
previousBlockhash: Blockhash;
|
|
2555
|
+
/** Slot index of this block's parent */
|
|
2556
|
+
parentSlot: number;
|
|
2557
|
+
/** Vector of transactions with status meta and original message */
|
|
2558
|
+
transactions: Array<{
|
|
2559
|
+
/** The details of the transaction */
|
|
2560
|
+
transaction: ParsedTransaction;
|
|
2561
|
+
/** Metadata produced from the transaction */
|
|
2562
|
+
meta: ParsedTransactionMeta | null;
|
|
2563
|
+
/** The transaction version */
|
|
2564
|
+
version?: TransactionVersion;
|
|
2565
|
+
}>;
|
|
2566
|
+
/** Vector of block rewards */
|
|
2567
|
+
rewards?: Array<{
|
|
2568
|
+
/** Public key of reward recipient */
|
|
2569
|
+
pubkey: string;
|
|
2570
|
+
/** Reward value in lamports */
|
|
2571
|
+
lamports: number;
|
|
2572
|
+
/** Account balance after reward is applied */
|
|
2573
|
+
postBalance: number | null;
|
|
2574
|
+
/** Type of reward received */
|
|
2575
|
+
rewardType: string | null;
|
|
2576
|
+
}>;
|
|
2577
|
+
/** The unix timestamp of when the block was processed */
|
|
2578
|
+
blockTime: number | null;
|
|
2579
|
+
/** The number of blocks beneath this block */
|
|
2580
|
+
blockHeight: number | null;
|
|
2581
|
+
};
|
|
2547
2582
|
/**
|
|
2548
2583
|
* A processed block fetched from the RPC API
|
|
2549
2584
|
*/
|
|
@@ -3455,6 +3490,13 @@ declare module '@solana/web3.js' {
|
|
|
3455
3490
|
slot: number,
|
|
3456
3491
|
rawConfig?: GetVersionedBlockConfig,
|
|
3457
3492
|
): Promise<VersionedBlockResponse | null>;
|
|
3493
|
+
/**
|
|
3494
|
+
* Fetch parsed transaction details for a confirmed or finalized block
|
|
3495
|
+
*/
|
|
3496
|
+
getParsedBlock(
|
|
3497
|
+
slot: number,
|
|
3498
|
+
rawConfig?: GetVersionedBlockConfig,
|
|
3499
|
+
): Promise<ParsedBlockResponse | null>;
|
|
3458
3500
|
getBlockHeight(
|
|
3459
3501
|
commitmentOrConfig?: Commitment | GetBlockHeightConfig,
|
|
3460
3502
|
): Promise<number>;
|
package/lib/index.esm.js
CHANGED
|
@@ -976,13 +976,13 @@ class MessageV0 {
|
|
|
976
976
|
getAccountKeys(args) {
|
|
977
977
|
let accountKeysFromLookups;
|
|
978
978
|
|
|
979
|
-
if (args && 'accountKeysFromLookups' in args) {
|
|
979
|
+
if (args && 'accountKeysFromLookups' in args && args.accountKeysFromLookups) {
|
|
980
980
|
if (this.numAccountKeysFromLookups != args.accountKeysFromLookups.writable.length + args.accountKeysFromLookups.readonly.length) {
|
|
981
981
|
throw new Error('Failed to get account keys because of a mismatch in the number of account keys from lookups');
|
|
982
982
|
}
|
|
983
983
|
|
|
984
984
|
accountKeysFromLookups = args.accountKeysFromLookups;
|
|
985
|
-
} else if (args && 'addressLookupTableAccounts' in args) {
|
|
985
|
+
} else if (args && 'addressLookupTableAccounts' in args && args.addressLookupTableAccounts) {
|
|
986
986
|
accountKeysFromLookups = this.resolveAddressTableLookups(args.addressLookupTableAccounts);
|
|
987
987
|
} else if (this.addressTableLookups.length > 0) {
|
|
988
988
|
throw new Error('Failed to get account keys because address table lookups were not resolved');
|
|
@@ -4460,6 +4460,28 @@ const GetBlockRpcResult = jsonRpcResult(nullable(type({
|
|
|
4460
4460
|
blockTime: nullable(number()),
|
|
4461
4461
|
blockHeight: nullable(number())
|
|
4462
4462
|
})));
|
|
4463
|
+
/**
|
|
4464
|
+
* Expected parsed JSON RPC response for the "getBlock" message
|
|
4465
|
+
*/
|
|
4466
|
+
|
|
4467
|
+
const GetParsedBlockRpcResult = jsonRpcResult(nullable(type({
|
|
4468
|
+
blockhash: string(),
|
|
4469
|
+
previousBlockhash: string(),
|
|
4470
|
+
parentSlot: number(),
|
|
4471
|
+
transactions: array(type({
|
|
4472
|
+
transaction: ParsedConfirmedTransactionResult,
|
|
4473
|
+
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
4474
|
+
version: optional(TransactionVersionStruct)
|
|
4475
|
+
})),
|
|
4476
|
+
rewards: optional(array(type({
|
|
4477
|
+
pubkey: string(),
|
|
4478
|
+
lamports: number(),
|
|
4479
|
+
postBalance: nullable(number()),
|
|
4480
|
+
rewardType: nullable(string())
|
|
4481
|
+
}))),
|
|
4482
|
+
blockTime: nullable(number()),
|
|
4483
|
+
blockHeight: nullable(number())
|
|
4484
|
+
})));
|
|
4463
4485
|
/**
|
|
4464
4486
|
* Expected JSON RPC response for the "getConfirmedBlock" message
|
|
4465
4487
|
*
|
|
@@ -5799,6 +5821,28 @@ class Connection {
|
|
|
5799
5821
|
}))
|
|
5800
5822
|
};
|
|
5801
5823
|
}
|
|
5824
|
+
/**
|
|
5825
|
+
* Fetch parsed transaction details for a confirmed or finalized block
|
|
5826
|
+
*/
|
|
5827
|
+
|
|
5828
|
+
|
|
5829
|
+
async getParsedBlock(slot, rawConfig) {
|
|
5830
|
+
const {
|
|
5831
|
+
commitment,
|
|
5832
|
+
config
|
|
5833
|
+
} = extractCommitmentFromConfig(rawConfig);
|
|
5834
|
+
|
|
5835
|
+
const args = this._buildArgsAtLeastConfirmed([slot], commitment, 'jsonParsed', config);
|
|
5836
|
+
|
|
5837
|
+
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
5838
|
+
const res = create(unsafeRes, GetParsedBlockRpcResult);
|
|
5839
|
+
|
|
5840
|
+
if ('error' in res) {
|
|
5841
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
5842
|
+
}
|
|
5843
|
+
|
|
5844
|
+
return res.result;
|
|
5845
|
+
}
|
|
5802
5846
|
/*
|
|
5803
5847
|
* Returns the current block height of the node
|
|
5804
5848
|
*/
|