@solana/web3.js 1.63.1 → 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 +44 -0
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +44 -0
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +44 -0
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +42 -0
- package/lib/index.esm.js +44 -0
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +44 -0
- 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 +44 -0
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +90 -0
package/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -1143,6 +1143,42 @@ export type BlockResponse = {
|
|
|
1143
1143
|
blockTime: number | null;
|
|
1144
1144
|
};
|
|
1145
1145
|
|
|
1146
|
+
/**
|
|
1147
|
+
* A block with parsed transactions
|
|
1148
|
+
*/
|
|
1149
|
+
export type ParsedBlockResponse = {
|
|
1150
|
+
/** Blockhash of this block */
|
|
1151
|
+
blockhash: Blockhash;
|
|
1152
|
+
/** Blockhash of this block's parent */
|
|
1153
|
+
previousBlockhash: Blockhash;
|
|
1154
|
+
/** Slot index of this block's parent */
|
|
1155
|
+
parentSlot: number;
|
|
1156
|
+
/** Vector of transactions with status meta and original message */
|
|
1157
|
+
transactions: Array<{
|
|
1158
|
+
/** The details of the transaction */
|
|
1159
|
+
transaction: ParsedTransaction;
|
|
1160
|
+
/** Metadata produced from the transaction */
|
|
1161
|
+
meta: ParsedTransactionMeta | null;
|
|
1162
|
+
/** The transaction version */
|
|
1163
|
+
version?: TransactionVersion;
|
|
1164
|
+
}>;
|
|
1165
|
+
/** Vector of block rewards */
|
|
1166
|
+
rewards?: Array<{
|
|
1167
|
+
/** Public key of reward recipient */
|
|
1168
|
+
pubkey: string;
|
|
1169
|
+
/** Reward value in lamports */
|
|
1170
|
+
lamports: number;
|
|
1171
|
+
/** Account balance after reward is applied */
|
|
1172
|
+
postBalance: number | null;
|
|
1173
|
+
/** Type of reward received */
|
|
1174
|
+
rewardType: string | null;
|
|
1175
|
+
}>;
|
|
1176
|
+
/** The unix timestamp of when the block was processed */
|
|
1177
|
+
blockTime: number | null;
|
|
1178
|
+
/** The number of blocks beneath this block */
|
|
1179
|
+
blockHeight: number | null;
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1146
1182
|
/**
|
|
1147
1183
|
* A processed block fetched from the RPC API
|
|
1148
1184
|
*/
|
|
@@ -2081,6 +2117,38 @@ const GetBlockRpcResult = jsonRpcResult(
|
|
|
2081
2117
|
),
|
|
2082
2118
|
);
|
|
2083
2119
|
|
|
2120
|
+
/**
|
|
2121
|
+
* Expected parsed JSON RPC response for the "getBlock" message
|
|
2122
|
+
*/
|
|
2123
|
+
const GetParsedBlockRpcResult = jsonRpcResult(
|
|
2124
|
+
nullable(
|
|
2125
|
+
pick({
|
|
2126
|
+
blockhash: string(),
|
|
2127
|
+
previousBlockhash: string(),
|
|
2128
|
+
parentSlot: number(),
|
|
2129
|
+
transactions: array(
|
|
2130
|
+
pick({
|
|
2131
|
+
transaction: ParsedConfirmedTransactionResult,
|
|
2132
|
+
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
2133
|
+
version: optional(TransactionVersionStruct),
|
|
2134
|
+
}),
|
|
2135
|
+
),
|
|
2136
|
+
rewards: optional(
|
|
2137
|
+
array(
|
|
2138
|
+
pick({
|
|
2139
|
+
pubkey: string(),
|
|
2140
|
+
lamports: number(),
|
|
2141
|
+
postBalance: nullable(number()),
|
|
2142
|
+
rewardType: nullable(string()),
|
|
2143
|
+
}),
|
|
2144
|
+
),
|
|
2145
|
+
),
|
|
2146
|
+
blockTime: nullable(number()),
|
|
2147
|
+
blockHeight: nullable(number()),
|
|
2148
|
+
}),
|
|
2149
|
+
),
|
|
2150
|
+
);
|
|
2151
|
+
|
|
2084
2152
|
/**
|
|
2085
2153
|
* Expected JSON RPC response for the "getConfirmedBlock" message
|
|
2086
2154
|
*
|
|
@@ -3878,6 +3946,28 @@ export class Connection {
|
|
|
3878
3946
|
};
|
|
3879
3947
|
}
|
|
3880
3948
|
|
|
3949
|
+
/**
|
|
3950
|
+
* Fetch parsed transaction details for a confirmed or finalized block
|
|
3951
|
+
*/
|
|
3952
|
+
async getParsedBlock(
|
|
3953
|
+
slot: number,
|
|
3954
|
+
rawConfig?: GetVersionedBlockConfig,
|
|
3955
|
+
): Promise<ParsedBlockResponse | null> {
|
|
3956
|
+
const {commitment, config} = extractCommitmentFromConfig(rawConfig);
|
|
3957
|
+
const args = this._buildArgsAtLeastConfirmed(
|
|
3958
|
+
[slot],
|
|
3959
|
+
commitment as Finality,
|
|
3960
|
+
'jsonParsed',
|
|
3961
|
+
config,
|
|
3962
|
+
);
|
|
3963
|
+
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
3964
|
+
const res = create(unsafeRes, GetParsedBlockRpcResult);
|
|
3965
|
+
if ('error' in res) {
|
|
3966
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
3967
|
+
}
|
|
3968
|
+
return res.result;
|
|
3969
|
+
}
|
|
3970
|
+
|
|
3881
3971
|
/*
|
|
3882
3972
|
* Returns the current block height of the node
|
|
3883
3973
|
*/
|