@settlemint/sdk-js 2.4.0-pr5eab7b31 → 2.4.0-pr60c1cb59

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 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:275](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L275)
65
+ Defined in: [settlemint.ts:239](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L239)
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:145](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L145)
112
+ Defined in: [settlemint.ts:127](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L127)
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:135](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L135)
120
+ Defined in: [settlemint.ts:117](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L117)
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: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) |
132
+ | <a id="accesstoken"></a> `accessToken?` | `string` | `undefined` | The access token used to authenticate with the SettleMint platform | - | [settlemint.ts:119](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L119) |
133
+ | <a id="anonymous"></a> `anonymous?` | `boolean` | `undefined` | Whether to allow anonymous access (no access token required) | - | [settlemint.ts:121](https://github.com/settlemint/sdk/blob/v2.4.0/sdk/js/src/settlemint.ts#L121) |
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
@@ -1,4 +1,3 @@
1
- /* SettleMint SDK - Main Package */
2
1
  //#region rolldown:runtime
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -142,9 +141,7 @@ const workspaceList = (gqlClient) => {
142
141
  const { workspaces } = await gqlClient.request(getWorkspacesAndApplications);
143
142
  const allWorkspaces = workspaces.reduce((acc, workspace) => {
144
143
  acc.push(workspace);
145
- if (workspace.childWorkspaces) {
146
- acc.push(...workspace.childWorkspaces);
147
- }
144
+ if (workspace.childWorkspaces) acc.push(...workspace.childWorkspaces);
148
145
  return acc;
149
146
  }, []);
150
147
  return allWorkspaces.sort((a, b) => a.name.localeCompare(b.name));
@@ -199,9 +196,7 @@ const workspaceDelete = (gqlClient) => {
199
196
  const workspaceAddCredits = (gqlClient) => {
200
197
  return async (workspaceId, amount) => {
201
198
  const id = (0, __settlemint_sdk_utils_validation.validate)(__settlemint_sdk_utils_validation.IdSchema, workspaceId);
202
- if (amount <= 0) {
203
- throw new Error("Credit amount must be a positive number");
204
- }
199
+ if (amount <= 0) throw new Error("Credit amount must be a positive number");
205
200
  const { addCredits: result } = await gqlClient.request(addCredits, {
206
201
  workspaceId: id,
207
202
  amount
@@ -378,9 +373,7 @@ const applicationAccessTokenCreate = (gqlClient) => {
378
373
  ...otherArgs,
379
374
  applicationId: application.id
380
375
  });
381
- if (!applicationAccessToken.token) {
382
- throw new Error("Failed to create application access token");
383
- }
376
+ if (!applicationAccessToken.token) throw new Error("Failed to create application access token");
384
377
  return applicationAccessToken.token;
385
378
  };
386
379
  };
@@ -411,17 +404,15 @@ function setClusterServiceDefaults(args) {
411
404
  */
412
405
  function setNetworkDefaults(args) {
413
406
  const clusterServiceArgs = setClusterServiceDefaults(args);
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
- }
407
+ if (args.consensusAlgorithm === "BESU_QBFT") return {
408
+ ...clusterServiceArgs,
409
+ chainId: args.chainId ?? 46040,
410
+ contractSizeLimit: args.contractSizeLimit ?? 2147483647,
411
+ evmStackSize: args.evmStackSize ?? 2048,
412
+ gasLimit: args.gasLimit ?? "9007199254740991",
413
+ gasPrice: args.gasPrice ?? 0,
414
+ secondsPerBlock: args.secondsPerBlock ?? 2
415
+ };
425
416
  return clusterServiceArgs;
426
417
  }
427
418
 
@@ -1540,8 +1531,8 @@ const insightsCreate = (gqlClient) => {
1540
1531
  const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName,...otherArgs } = args;
1541
1532
  const [application, blockchainNode, loadBalancer] = await Promise.all([
1542
1533
  applicationRead(gqlClient)(applicationUniqueName),
1543
- blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(undefined),
1544
- loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(undefined)
1534
+ blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(void 0),
1535
+ loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(void 0)
1545
1536
  ]);
1546
1537
  const { createInsights: insights } = await gqlClient.request(createInsights, {
1547
1538
  ...otherArgs,
@@ -2148,9 +2139,9 @@ const middlewareCreate = (gqlClient) => {
2148
2139
  const { applicationUniqueName, blockchainNodeUniqueName, loadBalancerUniqueName, storageUniqueName,...otherArgs } = args;
2149
2140
  const [application, blockchainNode, loadBalancer, storage] = await Promise.all([
2150
2141
  applicationRead(gqlClient)(applicationUniqueName),
2151
- blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(undefined),
2152
- loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(undefined),
2153
- storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(undefined)
2142
+ blockchainNodeUniqueName ? blockchainNodeRead(gqlClient)(blockchainNodeUniqueName) : Promise.resolve(void 0),
2143
+ loadBalancerUniqueName ? loadBalancerRead(gqlClient)(loadBalancerUniqueName) : Promise.resolve(void 0),
2144
+ storageUniqueName ? storageRead(gqlClient)(storageUniqueName) : Promise.resolve(void 0)
2154
2145
  ]);
2155
2146
  const { createMiddleware: middleware } = await gqlClient.request(createMiddleware, {
2156
2147
  ...otherArgs,
@@ -2416,7 +2407,7 @@ const privateKeyCreate = (gqlClient) => {
2416
2407
  const { applicationUniqueName, blockchainNodeUniqueNames, relayerKeyUniqueName,...otherArgs } = args;
2417
2408
  const application = await applicationRead(gqlClient)(applicationUniqueName);
2418
2409
  const blockchainNodes = blockchainNodeUniqueNames ? await Promise.all(blockchainNodeUniqueNames.map((uniqueName) => blockchainNodeRead(gqlClient)(uniqueName))) : [];
2419
- const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) : undefined;
2410
+ const relayerKey = relayerKeyUniqueName ? await privatekeyRead(gqlClient)(relayerKeyUniqueName) : void 0;
2420
2411
  const platformConfig = await getPlatformConfig(gqlClient)();
2421
2412
  const defaultProvider = platformConfig.deploymentEngineTargets.find((target) => !target.disabled && target.clusters.some((cluster) => !cluster.disabled));
2422
2413
  const defaultRegion = defaultProvider?.clusters.find((cluster) => !cluster.disabled);
@@ -2503,9 +2494,7 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
2503
2494
  }
2504
2495
  });
2505
2496
  if (!response.ok) {
2506
- if (response.status === 404) {
2507
- throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
2508
- }
2497
+ if (response.status === 404) throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
2509
2498
  throw new Error("Failed to get verification challenge");
2510
2499
  }
2511
2500
  const verificationChallenges = await response.json();
@@ -2518,9 +2507,7 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
2518
2507
  * @returns The pincode verification challenge response.
2519
2508
  */
2520
2509
  function getPincodeVerificationChallengeResponse({ verificationChallenge, pincode }) {
2521
- if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) {
2522
- throw new Error("Could not authenticate pin code, invalid challenge format");
2523
- }
2510
+ if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) throw new Error("Could not authenticate pin code, invalid challenge format");
2524
2511
  const { secret, salt } = verificationChallenge.challenge;
2525
2512
  return generateResponse(pincode, salt, secret);
2526
2513
  }
@@ -2553,13 +2540,8 @@ function getPincodeVerificationChallengeResponse({ verificationChallenge, pincod
2553
2540
  */
2554
2541
  function createSettleMintClient(options) {
2555
2542
  (0, __settlemint_sdk_utils_runtime.ensureServer)();
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
- }
2543
+ if (options.instance === __settlemint_sdk_utils_validation.STANDALONE_INSTANCE || options.instance === __settlemint_sdk_utils_validation.LOCAL_INSTANCE) if (options.anonymous) options.instance = "https://console.settlemint.com";
2544
+ else throw new Error("Standalone and local instances cannot connect to the SettleMint platform");
2563
2545
  const validatedOptions = options.anonymous ? (0, __settlemint_sdk_utils_validation.validate)(zod_v4.z.object({
2564
2546
  ...ClientOptionsSchema.shape,
2565
2547
  accessToken: zod_v4.z.literal("")