@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/LICENSE
CHANGED
|
@@ -182,11 +182,12 @@
|
|
|
182
182
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
183
|
replaced with your own identifying information. (Don't include
|
|
184
184
|
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format.
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
188
189
|
|
|
189
|
-
Copyright 2026
|
|
190
|
+
Copyright 2026 trustware.io (contact@trustware.io)
|
|
190
191
|
|
|
191
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -93,11 +93,13 @@ export function App() {
|
|
|
93
93
|
|
|
94
94
|
## Config Reference
|
|
95
95
|
|
|
96
|
-
`TrustwareConfigOptions` is the single source of truth. The
|
|
96
|
+
`TrustwareConfigOptions` is the single source of truth. The shape is a discriminated union
|
|
97
|
+
keyed on `mode` — `routes` is only required in the default `"deposit"` mode:
|
|
97
98
|
|
|
98
99
|
```ts
|
|
99
100
|
type TrustwareConfigOptions = {
|
|
100
101
|
apiKey: string;
|
|
102
|
+
mode?: "deposit"; // default, omit this field entirely for a normal deposit/top-up widget
|
|
101
103
|
routes: {
|
|
102
104
|
toChain: string;
|
|
103
105
|
toToken: string;
|
|
@@ -117,12 +119,40 @@ type TrustwareConfigOptions = {
|
|
|
117
119
|
messages?: Partial<TrustwareWidgetMessages>;
|
|
118
120
|
retry?: RetryConfig;
|
|
119
121
|
walletConnect?: WalletConnectConfig;
|
|
122
|
+
features?: FeatureFlags;
|
|
120
123
|
onError?: (error: TrustwareError) => void;
|
|
121
124
|
onSuccess?: (transaction: Transaction) => void;
|
|
122
125
|
onEvent?: (event: TrustwareEvent) => void;
|
|
126
|
+
} | {
|
|
127
|
+
apiKey: string;
|
|
128
|
+
mode: "swap"; // swap widget — from/to chain+token are chosen entirely in-widget
|
|
129
|
+
routes?: Partial<TrustwareConfigOptions["routes"]>; // optional, not required
|
|
130
|
+
// ...same common fields as above
|
|
123
131
|
};
|
|
124
132
|
```
|
|
125
133
|
|
|
134
|
+
### Modes
|
|
135
|
+
|
|
136
|
+
- **`"deposit"`** (default — `mode` can be omitted): the standard bridge/top-up widget.
|
|
137
|
+
`routes.toChain` and `routes.toToken` are required.
|
|
138
|
+
- **`"swap"`**: an in-widget token swap UI where the user picks both sides themselves.
|
|
139
|
+
`routes` is not required at all:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const trustwareConfig = {
|
|
143
|
+
apiKey: process.env.NEXT_PUBLIC_TRUSTWARE_API_KEY!,
|
|
144
|
+
mode: "swap",
|
|
145
|
+
} satisfies TrustwareConfigOptions;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use `features.swapDefaultDestToken` / `features.swapLockDestToken` /
|
|
149
|
+
`features.swapAllowedDestTokens` to steer the destination token selection (see
|
|
150
|
+
`FeatureFlags` in `src/types/config.ts`).
|
|
151
|
+
|
|
152
|
+
> The older `features: { swapMode: true }` flag (combined with a `routes` object) still
|
|
153
|
+
> works and is treated as equivalent to `mode: "swap"`, but is deprecated in favor of the
|
|
154
|
+
> `mode` field above.
|
|
155
|
+
|
|
126
156
|
### Route Fields
|
|
127
157
|
|
|
128
158
|
- `routes.toChain`: destination chain key or chain id string.
|
|
@@ -146,6 +176,7 @@ type TrustwareConfigOptions = {
|
|
|
146
176
|
- `messages`: top-level copy overrides.
|
|
147
177
|
- `retry`: API retry and rate-limit behavior.
|
|
148
178
|
- `walletConnect`: WalletConnect overrides.
|
|
179
|
+
- `features`: feature rollout controls, including swap-mode token selection constraints.
|
|
149
180
|
- `onError`, `onSuccess`, `onEvent`: lifecycle callbacks.
|
|
150
181
|
|
|
151
182
|
## Widget Usage Patterns
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
The Trustware SDK (`@trustware/sdk`) is licensed under the Apache License,
|
|
4
|
+
Version 2.0 (see `LICENSE`). The published bundle incorporates code from the
|
|
5
|
+
third-party open source packages listed below. Their license terms and
|
|
6
|
+
copyright notices are reproduced here as required by their respective
|
|
7
|
+
licenses.
|
|
8
|
+
|
|
9
|
+
This file covers code compiled **into** the SDK bundle. Packages installed
|
|
10
|
+
alongside the SDK as npm dependencies (`@reown/appkit`, `@reown/appkit-common`,
|
|
11
|
+
`@reown/appkit-universal-connector`, `@solana/web3.js`) and peer dependencies
|
|
12
|
+
(`react`, `react-dom`, `viem`) are distributed separately by their respective
|
|
13
|
+
owners under their own licenses and carry their own license files. Note that
|
|
14
|
+
the `@reown/appkit*` packages are licensed under the Reown Community License
|
|
15
|
+
Agreement, which is **not** an open source license; see the `LICENSE.md` file
|
|
16
|
+
in those packages for its terms.
|
|
17
|
+
|
|
18
|
+
## Bundled packages
|
|
19
|
+
|
|
20
|
+
| Package | License | Copyright |
|
|
21
|
+
|---------|---------|-----------|
|
|
22
|
+
| `@aa-sdk/core` | MIT | © 2023 Alchemy Insights, Inc. |
|
|
23
|
+
| `@account-kit/infra` | MIT | © 2023 Alchemy Insights, Inc. |
|
|
24
|
+
| `@account-kit/logging` | MIT | © 2023 Alchemy Insights, Inc. |
|
|
25
|
+
| `@account-kit/smart-contracts` | MIT | © 2023 Alchemy Insights, Inc. |
|
|
26
|
+
| `@solana/addresses` | MIT | © 2023 Solana Labs, Inc |
|
|
27
|
+
| `@solana/codecs-core` | MIT | © 2023 Solana Labs, Inc |
|
|
28
|
+
| `@solana/codecs-strings` | MIT | © 2023 Solana Labs, Inc |
|
|
29
|
+
| `@solana/errors` | MIT | © 2023 Solana Labs, Inc |
|
|
30
|
+
| `@solana/text-encoding-impl` | MIT | © 2023 Solana Labs, Inc |
|
|
31
|
+
| `zod` | MIT | © 2025 Colin McDonnell |
|
|
32
|
+
|
|
33
|
+
## License texts
|
|
34
|
+
|
|
35
|
+
### MIT License — Alchemy packages
|
|
36
|
+
|
|
37
|
+
Applies to: `@aa-sdk/core`, `@account-kit/infra`, `@account-kit/logging`,
|
|
38
|
+
`@account-kit/smart-contracts`
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
MIT License
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2023 Alchemy Insights, Inc.
|
|
44
|
+
|
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
46
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
47
|
+
in the Software without restriction, including without limitation the rights
|
|
48
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
50
|
+
furnished to do so, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
The above copyright notice and this permission notice shall be included in all
|
|
53
|
+
copies or substantial portions of the Software.
|
|
54
|
+
|
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
56
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
57
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
58
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
59
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
60
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
61
|
+
SOFTWARE.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### MIT License — Solana packages
|
|
65
|
+
|
|
66
|
+
Applies to: `@solana/addresses`, `@solana/codecs-core`,
|
|
67
|
+
`@solana/codecs-strings`, `@solana/errors`, `@solana/text-encoding-impl`
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
Copyright (c) 2023 Solana Labs, Inc
|
|
71
|
+
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
73
|
+
a copy of this software and associated documentation files (the
|
|
74
|
+
"Software"), to deal in the Software without restriction, including
|
|
75
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
76
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
77
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
78
|
+
the following conditions:
|
|
79
|
+
|
|
80
|
+
The above copyright notice and this permission notice shall be
|
|
81
|
+
included in all copies or substantial portions of the Software.
|
|
82
|
+
|
|
83
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
84
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
85
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
87
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
88
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
89
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### MIT License — zod
|
|
93
|
+
|
|
94
|
+
Applies to: `zod`
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
MIT License
|
|
98
|
+
|
|
99
|
+
Copyright (c) 2025 Colin McDonnell
|
|
100
|
+
|
|
101
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
102
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
103
|
+
in the Software without restriction, including without limitation the rights
|
|
104
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
105
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
106
|
+
furnished to do so, subject to the following conditions:
|
|
107
|
+
|
|
108
|
+
The above copyright notice and this permission notice shall be included in all
|
|
109
|
+
copies or substantial portions of the Software.
|
|
110
|
+
|
|
111
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
112
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
113
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
114
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
115
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
116
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
117
|
+
SOFTWARE.
|
|
118
|
+
```
|
package/dist/constants.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(constants_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(constants_exports);
|
|
32
32
|
var SDK_NAME = "@trustware/sdk";
|
|
33
|
-
var SDK_VERSION = "1.1.9-staging.
|
|
33
|
+
var SDK_VERSION = "1.1.9-staging.7";
|
|
34
34
|
var API_ROOT = "https://bv-staging-api.trustware.io";
|
|
35
35
|
var GTM_ID = "GTM-TZDGNCXB";
|
|
36
36
|
var API_PREFIX = "/api";
|
package/dist/constants.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig,
|
|
1
|
+
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, z as TrustwareTheme, O as WalletIdentity, a1 as walletManager, H as WalletAddressResolution, a4 as buildRoute, a5 as buildDepositAddress, a6 as submitReceipt, a7 as getStatus, a8 as pollStatus } from './manager-Dn4muk74.js';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.js';
|
|
3
3
|
import { T as Token } from './types-BJY9r-mz.js';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ type AddressValidationResult = {
|
|
|
8
8
|
};
|
|
9
9
|
declare function validateEvmAddress(address: string): AddressValidationResult;
|
|
10
10
|
declare function validateSeiAddress(address: string): AddressValidationResult;
|
|
11
|
+
declare function validateCosmosAddress(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
11
12
|
declare function validateSolanaAddress(address: string): AddressValidationResult;
|
|
12
13
|
declare function validateBtcAddress(address: string): AddressValidationResult;
|
|
13
14
|
declare function validateAddressForChain(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
@@ -140,4 +141,4 @@ declare const Trustware: {
|
|
|
140
141
|
};
|
|
141
142
|
type TrustwareCore = typeof Trustware;
|
|
142
143
|
|
|
143
|
-
export { Trustware as T, type TrustwareCore as a, validateBtcAddress as b,
|
|
144
|
+
export { Trustware as T, type TrustwareCore as a, validateBtcAddress as b, validateCosmosAddress as c, validateEvmAddress as d, validateRouteAddresses as e, validateSeiAddress as f, validateSolanaAddress as g, validateAddressForChain as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig,
|
|
1
|
+
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, z as TrustwareTheme, O as WalletIdentity, a1 as walletManager, H as WalletAddressResolution, a4 as buildRoute, a5 as buildDepositAddress, a6 as submitReceipt, a7 as getStatus, a8 as pollStatus } from './manager-DWFNyouP.cjs';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.cjs';
|
|
3
3
|
import { T as Token } from './types-DX3HtFcn.cjs';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ type AddressValidationResult = {
|
|
|
8
8
|
};
|
|
9
9
|
declare function validateEvmAddress(address: string): AddressValidationResult;
|
|
10
10
|
declare function validateSeiAddress(address: string): AddressValidationResult;
|
|
11
|
+
declare function validateCosmosAddress(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
11
12
|
declare function validateSolanaAddress(address: string): AddressValidationResult;
|
|
12
13
|
declare function validateBtcAddress(address: string): AddressValidationResult;
|
|
13
14
|
declare function validateAddressForChain(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
@@ -140,4 +141,4 @@ declare const Trustware: {
|
|
|
140
141
|
};
|
|
141
142
|
type TrustwareCore = typeof Trustware;
|
|
142
143
|
|
|
143
|
-
export { Trustware as T, type TrustwareCore as a, validateBtcAddress as b,
|
|
144
|
+
export { Trustware as T, type TrustwareCore as a, validateBtcAddress as b, validateCosmosAddress as c, validateEvmAddress as d, validateRouteAddresses as e, validateSeiAddress as f, validateSolanaAddress as g, validateAddressForChain as v };
|
package/dist/core.cjs
CHANGED
|
@@ -75,7 +75,7 @@ var init_constants = __esm({
|
|
|
75
75
|
"src/constants.ts"() {
|
|
76
76
|
"use strict";
|
|
77
77
|
SDK_NAME = "@trustware/sdk";
|
|
78
|
-
SDK_VERSION = "1.1.9-staging.
|
|
78
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
79
79
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
80
80
|
API_PREFIX = "/api";
|
|
81
81
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -284,7 +284,9 @@ var init_chains = __esm({
|
|
|
284
284
|
btc: "bitcoin",
|
|
285
285
|
bitcoin: "bitcoin",
|
|
286
286
|
sei: "cosmos",
|
|
287
|
-
"pacific-1": "cosmos"
|
|
287
|
+
"pacific-1": "cosmos",
|
|
288
|
+
nibiru: "cosmos",
|
|
289
|
+
"cataclysm-1": "cosmos"
|
|
288
290
|
};
|
|
289
291
|
}
|
|
290
292
|
});
|
|
@@ -1480,16 +1482,23 @@ function validateEvmAddress(address) {
|
|
|
1480
1482
|
}
|
|
1481
1483
|
return { isValid: true };
|
|
1482
1484
|
}
|
|
1483
|
-
function
|
|
1485
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
1486
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
1487
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
1488
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
1489
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
1490
|
+
}
|
|
1491
|
+
function validateCosmosAddress(address, chain) {
|
|
1484
1492
|
const trimmed = address.trim();
|
|
1485
|
-
|
|
1493
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
1494
|
+
if (prefix === "sei" && (0, import_viem.isAddress)(trimmed)) {
|
|
1486
1495
|
return { isValid: true };
|
|
1487
1496
|
}
|
|
1488
|
-
const result = validateBech32LikeAddress(trimmed,
|
|
1497
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
1489
1498
|
if (result.isValid) return result;
|
|
1490
1499
|
return {
|
|
1491
1500
|
isValid: false,
|
|
1492
|
-
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
1501
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
1493
1502
|
};
|
|
1494
1503
|
}
|
|
1495
1504
|
function validateSolanaAddress(address) {
|
|
@@ -1539,15 +1548,12 @@ function validateAddressForChain(address, chain) {
|
|
|
1539
1548
|
case "bitcoin":
|
|
1540
1549
|
return validateBtcAddress(trimmed);
|
|
1541
1550
|
case "cosmos":
|
|
1542
|
-
|
|
1543
|
-
return validateSeiAddress(trimmed);
|
|
1544
|
-
}
|
|
1545
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
1551
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
1546
1552
|
default:
|
|
1547
1553
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
1548
1554
|
}
|
|
1549
1555
|
}
|
|
1550
|
-
function validateAddressForRouteChain(address, chainType) {
|
|
1556
|
+
function validateAddressForRouteChain(address, chainType, chainRef) {
|
|
1551
1557
|
switch (normalizeChainType(chainType)) {
|
|
1552
1558
|
case "evm":
|
|
1553
1559
|
return validateEvmAddress(address);
|
|
@@ -1556,7 +1562,7 @@ function validateAddressForRouteChain(address, chainType) {
|
|
|
1556
1562
|
case "bitcoin":
|
|
1557
1563
|
return validateBtcAddress(address);
|
|
1558
1564
|
case "cosmos":
|
|
1559
|
-
return
|
|
1565
|
+
return validateCosmosAddress(address, chainRef ?? chainType);
|
|
1560
1566
|
default:
|
|
1561
1567
|
return { isValid: false, error: "Unsupported chain type." };
|
|
1562
1568
|
}
|
|
@@ -1578,14 +1584,18 @@ function validateRouteAddresses(params) {
|
|
|
1578
1584
|
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
1579
1585
|
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
1580
1586
|
if (isDepositFlow) {
|
|
1581
|
-
const fromResult2 = validateAddressForRouteChain(
|
|
1587
|
+
const fromResult2 = validateAddressForRouteChain(
|
|
1588
|
+
fromAddress,
|
|
1589
|
+
fromType,
|
|
1590
|
+
params.fromChain
|
|
1591
|
+
);
|
|
1582
1592
|
if (!fromResult2.isValid) {
|
|
1583
1593
|
return {
|
|
1584
1594
|
isValid: false,
|
|
1585
1595
|
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
1586
1596
|
};
|
|
1587
1597
|
}
|
|
1588
|
-
const toResult2 = toType === "cosmos" ?
|
|
1598
|
+
const toResult2 = toType === "cosmos" ? validateCosmosAddress(toAddress, params.toChain) : validateEvmAddress(toAddress);
|
|
1589
1599
|
if (!toResult2.isValid) {
|
|
1590
1600
|
return {
|
|
1591
1601
|
isValid: false,
|
|
@@ -1610,14 +1620,22 @@ function validateRouteAddresses(params) {
|
|
|
1610
1620
|
}
|
|
1611
1621
|
return { isValid: true };
|
|
1612
1622
|
}
|
|
1613
|
-
const fromResult = validateAddressForRouteChain(
|
|
1623
|
+
const fromResult = validateAddressForRouteChain(
|
|
1624
|
+
fromAddress,
|
|
1625
|
+
fromType,
|
|
1626
|
+
params.fromChain
|
|
1627
|
+
);
|
|
1614
1628
|
if (!fromResult.isValid) {
|
|
1615
1629
|
return {
|
|
1616
1630
|
isValid: false,
|
|
1617
1631
|
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
1618
1632
|
};
|
|
1619
1633
|
}
|
|
1620
|
-
const toResult = validateAddressForRouteChain(
|
|
1634
|
+
const toResult = validateAddressForRouteChain(
|
|
1635
|
+
toAddress,
|
|
1636
|
+
toType,
|
|
1637
|
+
params.toChain
|
|
1638
|
+
);
|
|
1621
1639
|
if (!toResult.isValid) {
|
|
1622
1640
|
return {
|
|
1623
1641
|
isValid: false,
|
|
@@ -1626,7 +1644,7 @@ function validateRouteAddresses(params) {
|
|
|
1626
1644
|
}
|
|
1627
1645
|
return { isValid: true };
|
|
1628
1646
|
}
|
|
1629
|
-
var import_viem, BECH32_CHARSET;
|
|
1647
|
+
var import_viem, BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
1630
1648
|
var init_address = __esm({
|
|
1631
1649
|
"src/validation/address.ts"() {
|
|
1632
1650
|
"use strict";
|
|
@@ -1634,6 +1652,12 @@ var init_address = __esm({
|
|
|
1634
1652
|
init_index_node4();
|
|
1635
1653
|
init_chains();
|
|
1636
1654
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
1655
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
1656
|
+
"pacific-1": "sei",
|
|
1657
|
+
sei: "sei",
|
|
1658
|
+
"cataclysm-1": "nibi",
|
|
1659
|
+
nibiru: "nibi"
|
|
1660
|
+
};
|
|
1637
1661
|
}
|
|
1638
1662
|
});
|
|
1639
1663
|
|
|
@@ -4001,7 +4025,7 @@ async function buildDepositAddress(body, signal) {
|
|
|
4001
4025
|
route
|
|
4002
4026
|
};
|
|
4003
4027
|
}
|
|
4004
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
4028
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
4005
4029
|
const r = await rateLimitedFetch(
|
|
4006
4030
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
4007
4031
|
{
|
|
@@ -4009,7 +4033,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
4009
4033
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
4010
4034
|
body: JSON.stringify({
|
|
4011
4035
|
txHash,
|
|
4012
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
4036
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
4037
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
4013
4038
|
})
|
|
4014
4039
|
}
|
|
4015
4040
|
);
|
|
@@ -4131,7 +4156,9 @@ var init_chainHelpers = __esm({
|
|
|
4131
4156
|
btc: "bitcoin",
|
|
4132
4157
|
bitcoin: "bitcoin",
|
|
4133
4158
|
sei: "cosmos",
|
|
4134
|
-
"pacific-1": "cosmos"
|
|
4159
|
+
"pacific-1": "cosmos",
|
|
4160
|
+
nibiru: "cosmos",
|
|
4161
|
+
"cataclysm-1": "cosmos"
|
|
4135
4162
|
};
|
|
4136
4163
|
SEI_EVM_CHAIN_ID = "1329";
|
|
4137
4164
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
@@ -4285,7 +4312,8 @@ function filterSupportedChains(chains) {
|
|
|
4285
4312
|
}
|
|
4286
4313
|
if (chainType === "cosmos") {
|
|
4287
4314
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
4288
|
-
|
|
4315
|
+
const isNibiru = normalizeChainKey2(chain.chainId ?? chain.id) === NIBIRU_COSMOS_CHAIN_ID;
|
|
4316
|
+
if (seiKey !== "sei" && !isNibiru) {
|
|
4289
4317
|
return false;
|
|
4290
4318
|
}
|
|
4291
4319
|
}
|
|
@@ -4385,7 +4413,7 @@ function useChains() {
|
|
|
4385
4413
|
error
|
|
4386
4414
|
};
|
|
4387
4415
|
}
|
|
4388
|
-
var import_react2, POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT;
|
|
4416
|
+
var import_react2, POPULAR_CHAINS_BY_TVL, POPULAR_LIMIT, NIBIRU_COSMOS_CHAIN_ID;
|
|
4389
4417
|
var init_useChains = __esm({
|
|
4390
4418
|
"src/core/useChains.ts"() {
|
|
4391
4419
|
"use strict";
|
|
@@ -4396,6 +4424,7 @@ var init_useChains = __esm({
|
|
|
4396
4424
|
init_popularChains();
|
|
4397
4425
|
POPULAR_CHAINS_BY_TVL = popularChains_default.byTvl;
|
|
4398
4426
|
POPULAR_LIMIT = popularChains_default.popularLimit;
|
|
4427
|
+
NIBIRU_COSMOS_CHAIN_ID = "cataclysm-1";
|
|
4399
4428
|
}
|
|
4400
4429
|
});
|
|
4401
4430
|
|
|
@@ -6180,46 +6209,80 @@ function normalizeSlippage(v) {
|
|
|
6180
6209
|
if (n > 5) return 5;
|
|
6181
6210
|
return n;
|
|
6182
6211
|
}
|
|
6212
|
+
function warnDeprecatedSwapModeFlag() {
|
|
6213
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
6214
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
6215
|
+
console.warn(
|
|
6216
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
6217
|
+
);
|
|
6218
|
+
}
|
|
6219
|
+
function resolveMode(input) {
|
|
6220
|
+
if (input.mode === "swap") return "swap";
|
|
6221
|
+
if (input.mode === "deposit") return "deposit";
|
|
6222
|
+
if (input.features?.swapMode) {
|
|
6223
|
+
warnDeprecatedSwapModeFlag();
|
|
6224
|
+
return "swap";
|
|
6225
|
+
}
|
|
6226
|
+
return "deposit";
|
|
6227
|
+
}
|
|
6183
6228
|
function resolveConfig(input) {
|
|
6184
6229
|
if (!input?.apiKey) {
|
|
6185
|
-
throw new
|
|
6230
|
+
throw new TrustwareError({
|
|
6231
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
6232
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
6233
|
+
userMessage: "Missing required API key configuration."
|
|
6234
|
+
});
|
|
6186
6235
|
}
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6236
|
+
const mode = resolveMode(input);
|
|
6237
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
6238
|
+
throw new TrustwareError({
|
|
6239
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
6240
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
6241
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
6242
|
+
});
|
|
6191
6243
|
}
|
|
6192
|
-
const toChain = input.routes
|
|
6193
|
-
if (input.routes
|
|
6244
|
+
const toChain = input.routes?.toChain;
|
|
6245
|
+
if (input.routes?.toAddress && toChain) {
|
|
6194
6246
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
6195
6247
|
if (!result.isValid) {
|
|
6196
6248
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
6197
|
-
throw new
|
|
6249
|
+
throw new TrustwareError({
|
|
6250
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
6251
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
6252
|
+
userMessage: "The configured destination address is invalid."
|
|
6253
|
+
});
|
|
6198
6254
|
}
|
|
6199
6255
|
}
|
|
6200
|
-
if (input.routes
|
|
6201
|
-
const
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6256
|
+
if (input.routes?.fromAddress) {
|
|
6257
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
6258
|
+
if (fromChain) {
|
|
6259
|
+
const result = validateAddressForChain(
|
|
6260
|
+
input.routes.fromAddress,
|
|
6261
|
+
fromChain
|
|
6262
|
+
);
|
|
6263
|
+
if (!result.isValid) {
|
|
6264
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
6265
|
+
throw new TrustwareError({
|
|
6266
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
6267
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
6268
|
+
userMessage: "The configured source address is invalid."
|
|
6269
|
+
});
|
|
6270
|
+
}
|
|
6208
6271
|
}
|
|
6209
6272
|
}
|
|
6210
6273
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
6211
6274
|
const routes = {
|
|
6212
|
-
toChain: input.routes
|
|
6213
|
-
toToken: input.routes
|
|
6214
|
-
fromToken: input.routes
|
|
6215
|
-
fromAddress: input.routes
|
|
6216
|
-
fromChain: input.routes
|
|
6217
|
-
toAddress: input.routes
|
|
6275
|
+
toChain: input.routes?.toChain ?? "",
|
|
6276
|
+
toToken: input.routes?.toToken ?? "",
|
|
6277
|
+
fromToken: input.routes?.fromToken,
|
|
6278
|
+
fromAddress: input.routes?.fromAddress,
|
|
6279
|
+
fromChain: input.routes?.fromChain,
|
|
6280
|
+
toAddress: input.routes?.toAddress,
|
|
6218
6281
|
defaultSlippage: normalizeSlippage(
|
|
6219
|
-
input.routes
|
|
6282
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
6220
6283
|
),
|
|
6221
6284
|
options: {
|
|
6222
|
-
...input.routes
|
|
6285
|
+
...input.routes?.options
|
|
6223
6286
|
}
|
|
6224
6287
|
};
|
|
6225
6288
|
const theme = input.theme ?? "system";
|
|
@@ -6238,13 +6301,16 @@ function resolveConfig(input) {
|
|
|
6238
6301
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
6239
6302
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
6240
6303
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
6241
|
-
|
|
6304
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
6305
|
+
// or the deprecated `features.swapMode` flag).
|
|
6306
|
+
swapMode: mode === "swap",
|
|
6242
6307
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
6243
6308
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
6244
6309
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
6245
6310
|
};
|
|
6246
6311
|
return {
|
|
6247
6312
|
apiKey: input.apiKey,
|
|
6313
|
+
mode,
|
|
6248
6314
|
routes,
|
|
6249
6315
|
autoDetectProvider,
|
|
6250
6316
|
theme,
|
|
@@ -6257,12 +6323,15 @@ function resolveConfig(input) {
|
|
|
6257
6323
|
onEvent: input.onEvent
|
|
6258
6324
|
};
|
|
6259
6325
|
}
|
|
6326
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
6260
6327
|
var init_merge = __esm({
|
|
6261
6328
|
"src/config/merge.ts"() {
|
|
6262
6329
|
"use strict";
|
|
6263
6330
|
init_defaults();
|
|
6264
6331
|
init_config();
|
|
6265
6332
|
init_index();
|
|
6333
|
+
init_TrustwareError();
|
|
6334
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
6266
6335
|
}
|
|
6267
6336
|
});
|
|
6268
6337
|
|