@defillama/sdk 5.0.252 → 5.0.253
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/build/abi/multicall3.js
CHANGED
|
@@ -13,7 +13,9 @@ export declare const SHELLEY_SLOT_OFFSET: number;
|
|
|
13
13
|
export declare function getEndpointList(): string[];
|
|
14
14
|
/** First configured base url. */
|
|
15
15
|
export declare function getEndpoint(): string;
|
|
16
|
-
/** Blockfrost project
|
|
16
|
+
/** All Blockfrost project ids from `BLOCKFROST_PROJECT_ID` (comma separated); throws when unset. */
|
|
17
|
+
export declare function getProjectIds(): string[];
|
|
18
|
+
/** A random Blockfrost project id from `BLOCKFROST_PROJECT_ID`; throws when unset. */
|
|
17
19
|
export declare function getProjectId(): string;
|
|
18
20
|
export interface AssetAmount {
|
|
19
21
|
/** `lovelace` or `<policyId><assetNameHex>` */
|
package/build/chains/cardano.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SHELLEY_SLOT_OFFSET = exports.SHELLEY_START_SLOT = exports.SHELLEY_START_TIME = exports.MAX_PAGE_SIZE = exports.DEFAULT_ENDPOINT = void 0;
|
|
7
7
|
exports.getEndpointList = getEndpointList;
|
|
8
8
|
exports.getEndpoint = getEndpoint;
|
|
9
|
+
exports.getProjectIds = getProjectIds;
|
|
9
10
|
exports.getProjectId = getProjectId;
|
|
10
11
|
exports.blockfrost = blockfrost;
|
|
11
12
|
exports.blockfrostAll = blockfrostAll;
|
|
@@ -53,8 +54,8 @@ exports.lovelaceToAda = lovelaceToAda;
|
|
|
53
54
|
* every function returns raw chain values (lovelace / asset quantities as strings).
|
|
54
55
|
*
|
|
55
56
|
* Configuration:
|
|
56
|
-
* - `BLOCKFROST_PROJECT_ID` (required, also `SDK_` / `LLAMA_SDK_` prefixed): Blockfrost api key
|
|
57
|
-
* No key is embedded in the sdk.
|
|
57
|
+
* - `BLOCKFROST_PROJECT_ID` (required, also `SDK_` / `LLAMA_SDK_` prefixed): Blockfrost api key(s),
|
|
58
|
+
* comma separated. A random key is picked per request and reused by its retries. No key is embedded in the sdk.
|
|
58
59
|
* - `CARDANO_BLOCKFROST` (optional, comma separated): api base url(s), default
|
|
59
60
|
* `https://cardano-mainnet.blockfrost.io/api/v0`.
|
|
60
61
|
* - `CARDANO_RPC_CONCURRENCY` (optional): max parallel requests, default 5.
|
|
@@ -92,12 +93,18 @@ function getEndpointList() {
|
|
|
92
93
|
function getEndpoint() {
|
|
93
94
|
return getEndpointList()[0];
|
|
94
95
|
}
|
|
95
|
-
/** Blockfrost project
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
/** All Blockfrost project ids from `BLOCKFROST_PROJECT_ID` (comma separated); throws when unset. */
|
|
97
|
+
function getProjectIds() {
|
|
98
|
+
var _a;
|
|
99
|
+
const ids = ((_a = (0, env_1.getEnvValue)(PROJECT_ID_ENV_KEY)) !== null && _a !== void 0 ? _a : '').split(',').map(i => i.trim()).filter(Boolean);
|
|
100
|
+
if (!ids.length)
|
|
99
101
|
throw new Error(`[chains.cardano] missing Blockfrost api key: set the ${PROJECT_ID_ENV_KEY} env var (https://blockfrost.io)`);
|
|
100
|
-
return
|
|
102
|
+
return ids;
|
|
103
|
+
}
|
|
104
|
+
/** A random Blockfrost project id from `BLOCKFROST_PROJECT_ID`; throws when unset. */
|
|
105
|
+
function getProjectId() {
|
|
106
|
+
const ids = getProjectIds();
|
|
107
|
+
return ids[Math.floor(Math.random() * ids.length)];
|
|
101
108
|
}
|
|
102
109
|
// ---------------------------------------------------------------------------
|
|
103
110
|
// client
|
|
@@ -114,7 +121,7 @@ function isNotFound(e) {
|
|
|
114
121
|
*/
|
|
115
122
|
async function blockfrost({ path, params, allowNotFound = false, timeout = DEFAULT_TIMEOUT, retries }) {
|
|
116
123
|
const endpoints = getEndpointList();
|
|
117
|
-
const headers = { project_id: getProjectId(), 'Content-Type': 'application/json' };
|
|
124
|
+
const headers = { project_id: getProjectId(), 'Content-Type': 'application/json' }; // one key per call, reused by retries
|
|
118
125
|
const config = { timeout, headers, params };
|
|
119
126
|
const limiter = (0, rpc_1.getLimiter)(LIMITER_KEY, CONCURRENCY);
|
|
120
127
|
const res = await (0, rpc_1.withRetry)(async (attempt) => {
|