@trustware/sdk-staging 1.1.9-staging.6 → 1.1.9-staging.7
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 +5 -4
- package/README.md +32 -1
- package/THIRD_PARTY_NOTICES.md +118 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-2oZuxC1J.d.ts → core-DzqVEWwP.d.ts} +3 -2
- package/dist/{core-BTPkApRH.d.cts → core-gNyi5xsp.d.cts} +3 -2
- package/dist/core.cjs +116 -47
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +116 -47
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-B8xXLwHK.d.ts → detect-Cprq6X9o.d.ts} +1 -1
- package/dist/{detect-C8xpZRrL.d.cts → detect-DWL4uExV.d.cts} +1 -1
- package/dist/index.cjs +154 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +153 -70
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BZwbtOyf.d.cts → manager-DWFNyouP.d.cts} +41 -18
- package/dist/{manager-BMO1O-cW.d.ts → manager-Dn4muk74.d.ts} +41 -18
- package/dist/smart-account.cjs +117 -39
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +117 -39
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +113 -36
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +113 -36
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +119 -49
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +119 -49
- package/dist/widget.mjs.map +1 -1
- package/package.json +3 -2
|
@@ -210,7 +210,11 @@ declare function buildDepositAddress(body: BuildRouteBody, signal?: AbortSignal)
|
|
|
210
210
|
};
|
|
211
211
|
route: RoutePlan | undefined;
|
|
212
212
|
}>;
|
|
213
|
-
declare function submitReceipt(intentId: string, txHash: string, sponsorshipRequestId?: string
|
|
213
|
+
declare function submitReceipt(intentId: string, txHash: string, sponsorshipRequestId?: string,
|
|
214
|
+
/** Connected wallet (EOA) that originated the payment. Pass when the route
|
|
215
|
+
* executes from a smart account, so the backend records the tx against the
|
|
216
|
+
* address the user actually connects with. */
|
|
217
|
+
eoaAddress?: string): Promise<any>;
|
|
214
218
|
declare function getStatus(intentId: string): Promise<Transaction>;
|
|
215
219
|
declare function pollStatus(intentId: string, { intervalMs, timeoutMs }?: {
|
|
216
220
|
intervalMs?: number | undefined;
|
|
@@ -249,6 +253,9 @@ type Transaction = {
|
|
|
249
253
|
intentId: string;
|
|
250
254
|
fromAddress: string;
|
|
251
255
|
toAddress: string;
|
|
256
|
+
/** Connected wallet (EOA) that originated the payment when the sender is a
|
|
257
|
+
* smart account. Wire field: `origin_eoa`. */
|
|
258
|
+
origin_eoa?: string;
|
|
252
259
|
fromChainId: string | number;
|
|
253
260
|
toChainId: string | number;
|
|
254
261
|
sourceTxHash: string;
|
|
@@ -412,23 +419,25 @@ type ResolvedWalletConnectConfig = {
|
|
|
412
419
|
relayUrl?: string;
|
|
413
420
|
showQrModal: boolean;
|
|
414
421
|
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
};
|
|
422
|
+
/** Destination/source route defaults. Required in "deposit" mode; optional (and only
|
|
423
|
+
* partially meaningful) in "swap" mode, where chains/tokens are chosen entirely in-widget. */
|
|
424
|
+
type RoutesConfig = {
|
|
425
|
+
toChain: string;
|
|
426
|
+
toToken: string;
|
|
427
|
+
fromToken?: string;
|
|
428
|
+
fromChain?: string;
|
|
429
|
+
fromAddress?: string;
|
|
430
|
+
toAddress?: string;
|
|
431
|
+
defaultSlippage?: number;
|
|
432
|
+
options?: {
|
|
433
|
+
routeRefreshMs?: number;
|
|
434
|
+
fixedFromAmount?: string | number;
|
|
435
|
+
minAmountOut?: string | number;
|
|
436
|
+
maxAmountOut?: string | number;
|
|
431
437
|
};
|
|
438
|
+
};
|
|
439
|
+
type CommonConfigOptions = {
|
|
440
|
+
apiKey: string;
|
|
432
441
|
autoDetectProvider?: boolean;
|
|
433
442
|
theme?: TrustwareTheme;
|
|
434
443
|
messages?: Partial<TrustwareWidgetMessages>;
|
|
@@ -439,8 +448,18 @@ type TrustwareConfigOptions = {
|
|
|
439
448
|
onSuccess?: (transaction: Transaction) => void;
|
|
440
449
|
onEvent?: (event: TrustwareEvent) => void;
|
|
441
450
|
};
|
|
451
|
+
type TrustwareConfigOptions = CommonConfigOptions & ({
|
|
452
|
+
/** Default mode: bridge/top-up to a preconfigured destination chain+token. */
|
|
453
|
+
mode?: "deposit";
|
|
454
|
+
routes: RoutesConfig;
|
|
455
|
+
} | {
|
|
456
|
+
/** Swap mode: from/to chain+token are chosen entirely in-widget; `routes` is not required. */
|
|
457
|
+
mode: "swap";
|
|
458
|
+
routes?: Partial<RoutesConfig>;
|
|
459
|
+
});
|
|
442
460
|
type ResolvedTrustwareConfig = {
|
|
443
461
|
apiKey: string;
|
|
462
|
+
mode: "deposit" | "swap";
|
|
444
463
|
routes: {
|
|
445
464
|
toChain: string;
|
|
446
465
|
toToken: string;
|
|
@@ -476,6 +495,10 @@ type FeatureFlags = {
|
|
|
476
495
|
tokensPagination?: boolean;
|
|
477
496
|
balanceStreaming?: boolean;
|
|
478
497
|
shouldAllowGA4?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated Use top-level `mode: "swap"` on `TrustwareConfigOptions` instead. Still
|
|
500
|
+
* supported for backward compatibility and treated as equivalent to `mode: "swap"`.
|
|
501
|
+
*/
|
|
479
502
|
swapMode?: boolean;
|
|
480
503
|
/**
|
|
481
504
|
* Pre-selects the destination token in swap mode. When set, the widget opens
|
|
@@ -682,4 +705,4 @@ declare function useWalletInfo(wagmi?: WagmiBridge): {
|
|
|
682
705
|
};
|
|
683
706
|
declare function useWalletExternalDisconnect(cb: () => void): void;
|
|
684
707
|
|
|
685
|
-
export {
|
|
708
|
+
export { useWalletInfo as $, type TrustwareWidgetMessages as A, type BuildRouteResult as B, type WagmiBridge as C, DEFAULT_AUTO_DETECT_PROVIDER as D, type EIP1193 as E, type FeatureFlags as F, type WagmiConnector as G, type WalletAddressResolution as H, IdentityStore as I, type WalletAddressSource as J, type WalletCategory as K, type WalletConnectConfig as L, type WalletEcosystem as M, type WalletId as N, type WalletIdentity as O, type WalletIdentityAddress as P, type WalletIdentityChainLike as Q, type RateLimitInfo as R, type SimpleWalletInterface as S, type TrustwareConfigOptions as T, type WalletMeta as U, buildWalletIdentityAddress as V, type WalletInterFaceAPI as W, createWalletIdentity as X, resolveWalletAddressForChain as Y, upsertWalletIdentityAddress as Z, useWalletExternalDisconnect as _, TrustwareError as a, useWireDetectionIntoManager as a0, walletManager as a1, type WalletSnapshot as a2, useWalletConnectConnect as a3, buildRoute as a4, buildDepositAddress as a5, submitReceipt as a6, getStatus as a7, pollStatus as a8, type Transaction as b, type TrustwareEvent as c, DEFAULT_FEATURE_FLAGS as d, DEFAULT_MESSAGES as e, DEFAULT_RETRY_CONFIG as f, DEFAULT_SLIPPAGE as g, type DetectedWallet as h, type EIP6963ProviderDetail as i, type EvmWalletInterface as j, type ResolvedFeatureFlags as k, type ResolvedRetryConfig as l, type ResolvedTrustwareConfig as m, type ResolvedWalletConnectConfig as n, type RetryConfig as o, type RouteEstimate as p, type RouteIntent as q, type RouteParams as r, type RoutePlan as s, type RouteSponsorship as t, type RoutesConfig as u, type SolanaProviderLike as v, type SolanaWalletInterface as w, type SponsorshipApproval as x, type SwapTokenRef as y, type TrustwareTheme as z };
|
|
@@ -210,7 +210,11 @@ declare function buildDepositAddress(body: BuildRouteBody, signal?: AbortSignal)
|
|
|
210
210
|
};
|
|
211
211
|
route: RoutePlan | undefined;
|
|
212
212
|
}>;
|
|
213
|
-
declare function submitReceipt(intentId: string, txHash: string, sponsorshipRequestId?: string
|
|
213
|
+
declare function submitReceipt(intentId: string, txHash: string, sponsorshipRequestId?: string,
|
|
214
|
+
/** Connected wallet (EOA) that originated the payment. Pass when the route
|
|
215
|
+
* executes from a smart account, so the backend records the tx against the
|
|
216
|
+
* address the user actually connects with. */
|
|
217
|
+
eoaAddress?: string): Promise<any>;
|
|
214
218
|
declare function getStatus(intentId: string): Promise<Transaction>;
|
|
215
219
|
declare function pollStatus(intentId: string, { intervalMs, timeoutMs }?: {
|
|
216
220
|
intervalMs?: number | undefined;
|
|
@@ -249,6 +253,9 @@ type Transaction = {
|
|
|
249
253
|
intentId: string;
|
|
250
254
|
fromAddress: string;
|
|
251
255
|
toAddress: string;
|
|
256
|
+
/** Connected wallet (EOA) that originated the payment when the sender is a
|
|
257
|
+
* smart account. Wire field: `origin_eoa`. */
|
|
258
|
+
origin_eoa?: string;
|
|
252
259
|
fromChainId: string | number;
|
|
253
260
|
toChainId: string | number;
|
|
254
261
|
sourceTxHash: string;
|
|
@@ -412,23 +419,25 @@ type ResolvedWalletConnectConfig = {
|
|
|
412
419
|
relayUrl?: string;
|
|
413
420
|
showQrModal: boolean;
|
|
414
421
|
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
};
|
|
422
|
+
/** Destination/source route defaults. Required in "deposit" mode; optional (and only
|
|
423
|
+
* partially meaningful) in "swap" mode, where chains/tokens are chosen entirely in-widget. */
|
|
424
|
+
type RoutesConfig = {
|
|
425
|
+
toChain: string;
|
|
426
|
+
toToken: string;
|
|
427
|
+
fromToken?: string;
|
|
428
|
+
fromChain?: string;
|
|
429
|
+
fromAddress?: string;
|
|
430
|
+
toAddress?: string;
|
|
431
|
+
defaultSlippage?: number;
|
|
432
|
+
options?: {
|
|
433
|
+
routeRefreshMs?: number;
|
|
434
|
+
fixedFromAmount?: string | number;
|
|
435
|
+
minAmountOut?: string | number;
|
|
436
|
+
maxAmountOut?: string | number;
|
|
431
437
|
};
|
|
438
|
+
};
|
|
439
|
+
type CommonConfigOptions = {
|
|
440
|
+
apiKey: string;
|
|
432
441
|
autoDetectProvider?: boolean;
|
|
433
442
|
theme?: TrustwareTheme;
|
|
434
443
|
messages?: Partial<TrustwareWidgetMessages>;
|
|
@@ -439,8 +448,18 @@ type TrustwareConfigOptions = {
|
|
|
439
448
|
onSuccess?: (transaction: Transaction) => void;
|
|
440
449
|
onEvent?: (event: TrustwareEvent) => void;
|
|
441
450
|
};
|
|
451
|
+
type TrustwareConfigOptions = CommonConfigOptions & ({
|
|
452
|
+
/** Default mode: bridge/top-up to a preconfigured destination chain+token. */
|
|
453
|
+
mode?: "deposit";
|
|
454
|
+
routes: RoutesConfig;
|
|
455
|
+
} | {
|
|
456
|
+
/** Swap mode: from/to chain+token are chosen entirely in-widget; `routes` is not required. */
|
|
457
|
+
mode: "swap";
|
|
458
|
+
routes?: Partial<RoutesConfig>;
|
|
459
|
+
});
|
|
442
460
|
type ResolvedTrustwareConfig = {
|
|
443
461
|
apiKey: string;
|
|
462
|
+
mode: "deposit" | "swap";
|
|
444
463
|
routes: {
|
|
445
464
|
toChain: string;
|
|
446
465
|
toToken: string;
|
|
@@ -476,6 +495,10 @@ type FeatureFlags = {
|
|
|
476
495
|
tokensPagination?: boolean;
|
|
477
496
|
balanceStreaming?: boolean;
|
|
478
497
|
shouldAllowGA4?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* @deprecated Use top-level `mode: "swap"` on `TrustwareConfigOptions` instead. Still
|
|
500
|
+
* supported for backward compatibility and treated as equivalent to `mode: "swap"`.
|
|
501
|
+
*/
|
|
479
502
|
swapMode?: boolean;
|
|
480
503
|
/**
|
|
481
504
|
* Pre-selects the destination token in swap mode. When set, the widget opens
|
|
@@ -682,4 +705,4 @@ declare function useWalletInfo(wagmi?: WagmiBridge): {
|
|
|
682
705
|
};
|
|
683
706
|
declare function useWalletExternalDisconnect(cb: () => void): void;
|
|
684
707
|
|
|
685
|
-
export {
|
|
708
|
+
export { useWalletInfo as $, type TrustwareWidgetMessages as A, type BuildRouteResult as B, type WagmiBridge as C, DEFAULT_AUTO_DETECT_PROVIDER as D, type EIP1193 as E, type FeatureFlags as F, type WagmiConnector as G, type WalletAddressResolution as H, IdentityStore as I, type WalletAddressSource as J, type WalletCategory as K, type WalletConnectConfig as L, type WalletEcosystem as M, type WalletId as N, type WalletIdentity as O, type WalletIdentityAddress as P, type WalletIdentityChainLike as Q, type RateLimitInfo as R, type SimpleWalletInterface as S, type TrustwareConfigOptions as T, type WalletMeta as U, buildWalletIdentityAddress as V, type WalletInterFaceAPI as W, createWalletIdentity as X, resolveWalletAddressForChain as Y, upsertWalletIdentityAddress as Z, useWalletExternalDisconnect as _, TrustwareError as a, useWireDetectionIntoManager as a0, walletManager as a1, type WalletSnapshot as a2, useWalletConnectConnect as a3, buildRoute as a4, buildDepositAddress as a5, submitReceipt as a6, getStatus as a7, pollStatus as a8, type Transaction as b, type TrustwareEvent as c, DEFAULT_FEATURE_FLAGS as d, DEFAULT_MESSAGES as e, DEFAULT_RETRY_CONFIG as f, DEFAULT_SLIPPAGE as g, type DetectedWallet as h, type EIP6963ProviderDetail as i, type EvmWalletInterface as j, type ResolvedFeatureFlags as k, type ResolvedRetryConfig as l, type ResolvedTrustwareConfig as m, type ResolvedWalletConnectConfig as n, type RetryConfig as o, type RouteEstimate as p, type RouteIntent as q, type RouteParams as r, type RoutePlan as s, type RouteSponsorship as t, type RoutesConfig as u, type SolanaProviderLike as v, type SolanaWalletInterface as w, type SponsorshipApproval as x, type SwapTokenRef as y, type TrustwareTheme as z };
|
package/dist/smart-account.cjs
CHANGED
|
@@ -12265,7 +12265,7 @@ var init_constants = __esm({
|
|
|
12265
12265
|
"src/constants.ts"() {
|
|
12266
12266
|
"use strict";
|
|
12267
12267
|
SDK_NAME = "@trustware/sdk";
|
|
12268
|
-
SDK_VERSION = "1.1.9-staging.
|
|
12268
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
12269
12269
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
12270
12270
|
API_PREFIX = "/api";
|
|
12271
12271
|
}
|
|
@@ -13223,7 +13223,9 @@ var init_chains2 = __esm({
|
|
|
13223
13223
|
btc: "bitcoin",
|
|
13224
13224
|
bitcoin: "bitcoin",
|
|
13225
13225
|
sei: "cosmos",
|
|
13226
|
-
"pacific-1": "cosmos"
|
|
13226
|
+
"pacific-1": "cosmos",
|
|
13227
|
+
nibiru: "cosmos",
|
|
13228
|
+
"cataclysm-1": "cosmos"
|
|
13227
13229
|
};
|
|
13228
13230
|
}
|
|
13229
13231
|
});
|
|
@@ -13266,16 +13268,23 @@ function validateEvmAddress(address) {
|
|
|
13266
13268
|
}
|
|
13267
13269
|
return { isValid: true };
|
|
13268
13270
|
}
|
|
13269
|
-
function
|
|
13271
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
13272
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
13273
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
13274
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
13275
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
13276
|
+
}
|
|
13277
|
+
function validateCosmosAddress(address, chain) {
|
|
13270
13278
|
const trimmed = address.trim();
|
|
13271
|
-
|
|
13279
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
13280
|
+
if (prefix === "sei" && (0, import_viem37.isAddress)(trimmed)) {
|
|
13272
13281
|
return { isValid: true };
|
|
13273
13282
|
}
|
|
13274
|
-
const result = validateBech32LikeAddress(trimmed,
|
|
13283
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
13275
13284
|
if (result.isValid) return result;
|
|
13276
13285
|
return {
|
|
13277
13286
|
isValid: false,
|
|
13278
|
-
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
13287
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
13279
13288
|
};
|
|
13280
13289
|
}
|
|
13281
13290
|
function validateSolanaAddress(address) {
|
|
@@ -13325,15 +13334,12 @@ function validateAddressForChain(address, chain) {
|
|
|
13325
13334
|
case "bitcoin":
|
|
13326
13335
|
return validateBtcAddress(trimmed);
|
|
13327
13336
|
case "cosmos":
|
|
13328
|
-
|
|
13329
|
-
return validateSeiAddress(trimmed);
|
|
13330
|
-
}
|
|
13331
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
13337
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
13332
13338
|
default:
|
|
13333
13339
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
13334
13340
|
}
|
|
13335
13341
|
}
|
|
13336
|
-
var import_viem37, BECH32_CHARSET;
|
|
13342
|
+
var import_viem37, BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
13337
13343
|
var init_address = __esm({
|
|
13338
13344
|
"src/validation/address.ts"() {
|
|
13339
13345
|
"use strict";
|
|
@@ -13341,6 +13347,12 @@ var init_address = __esm({
|
|
|
13341
13347
|
init_index_node4();
|
|
13342
13348
|
init_chains2();
|
|
13343
13349
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
13350
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
13351
|
+
"pacific-1": "sei",
|
|
13352
|
+
sei: "sei",
|
|
13353
|
+
"cataclysm-1": "nibi",
|
|
13354
|
+
nibiru: "nibi"
|
|
13355
|
+
};
|
|
13344
13356
|
}
|
|
13345
13357
|
});
|
|
13346
13358
|
|
|
@@ -13352,7 +13364,7 @@ var init_identity = __esm({
|
|
|
13352
13364
|
});
|
|
13353
13365
|
|
|
13354
13366
|
// src/core/routes.ts
|
|
13355
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
13367
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
13356
13368
|
const r = await rateLimitedFetch(
|
|
13357
13369
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
13358
13370
|
{
|
|
@@ -13360,7 +13372,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
13360
13372
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
13361
13373
|
body: JSON.stringify({
|
|
13362
13374
|
txHash,
|
|
13363
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
13375
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
13376
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
13364
13377
|
})
|
|
13365
13378
|
}
|
|
13366
13379
|
);
|
|
@@ -13375,6 +13388,31 @@ var init_routes = __esm({
|
|
|
13375
13388
|
}
|
|
13376
13389
|
});
|
|
13377
13390
|
|
|
13391
|
+
// src/errors/TrustwareError.ts
|
|
13392
|
+
var TrustwareError;
|
|
13393
|
+
var init_TrustwareError = __esm({
|
|
13394
|
+
"src/errors/TrustwareError.ts"() {
|
|
13395
|
+
"use strict";
|
|
13396
|
+
TrustwareError = class extends Error {
|
|
13397
|
+
constructor(params) {
|
|
13398
|
+
super(params.message);
|
|
13399
|
+
this.name = "TrustwareError";
|
|
13400
|
+
this.code = params.code;
|
|
13401
|
+
this.userMessage = params.userMessage;
|
|
13402
|
+
this.cause = params.cause;
|
|
13403
|
+
}
|
|
13404
|
+
toJSON() {
|
|
13405
|
+
return {
|
|
13406
|
+
name: this.name,
|
|
13407
|
+
code: this.code,
|
|
13408
|
+
message: this.message,
|
|
13409
|
+
userMessage: this.userMessage
|
|
13410
|
+
};
|
|
13411
|
+
}
|
|
13412
|
+
};
|
|
13413
|
+
}
|
|
13414
|
+
});
|
|
13415
|
+
|
|
13378
13416
|
// src/types/routes.ts
|
|
13379
13417
|
var init_routes2 = __esm({
|
|
13380
13418
|
"src/types/routes.ts"() {
|
|
@@ -13454,46 +13492,80 @@ function normalizeSlippage(v) {
|
|
|
13454
13492
|
if (n > 5) return 5;
|
|
13455
13493
|
return n;
|
|
13456
13494
|
}
|
|
13495
|
+
function warnDeprecatedSwapModeFlag() {
|
|
13496
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
13497
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
13498
|
+
console.warn(
|
|
13499
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
13500
|
+
);
|
|
13501
|
+
}
|
|
13502
|
+
function resolveMode(input) {
|
|
13503
|
+
if (input.mode === "swap") return "swap";
|
|
13504
|
+
if (input.mode === "deposit") return "deposit";
|
|
13505
|
+
if (input.features?.swapMode) {
|
|
13506
|
+
warnDeprecatedSwapModeFlag();
|
|
13507
|
+
return "swap";
|
|
13508
|
+
}
|
|
13509
|
+
return "deposit";
|
|
13510
|
+
}
|
|
13457
13511
|
function resolveConfig(input) {
|
|
13458
13512
|
if (!input?.apiKey) {
|
|
13459
|
-
throw new
|
|
13513
|
+
throw new TrustwareError({
|
|
13514
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13515
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
13516
|
+
userMessage: "Missing required API key configuration."
|
|
13517
|
+
});
|
|
13460
13518
|
}
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13519
|
+
const mode = resolveMode(input);
|
|
13520
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
13521
|
+
throw new TrustwareError({
|
|
13522
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13523
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
13524
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
13525
|
+
});
|
|
13465
13526
|
}
|
|
13466
|
-
const toChain = input.routes
|
|
13467
|
-
if (input.routes
|
|
13527
|
+
const toChain = input.routes?.toChain;
|
|
13528
|
+
if (input.routes?.toAddress && toChain) {
|
|
13468
13529
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
13469
13530
|
if (!result.isValid) {
|
|
13470
13531
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
13471
|
-
throw new
|
|
13532
|
+
throw new TrustwareError({
|
|
13533
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13534
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
13535
|
+
userMessage: "The configured destination address is invalid."
|
|
13536
|
+
});
|
|
13472
13537
|
}
|
|
13473
13538
|
}
|
|
13474
|
-
if (input.routes
|
|
13475
|
-
const
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13539
|
+
if (input.routes?.fromAddress) {
|
|
13540
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
13541
|
+
if (fromChain) {
|
|
13542
|
+
const result = validateAddressForChain(
|
|
13543
|
+
input.routes.fromAddress,
|
|
13544
|
+
fromChain
|
|
13545
|
+
);
|
|
13546
|
+
if (!result.isValid) {
|
|
13547
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
13548
|
+
throw new TrustwareError({
|
|
13549
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13550
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
13551
|
+
userMessage: "The configured source address is invalid."
|
|
13552
|
+
});
|
|
13553
|
+
}
|
|
13482
13554
|
}
|
|
13483
13555
|
}
|
|
13484
13556
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
13485
13557
|
const routes = {
|
|
13486
|
-
toChain: input.routes
|
|
13487
|
-
toToken: input.routes
|
|
13488
|
-
fromToken: input.routes
|
|
13489
|
-
fromAddress: input.routes
|
|
13490
|
-
fromChain: input.routes
|
|
13491
|
-
toAddress: input.routes
|
|
13558
|
+
toChain: input.routes?.toChain ?? "",
|
|
13559
|
+
toToken: input.routes?.toToken ?? "",
|
|
13560
|
+
fromToken: input.routes?.fromToken,
|
|
13561
|
+
fromAddress: input.routes?.fromAddress,
|
|
13562
|
+
fromChain: input.routes?.fromChain,
|
|
13563
|
+
toAddress: input.routes?.toAddress,
|
|
13492
13564
|
defaultSlippage: normalizeSlippage(
|
|
13493
|
-
input.routes
|
|
13565
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
13494
13566
|
),
|
|
13495
13567
|
options: {
|
|
13496
|
-
...input.routes
|
|
13568
|
+
...input.routes?.options
|
|
13497
13569
|
}
|
|
13498
13570
|
};
|
|
13499
13571
|
const theme = input.theme ?? "system";
|
|
@@ -13512,13 +13584,16 @@ function resolveConfig(input) {
|
|
|
13512
13584
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
13513
13585
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
13514
13586
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
13515
|
-
|
|
13587
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
13588
|
+
// or the deprecated `features.swapMode` flag).
|
|
13589
|
+
swapMode: mode === "swap",
|
|
13516
13590
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
13517
13591
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
13518
13592
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
13519
13593
|
};
|
|
13520
13594
|
return {
|
|
13521
13595
|
apiKey: input.apiKey,
|
|
13596
|
+
mode,
|
|
13522
13597
|
routes,
|
|
13523
13598
|
autoDetectProvider,
|
|
13524
13599
|
theme,
|
|
@@ -13531,12 +13606,15 @@ function resolveConfig(input) {
|
|
|
13531
13606
|
onEvent: input.onEvent
|
|
13532
13607
|
};
|
|
13533
13608
|
}
|
|
13609
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
13534
13610
|
var init_merge = __esm({
|
|
13535
13611
|
"src/config/merge.ts"() {
|
|
13536
13612
|
"use strict";
|
|
13537
13613
|
init_defaults3();
|
|
13538
13614
|
init_config();
|
|
13539
13615
|
init_index();
|
|
13616
|
+
init_TrustwareError();
|
|
13617
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
13540
13618
|
}
|
|
13541
13619
|
});
|
|
13542
13620
|
|
|
@@ -14641,7 +14719,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
14641
14719
|
);
|
|
14642
14720
|
}
|
|
14643
14721
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
14644
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
14722
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
14645
14723
|
return { userOpHash, txHash, intentId };
|
|
14646
14724
|
}
|
|
14647
14725
|
var NATIVE_ADDRS;
|