@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.63.0",
3
+ "version": "1.64.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
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
  */
package/src/message/v0.ts CHANGED
@@ -42,10 +42,10 @@ export type CompileV0Args = {
42
42
 
43
43
  export type GetAccountKeysArgs =
44
44
  | {
45
- accountKeysFromLookups: AccountKeysFromLookups;
45
+ accountKeysFromLookups?: AccountKeysFromLookups | null;
46
46
  }
47
47
  | {
48
- addressLookupTableAccounts: AddressLookupTableAccount[];
48
+ addressLookupTableAccounts?: AddressLookupTableAccount[] | null;
49
49
  };
50
50
 
51
51
  export class MessageV0 {
@@ -77,7 +77,11 @@ export class MessageV0 {
77
77
 
78
78
  getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys {
79
79
  let accountKeysFromLookups: AccountKeysFromLookups | undefined;
80
- if (args && 'accountKeysFromLookups' in args) {
80
+ if (
81
+ args &&
82
+ 'accountKeysFromLookups' in args &&
83
+ args.accountKeysFromLookups
84
+ ) {
81
85
  if (
82
86
  this.numAccountKeysFromLookups !=
83
87
  args.accountKeysFromLookups.writable.length +
@@ -88,7 +92,11 @@ export class MessageV0 {
88
92
  );
89
93
  }
90
94
  accountKeysFromLookups = args.accountKeysFromLookups;
91
- } else if (args && 'addressLookupTableAccounts' in args) {
95
+ } else if (
96
+ args &&
97
+ 'addressLookupTableAccounts' in args &&
98
+ args.addressLookupTableAccounts
99
+ ) {
92
100
  accountKeysFromLookups = this.resolveAddressTableLookups(
93
101
  args.addressLookupTableAccounts,
94
102
  );