@settlemint/sdk-js 2.4.0-pr5e77a5ab → 2.4.0-pr5eab7b31
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 +40 -22
- package/dist/settlemint.cjs.map +1 -1
- package/dist/settlemint.d.cts +40836 -322
- package/dist/settlemint.d.ts +40803 -290
- package/dist/settlemint.js +40 -22
- package/dist/settlemint.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ The SettleMint JavaScript SDK provides a type-safe wrapper around the SettleMint
|
|
|
62
62
|
|
|
63
63
|
> **createSettleMintClient**(`options`): [`SettlemintClient`](#settlemintclient)
|
|
64
64
|
|
|
65
|
-
Defined in: [settlemint.ts:
|
|
65
|
+
Defined in: [settlemint.ts:275](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L275)
|
|
66
66
|
|
|
67
67
|
Creates a SettleMint client with the provided options. The client provides methods to interact with
|
|
68
68
|
various SettleMint resources like workspaces, applications, blockchain networks, blockchain nodes, middleware,
|
|
@@ -109,7 +109,7 @@ const workspace = await client.workspace.read('workspace-unique-name');
|
|
|
109
109
|
|
|
110
110
|
#### SettlemintClient
|
|
111
111
|
|
|
112
|
-
Defined in: [settlemint.ts:
|
|
112
|
+
Defined in: [settlemint.ts:145](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L145)
|
|
113
113
|
|
|
114
114
|
Client interface for interacting with the SettleMint platform.
|
|
115
115
|
|
|
@@ -117,7 +117,7 @@ Client interface for interacting with the SettleMint platform.
|
|
|
117
117
|
|
|
118
118
|
#### SettlemintClientOptions
|
|
119
119
|
|
|
120
|
-
Defined in: [settlemint.ts:
|
|
120
|
+
Defined in: [settlemint.ts:135](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L135)
|
|
121
121
|
|
|
122
122
|
Options for the Settlemint client.
|
|
123
123
|
|
|
@@ -129,8 +129,8 @@ Options for the Settlemint client.
|
|
|
129
129
|
|
|
130
130
|
| Property | Type | Default value | Description | Inherited from | Defined in |
|
|
131
131
|
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
132
|
-
| <a id="accesstoken"></a> `accessToken?` | `string` | `undefined` | The access token used to authenticate with the SettleMint platform | - | [settlemint.ts:
|
|
133
|
-
| <a id="anonymous"></a> `anonymous?` | `boolean` | `undefined` | Whether to allow anonymous access (no access token required) | - | [settlemint.ts:
|
|
132
|
+
| <a id="accesstoken"></a> `accessToken?` | `string` | `undefined` | The access token used to authenticate with the SettleMint platform | - | [settlemint.ts:137](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L137) |
|
|
133
|
+
| <a id="anonymous"></a> `anonymous?` | `boolean` | `undefined` | Whether to allow anonymous access (no access token required) | - | [settlemint.ts:139](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L139) |
|
|
134
134
|
| <a id="instance"></a> `instance` | `string` | `UrlSchema` | The URL of the SettleMint instance to connect to | `Omit.instance` | [helpers/client-options.schema.ts:11](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/helpers/client-options.schema.ts#L11) |
|
|
135
135
|
|
|
136
136
|
### Type Aliases
|
package/dist/settlemint.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* SettleMint SDK - Main Package */
|
|
1
2
|
//#region rolldown:runtime
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -141,7 +142,9 @@ const workspaceList = (gqlClient) => {
|
|
|
141
142
|
const { workspaces } = await gqlClient.request(getWorkspacesAndApplications);
|
|
142
143
|
const allWorkspaces = workspaces.reduce((acc, workspace) => {
|
|
143
144
|
acc.push(workspace);
|
|
144
|
-
if (workspace.childWorkspaces)
|
|
145
|
+
if (workspace.childWorkspaces) {
|
|
146
|
+
acc.push(...workspace.childWorkspaces);
|
|
147
|
+
}
|
|
145
148
|
return acc;
|
|
146
149
|
}, []);
|
|
147
150
|
return allWorkspaces.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -196,7 +199,9 @@ const workspaceDelete = (gqlClient) => {
|
|
|
196
199
|
const workspaceAddCredits = (gqlClient) => {
|
|
197
200
|
return async (workspaceId, amount) => {
|
|
198
201
|
const id = (0, __settlemint_sdk_utils_validation.validate)(__settlemint_sdk_utils_validation.IdSchema, workspaceId);
|
|
199
|
-
if (amount <= 0)
|
|
202
|
+
if (amount <= 0) {
|
|
203
|
+
throw new Error("Credit amount must be a positive number");
|
|
204
|
+
}
|
|
200
205
|
const { addCredits: result } = await gqlClient.request(addCredits, {
|
|
201
206
|
workspaceId: id,
|
|
202
207
|
amount
|
|
@@ -373,7 +378,9 @@ const applicationAccessTokenCreate = (gqlClient) => {
|
|
|
373
378
|
...otherArgs,
|
|
374
379
|
applicationId: application.id
|
|
375
380
|
});
|
|
376
|
-
if (!applicationAccessToken.token)
|
|
381
|
+
if (!applicationAccessToken.token) {
|
|
382
|
+
throw new Error("Failed to create application access token");
|
|
383
|
+
}
|
|
377
384
|
return applicationAccessToken.token;
|
|
378
385
|
};
|
|
379
386
|
};
|
|
@@ -404,15 +411,17 @@ function setClusterServiceDefaults(args) {
|
|
|
404
411
|
*/
|
|
405
412
|
function setNetworkDefaults(args) {
|
|
406
413
|
const clusterServiceArgs = setClusterServiceDefaults(args);
|
|
407
|
-
if (args.consensusAlgorithm === "BESU_QBFT")
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
if (args.consensusAlgorithm === "BESU_QBFT") {
|
|
415
|
+
return {
|
|
416
|
+
...clusterServiceArgs,
|
|
417
|
+
chainId: args.chainId ?? 46040,
|
|
418
|
+
contractSizeLimit: args.contractSizeLimit ?? 2147483647,
|
|
419
|
+
evmStackSize: args.evmStackSize ?? 2048,
|
|
420
|
+
gasLimit: args.gasLimit ?? "9007199254740991",
|
|
421
|
+
gasPrice: args.gasPrice ?? 0,
|
|
422
|
+
secondsPerBlock: args.secondsPerBlock ?? 2
|
|
423
|
+
};
|
|
424
|
+
}
|
|
416
425
|
return clusterServiceArgs;
|
|
417
426
|
}
|
|
418
427
|
|
|
@@ -1531,8 +1540,8 @@ const insightsCreate = (gqlClient) => {
|
|
|
1531
1540
|
const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName,...otherArgs } = args;
|
|
1532
1541
|
const [application, blockchainNode, loadBalancer] = await Promise.all([
|
|
1533
1542
|
applicationRead(gqlClient)(applicationUniqueName),
|
|
1534
|
-
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(
|
|
1535
|
-
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(
|
|
1543
|
+
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(undefined),
|
|
1544
|
+
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(undefined)
|
|
1536
1545
|
]);
|
|
1537
1546
|
const { createInsights: insights } = await gqlClient.request(createInsights, {
|
|
1538
1547
|
...otherArgs,
|
|
@@ -2139,9 +2148,9 @@ const middlewareCreate = (gqlClient) => {
|
|
|
2139
2148
|
const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName, storageUniqueName,...otherArgs } = args;
|
|
2140
2149
|
const [application, blockchainNode, loadBalancer, storage] = await Promise.all([
|
|
2141
2150
|
applicationRead(gqlClient)(applicationUniqueName),
|
|
2142
|
-
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(
|
|
2143
|
-
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(
|
|
2144
|
-
storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(
|
|
2151
|
+
blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(undefined),
|
|
2152
|
+
loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(undefined),
|
|
2153
|
+
storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(undefined)
|
|
2145
2154
|
]);
|
|
2146
2155
|
const { createMiddleware: middleware } = await gqlClient.request(createMiddleware, {
|
|
2147
2156
|
...otherArgs,
|
|
@@ -2407,7 +2416,7 @@ const privateKeyCreate = (gqlClient) => {
|
|
|
2407
2416
|
const { applicationUniqueName, blockchainNodeUniqueNames, relayerKeyUniqueName,...otherArgs } = args;
|
|
2408
2417
|
const application = await applicationRead(gqlClient)(applicationUniqueName);
|
|
2409
2418
|
const blockchainNodes = blockchainNodeUniqueNames ? await Promise.all(blockchainNodeUniqueNames.map((uniqueName) => blockchainNodeRead(gqlClient)(uniqueName))) : [];
|
|
2410
|
-
const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) :
|
|
2419
|
+
const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) : undefined;
|
|
2411
2420
|
const platformConfig = await getPlatformConfig(gqlClient)();
|
|
2412
2421
|
const defaultProvider = platformConfig.deploymentEngineTargets.find((target) => !target.disabled && target.clusters.some((cluster) => !cluster.disabled));
|
|
2413
2422
|
const defaultRegion = defaultProvider?.clusters.find((cluster) => !cluster.disabled);
|
|
@@ -2494,7 +2503,9 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
|
|
|
2494
2503
|
}
|
|
2495
2504
|
});
|
|
2496
2505
|
if (!response.ok) {
|
|
2497
|
-
if (response.status === 404)
|
|
2506
|
+
if (response.status === 404) {
|
|
2507
|
+
throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
|
|
2508
|
+
}
|
|
2498
2509
|
throw new Error("Failed to get verification challenge");
|
|
2499
2510
|
}
|
|
2500
2511
|
const verificationChallenges = await response.json();
|
|
@@ -2507,7 +2518,9 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
|
|
|
2507
2518
|
* @returns The pincode verification challenge response.
|
|
2508
2519
|
*/
|
|
2509
2520
|
function getPincodeVerificationChallengeResponse({ verificationChallenge, pincode }) {
|
|
2510
|
-
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt)
|
|
2521
|
+
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) {
|
|
2522
|
+
throw new Error("Could not authenticate pin code, invalid challenge format");
|
|
2523
|
+
}
|
|
2511
2524
|
const { secret, salt } = verificationChallenge.challenge;
|
|
2512
2525
|
return generateResponse(pincode, salt, secret);
|
|
2513
2526
|
}
|
|
@@ -2540,8 +2553,13 @@ function getPincodeVerificationChallengeResponse({ verificationChallenge, pincod
|
|
|
2540
2553
|
*/
|
|
2541
2554
|
function createSettleMintClient(options) {
|
|
2542
2555
|
(0, __settlemint_sdk_utils_runtime.ensureServer)();
|
|
2543
|
-
if (options.instance === __settlemint_sdk_utils_validation.STANDALONE_INSTANCE || options.instance === __settlemint_sdk_utils_validation.LOCAL_INSTANCE)
|
|
2544
|
-
|
|
2556
|
+
if (options.instance === __settlemint_sdk_utils_validation.STANDALONE_INSTANCE || options.instance === __settlemint_sdk_utils_validation.LOCAL_INSTANCE) {
|
|
2557
|
+
if (options.anonymous) {
|
|
2558
|
+
options.instance = "https://console.settlemint.com";
|
|
2559
|
+
} else {
|
|
2560
|
+
throw new Error("Standalone and local instances cannot connect to the SettleMint platform");
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2545
2563
|
const validatedOptions = options.anonymous ? (0, __settlemint_sdk_utils_validation.validate)(zod_v4.z.object({
|
|
2546
2564
|
...ClientOptionsSchema.shape,
|
|
2547
2565
|
accessToken: zod_v4.z.literal("")
|