@trustware/sdk-staging 1.0.17-staging.14 → 1.0.17-staging.15

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.
@@ -29,7 +29,7 @@ __export(constants_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(constants_exports);
31
31
  var SDK_NAME = "@trustware/sdk";
32
- var SDK_VERSION = "1.0.17-staging.14";
32
+ var SDK_VERSION = "1.0.17-staging.15";
33
33
  var API_ROOT = "https://bv-staging-api.trustware.io";
34
34
  var API_PREFIX = "/api";
35
35
  var ASSETS_BASE_URL = "https://app.trustware.io";
@@ -1,6 +1,6 @@
1
1
  // src/constants.ts
2
2
  var SDK_NAME = "@trustware/sdk";
3
- var SDK_VERSION = "1.0.17-staging.14";
3
+ var SDK_VERSION = "1.0.17-staging.15";
4
4
  var API_ROOT = "https://bv-staging-api.trustware.io";
5
5
  var API_PREFIX = "/api";
6
6
  var ASSETS_BASE_URL = "https://app.trustware.io";
@@ -0,0 +1,435 @@
1
+ import { p as ChainDef, o as ChainType, B as BalanceRow, n as WalletAddressBalanceWrapper, W as WalletInterFaceAPI, x as WalletIdentity, A as walletManager, y as WalletAddressResolution } from './manager-CgpuAzqn.js';
2
+ import { T as Token } from './types-BrVfNxND.js';
3
+
4
+ declare enum TrustwareErrorCode {
5
+ INVALID_CONFIG = "INVALID_CONFIG",
6
+ INVALID_API_KEY = "INVALID_API_KEY",
7
+ WALLET_NOT_CONNECTED = "WALLET_NOT_CONNECTED",
8
+ BRIDGE_FAILED = "BRIDGE_FAILED",
9
+ NETWORK_ERROR = "NETWORK_ERROR",
10
+ UNKNOWN_ERROR = "UNKNOWN_ERROR",
11
+ INPUT_ERROR = "INPUT_ERROR"
12
+ }
13
+
14
+ declare class TrustwareError extends Error {
15
+ code: TrustwareErrorCode;
16
+ userMessage?: string;
17
+ cause?: unknown;
18
+ constructor(params: {
19
+ code: TrustwareErrorCode;
20
+ message: string;
21
+ userMessage?: string;
22
+ cause?: unknown;
23
+ });
24
+ toJSON(): {
25
+ name: string;
26
+ code: TrustwareErrorCode;
27
+ message: string;
28
+ userMessage: string | undefined;
29
+ };
30
+ }
31
+
32
+ type TrustwareWidgetTheme = {
33
+ primaryColor: string;
34
+ secondaryColor: string;
35
+ backgroundColor: string;
36
+ textColor: string;
37
+ borderColor: string;
38
+ radius: number;
39
+ };
40
+ type TrustwareWidgetMessages = {
41
+ title: string;
42
+ description: string;
43
+ };
44
+ declare const DEFAULT_THEME: TrustwareWidgetTheme;
45
+ declare const DEFAULT_MESSAGES: TrustwareWidgetMessages;
46
+
47
+ type BuildRouteBody = {
48
+ fromChain: string;
49
+ toChain: string;
50
+ fromToken: string;
51
+ toToken: string;
52
+ fromAmount: string;
53
+ fromAddress: string;
54
+ toAddress: string;
55
+ fromAmountUsd?: string;
56
+ fromAmountUSD?: string;
57
+ refundAddress?: string;
58
+ direction?: string;
59
+ slippage?: number;
60
+ slippageBps?: number;
61
+ linkId?: string;
62
+ memo?: string;
63
+ };
64
+ type TxRequest = {
65
+ to?: string;
66
+ target?: string;
67
+ data: string;
68
+ value?: string;
69
+ gasLimit?: string;
70
+ maxFeePerGas?: string;
71
+ maxPriorityFeePerGas?: string;
72
+ chainId?: number | string;
73
+ gasPrice?: string;
74
+ };
75
+ declare function buildRoute(body: BuildRouteBody, signal?: AbortSignal): Promise<{
76
+ intentId: string;
77
+ txReq: TxRequest;
78
+ actions: unknown[];
79
+ finalExchangeRate: {
80
+ fromAmountUSD?: string;
81
+ toAmountMinUSD?: string;
82
+ };
83
+ route: RoutePlan | undefined;
84
+ }>;
85
+ declare function buildDepositAddress(body: BuildRouteBody, signal?: AbortSignal): Promise<{
86
+ intentId: string;
87
+ depositAddress: string;
88
+ actions: unknown[];
89
+ finalExchangeRate: {
90
+ fromAmountUSD?: string;
91
+ toAmountMinUSD?: string;
92
+ };
93
+ route: RoutePlan | undefined;
94
+ }>;
95
+ declare function submitReceipt(intentId: string, txHash: string): Promise<any>;
96
+ declare function getStatus(intentId: string): Promise<Transaction>;
97
+ declare function pollStatus(intentId: string, { intervalMs, timeoutMs }?: {
98
+ intervalMs?: number | undefined;
99
+ timeoutMs?: number | undefined;
100
+ }): Promise<Transaction>;
101
+
102
+ type RouteParams = {
103
+ fromChain: string;
104
+ toChain: string;
105
+ fromToken: string;
106
+ toToken: string;
107
+ fromAmount: string | number;
108
+ fromAddress: string;
109
+ toAddress: string;
110
+ slippage?: number;
111
+ };
112
+ type RouteIntent = {
113
+ id: string;
114
+ fromChainId: string | number;
115
+ toChainId: string | number;
116
+ fromToken: string;
117
+ toToken: string;
118
+ fromAddress: string;
119
+ toAddress: string;
120
+ fromAmountWei: string | number;
121
+ quoteToAmountWei: string | number;
122
+ minToAmountWei: string | number;
123
+ requestId?: string;
124
+ routeRaw?: unknown;
125
+ status: "created" | "submitted" | "bridging" | "success" | "failed";
126
+ createdDate: Date | string;
127
+ updatedDate: Date | string;
128
+ };
129
+ type Transaction = {
130
+ id: string;
131
+ intentId: string;
132
+ fromAddress: string;
133
+ toAddress: string;
134
+ fromChainId: string | number;
135
+ toChainId: string | number;
136
+ sourceTxHash: string;
137
+ destTxHash: string;
138
+ requestId: string;
139
+ transactionRequest: unknown;
140
+ status: "submitted" | "bridging" | "success" | "failed";
141
+ statusRaw?: unknown;
142
+ routePath?: unknown;
143
+ routeStatus?: unknown;
144
+ toAmountWei?: string | number;
145
+ fromChainBlock: number;
146
+ toChainBlock: number;
147
+ fromChainTxUrl?: string;
148
+ toChainTxUrl?: string;
149
+ gasStatus?: string;
150
+ isGMPTransaction?: boolean;
151
+ axelarTransactionUrl?: string;
152
+ createdDate: Date | string;
153
+ updatedDate: Date | string;
154
+ timeSpentMs?: number;
155
+ };
156
+ type RouteEstimate = {
157
+ fromAmount?: string;
158
+ toAmount?: string;
159
+ toAmountMin?: string;
160
+ fromAmountUsd?: string;
161
+ toAmountUsd?: string;
162
+ totalFeesUsd?: string;
163
+ toAmountMinUsd?: string;
164
+ fees?: unknown[];
165
+ };
166
+ type RoutePlan = {
167
+ estimate?: RouteEstimate;
168
+ execution?: {
169
+ transaction?: TxRequest;
170
+ };
171
+ steps?: unknown[];
172
+ provider?: string;
173
+ requestId?: string;
174
+ reliabilityScore?: number;
175
+ diagnostics?: {
176
+ rawPayload?: unknown;
177
+ };
178
+ };
179
+ type BuildRouteResult = {
180
+ intentId: string;
181
+ txReq: TxRequest;
182
+ actions: unknown[];
183
+ finalExchangeRate: {
184
+ fromAmountUSD?: string;
185
+ toAmountMinUSD?: string;
186
+ };
187
+ route: RoutePlan | undefined;
188
+ };
189
+
190
+ type TrustwareEvent = {
191
+ type: "error";
192
+ error: TrustwareError;
193
+ } | {
194
+ type: "transaction_started";
195
+ } | {
196
+ type: "transaction_success";
197
+ txHash: string;
198
+ transaction?: Transaction;
199
+ } | {
200
+ type: "wallet_connected";
201
+ address: string;
202
+ };
203
+
204
+ /** WalletConnect configuration options (all optional - SDK has built-in defaults) */
205
+ type WalletConnectConfig = {
206
+ /** Override the built-in WalletConnect project ID (optional - SDK includes one) */
207
+ projectId?: string;
208
+ /** Chain IDs to support (defaults to [1] for Ethereum mainnet) */
209
+ chains?: number[];
210
+ /** Optional chain IDs (chains that can be switched to) */
211
+ optionalChains?: number[];
212
+ /** dApp metadata shown in wallet */
213
+ metadata?: {
214
+ name: string;
215
+ description?: string;
216
+ url: string;
217
+ icons?: string[];
218
+ };
219
+ /** Custom relay URL (defaults to WalletConnect's relay) */
220
+ relayUrl?: string;
221
+ /** Whether to show our custom QR modal (default: true) */
222
+ showQrModal?: boolean;
223
+ /** Disable WalletConnect entirely (default: false) */
224
+ disabled?: boolean;
225
+ };
226
+ /** Resolved WalletConnect config with defaults applied */
227
+ type ResolvedWalletConnectConfig = {
228
+ projectId: string;
229
+ chains: number[];
230
+ optionalChains: number[];
231
+ metadata: {
232
+ name: string;
233
+ description: string;
234
+ url: string;
235
+ icons: string[];
236
+ };
237
+ relayUrl?: string;
238
+ showQrModal: boolean;
239
+ };
240
+ type TrustwareConfigOptions = {
241
+ apiKey: string;
242
+ routes: {
243
+ toChain: string;
244
+ toToken: string;
245
+ fromToken?: string;
246
+ fromAddress?: string;
247
+ toAddress?: string;
248
+ defaultSlippage?: number;
249
+ routeType?: string;
250
+ options?: {
251
+ routeRefreshMs?: number;
252
+ fixedFromAmount?: string | number;
253
+ minAmountOut?: string | number;
254
+ maxAmountOut?: string | number;
255
+ };
256
+ };
257
+ autoDetectProvider?: boolean;
258
+ theme?: TrustwareWidgetTheme;
259
+ messages?: Partial<TrustwareWidgetMessages>;
260
+ retry?: RetryConfig;
261
+ walletConnect?: WalletConnectConfig;
262
+ onError?: (error: TrustwareError) => void;
263
+ onSuccess?: (transaction: Transaction) => void;
264
+ onEvent?: (event: TrustwareEvent) => void;
265
+ };
266
+ type ResolvedTrustwareConfig = {
267
+ apiKey: string;
268
+ routes: {
269
+ toChain: string;
270
+ toToken: string;
271
+ fromToken?: string;
272
+ fromAddress?: string;
273
+ toAddress?: string;
274
+ defaultSlippage: number;
275
+ routeType: string;
276
+ options: {
277
+ routeRefreshMs?: number;
278
+ fixedFromAmount?: string | number;
279
+ minAmountOut?: string | number;
280
+ maxAmountOut?: string | number;
281
+ };
282
+ };
283
+ autoDetectProvider: boolean;
284
+ theme: TrustwareWidgetTheme;
285
+ messages: TrustwareWidgetMessages;
286
+ retry: ResolvedRetryConfig;
287
+ walletConnect?: ResolvedWalletConnectConfig;
288
+ onError?: (error: TrustwareError) => void;
289
+ onSuccess?: (transaction: Transaction) => void;
290
+ onEvent?: (event: TrustwareEvent) => void;
291
+ };
292
+ declare const DEFAULT_SLIPPAGE = 1;
293
+ declare const DEFAULT_AUTO_DETECT_PROVIDER = false;
294
+ type RateLimitInfo = {
295
+ /** Maximum requests allowed in the current window */
296
+ limit: number;
297
+ /** Requests remaining in the current window */
298
+ remaining: number;
299
+ /** Unix timestamp when the rate limit window resets */
300
+ reset: number;
301
+ /** Seconds until rate limit resets (only present on 429 responses) */
302
+ retryAfter?: number;
303
+ };
304
+ type RetryConfig = {
305
+ /** Enable automatic retry on 429 responses (default: true). Note: This does NOT disable backend rate limits, only client-side retry behavior. */
306
+ autoRetry?: boolean;
307
+ /** Maximum number of retries on 429 (default: 3) */
308
+ maxRetries?: number;
309
+ /** Base delay in ms for exponential backoff (default: 1000) */
310
+ baseDelayMs?: number;
311
+ /** Callback when rate limit info is received from server */
312
+ onRateLimitInfo?: (info: RateLimitInfo) => void;
313
+ /** Callback when rate limit is hit (429 received) */
314
+ onRateLimited?: (info: RateLimitInfo, retryCount: number) => void;
315
+ /** Callback when remaining requests fall below threshold */
316
+ onRateLimitApproaching?: (info: RateLimitInfo, threshold: number) => void;
317
+ /** Threshold for onRateLimitApproaching callback (default: 5) */
318
+ approachingThreshold?: number;
319
+ };
320
+ type ResolvedRetryConfig = {
321
+ autoRetry: boolean;
322
+ maxRetries: number;
323
+ baseDelayMs: number;
324
+ approachingThreshold: number;
325
+ onRateLimitInfo?: (info: RateLimitInfo) => void;
326
+ onRateLimited?: (info: RateLimitInfo, retryCount: number) => void;
327
+ onRateLimitApproaching?: (info: RateLimitInfo, threshold: number) => void;
328
+ };
329
+ declare const DEFAULT_RETRY_CONFIG: ResolvedRetryConfig;
330
+
331
+ type AddressValidationResult = {
332
+ isValid: boolean;
333
+ error?: string;
334
+ };
335
+ declare function validateEvmAddress(address: string): AddressValidationResult;
336
+ declare function validateSeiAddress(address: string): AddressValidationResult;
337
+ declare function validateSolanaAddress(address: string): AddressValidationResult;
338
+ declare function validateBtcAddress(address: string): AddressValidationResult;
339
+ declare function validateAddressForChain(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
340
+ declare function validateRouteAddresses(params: {
341
+ fromChain?: ChainDef | ChainType | string | null;
342
+ toChain?: ChainDef | ChainType | string | null;
343
+ fromAddress: string;
344
+ toAddress: string;
345
+ refundAddress?: string;
346
+ direction?: string;
347
+ }): AddressValidationResult;
348
+
349
+ /** Map chain reference -> backend chain_key and return enriched balances */
350
+ declare function getBalances(chainRef: string | number, address: string): Promise<BalanceRow[]>;
351
+ declare function getBalancesByAddress(address: string): Promise<WalletAddressBalanceWrapper[]>;
352
+
353
+ declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number | string): Promise<string>;
354
+ declare function runTopUp(params: {
355
+ fromChain?: string;
356
+ toChain?: string;
357
+ fromToken?: string;
358
+ toToken?: string;
359
+ toAddress?: string;
360
+ fromAmount: string | number;
361
+ }): Promise<Transaction>;
362
+
363
+ interface UseChainsResult {
364
+ /** All available chains */
365
+ chains: ChainDef[];
366
+ /** Popular/featured chains (Ethereum, Polygon, Base) */
367
+ popularChains: ChainDef[];
368
+ /** Other chains (not in popular list) */
369
+ otherChains: ChainDef[];
370
+ /** Whether chains are currently loading */
371
+ isLoading: boolean;
372
+ /** Error message if loading failed */
373
+ error: string | null;
374
+ chainMap: Map<string, ChainDef>;
375
+ }
376
+ /**
377
+ * Hook to load available chains from the registry.
378
+ * Returns chains split into popular and other categories.
379
+ */
380
+ declare function useChains(): UseChainsResult;
381
+
382
+ interface UseTokensResult {
383
+ /** All available tokens for the selected chain */
384
+ tokens: Token[];
385
+ /** Filtered tokens based on search query */
386
+ filteredTokens: Token[];
387
+ /** Whether tokens are currently loading */
388
+ isLoading: boolean;
389
+ /** Error message if loading failed */
390
+ error: string | null;
391
+ /** Current search query */
392
+ searchQuery: string;
393
+ /** Set the search query to filter tokens */
394
+ setSearchQuery: (query: string) => void;
395
+ }
396
+ /**
397
+ * Hook to load available tokens for a selected chain from the registry.
398
+ * Supports filtering tokens by name or symbol.
399
+ */
400
+ declare function useTokens(chainId: number | null | undefined): UseTokensResult;
401
+
402
+ declare const Trustware: {
403
+ /** Initialize config */
404
+ init(cfg: TrustwareConfigOptions): Promise</*elided*/ any>;
405
+ /** Attach a wallet interface directly (skips detection) */
406
+ useWallet(w: WalletInterFaceAPI): /*elided*/ any;
407
+ /** Best-effort background attach to detected wallet(s) (detection hook should be running in the app) */
408
+ autoDetect(_timeoutMs?: number): Promise<boolean>;
409
+ /** Read resolved config */
410
+ getConfig(): ResolvedTrustwareConfig;
411
+ setDestinationAddress(address?: string | null): /*elided*/ any;
412
+ /** Read active wallet */
413
+ getWallet(): WalletInterFaceAPI | null;
414
+ getIdentity(): WalletIdentity;
415
+ resolveAddressForChain(chain: Parameters<typeof walletManager.resolveAddressForChain>[0]): WalletAddressResolution;
416
+ addIdentityAddress(address: Parameters<typeof walletManager.addIdentityAddress>[0]): /*elided*/ any;
417
+ /** Simple helpers */
418
+ getAddress(): Promise<string>;
419
+ buildRoute: typeof buildRoute;
420
+ buildDepositAddress: typeof buildDepositAddress;
421
+ submitReceipt: typeof submitReceipt;
422
+ getStatus: typeof getStatus;
423
+ pollStatus: typeof pollStatus;
424
+ getBalances: typeof getBalances;
425
+ getBalancesByAddress: typeof getBalancesByAddress;
426
+ useChains: typeof useChains;
427
+ useTokens: typeof useTokens;
428
+ validateAddressForChain: typeof validateAddressForChain;
429
+ validateRouteAddresses: typeof validateRouteAddresses;
430
+ sendRouteTransaction: typeof sendRouteTransaction;
431
+ runTopUp: typeof runTopUp;
432
+ };
433
+ type TrustwareCore = typeof Trustware;
434
+
435
+ export { type BuildRouteResult as B, DEFAULT_SLIPPAGE as D, type RateLimitInfo as R, type TrustwareConfigOptions as T, type WalletConnectConfig as W, Trustware as a, TrustwareError as b, type Transaction as c, type TrustwareEvent as d, type TrustwareCore as e, validateSeiAddress as f, validateSolanaAddress as g, validateBtcAddress as h, validateAddressForChain as i, validateRouteAddresses as j, type ResolvedWalletConnectConfig as k, type ResolvedTrustwareConfig as l, DEFAULT_AUTO_DETECT_PROVIDER as m, type RetryConfig as n, type ResolvedRetryConfig as o, DEFAULT_RETRY_CONFIG as p, type RouteParams as q, type RouteIntent as r, type RouteEstimate as s, type RoutePlan as t, type TrustwareWidgetTheme as u, validateEvmAddress as v, type TrustwareWidgetMessages as w, DEFAULT_THEME as x, DEFAULT_MESSAGES as y };