@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
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { T as Trustware } from './core-
|
|
2
|
-
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as
|
|
3
|
-
import { R as RateLimitInfo, T as TrustwareConfigOptions, W as WalletInterFaceAPI, a as TrustwareError, b as Transaction, c as TrustwareEvent } from './manager-
|
|
4
|
-
export { B as BuildRouteResult, D as DEFAULT_AUTO_DETECT_PROVIDER, d as DEFAULT_FEATURE_FLAGS, e as DEFAULT_MESSAGES, f as DEFAULT_RETRY_CONFIG, g as DEFAULT_SLIPPAGE, h as DetectedWallet, E as EIP1193, i as EIP6963ProviderDetail, j as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, k as ResolvedFeatureFlags, l as ResolvedRetryConfig, m as ResolvedTrustwareConfig, n as ResolvedWalletConnectConfig, o as RetryConfig, p as RouteEstimate, q as RouteIntent, r as RouteParams, s as RoutePlan, t as RouteSponsorship, S as SimpleWalletInterface,
|
|
1
|
+
import { T as Trustware } from './core-gNyi5xsp.cjs';
|
|
2
|
+
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-gNyi5xsp.cjs';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, W as WalletInterFaceAPI, a as TrustwareError, b as Transaction, c as TrustwareEvent } from './manager-DWFNyouP.cjs';
|
|
4
|
+
export { B as BuildRouteResult, D as DEFAULT_AUTO_DETECT_PROVIDER, d as DEFAULT_FEATURE_FLAGS, e as DEFAULT_MESSAGES, f as DEFAULT_RETRY_CONFIG, g as DEFAULT_SLIPPAGE, h as DetectedWallet, E as EIP1193, i as EIP6963ProviderDetail, j as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, k as ResolvedFeatureFlags, l as ResolvedRetryConfig, m as ResolvedTrustwareConfig, n as ResolvedWalletConnectConfig, o as RetryConfig, p as RouteEstimate, q as RouteIntent, r as RouteParams, s as RoutePlan, t as RouteSponsorship, u as RoutesConfig, S as SimpleWalletInterface, v as SolanaProviderLike, w as SolanaWalletInterface, x as SponsorshipApproval, y as SwapTokenRef, z as TrustwareTheme, A as TrustwareWidgetMessages, C as WagmiBridge, G as WagmiConnector, H as WalletAddressResolution, J as WalletAddressSource, K as WalletCategory, L as WalletConnectConfig, M as WalletEcosystem, N as WalletId, O as WalletIdentity, P as WalletIdentityAddress, Q as WalletIdentityChainLike, U as WalletMeta, V as buildWalletIdentityAddress, X as createWalletIdentity, Y as resolveWalletAddressForChain, Z as upsertWalletIdentityAddress, _ as useWalletExternalDisconnect, $ as useWalletInfo, a0 as useWireDetectionIntoManager, a1 as walletManager } from './manager-DWFNyouP.cjs';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { C as ChainDef } from './blockchain-BxAFzp0s.cjs';
|
|
8
8
|
export { B as BalanceRow, a as BalanceStreamOptions, b as ChainMeta, c as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, d as TokenMeta, e as TokenPageInfo, f as TokenPageOptions, g as TokenPageResult, h as TokenType, i as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.cjs';
|
|
9
9
|
import { T as Token, Y as YourTokenData } from './types-DX3HtFcn.cjs';
|
|
10
|
-
export { c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, a as useWagmi, b as useWalletDetection } from './detect-
|
|
10
|
+
export { c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, a as useWagmi, b as useWalletDetection } from './detect-DWL4uExV.cjs';
|
|
11
11
|
export { TrustwareWidget } from './widget.cjs';
|
|
12
12
|
export { API_PREFIX, API_ROOT, ASSETS_BASE_URL, GTM_ID, SDK_NAME, SDK_VERSION, WALLETCONNECT_PROJECT_ID } from './constants.cjs';
|
|
13
13
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { T as Trustware } from './core-
|
|
2
|
-
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as
|
|
3
|
-
import { R as RateLimitInfo, T as TrustwareConfigOptions, W as WalletInterFaceAPI, a as TrustwareError, b as Transaction, c as TrustwareEvent } from './manager-
|
|
4
|
-
export { B as BuildRouteResult, D as DEFAULT_AUTO_DETECT_PROVIDER, d as DEFAULT_FEATURE_FLAGS, e as DEFAULT_MESSAGES, f as DEFAULT_RETRY_CONFIG, g as DEFAULT_SLIPPAGE, h as DetectedWallet, E as EIP1193, i as EIP6963ProviderDetail, j as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, k as ResolvedFeatureFlags, l as ResolvedRetryConfig, m as ResolvedTrustwareConfig, n as ResolvedWalletConnectConfig, o as RetryConfig, p as RouteEstimate, q as RouteIntent, r as RouteParams, s as RoutePlan, t as RouteSponsorship, S as SimpleWalletInterface,
|
|
1
|
+
import { T as Trustware } from './core-DzqVEWwP.js';
|
|
2
|
+
export { a as TrustwareCore, v as validateAddressForChain, b as validateBtcAddress, c as validateCosmosAddress, d as validateEvmAddress, e as validateRouteAddresses, f as validateSeiAddress, g as validateSolanaAddress } from './core-DzqVEWwP.js';
|
|
3
|
+
import { R as RateLimitInfo, T as TrustwareConfigOptions, W as WalletInterFaceAPI, a as TrustwareError, b as Transaction, c as TrustwareEvent } from './manager-Dn4muk74.js';
|
|
4
|
+
export { B as BuildRouteResult, D as DEFAULT_AUTO_DETECT_PROVIDER, d as DEFAULT_FEATURE_FLAGS, e as DEFAULT_MESSAGES, f as DEFAULT_RETRY_CONFIG, g as DEFAULT_SLIPPAGE, h as DetectedWallet, E as EIP1193, i as EIP6963ProviderDetail, j as EvmWalletInterface, F as FeatureFlags, I as IdentityStore, k as ResolvedFeatureFlags, l as ResolvedRetryConfig, m as ResolvedTrustwareConfig, n as ResolvedWalletConnectConfig, o as RetryConfig, p as RouteEstimate, q as RouteIntent, r as RouteParams, s as RoutePlan, t as RouteSponsorship, u as RoutesConfig, S as SimpleWalletInterface, v as SolanaProviderLike, w as SolanaWalletInterface, x as SponsorshipApproval, y as SwapTokenRef, z as TrustwareTheme, A as TrustwareWidgetMessages, C as WagmiBridge, G as WagmiConnector, H as WalletAddressResolution, J as WalletAddressSource, K as WalletCategory, L as WalletConnectConfig, M as WalletEcosystem, N as WalletId, O as WalletIdentity, P as WalletIdentityAddress, Q as WalletIdentityChainLike, U as WalletMeta, V as buildWalletIdentityAddress, X as createWalletIdentity, Y as resolveWalletAddressForChain, Z as upsertWalletIdentityAddress, _ as useWalletExternalDisconnect, $ as useWalletInfo, a0 as useWireDetectionIntoManager, a1 as walletManager } from './manager-Dn4muk74.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { C as ChainDef } from './blockchain-BxAFzp0s.js';
|
|
8
8
|
export { B as BalanceRow, a as BalanceStreamOptions, b as ChainMeta, c as ChainType, G as GetBalancesOptions, N as NativeCurrency, T as TokenDef, d as TokenMeta, e as TokenPageInfo, f as TokenPageOptions, g as TokenPageResult, h as TokenType, i as TokenWithBalance, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.js';
|
|
9
9
|
import { T as Token, Y as YourTokenData } from './types-BJY9r-mz.js';
|
|
10
|
-
export { c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, a as useWagmi, b as useWalletDetection } from './detect-
|
|
10
|
+
export { c as connectDetectedWallet, t as toWalletInterfaceFromDetected, u as useEIP1193, a as useWagmi, b as useWalletDetection } from './detect-Cprq6X9o.js';
|
|
11
11
|
export { TrustwareWidget } from './widget.js';
|
|
12
12
|
export { API_PREFIX, API_ROOT, ASSETS_BASE_URL, GTM_ID, SDK_NAME, SDK_VERSION, WALLETCONNECT_PROJECT_ID } from './constants.js';
|
|
13
13
|
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,31 @@ var init_config = __esm({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// src/errors/TrustwareError.ts
|
|
53
|
+
var TrustwareError;
|
|
54
|
+
var init_TrustwareError = __esm({
|
|
55
|
+
"src/errors/TrustwareError.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
TrustwareError = class extends Error {
|
|
58
|
+
constructor(params) {
|
|
59
|
+
super(params.message);
|
|
60
|
+
this.name = "TrustwareError";
|
|
61
|
+
this.code = params.code;
|
|
62
|
+
this.userMessage = params.userMessage;
|
|
63
|
+
this.cause = params.cause;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
name: this.name,
|
|
68
|
+
code: this.code,
|
|
69
|
+
message: this.message,
|
|
70
|
+
userMessage: this.userMessage
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
52
77
|
// src/config/merge.ts
|
|
53
78
|
function deepMerge(base2, patch) {
|
|
54
79
|
if (!patch) return { ...base2 };
|
|
@@ -69,46 +94,80 @@ function normalizeSlippage(v) {
|
|
|
69
94
|
if (n > 5) return 5;
|
|
70
95
|
return n;
|
|
71
96
|
}
|
|
97
|
+
function warnDeprecatedSwapModeFlag() {
|
|
98
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
99
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
100
|
+
console.warn(
|
|
101
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function resolveMode(input) {
|
|
105
|
+
if (input.mode === "swap") return "swap";
|
|
106
|
+
if (input.mode === "deposit") return "deposit";
|
|
107
|
+
if (input.features?.swapMode) {
|
|
108
|
+
warnDeprecatedSwapModeFlag();
|
|
109
|
+
return "swap";
|
|
110
|
+
}
|
|
111
|
+
return "deposit";
|
|
112
|
+
}
|
|
72
113
|
function resolveConfig(input) {
|
|
73
114
|
if (!input?.apiKey) {
|
|
74
|
-
throw new
|
|
115
|
+
throw new TrustwareError({
|
|
116
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
117
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
118
|
+
userMessage: "Missing required API key configuration."
|
|
119
|
+
});
|
|
75
120
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
121
|
+
const mode = resolveMode(input);
|
|
122
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
123
|
+
throw new TrustwareError({
|
|
124
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
125
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
126
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
127
|
+
});
|
|
80
128
|
}
|
|
81
|
-
const toChain = input.routes
|
|
82
|
-
if (input.routes
|
|
129
|
+
const toChain = input.routes?.toChain;
|
|
130
|
+
if (input.routes?.toAddress && toChain) {
|
|
83
131
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
84
132
|
if (!result.isValid) {
|
|
85
133
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
86
|
-
throw new
|
|
134
|
+
throw new TrustwareError({
|
|
135
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
136
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
137
|
+
userMessage: "The configured destination address is invalid."
|
|
138
|
+
});
|
|
87
139
|
}
|
|
88
140
|
}
|
|
89
|
-
if (input.routes
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
141
|
+
if (input.routes?.fromAddress) {
|
|
142
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
143
|
+
if (fromChain) {
|
|
144
|
+
const result = validateAddressForChain(
|
|
145
|
+
input.routes.fromAddress,
|
|
146
|
+
fromChain
|
|
147
|
+
);
|
|
148
|
+
if (!result.isValid) {
|
|
149
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
150
|
+
throw new TrustwareError({
|
|
151
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
152
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
153
|
+
userMessage: "The configured source address is invalid."
|
|
154
|
+
});
|
|
155
|
+
}
|
|
97
156
|
}
|
|
98
157
|
}
|
|
99
158
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
100
159
|
const routes = {
|
|
101
|
-
toChain: input.routes
|
|
102
|
-
toToken: input.routes
|
|
103
|
-
fromToken: input.routes
|
|
104
|
-
fromAddress: input.routes
|
|
105
|
-
fromChain: input.routes
|
|
106
|
-
toAddress: input.routes
|
|
160
|
+
toChain: input.routes?.toChain ?? "",
|
|
161
|
+
toToken: input.routes?.toToken ?? "",
|
|
162
|
+
fromToken: input.routes?.fromToken,
|
|
163
|
+
fromAddress: input.routes?.fromAddress,
|
|
164
|
+
fromChain: input.routes?.fromChain,
|
|
165
|
+
toAddress: input.routes?.toAddress,
|
|
107
166
|
defaultSlippage: normalizeSlippage(
|
|
108
|
-
input.routes
|
|
167
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
109
168
|
),
|
|
110
169
|
options: {
|
|
111
|
-
...input.routes
|
|
170
|
+
...input.routes?.options
|
|
112
171
|
}
|
|
113
172
|
};
|
|
114
173
|
const theme = input.theme ?? "system";
|
|
@@ -127,13 +186,16 @@ function resolveConfig(input) {
|
|
|
127
186
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
128
187
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
129
188
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
130
|
-
|
|
189
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
190
|
+
// or the deprecated `features.swapMode` flag).
|
|
191
|
+
swapMode: mode === "swap",
|
|
131
192
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
132
193
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
133
194
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
134
195
|
};
|
|
135
196
|
return {
|
|
136
197
|
apiKey: input.apiKey,
|
|
198
|
+
mode,
|
|
137
199
|
routes,
|
|
138
200
|
autoDetectProvider,
|
|
139
201
|
theme,
|
|
@@ -146,12 +208,15 @@ function resolveConfig(input) {
|
|
|
146
208
|
onEvent: input.onEvent
|
|
147
209
|
};
|
|
148
210
|
}
|
|
211
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
149
212
|
var init_merge = __esm({
|
|
150
213
|
"src/config/merge.ts"() {
|
|
151
214
|
"use strict";
|
|
152
215
|
init_defaults();
|
|
153
216
|
init_config();
|
|
154
217
|
init_index();
|
|
218
|
+
init_TrustwareError();
|
|
219
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
155
220
|
}
|
|
156
221
|
});
|
|
157
222
|
|
|
@@ -408,7 +473,7 @@ var init_constants = __esm({
|
|
|
408
473
|
"src/constants.ts"() {
|
|
409
474
|
"use strict";
|
|
410
475
|
SDK_NAME = "@trustware/sdk";
|
|
411
|
-
SDK_VERSION = "1.1.9-staging.
|
|
476
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
412
477
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
413
478
|
GTM_ID = "GTM-TZDGNCXB";
|
|
414
479
|
API_PREFIX = "/api";
|
|
@@ -2392,7 +2457,9 @@ var init_chains = __esm({
|
|
|
2392
2457
|
btc: "bitcoin",
|
|
2393
2458
|
bitcoin: "bitcoin",
|
|
2394
2459
|
sei: "cosmos",
|
|
2395
|
-
"pacific-1": "cosmos"
|
|
2460
|
+
"pacific-1": "cosmos",
|
|
2461
|
+
nibiru: "cosmos",
|
|
2462
|
+
"cataclysm-1": "cosmos"
|
|
2396
2463
|
};
|
|
2397
2464
|
}
|
|
2398
2465
|
});
|
|
@@ -2448,6 +2515,25 @@ function validateSeiAddress(address) {
|
|
|
2448
2515
|
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
2449
2516
|
};
|
|
2450
2517
|
}
|
|
2518
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
2519
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
2520
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
2521
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
2522
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
2523
|
+
}
|
|
2524
|
+
function validateCosmosAddress(address, chain) {
|
|
2525
|
+
const trimmed = address.trim();
|
|
2526
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
2527
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
2528
|
+
return { isValid: true };
|
|
2529
|
+
}
|
|
2530
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
2531
|
+
if (result.isValid) return result;
|
|
2532
|
+
return {
|
|
2533
|
+
isValid: false,
|
|
2534
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2451
2537
|
function validateSolanaAddress(address) {
|
|
2452
2538
|
const trimmed = address.trim();
|
|
2453
2539
|
if (trimmed.startsWith("0x") || isEvmAddress(trimmed)) {
|
|
@@ -2495,15 +2581,12 @@ function validateAddressForChain(address, chain) {
|
|
|
2495
2581
|
case "bitcoin":
|
|
2496
2582
|
return validateBtcAddress(trimmed);
|
|
2497
2583
|
case "cosmos":
|
|
2498
|
-
|
|
2499
|
-
return validateSeiAddress(trimmed);
|
|
2500
|
-
}
|
|
2501
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
2584
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
2502
2585
|
default:
|
|
2503
2586
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
2504
2587
|
}
|
|
2505
2588
|
}
|
|
2506
|
-
function validateAddressForRouteChain(address, chainType) {
|
|
2589
|
+
function validateAddressForRouteChain(address, chainType, chainRef) {
|
|
2507
2590
|
switch (normalizeChainType(chainType)) {
|
|
2508
2591
|
case "evm":
|
|
2509
2592
|
return validateEvmAddress(address);
|
|
@@ -2512,7 +2595,7 @@ function validateAddressForRouteChain(address, chainType) {
|
|
|
2512
2595
|
case "bitcoin":
|
|
2513
2596
|
return validateBtcAddress(address);
|
|
2514
2597
|
case "cosmos":
|
|
2515
|
-
return
|
|
2598
|
+
return validateCosmosAddress(address, chainRef ?? chainType);
|
|
2516
2599
|
default:
|
|
2517
2600
|
return { isValid: false, error: "Unsupported chain type." };
|
|
2518
2601
|
}
|
|
@@ -2534,14 +2617,18 @@ function validateRouteAddresses(params) {
|
|
|
2534
2617
|
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
2535
2618
|
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
2536
2619
|
if (isDepositFlow) {
|
|
2537
|
-
const fromResult2 = validateAddressForRouteChain(
|
|
2620
|
+
const fromResult2 = validateAddressForRouteChain(
|
|
2621
|
+
fromAddress,
|
|
2622
|
+
fromType,
|
|
2623
|
+
params.fromChain
|
|
2624
|
+
);
|
|
2538
2625
|
if (!fromResult2.isValid) {
|
|
2539
2626
|
return {
|
|
2540
2627
|
isValid: false,
|
|
2541
2628
|
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
2542
2629
|
};
|
|
2543
2630
|
}
|
|
2544
|
-
const toResult2 = toType === "cosmos" ?
|
|
2631
|
+
const toResult2 = toType === "cosmos" ? validateCosmosAddress(toAddress, params.toChain) : validateEvmAddress(toAddress);
|
|
2545
2632
|
if (!toResult2.isValid) {
|
|
2546
2633
|
return {
|
|
2547
2634
|
isValid: false,
|
|
@@ -2566,14 +2653,22 @@ function validateRouteAddresses(params) {
|
|
|
2566
2653
|
}
|
|
2567
2654
|
return { isValid: true };
|
|
2568
2655
|
}
|
|
2569
|
-
const fromResult = validateAddressForRouteChain(
|
|
2656
|
+
const fromResult = validateAddressForRouteChain(
|
|
2657
|
+
fromAddress,
|
|
2658
|
+
fromType,
|
|
2659
|
+
params.fromChain
|
|
2660
|
+
);
|
|
2570
2661
|
if (!fromResult.isValid) {
|
|
2571
2662
|
return {
|
|
2572
2663
|
isValid: false,
|
|
2573
2664
|
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
2574
2665
|
};
|
|
2575
2666
|
}
|
|
2576
|
-
const toResult = validateAddressForRouteChain(
|
|
2667
|
+
const toResult = validateAddressForRouteChain(
|
|
2668
|
+
toAddress,
|
|
2669
|
+
toType,
|
|
2670
|
+
params.toChain
|
|
2671
|
+
);
|
|
2577
2672
|
if (!toResult.isValid) {
|
|
2578
2673
|
return {
|
|
2579
2674
|
isValid: false,
|
|
@@ -2582,13 +2677,19 @@ function validateRouteAddresses(params) {
|
|
|
2582
2677
|
}
|
|
2583
2678
|
return { isValid: true };
|
|
2584
2679
|
}
|
|
2585
|
-
var BECH32_CHARSET;
|
|
2680
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
2586
2681
|
var init_address = __esm({
|
|
2587
2682
|
"src/validation/address.ts"() {
|
|
2588
2683
|
"use strict";
|
|
2589
2684
|
init_index_node4();
|
|
2590
2685
|
init_chains();
|
|
2591
2686
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
2687
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
2688
|
+
"pacific-1": "sei",
|
|
2689
|
+
sei: "sei",
|
|
2690
|
+
"cataclysm-1": "nibi",
|
|
2691
|
+
nibiru: "nibi"
|
|
2692
|
+
};
|
|
2592
2693
|
}
|
|
2593
2694
|
});
|
|
2594
2695
|
|
|
@@ -4352,7 +4453,7 @@ async function buildDepositAddress(body, signal) {
|
|
|
4352
4453
|
route
|
|
4353
4454
|
};
|
|
4354
4455
|
}
|
|
4355
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
4456
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
4356
4457
|
const r = await rateLimitedFetch(
|
|
4357
4458
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
4358
4459
|
{
|
|
@@ -4360,7 +4461,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
4360
4461
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
4361
4462
|
body: JSON.stringify({
|
|
4362
4463
|
txHash,
|
|
4363
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
4464
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
4465
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
4364
4466
|
})
|
|
4365
4467
|
}
|
|
4366
4468
|
);
|
|
@@ -5318,7 +5420,9 @@ var init_chainHelpers = __esm({
|
|
|
5318
5420
|
btc: "bitcoin",
|
|
5319
5421
|
bitcoin: "bitcoin",
|
|
5320
5422
|
sei: "cosmos",
|
|
5321
|
-
"pacific-1": "cosmos"
|
|
5423
|
+
"pacific-1": "cosmos",
|
|
5424
|
+
nibiru: "cosmos",
|
|
5425
|
+
"cataclysm-1": "cosmos"
|
|
5322
5426
|
};
|
|
5323
5427
|
SEI_EVM_CHAIN_ID = "1329";
|
|
5324
5428
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
@@ -5534,7 +5638,8 @@ function filterSupportedChains(chains) {
|
|
|
5534
5638
|
}
|
|
5535
5639
|
if (chainType === "cosmos") {
|
|
5536
5640
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
5537
|
-
|
|
5641
|
+
const isNibiru = normalizeChainKey2(chain.chainId ?? chain.id) === NIBIRU_COSMOS_CHAIN_ID;
|
|
5642
|
+
if (seiKey !== "sei" && !isNibiru) {
|
|
5538
5643
|
return false;
|
|
5539
5644
|
}
|
|
5540
5645
|
}
|
|
@@ -5634,7 +5739,7 @@ function useChains() {
|
|
|
5634
5739
|
error
|
|
5635
5740
|
};
|
|
5636
5741
|
}
|
|
5637
|
-
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT;
|
|
5742
|
+
var POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT, NIBIRU_COSMOS_CHAIN_ID;
|
|
5638
5743
|
var init_useChains = __esm({
|
|
5639
5744
|
"src/core/useChains.ts"() {
|
|
5640
5745
|
"use strict";
|
|
@@ -5644,6 +5749,7 @@ var init_useChains = __esm({
|
|
|
5644
5749
|
init_popularChains();
|
|
5645
5750
|
POPULAR_CHAINS_BY_TVL = popularChains_default.byTvl;
|
|
5646
5751
|
POPULAR_LIMIT = popularChains_default.popularLimit;
|
|
5752
|
+
NIBIRU_COSMOS_CHAIN_ID = "cataclysm-1";
|
|
5647
5753
|
}
|
|
5648
5754
|
});
|
|
5649
5755
|
|
|
@@ -7324,31 +7430,6 @@ var init_useTokens = __esm({
|
|
|
7324
7430
|
}
|
|
7325
7431
|
});
|
|
7326
7432
|
|
|
7327
|
-
// src/errors/TrustwareError.ts
|
|
7328
|
-
var TrustwareError;
|
|
7329
|
-
var init_TrustwareError = __esm({
|
|
7330
|
-
"src/errors/TrustwareError.ts"() {
|
|
7331
|
-
"use strict";
|
|
7332
|
-
TrustwareError = class extends Error {
|
|
7333
|
-
constructor(params) {
|
|
7334
|
-
super(params.message);
|
|
7335
|
-
this.name = "TrustwareError";
|
|
7336
|
-
this.code = params.code;
|
|
7337
|
-
this.userMessage = params.userMessage;
|
|
7338
|
-
this.cause = params.cause;
|
|
7339
|
-
}
|
|
7340
|
-
toJSON() {
|
|
7341
|
-
return {
|
|
7342
|
-
name: this.name,
|
|
7343
|
-
code: this.code,
|
|
7344
|
-
message: this.message,
|
|
7345
|
-
userMessage: this.userMessage
|
|
7346
|
-
};
|
|
7347
|
-
}
|
|
7348
|
-
};
|
|
7349
|
-
}
|
|
7350
|
-
});
|
|
7351
|
-
|
|
7352
7433
|
// src/core/index.ts
|
|
7353
7434
|
var _lastValidatedKey, Trustware;
|
|
7354
7435
|
var init_core = __esm({
|
|
@@ -7950,6 +8031,7 @@ function useTrustwareConfig() {
|
|
|
7950
8031
|
} catch {
|
|
7951
8032
|
return {
|
|
7952
8033
|
apiKey: "",
|
|
8034
|
+
mode: "deposit",
|
|
7953
8035
|
routes: {
|
|
7954
8036
|
toChain: "",
|
|
7955
8037
|
toToken: "",
|
|
@@ -31468,7 +31550,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
31468
31550
|
);
|
|
31469
31551
|
}
|
|
31470
31552
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
31471
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
31553
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
31472
31554
|
return { userOpHash, txHash, intentId };
|
|
31473
31555
|
}
|
|
31474
31556
|
var NATIVE_ADDRS;
|
|
@@ -39757,7 +39839,7 @@ var init_TrustwareWidgetV2 = __esm({
|
|
|
39757
39839
|
if (!isOpen) {
|
|
39758
39840
|
return null;
|
|
39759
39841
|
}
|
|
39760
|
-
if (config.
|
|
39842
|
+
if (config.mode === "swap") {
|
|
39761
39843
|
return /* @__PURE__ */ jsx60(SwapMode, { theme, style });
|
|
39762
39844
|
}
|
|
39763
39845
|
return /* @__PURE__ */ jsx60(DepositProvider, { initialStep: effectiveInitialStep, children: /* @__PURE__ */ jsx60(
|
|
@@ -39887,6 +39969,7 @@ export {
|
|
|
39887
39969
|
useWireDetectionIntoManager,
|
|
39888
39970
|
validateAddressForChain,
|
|
39889
39971
|
validateBtcAddress,
|
|
39972
|
+
validateCosmosAddress,
|
|
39890
39973
|
validateEvmAddress,
|
|
39891
39974
|
validateRouteAddresses,
|
|
39892
39975
|
validateSeiAddress,
|