@solana/web3.js 1.73.4 → 1.75.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 +61 -25
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +61 -25
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +61 -25
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +21 -1
- package/lib/index.esm.js +61 -25
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +61 -25
- 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 +61 -25
- package/lib/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/connection.ts +89 -21
package/lib/index.d.ts
CHANGED
|
@@ -2101,6 +2101,22 @@ type InflationReward = {
|
|
|
2101
2101
|
/** vote account commission when the reward was credited */
|
|
2102
2102
|
commission?: number | null;
|
|
2103
2103
|
};
|
|
2104
|
+
type RecentPrioritizationFees = {
|
|
2105
|
+
/** slot in which the fee was observed */
|
|
2106
|
+
slot: number;
|
|
2107
|
+
/** the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of 0.000001 lamports*/
|
|
2108
|
+
prioritizationFee: number;
|
|
2109
|
+
};
|
|
2110
|
+
/**
|
|
2111
|
+
* Configuration object for changing `getRecentPrioritizationFees` query behavior
|
|
2112
|
+
*/
|
|
2113
|
+
type GetRecentPrioritizationFeesConfig = {
|
|
2114
|
+
/**
|
|
2115
|
+
* If this parameter is provided, the response will reflect a fee to land a transaction locking
|
|
2116
|
+
* all of the provided accounts as writable.
|
|
2117
|
+
*/
|
|
2118
|
+
lockedWritableAccounts?: PublicKey[];
|
|
2119
|
+
};
|
|
2104
2120
|
type InflationRate = {
|
|
2105
2121
|
/** total inflation */
|
|
2106
2122
|
total: number;
|
|
@@ -3286,6 +3302,10 @@ export class Connection {
|
|
|
3286
3302
|
* Fetch the fee for a message from the cluster, return with context
|
|
3287
3303
|
*/
|
|
3288
3304
|
getFeeForMessage(message: VersionedMessage, commitment?: Commitment): Promise<RpcResponseAndContext<number | null>>;
|
|
3305
|
+
/**
|
|
3306
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
3307
|
+
*/
|
|
3308
|
+
getRecentPrioritizationFees(config?: GetRecentPrioritizationFeesConfig): Promise<RecentPrioritizationFees[]>;
|
|
3289
3309
|
/**
|
|
3290
3310
|
* Fetch a recent blockhash from the cluster
|
|
3291
3311
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
|
@@ -3355,7 +3375,7 @@ export class Connection {
|
|
|
3355
3375
|
getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
|
|
3356
3376
|
transactionDetails: 'none';
|
|
3357
3377
|
}): Promise<ParsedNoneModeBlockResponse>;
|
|
3358
|
-
getBlockHeight(commitmentOrConfig?: Commitment | GetBlockHeightConfig)
|
|
3378
|
+
getBlockHeight: (commitmentOrConfig?: Commitment | GetBlockHeightConfig) => Promise<number>;
|
|
3359
3379
|
getBlockProduction(configOrCommitment?: GetBlockProductionConfig | Commitment): Promise<RpcResponseAndContext<BlockProduction>>;
|
|
3360
3380
|
/**
|
|
3361
3381
|
* Fetch a confirmed or finalized transaction from the cluster.
|
package/lib/index.esm.js
CHANGED
|
@@ -5998,6 +5998,13 @@ const GetInflationRewardResult = jsonRpcResult(array(nullable(type({
|
|
|
5998
5998
|
postBalance: number(),
|
|
5999
5999
|
commission: optional(nullable(number()))
|
|
6000
6000
|
}))));
|
|
6001
|
+
/**
|
|
6002
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
6003
|
+
*/
|
|
6004
|
+
const GetRecentPrioritizationFeesResult = array(type({
|
|
6005
|
+
slot: number(),
|
|
6006
|
+
prioritizationFee: number()
|
|
6007
|
+
}));
|
|
6001
6008
|
/**
|
|
6002
6009
|
* Expected JSON RPC response for the "getInflationRate" message
|
|
6003
6010
|
*/
|
|
@@ -6222,6 +6229,11 @@ const GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);
|
|
|
6222
6229
|
*/
|
|
6223
6230
|
const GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);
|
|
6224
6231
|
|
|
6232
|
+
/**
|
|
6233
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
6234
|
+
*/
|
|
6235
|
+
const GetRecentPrioritizationFeesRpcResult = jsonRpcResult(GetRecentPrioritizationFeesResult);
|
|
6236
|
+
|
|
6225
6237
|
/**
|
|
6226
6238
|
* Expected JSON RPC response for the "getEpochInfo" message
|
|
6227
6239
|
*/
|
|
@@ -6977,7 +6989,7 @@ class Connection {
|
|
|
6977
6989
|
* @param endpoint URL to the fullnode JSON RPC endpoint
|
|
6978
6990
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
6979
6991
|
*/
|
|
6980
|
-
constructor(endpoint,
|
|
6992
|
+
constructor(endpoint, _commitmentOrConfig) {
|
|
6981
6993
|
this._commitment = void 0;
|
|
6982
6994
|
this._confirmTransactionInitialTimeout = void 0;
|
|
6983
6995
|
this._rpcEndpoint = void 0;
|
|
@@ -7005,23 +7017,47 @@ class Connection {
|
|
|
7005
7017
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
7006
7018
|
this._subscriptionsByHash = {};
|
|
7007
7019
|
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
7020
|
+
this.getBlockHeight = (() => {
|
|
7021
|
+
const requestPromises = {};
|
|
7022
|
+
return async commitmentOrConfig => {
|
|
7023
|
+
const {
|
|
7024
|
+
commitment,
|
|
7025
|
+
config
|
|
7026
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
7027
|
+
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
7028
|
+
const requestHash = fastStableStringify$1(args);
|
|
7029
|
+
requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
|
|
7030
|
+
try {
|
|
7031
|
+
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
7032
|
+
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
7033
|
+
if ('error' in res) {
|
|
7034
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
7035
|
+
}
|
|
7036
|
+
return res.result;
|
|
7037
|
+
} finally {
|
|
7038
|
+
delete requestPromises[requestHash];
|
|
7039
|
+
}
|
|
7040
|
+
})();
|
|
7041
|
+
return await requestPromises[requestHash];
|
|
7042
|
+
};
|
|
7043
|
+
})();
|
|
7008
7044
|
let wsEndpoint;
|
|
7009
7045
|
let httpHeaders;
|
|
7010
7046
|
let fetch;
|
|
7011
7047
|
let fetchMiddleware;
|
|
7012
7048
|
let disableRetryOnRateLimit;
|
|
7013
7049
|
let httpAgent;
|
|
7014
|
-
if (
|
|
7015
|
-
this._commitment =
|
|
7016
|
-
} else if (
|
|
7017
|
-
this._commitment =
|
|
7018
|
-
this._confirmTransactionInitialTimeout =
|
|
7019
|
-
wsEndpoint =
|
|
7020
|
-
httpHeaders =
|
|
7021
|
-
fetch =
|
|
7022
|
-
fetchMiddleware =
|
|
7023
|
-
disableRetryOnRateLimit =
|
|
7024
|
-
httpAgent =
|
|
7050
|
+
if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
|
|
7051
|
+
this._commitment = _commitmentOrConfig;
|
|
7052
|
+
} else if (_commitmentOrConfig) {
|
|
7053
|
+
this._commitment = _commitmentOrConfig.commitment;
|
|
7054
|
+
this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
7055
|
+
wsEndpoint = _commitmentOrConfig.wsEndpoint;
|
|
7056
|
+
httpHeaders = _commitmentOrConfig.httpHeaders;
|
|
7057
|
+
fetch = _commitmentOrConfig.fetch;
|
|
7058
|
+
fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
|
|
7059
|
+
disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
|
|
7060
|
+
httpAgent = _commitmentOrConfig.httpAgent;
|
|
7025
7061
|
}
|
|
7026
7062
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
7027
7063
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
@@ -8095,6 +8131,19 @@ class Connection {
|
|
|
8095
8131
|
return res.result;
|
|
8096
8132
|
}
|
|
8097
8133
|
|
|
8134
|
+
/**
|
|
8135
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
8136
|
+
*/
|
|
8137
|
+
async getRecentPrioritizationFees(config) {
|
|
8138
|
+
const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
|
|
8139
|
+
const args = this._buildArgs(accounts?.length ? [accounts] : []);
|
|
8140
|
+
const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);
|
|
8141
|
+
const res = create(unsafeRes, GetRecentPrioritizationFeesRpcResult);
|
|
8142
|
+
if ('error' in res) {
|
|
8143
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent prioritization fees');
|
|
8144
|
+
}
|
|
8145
|
+
return res.result;
|
|
8146
|
+
}
|
|
8098
8147
|
/**
|
|
8099
8148
|
* Fetch a recent blockhash from the cluster
|
|
8100
8149
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
|
@@ -8279,19 +8328,6 @@ class Connection {
|
|
|
8279
8328
|
/*
|
|
8280
8329
|
* Returns the current block height of the node
|
|
8281
8330
|
*/
|
|
8282
|
-
async getBlockHeight(commitmentOrConfig) {
|
|
8283
|
-
const {
|
|
8284
|
-
commitment,
|
|
8285
|
-
config
|
|
8286
|
-
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
8287
|
-
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
8288
|
-
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
8289
|
-
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
8290
|
-
if ('error' in res) {
|
|
8291
|
-
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
8292
|
-
}
|
|
8293
|
-
return res.result;
|
|
8294
|
-
}
|
|
8295
8331
|
|
|
8296
8332
|
/*
|
|
8297
8333
|
* Returns recent block production information from the current or previous epoch
|