@bolt-liquidity-hq/core 0.1.0-beta.10

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2025] Bolt Liquidity
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @bolt-liquidity-hq/core
2
+
3
+ Core types, interfaces, and utilities for the Bolt Liquidity SDK ecosystem.
4
+
5
+ ## 📦 Installation
6
+
7
+ ```bash
8
+ # Using npm
9
+ npm install @bolt-liquidity-hq/core
10
+
11
+ # Using yarn
12
+ yarn add @bolt-liquidity-hq/core
13
+
14
+ # Using pnpm
15
+ pnpm add @bolt-liquidity-hq/core
16
+ ```
17
+
18
+ ## 🎯 Purpose
19
+
20
+ This package provides the foundational building blocks used across all Bolt Liquidity SDK packages:
21
+
22
+ - **Type Definitions**: Strongly-typed interfaces for assets, chains, prices, and more
23
+ - **Base Classes**: Abstract implementations for clients and error handling
24
+ - **Utility Functions**: Common helpers for formatting, validation, and conversion
25
+ - **Constants**: Shared configuration values and defaults
26
+
27
+ ## 📚 What's Included
28
+
29
+ ### Types & Interfaces
30
+
31
+ ```typescript
32
+ import {
33
+ Asset,
34
+ ChainConfig,
35
+ Price,
36
+ SwapParams,
37
+ Pool,
38
+ OracleConfig,
39
+ RouterConfig,
40
+ } from '@bolt-liquidity-hq/core';
41
+ ```
42
+
43
+ ### Error Classes
44
+
45
+ ```typescript
46
+ import {
47
+ BaseError,
48
+ NotFoundError,
49
+ InvalidParameterError,
50
+ TransactionError,
51
+ } from '@bolt-liquidity-hq/core';
52
+
53
+ // Type-safe error handling
54
+ try {
55
+ // ... operation
56
+ } catch (error) {
57
+ if (error instanceof NotFoundError) {
58
+ console.error('Resource not found:', error.message);
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### Utility Functions
64
+
65
+ ```typescript
66
+ import { getCoinFromAmountWithDenomString } from '@bolt-liquidity-hq/core';
67
+
68
+ // Extract coin from a string
69
+ const parsed = getCoinFromAmountWithDenomString('1000000uatom'); // { amount: "1000000", denom: "uatom" }
70
+ ```
71
+
72
+ ### Base Classes
73
+
74
+ ```typescript
75
+ import { BaseClient } from '@bolt-liquidity-hq/core';
76
+
77
+ // Extend for blockchain-specific implementations
78
+ class MyCustomClient extends BaseClient {
79
+ // Implementation details
80
+ }
81
+ ```
82
+
83
+ ## 📖 API Reference
84
+
85
+ Full API documentation is available in our [docs](https://bolt-liquidity-hq.github.io/bolt-liquidity-ts-sdk/).
86
+
87
+ ## Development
88
+
89
+ See the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
90
+
91
+ ## 📄 License
92
+
93
+ Apache 2.0 - see [LICENSE](../../LICENSE) for details.
package/dist/index.cjs ADDED
@@ -0,0 +1,393 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // src/index.ts
23
+ var index_exports = {};
24
+ __export(index_exports, {
25
+ BaseClient: () => BaseClient,
26
+ BoltSdkErrorBase: () => BoltSdkErrorBase,
27
+ InsufficientFundsError: () => InsufficientFundsError,
28
+ InvalidAddressError: () => InvalidAddressError,
29
+ InvalidObjectError: () => InvalidObjectError,
30
+ InvalidParameterError: () => InvalidParameterError,
31
+ InvalidTypeError: () => InvalidTypeError,
32
+ MissingParameterError: () => MissingParameterError,
33
+ NetworkError: () => NetworkError,
34
+ NotFoundError: () => NotFoundError,
35
+ ParameterOutOfRangeError: () => ParameterOutOfRangeError,
36
+ ParseError: () => ParseError,
37
+ TransactionEventNotFoundError: () => TransactionEventNotFoundError,
38
+ TransactionFailedError: () => TransactionFailedError,
39
+ UnexpectedError: () => UnexpectedError,
40
+ getCoinFromAmountWithDenomString: () => getCoinFromAmountWithDenomString
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+
44
+ // src/errors.ts
45
+ var BoltSdkErrorBase = class extends Error {
46
+ /**
47
+ * Creates a new BoltSdkErrorBase instance.
48
+ *
49
+ * @param code - The error code categorizing this error
50
+ * @param message - Human-readable error message
51
+ * @param context - Optional additional context or state information
52
+ */
53
+ constructor(code, message, context) {
54
+ super(message);
55
+ this.code = code;
56
+ /** Optional additional context data that might help debugging */
57
+ __publicField(this, "context");
58
+ this.name = this.constructor.name;
59
+ this.context = context;
60
+ }
61
+ };
62
+ var NotFoundError = class extends BoltSdkErrorBase {
63
+ /**
64
+ * Creates a new NotFoundError instance.
65
+ *
66
+ * @param resource - The type of resource that was not found
67
+ * @param details - Optional additional details about what was searched for
68
+ * @param context - Optional additional context or state information
69
+ */
70
+ constructor(resource, details, context) {
71
+ super(
72
+ 1e3 /* NOT_FOUND */,
73
+ `Resource not found: ${resource}.${details ? ` Details: ${details}` : ""}`,
74
+ context
75
+ );
76
+ }
77
+ };
78
+ var InvalidObjectError = class extends BoltSdkErrorBase {
79
+ /**
80
+ * Creates a new InvalidObjectError instance.
81
+ *
82
+ * @param details - Optional description of what is invalid about the object
83
+ * @param context - Optional additional context or state information
84
+ */
85
+ constructor(details, context) {
86
+ super(
87
+ 1001 /* INVALID_OBJECT */,
88
+ `Invalid object or data structure!${details ? ` Details: ${details}` : ""}`,
89
+ context
90
+ );
91
+ }
92
+ };
93
+ var InvalidTypeError = class extends BoltSdkErrorBase {
94
+ /**
95
+ * Creates a new InvalidTypeError instance.
96
+ *
97
+ * @param expectedType - The type that was expected
98
+ * @param receivedType - The actual type that was received
99
+ * @param context - Optional additional context or state information
100
+ */
101
+ constructor(expectedType, receivedType, context) {
102
+ super(
103
+ 1002 /* INVALID_TYPE */,
104
+ `Invalid object type! Expected: ${expectedType}, Received: ${receivedType}`,
105
+ context
106
+ );
107
+ }
108
+ };
109
+ var ParseError = class extends BoltSdkErrorBase {
110
+ /**
111
+ * Creates a new ParseError instance.
112
+ *
113
+ * @param targetType - The TypeScript type or interface name that parsing failed for
114
+ * @param details - Specific details about what failed during parsing
115
+ * @param context - Optional additional context including the raw data that failed to parse
116
+ */
117
+ constructor(targetType, details, context) {
118
+ super(
119
+ 1002 /* INVALID_TYPE */,
120
+ `Failed to parse response to type '${targetType}': ${details}`,
121
+ context
122
+ );
123
+ }
124
+ };
125
+ var InsufficientFundsError = class extends BoltSdkErrorBase {
126
+ /**
127
+ * Creates a new InsufficientFundsError instance.
128
+ *
129
+ * @param required - The amount required for the operation
130
+ * @param available - The amount available in the account
131
+ * @param context - Optional additional context or state information
132
+ */
133
+ constructor(required, available, context) {
134
+ super(
135
+ 2e3 /* INSUFFICIENT_FUNDS */,
136
+ `Insufficient funds to complete the transaction! Required: ${required}, Available: ${available}`,
137
+ context
138
+ );
139
+ }
140
+ };
141
+ var InvalidAddressError = class extends BoltSdkErrorBase {
142
+ /**
143
+ * Creates a new InvalidAddressError instance.
144
+ *
145
+ * @param address - The invalid address that was provided
146
+ * @param context - Optional additional context or state information
147
+ */
148
+ constructor(address, context) {
149
+ super(
150
+ 2001 /* INVALID_ADDRESS */,
151
+ `Invalid blockchain address provided: ${address}`,
152
+ context
153
+ );
154
+ }
155
+ };
156
+ var TransactionFailedError = class extends BoltSdkErrorBase {
157
+ /**
158
+ * Creates a new TransactionFailedError instance.
159
+ *
160
+ * @param transactionId - The transaction hash or identifier
161
+ * @param details - Optional details about why the transaction failed
162
+ * @param context - Optional additional context or state information
163
+ */
164
+ constructor(transactionId, details, context) {
165
+ super(
166
+ 2002 /* TRANSACTION_FAILED */,
167
+ `Transaction failed or was reverted! Transaction ID: ${transactionId}.${details ? ` Details: ${details}` : ""}`,
168
+ context
169
+ );
170
+ }
171
+ };
172
+ var TransactionEventNotFoundError = class extends BoltSdkErrorBase {
173
+ /**
174
+ * Creates a new TransactionEventNotFoundError instance.
175
+ *
176
+ * @param eventName - The name of the event that was expected
177
+ * @param details - Optional details about the context
178
+ * @param context - Optional additional context or state information
179
+ */
180
+ constructor(eventName, details, context) {
181
+ super(
182
+ 2003 /* TRANSACTION_EVENT_NOT_FOUND */,
183
+ `Transaction Event not found: ${eventName}.${details ? ` Details: ${details}` : ""}`,
184
+ context
185
+ );
186
+ }
187
+ };
188
+ var NetworkError = class extends BoltSdkErrorBase {
189
+ /**
190
+ * Creates a new NetworkError instance.
191
+ *
192
+ * @param details - Optional details about the network failure
193
+ * @param context - Optional additional context or state information
194
+ */
195
+ constructor(details, context) {
196
+ super(
197
+ 3e3 /* NETWORK_ERROR */,
198
+ `Network error occurred!${details ? ` Details: ${details}` : ""}`,
199
+ context
200
+ );
201
+ }
202
+ };
203
+ var InvalidParameterError = class extends BoltSdkErrorBase {
204
+ /**
205
+ * Creates a new InvalidParameterError instance.
206
+ *
207
+ * @param parameterName - The name of the invalid parameter
208
+ * @param expected - Description of what was expected
209
+ * @param receivedValue - The actual value that was provided
210
+ * @param details - Optional additional details or constraints
211
+ * @param context - Optional additional context or state information
212
+ *
213
+ * @template T - The type of the received value
214
+ */
215
+ constructor(parameterName, expected, receivedValue, details, context) {
216
+ super(
217
+ 4e3 /* INVALID_PARAMETER */,
218
+ `Invalid parameter '${parameterName}': expected ${expected}, received ${typeof receivedValue}${details ? `. ${details}` : ""}`,
219
+ context
220
+ );
221
+ }
222
+ };
223
+ var MissingParameterError = class extends BoltSdkErrorBase {
224
+ /**
225
+ * Creates a new MissingParameterError instance.
226
+ *
227
+ * @param parameterName - The name of the missing parameter
228
+ * @param expectedLocation - Optional context about where the parameter was expected to be found
229
+ * @param context - Optional additional context or state information
230
+ */
231
+ constructor(parameterName, expectedLocation, context) {
232
+ super(
233
+ 4001 /* MISSING_PARAMETER */,
234
+ `Required parameter '${parameterName}' is missing${context ? ` in ${expectedLocation}` : ""}`,
235
+ context
236
+ );
237
+ }
238
+ };
239
+ var ParameterOutOfRangeError = class extends BoltSdkErrorBase {
240
+ /**
241
+ * Creates a new ParameterOutOfRangeError instance.
242
+ *
243
+ * @param parameterName - The name of the parameter that's out of range
244
+ * @param value - The actual value that was provided
245
+ * @param min - Optional minimum acceptable value (inclusive)
246
+ * @param max - Optional maximum acceptable value (inclusive)
247
+ * @param details - Optional additional details about the constraint
248
+ * @param context - Optional additional context or state information
249
+ */
250
+ constructor(parameterName, value, min, max, details, context) {
251
+ let rangeMessage = "";
252
+ if (min !== void 0 && max !== void 0) {
253
+ rangeMessage = ` Expected value between ${min} and ${max}, but received ${value}`;
254
+ } else if (min !== void 0) {
255
+ rangeMessage = ` Expected value >= ${min}, but received ${value}`;
256
+ } else if (max !== void 0) {
257
+ rangeMessage = ` Expected value <= ${max}, but received ${value}`;
258
+ }
259
+ super(
260
+ 4002 /* PARAMETER_OUT_OF_RANGE */,
261
+ `Parameter '${parameterName}' is out of range.${rangeMessage}${details ? `. ${details}` : ""}`,
262
+ context
263
+ );
264
+ }
265
+ };
266
+ var UnexpectedError = class _UnexpectedError extends BoltSdkErrorBase {
267
+ /**
268
+ * Creates a new UnexpectedError instance.
269
+ *
270
+ * @param message - A description of the unexpected error
271
+ * @param originalError - Optional original error that was caught
272
+ * @param context - Optional additional context or state information
273
+ */
274
+ constructor(message, originalError, context) {
275
+ super(9e3 /* UNEXPECTED_ERROR */, message, context);
276
+ /** The original error that was caught, if any */
277
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
278
+ __publicField(this, "originalError");
279
+ this.originalError = originalError;
280
+ if (originalError instanceof Error && originalError.stack) {
281
+ this.stack = this.stack + "\n\nCaused by:\n" + originalError.stack;
282
+ }
283
+ }
284
+ /**
285
+ * Creates an UnexpectedError from an unknown caught value.
286
+ * This is a convenience method for error handling blocks.
287
+ *
288
+ * @param caught - The value that was caught in a try-catch block
289
+ * @param message - Optional custom message to prepend
290
+ * @param context - Optional additional context
291
+ * @returns A new UnexpectedError instance
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * try {
296
+ * await riskyOperation();
297
+ * } catch (caught) {
298
+ * throw UnexpectedError.from(
299
+ * caught,
300
+ * "Failed to execute risky operation",
301
+ * { operation: 'riskyOperation', timestamp: Date.now() }
302
+ * );
303
+ * }
304
+ * ```
305
+ */
306
+ static from(caught, message, context) {
307
+ const errorMessage = message ? `${message}: ${caught instanceof Error ? caught.message : String(caught)}` : caught instanceof Error ? caught.message : String(caught);
308
+ return new _UnexpectedError(errorMessage, caught, context);
309
+ }
310
+ };
311
+
312
+ // src/helpers/asset.ts
313
+ var getCoinFromAmountWithDenomString = (amountWithDenom) => {
314
+ const match = amountWithDenom.match(/^(\d+)(.+)$/);
315
+ if (!match || !match[1] || !match[2]) {
316
+ throw new InvalidParameterError(
317
+ "amountWithDenom",
318
+ "a string with the amount followed by the denom",
319
+ amountWithDenom
320
+ );
321
+ }
322
+ return { amount: match[1], denom: match[2] };
323
+ };
324
+
325
+ // src/lib/client.ts
326
+ var BaseClient = class {
327
+ /**
328
+ * Creates a new instance of the BaseClient.
329
+ *
330
+ * @param config - (Optional) Configuration object for the client
331
+ * @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, and assets
332
+ * @param config.customOverride.chainConfig - (Optional) Chain configuration object
333
+ * @param config.customOverride.chainConfig.id - (Optional) The chain ID of the blockchain network (e.g., "archway-1")
334
+ * @param config.customOverride.chainConfig.name - (Optional) The human-readable name of the chain (e.g., "Archway")
335
+ * @param config.customOverride.chainConfig.rpcEndpoint - (Optional) RPC endpoint URL for the blockchain network
336
+ * @param config.customOverride.contracts - (Optional) Contract addresses for oracle and router
337
+ * @param config.customOverride.contracts.oracle - (Optional) Oracle contract address
338
+ * @param config.customOverride.contracts.router - (Optional) Router contract address
339
+ * @param config.customOverride.assetsConfig - (Optional) Configuration for supported assets indexed by symbol
340
+ *
341
+ * @throws {InvalidObjectError} Thrown when required configuration fields are missing
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * const client = new ConcreteClient({
346
+ * customOverride: {
347
+ * chainConfig: {
348
+ * id: 'archway-1',
349
+ * name: 'Archway',
350
+ * rpcEndpoint: 'https://rpc.example.com'
351
+ * },
352
+ * contracts: {
353
+ * oracle: 'archway1oracle...',
354
+ * router: 'archway1router...'
355
+ * },
356
+ * assetsConfig: {
357
+ * 'ARCH': {
358
+ * symbol: 'ARCH',
359
+ * name: 'Archway',
360
+ * chainId: 'archway-1',
361
+ * denom: 'aarch',
362
+ * decimals: 18,
363
+ * logo: 'https://...',
364
+ * coingeckoId: 'archway'
365
+ * }
366
+ * }
367
+ * }
368
+ * });
369
+ * ```
370
+ */
371
+ constructor(config) {
372
+ /**
373
+ * The blockchain network configuration containing chain ID, name, and RPC endpoint
374
+ */
375
+ __publicField(this, "chainConfig");
376
+ /**
377
+ * Smart contract addresses for making Bolt queries and transactions in the blockchain
378
+ */
379
+ __publicField(this, "contracts");
380
+ /**
381
+ * Configuration mapping of supported assets indexed by their symbol
382
+ */
383
+ __publicField(this, "assetsConfig");
384
+ const { customOverride: { chainConfig, contracts, assetsConfig } = {} } = config ?? {};
385
+ if (!chainConfig || !chainConfig?.id || !chainConfig?.name || !chainConfig?.rpcEndpoint || !contracts?.oracle || !contracts?.router || !assetsConfig) {
386
+ throw new InvalidObjectError("ClientConfig is missing fields");
387
+ }
388
+ this.chainConfig = chainConfig;
389
+ this.contracts = contracts;
390
+ this.assetsConfig = assetsConfig;
391
+ }
392
+ };
393
+ //# sourceMappingURL=index.cjs.map