@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/wallet.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-
|
|
1
|
+
import { v as SolanaProviderLike, U as WalletMeta, h as DetectedWallet, N as WalletId, w as SolanaWalletInterface } from './manager-DWFNyouP.cjs';
|
|
2
|
+
export { C as WagmiBridge, G as WagmiConnector, a2 as WalletSnapshot, a3 as useWalletConnectConnect, _ as useWalletExternalDisconnect, $ as useWalletInfo, a0 as useWireDetectionIntoManager, a1 as walletManager } from './manager-DWFNyouP.cjs';
|
|
3
|
+
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-DWL4uExV.cjs';
|
|
4
4
|
import './blockchain-BxAFzp0s.cjs';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-
|
|
1
|
+
import { v as SolanaProviderLike, U as WalletMeta, h as DetectedWallet, N as WalletId, w as SolanaWalletInterface } from './manager-Dn4muk74.js';
|
|
2
|
+
export { C as WagmiBridge, G as WagmiConnector, a2 as WalletSnapshot, a3 as useWalletConnectConnect, _ as useWalletExternalDisconnect, $ as useWalletInfo, a0 as useWireDetectionIntoManager, a1 as walletManager } from './manager-Dn4muk74.js';
|
|
3
|
+
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-Cprq6X9o.js';
|
|
4
4
|
import './blockchain-BxAFzp0s.js';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
package/dist/wallet.mjs
CHANGED
|
@@ -224,7 +224,7 @@ var init_constants = __esm({
|
|
|
224
224
|
"src/constants.ts"() {
|
|
225
225
|
"use strict";
|
|
226
226
|
SDK_NAME = "@trustware/sdk";
|
|
227
|
-
SDK_VERSION = "1.1.9-staging.
|
|
227
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
228
228
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
229
229
|
API_PREFIX = "/api";
|
|
230
230
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -1188,7 +1188,9 @@ var init_chains = __esm({
|
|
|
1188
1188
|
btc: "bitcoin",
|
|
1189
1189
|
bitcoin: "bitcoin",
|
|
1190
1190
|
sei: "cosmos",
|
|
1191
|
-
"pacific-1": "cosmos"
|
|
1191
|
+
"pacific-1": "cosmos",
|
|
1192
|
+
nibiru: "cosmos",
|
|
1193
|
+
"cataclysm-1": "cosmos"
|
|
1192
1194
|
};
|
|
1193
1195
|
}
|
|
1194
1196
|
});
|
|
@@ -1232,16 +1234,23 @@ function validateEvmAddress(address) {
|
|
|
1232
1234
|
}
|
|
1233
1235
|
return { isValid: true };
|
|
1234
1236
|
}
|
|
1235
|
-
function
|
|
1237
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
1238
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
1239
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
1240
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
1241
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
1242
|
+
}
|
|
1243
|
+
function validateCosmosAddress(address, chain) {
|
|
1236
1244
|
const trimmed = address.trim();
|
|
1237
|
-
|
|
1245
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
1246
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
1238
1247
|
return { isValid: true };
|
|
1239
1248
|
}
|
|
1240
|
-
const result = validateBech32LikeAddress(trimmed,
|
|
1249
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
1241
1250
|
if (result.isValid) return result;
|
|
1242
1251
|
return {
|
|
1243
1252
|
isValid: false,
|
|
1244
|
-
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
1253
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
1245
1254
|
};
|
|
1246
1255
|
}
|
|
1247
1256
|
function validateSolanaAddress(address) {
|
|
@@ -1291,21 +1300,49 @@ function validateAddressForChain(address, chain) {
|
|
|
1291
1300
|
case "bitcoin":
|
|
1292
1301
|
return validateBtcAddress(trimmed);
|
|
1293
1302
|
case "cosmos":
|
|
1294
|
-
|
|
1295
|
-
return validateSeiAddress(trimmed);
|
|
1296
|
-
}
|
|
1297
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
1303
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
1298
1304
|
default:
|
|
1299
1305
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
1300
1306
|
}
|
|
1301
1307
|
}
|
|
1302
|
-
var BECH32_CHARSET;
|
|
1308
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
1303
1309
|
var init_address = __esm({
|
|
1304
1310
|
"src/validation/address.ts"() {
|
|
1305
1311
|
"use strict";
|
|
1306
1312
|
init_index_node4();
|
|
1307
1313
|
init_chains();
|
|
1308
1314
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
1315
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
1316
|
+
"pacific-1": "sei",
|
|
1317
|
+
sei: "sei",
|
|
1318
|
+
"cataclysm-1": "nibi",
|
|
1319
|
+
nibiru: "nibi"
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
// src/errors/TrustwareError.ts
|
|
1325
|
+
var TrustwareError;
|
|
1326
|
+
var init_TrustwareError = __esm({
|
|
1327
|
+
"src/errors/TrustwareError.ts"() {
|
|
1328
|
+
"use strict";
|
|
1329
|
+
TrustwareError = class extends Error {
|
|
1330
|
+
constructor(params) {
|
|
1331
|
+
super(params.message);
|
|
1332
|
+
this.name = "TrustwareError";
|
|
1333
|
+
this.code = params.code;
|
|
1334
|
+
this.userMessage = params.userMessage;
|
|
1335
|
+
this.cause = params.cause;
|
|
1336
|
+
}
|
|
1337
|
+
toJSON() {
|
|
1338
|
+
return {
|
|
1339
|
+
name: this.name,
|
|
1340
|
+
code: this.code,
|
|
1341
|
+
message: this.message,
|
|
1342
|
+
userMessage: this.userMessage
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1309
1346
|
}
|
|
1310
1347
|
});
|
|
1311
1348
|
|
|
@@ -3593,46 +3630,80 @@ function normalizeSlippage(v) {
|
|
|
3593
3630
|
if (n > 5) return 5;
|
|
3594
3631
|
return n;
|
|
3595
3632
|
}
|
|
3633
|
+
function warnDeprecatedSwapModeFlag() {
|
|
3634
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
3635
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
3636
|
+
console.warn(
|
|
3637
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
3638
|
+
);
|
|
3639
|
+
}
|
|
3640
|
+
function resolveMode(input) {
|
|
3641
|
+
if (input.mode === "swap") return "swap";
|
|
3642
|
+
if (input.mode === "deposit") return "deposit";
|
|
3643
|
+
if (input.features?.swapMode) {
|
|
3644
|
+
warnDeprecatedSwapModeFlag();
|
|
3645
|
+
return "swap";
|
|
3646
|
+
}
|
|
3647
|
+
return "deposit";
|
|
3648
|
+
}
|
|
3596
3649
|
function resolveConfig(input) {
|
|
3597
3650
|
if (!input?.apiKey) {
|
|
3598
|
-
throw new
|
|
3651
|
+
throw new TrustwareError({
|
|
3652
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
3653
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
3654
|
+
userMessage: "Missing required API key configuration."
|
|
3655
|
+
});
|
|
3599
3656
|
}
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3657
|
+
const mode = resolveMode(input);
|
|
3658
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
3659
|
+
throw new TrustwareError({
|
|
3660
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
3661
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
3662
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
3663
|
+
});
|
|
3604
3664
|
}
|
|
3605
|
-
const toChain = input.routes
|
|
3606
|
-
if (input.routes
|
|
3665
|
+
const toChain = input.routes?.toChain;
|
|
3666
|
+
if (input.routes?.toAddress && toChain) {
|
|
3607
3667
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
3608
3668
|
if (!result.isValid) {
|
|
3609
3669
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
3610
|
-
throw new
|
|
3670
|
+
throw new TrustwareError({
|
|
3671
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
3672
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
3673
|
+
userMessage: "The configured destination address is invalid."
|
|
3674
|
+
});
|
|
3611
3675
|
}
|
|
3612
3676
|
}
|
|
3613
|
-
if (input.routes
|
|
3614
|
-
const
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3677
|
+
if (input.routes?.fromAddress) {
|
|
3678
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
3679
|
+
if (fromChain) {
|
|
3680
|
+
const result = validateAddressForChain(
|
|
3681
|
+
input.routes.fromAddress,
|
|
3682
|
+
fromChain
|
|
3683
|
+
);
|
|
3684
|
+
if (!result.isValid) {
|
|
3685
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
3686
|
+
throw new TrustwareError({
|
|
3687
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
3688
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
3689
|
+
userMessage: "The configured source address is invalid."
|
|
3690
|
+
});
|
|
3691
|
+
}
|
|
3621
3692
|
}
|
|
3622
3693
|
}
|
|
3623
3694
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
3624
3695
|
const routes = {
|
|
3625
|
-
toChain: input.routes
|
|
3626
|
-
toToken: input.routes
|
|
3627
|
-
fromToken: input.routes
|
|
3628
|
-
fromAddress: input.routes
|
|
3629
|
-
fromChain: input.routes
|
|
3630
|
-
toAddress: input.routes
|
|
3696
|
+
toChain: input.routes?.toChain ?? "",
|
|
3697
|
+
toToken: input.routes?.toToken ?? "",
|
|
3698
|
+
fromToken: input.routes?.fromToken,
|
|
3699
|
+
fromAddress: input.routes?.fromAddress,
|
|
3700
|
+
fromChain: input.routes?.fromChain,
|
|
3701
|
+
toAddress: input.routes?.toAddress,
|
|
3631
3702
|
defaultSlippage: normalizeSlippage(
|
|
3632
|
-
input.routes
|
|
3703
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
3633
3704
|
),
|
|
3634
3705
|
options: {
|
|
3635
|
-
...input.routes
|
|
3706
|
+
...input.routes?.options
|
|
3636
3707
|
}
|
|
3637
3708
|
};
|
|
3638
3709
|
const theme = input.theme ?? "system";
|
|
@@ -3651,13 +3722,16 @@ function resolveConfig(input) {
|
|
|
3651
3722
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
3652
3723
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
3653
3724
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
3654
|
-
|
|
3725
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
3726
|
+
// or the deprecated `features.swapMode` flag).
|
|
3727
|
+
swapMode: mode === "swap",
|
|
3655
3728
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
3656
3729
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
3657
3730
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
3658
3731
|
};
|
|
3659
3732
|
return {
|
|
3660
3733
|
apiKey: input.apiKey,
|
|
3734
|
+
mode,
|
|
3661
3735
|
routes,
|
|
3662
3736
|
autoDetectProvider,
|
|
3663
3737
|
theme,
|
|
@@ -3670,12 +3744,15 @@ function resolveConfig(input) {
|
|
|
3670
3744
|
onEvent: input.onEvent
|
|
3671
3745
|
};
|
|
3672
3746
|
}
|
|
3747
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
3673
3748
|
var init_merge = __esm({
|
|
3674
3749
|
"src/config/merge.ts"() {
|
|
3675
3750
|
"use strict";
|
|
3676
3751
|
init_defaults();
|
|
3677
3752
|
init_config();
|
|
3678
3753
|
init_index();
|
|
3754
|
+
init_TrustwareError();
|
|
3755
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
3679
3756
|
}
|
|
3680
3757
|
});
|
|
3681
3758
|
|