@trustware/sdk-staging 1.1.9-staging.6 → 1.1.10-staging.0
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-BTPkApRH.d.cts → core-B7Ez-5-r.d.cts} +3 -2
- package/dist/{core-2oZuxC1J.d.ts → core-BPLiD1UG.d.ts} +3 -2
- package/dist/core.cjs +246 -48
- 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 +247 -48
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +300 -76
- 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 +325 -103
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BMO1O-cW.d.ts → manager-B6NNV-E_.d.ts} +129 -18
- package/dist/{manager-BZwbtOyf.d.cts → manager-BwjyFjjz.d.cts} +129 -18
- package/dist/{detect-B8xXLwHK.d.ts → metadata-BiTMMvlY.d.ts} +5 -2
- package/dist/{detect-C8xpZRrL.d.cts → metadata-HCflXcsF.d.cts} +5 -2
- package/dist/smart-account.cjs +117 -39
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +235 -222
- package/dist/smart-account.d.ts +235 -222
- 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 +4 -7
- package/dist/wallet.d.ts +4 -7
- package/dist/wallet.mjs +113 -36
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +239 -54
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +267 -81
- package/dist/widget.mjs.map +1 -1
- package/package.json +3 -2
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.
|
|
12268
|
+
SDK_VERSION = "1.1.10-staging.0";
|
|
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;
|