@settlemint/sdk-js 2.4.0-pr7c98613c → 2.4.0-pr7dabb22d
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/README.md +5 -5
- package/dist/settlemint.cjs +22 -40
- package/dist/settlemint.cjs.map +1 -1
- package/dist/settlemint.d.cts +448 -40962
- package/dist/settlemint.d.ts +423 -40936
- package/dist/settlemint.js +22 -40
- package/dist/settlemint.js.map +1 -1
- package/package.json +3 -5
package/dist/settlemint.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* SettleMint SDK - Main Package */
|
|
2
1
|
import { fetchWithRetry } from "@settlemint/sdk-utils/http";
|
|
3
2
|
import { ensureServer } from "@settlemint/sdk-utils/runtime";
|
|
4
3
|
import { AccessTokenSchema, IdSchema, LOCAL_INSTANCE, STANDALONE_INSTANCE, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
|
|
@@ -119,9 +118,7 @@ const workspaceList = (gqlClient) => {
|
|
|
119
118
|
const { workspaces } = await gqlClient.request(getWorkspacesAndApplications);
|
|
120
119
|
const allWorkspaces = workspaces.reduce((acc, workspace) => {
|
|
121
120
|
acc.push(workspace);
|
|
122
|
-
if (workspace.childWorkspaces)
|
|
123
|
-
acc.push(...workspace.childWorkspaces);
|
|
124
|
-
}
|
|
121
|
+
if (workspace.childWorkspaces) acc.push(...workspace.childWorkspaces);
|
|
125
122
|
return acc;
|
|
126
123
|
}, []);
|
|
127
124
|
return allWorkspaces.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -176,9 +173,7 @@ const workspaceDelete = (gqlClient) => {
|
|
|
176
173
|
const workspaceAddCredits = (gqlClient) => {
|
|
177
174
|
return async (workspaceId, amount) => {
|
|
178
175
|
const id = validate(IdSchema, workspaceId);
|
|
179
|
-
if (amount <= 0)
|
|
180
|
-
throw new Error("Credit amount must be a positive number");
|
|
181
|
-
}
|
|
176
|
+
if (amount <= 0) throw new Error("Credit amount must be a positive number");
|
|
182
177
|
const { addCredits: result } = await gqlClient.request(addCredits, {
|
|
183
178
|
workspaceId: id,
|
|
184
179
|
amount
|
|
@@ -355,9 +350,7 @@ const applicationAccessTokenCreate = (gqlClient) => {
|
|
|
355
350
|
...otherArgs,
|
|
356
351
|
applicationId: application.id
|
|
357
352
|
});
|
|
358
|
-
if (!applicationAccessToken.token)
|
|
359
|
-
throw new Error("Failed to create application access token");
|
|
360
|
-
}
|
|
353
|
+
if (!applicationAccessToken.token) throw new Error("Failed to create application access token");
|
|
361
354
|
return applicationAccessToken.token;
|
|
362
355
|
};
|
|
363
356
|
};
|
|
@@ -388,17 +381,15 @@ function setClusterServiceDefaults(args) {
|
|
|
388
381
|
*/
|
|
389
382
|
function setNetworkDefaults(args) {
|
|
390
383
|
const clusterServiceArgs = setClusterServiceDefaults(args);
|
|
391
|
-
if (args.consensusAlgorithm === "BESU_QBFT") {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
401
|
-
}
|
|
384
|
+
if (args.consensusAlgorithm === "BESU_QBFT") return {
|
|
385
|
+
...clusterServiceArgs,
|
|
386
|
+
chainId: args.chainId ?? 46040,
|
|
387
|
+
contractSizeLimit: args.contractSizeLimit ?? 2147483647,
|
|
388
|
+
evmStackSize: args.evmStackSize ?? 2048,
|
|
389
|
+
gasLimit: args.gasLimit ?? "9007199254740991",
|
|
390
|
+
gasPrice: args.gasPrice ?? 0,
|
|
391
|
+
secondsPerBlock: args.secondsPerBlock ?? 2
|
|
392
|
+
};
|
|
402
393
|
return clusterServiceArgs;
|
|
403
394
|
}
|
|
404
395
|
|
|
@@ -1517,8 +1508,8 @@ const insightsCreate = (gqlClient) => {
|
|
|
1517
1508
|
const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName,...otherArgs } = args;
|
|
1518
1509
|
const [application, blockchainNode, loadBalancer] = await Promise.all([
|
|
1519
1510
|
applicationRead(gqlClient)(applicationUniqueName),
|
|
1520
|
-
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(
|
|
1521
|
-
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(
|
|
1511
|
+
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(void 0),
|
|
1512
|
+
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(void 0)
|
|
1522
1513
|
]);
|
|
1523
1514
|
const { createInsights: insights } = await gqlClient.request(createInsights, {
|
|
1524
1515
|
...otherArgs,
|
|
@@ -2125,9 +2116,9 @@ const middlewareCreate = (gqlClient) => {
|
|
|
2125
2116
|
const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName, storageUniqueName,...otherArgs } = args;
|
|
2126
2117
|
const [application, blockchainNode, loadBalancer, storage] = await Promise.all([
|
|
2127
2118
|
applicationRead(gqlClient)(applicationUniqueName),
|
|
2128
|
-
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(
|
|
2129
|
-
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(
|
|
2130
|
-
storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(
|
|
2119
|
+
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(void 0),
|
|
2120
|
+
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(void 0),
|
|
2121
|
+
storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(void 0)
|
|
2131
2122
|
]);
|
|
2132
2123
|
const { createMiddleware: middleware } = await gqlClient.request(createMiddleware, {
|
|
2133
2124
|
...otherArgs,
|
|
@@ -2393,7 +2384,7 @@ const privateKeyCreate = (gqlClient) => {
|
|
|
2393
2384
|
const { applicationUniqueName, blockchainNodeUniqueNames, relayerKeyUniqueName,...otherArgs } = args;
|
|
2394
2385
|
const application = await applicationRead(gqlClient)(applicationUniqueName);
|
|
2395
2386
|
const blockchainNodes = blockchainNodeUniqueNames ? await Promise.all(blockchainNodeUniqueNames.map((uniqueName) => blockchainNodeRead(gqlClient)(uniqueName))) : [];
|
|
2396
|
-
const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) :
|
|
2387
|
+
const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) : void 0;
|
|
2397
2388
|
const platformConfig = await getPlatformConfig(gqlClient)();
|
|
2398
2389
|
const defaultProvider = platformConfig.deploymentEngineTargets.find((target) => !target.disabled && target.clusters.some((cluster) => !cluster.disabled));
|
|
2399
2390
|
const defaultRegion = defaultProvider?.clusters.find((cluster) => !cluster.disabled);
|
|
@@ -2480,9 +2471,7 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
|
|
|
2480
2471
|
}
|
|
2481
2472
|
});
|
|
2482
2473
|
if (!response.ok) {
|
|
2483
|
-
if (response.status === 404) {
|
|
2484
|
-
throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
|
|
2485
|
-
}
|
|
2474
|
+
if (response.status === 404) throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
|
|
2486
2475
|
throw new Error("Failed to get verification challenge");
|
|
2487
2476
|
}
|
|
2488
2477
|
const verificationChallenges = await response.json();
|
|
@@ -2495,9 +2484,7 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
|
|
|
2495
2484
|
* @returns The pincode verification challenge response.
|
|
2496
2485
|
*/
|
|
2497
2486
|
function getPincodeVerificationChallengeResponse({ verificationChallenge, pincode }) {
|
|
2498
|
-
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt)
|
|
2499
|
-
throw new Error("Could not authenticate pin code, invalid challenge format");
|
|
2500
|
-
}
|
|
2487
|
+
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) throw new Error("Could not authenticate pin code, invalid challenge format");
|
|
2501
2488
|
const { secret, salt } = verificationChallenge.challenge;
|
|
2502
2489
|
return generateResponse(pincode, salt, secret);
|
|
2503
2490
|
}
|
|
@@ -2530,13 +2517,8 @@ function getPincodeVerificationChallengeResponse({ verificationChallenge, pincod
|
|
|
2530
2517
|
*/
|
|
2531
2518
|
function createSettleMintClient(options) {
|
|
2532
2519
|
ensureServer();
|
|
2533
|
-
if (options.instance === STANDALONE_INSTANCE || options.instance === LOCAL_INSTANCE)
|
|
2534
|
-
|
|
2535
|
-
options.instance = "https://console.settlemint.com";
|
|
2536
|
-
} else {
|
|
2537
|
-
throw new Error("Standalone and local instances cannot connect to the SettleMint platform");
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2520
|
+
if (options.instance === STANDALONE_INSTANCE || options.instance === LOCAL_INSTANCE) if (options.anonymous) options.instance = "https://console.settlemint.com";
|
|
2521
|
+
else throw new Error("Standalone and local instances cannot connect to the SettleMint platform");
|
|
2540
2522
|
const validatedOptions = options.anonymous ? validate(z.object({
|
|
2541
2523
|
...ClientOptionsSchema.shape,
|
|
2542
2524
|
accessToken: z.literal("")
|