@trustware/sdk-staging 1.1.9-staging.5 → 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-CwT8Wd1x.d.ts → core-DzqVEWwP.d.ts} +3 -2
- package/dist/{core-Dy_rZl5y.d.cts → core-gNyi5xsp.d.cts} +3 -2
- package/dist/core.cjs +287 -75
- 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 +287 -75
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-d2PUaxE_.d.ts → detect-Cprq6X9o.d.ts} +1 -1
- package/dist/{detect-DVpECOTa.d.cts → detect-DWL4uExV.d.cts} +1 -1
- package/dist/index.cjs +685 -160
- 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 +936 -410
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-B5aklGtm.d.cts → manager-DWFNyouP.d.cts} +48 -20
- package/dist/{manager-xFiq0SHr.d.ts → manager-Dn4muk74.d.ts} +48 -20
- 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 +308 -72
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +6 -4
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.mjs +306 -72
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +650 -139
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +868 -355
- package/dist/widget.mjs.map +1 -1
- package/package.json +3 -2
package/dist/smart-account.mjs
CHANGED
|
@@ -12241,7 +12241,7 @@ var init_constants = __esm({
|
|
|
12241
12241
|
"src/constants.ts"() {
|
|
12242
12242
|
"use strict";
|
|
12243
12243
|
SDK_NAME = "@trustware/sdk";
|
|
12244
|
-
SDK_VERSION = "1.1.9-staging.
|
|
12244
|
+
SDK_VERSION = "1.1.9-staging.7";
|
|
12245
12245
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
12246
12246
|
API_PREFIX = "/api";
|
|
12247
12247
|
}
|
|
@@ -13199,7 +13199,9 @@ var init_chains2 = __esm({
|
|
|
13199
13199
|
btc: "bitcoin",
|
|
13200
13200
|
bitcoin: "bitcoin",
|
|
13201
13201
|
sei: "cosmos",
|
|
13202
|
-
"pacific-1": "cosmos"
|
|
13202
|
+
"pacific-1": "cosmos",
|
|
13203
|
+
nibiru: "cosmos",
|
|
13204
|
+
"cataclysm-1": "cosmos"
|
|
13203
13205
|
};
|
|
13204
13206
|
}
|
|
13205
13207
|
});
|
|
@@ -13243,16 +13245,23 @@ function validateEvmAddress(address) {
|
|
|
13243
13245
|
}
|
|
13244
13246
|
return { isValid: true };
|
|
13245
13247
|
}
|
|
13246
|
-
function
|
|
13248
|
+
function resolveCosmosBech32Prefix(chain) {
|
|
13249
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
13250
|
+
const identifier = chainDef?.networkIdentifier ?? chainDef?.chainId ?? chainDef?.id ?? (typeof chain === "string" ? chain : void 0);
|
|
13251
|
+
const normalized = String(identifier ?? "").trim().toLowerCase();
|
|
13252
|
+
return COSMOS_BECH32_PREFIX_BY_CHAIN_ID[normalized] ?? "sei";
|
|
13253
|
+
}
|
|
13254
|
+
function validateCosmosAddress(address, chain) {
|
|
13247
13255
|
const trimmed = address.trim();
|
|
13248
|
-
|
|
13256
|
+
const prefix = resolveCosmosBech32Prefix(chain);
|
|
13257
|
+
if (prefix === "sei" && isEvmAddress(trimmed)) {
|
|
13249
13258
|
return { isValid: true };
|
|
13250
13259
|
}
|
|
13251
|
-
const result = validateBech32LikeAddress(trimmed,
|
|
13260
|
+
const result = validateBech32LikeAddress(trimmed, prefix);
|
|
13252
13261
|
if (result.isValid) return result;
|
|
13253
13262
|
return {
|
|
13254
13263
|
isValid: false,
|
|
13255
|
-
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
13264
|
+
error: prefix === "sei" ? "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings." : `Address must be a valid ${prefix}1 bech32 string.`
|
|
13256
13265
|
};
|
|
13257
13266
|
}
|
|
13258
13267
|
function validateSolanaAddress(address) {
|
|
@@ -13302,21 +13311,24 @@ function validateAddressForChain(address, chain) {
|
|
|
13302
13311
|
case "bitcoin":
|
|
13303
13312
|
return validateBtcAddress(trimmed);
|
|
13304
13313
|
case "cosmos":
|
|
13305
|
-
|
|
13306
|
-
return validateSeiAddress(trimmed);
|
|
13307
|
-
}
|
|
13308
|
-
return validateBech32LikeAddress(trimmed, "sei");
|
|
13314
|
+
return validateCosmosAddress(trimmed, chainDef ?? chain);
|
|
13309
13315
|
default:
|
|
13310
13316
|
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
13311
13317
|
}
|
|
13312
13318
|
}
|
|
13313
|
-
var BECH32_CHARSET;
|
|
13319
|
+
var BECH32_CHARSET, COSMOS_BECH32_PREFIX_BY_CHAIN_ID;
|
|
13314
13320
|
var init_address = __esm({
|
|
13315
13321
|
"src/validation/address.ts"() {
|
|
13316
13322
|
"use strict";
|
|
13317
13323
|
init_index_node4();
|
|
13318
13324
|
init_chains2();
|
|
13319
13325
|
BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
13326
|
+
COSMOS_BECH32_PREFIX_BY_CHAIN_ID = {
|
|
13327
|
+
"pacific-1": "sei",
|
|
13328
|
+
sei: "sei",
|
|
13329
|
+
"cataclysm-1": "nibi",
|
|
13330
|
+
nibiru: "nibi"
|
|
13331
|
+
};
|
|
13320
13332
|
}
|
|
13321
13333
|
});
|
|
13322
13334
|
|
|
@@ -13328,7 +13340,7 @@ var init_identity = __esm({
|
|
|
13328
13340
|
});
|
|
13329
13341
|
|
|
13330
13342
|
// src/core/routes.ts
|
|
13331
|
-
async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
13343
|
+
async function submitReceipt(intentId, txHash, sponsorshipRequestId, eoaAddress) {
|
|
13332
13344
|
const r = await rateLimitedFetch(
|
|
13333
13345
|
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
13334
13346
|
{
|
|
@@ -13336,7 +13348,8 @@ async function submitReceipt(intentId, txHash, sponsorshipRequestId) {
|
|
|
13336
13348
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
13337
13349
|
body: JSON.stringify({
|
|
13338
13350
|
txHash,
|
|
13339
|
-
...sponsorshipRequestId ? { sponsorshipRequestId } : {}
|
|
13351
|
+
...sponsorshipRequestId ? { sponsorshipRequestId } : {},
|
|
13352
|
+
...eoaAddress ? { eoaAddress } : {}
|
|
13340
13353
|
})
|
|
13341
13354
|
}
|
|
13342
13355
|
);
|
|
@@ -13351,6 +13364,31 @@ var init_routes = __esm({
|
|
|
13351
13364
|
}
|
|
13352
13365
|
});
|
|
13353
13366
|
|
|
13367
|
+
// src/errors/TrustwareError.ts
|
|
13368
|
+
var TrustwareError;
|
|
13369
|
+
var init_TrustwareError = __esm({
|
|
13370
|
+
"src/errors/TrustwareError.ts"() {
|
|
13371
|
+
"use strict";
|
|
13372
|
+
TrustwareError = class extends Error {
|
|
13373
|
+
constructor(params) {
|
|
13374
|
+
super(params.message);
|
|
13375
|
+
this.name = "TrustwareError";
|
|
13376
|
+
this.code = params.code;
|
|
13377
|
+
this.userMessage = params.userMessage;
|
|
13378
|
+
this.cause = params.cause;
|
|
13379
|
+
}
|
|
13380
|
+
toJSON() {
|
|
13381
|
+
return {
|
|
13382
|
+
name: this.name,
|
|
13383
|
+
code: this.code,
|
|
13384
|
+
message: this.message,
|
|
13385
|
+
userMessage: this.userMessage
|
|
13386
|
+
};
|
|
13387
|
+
}
|
|
13388
|
+
};
|
|
13389
|
+
}
|
|
13390
|
+
});
|
|
13391
|
+
|
|
13354
13392
|
// src/types/routes.ts
|
|
13355
13393
|
var init_routes2 = __esm({
|
|
13356
13394
|
"src/types/routes.ts"() {
|
|
@@ -13430,46 +13468,80 @@ function normalizeSlippage(v) {
|
|
|
13430
13468
|
if (n > 5) return 5;
|
|
13431
13469
|
return n;
|
|
13432
13470
|
}
|
|
13471
|
+
function warnDeprecatedSwapModeFlag() {
|
|
13472
|
+
if (hasWarnedDeprecatedSwapModeFlag) return;
|
|
13473
|
+
hasWarnedDeprecatedSwapModeFlag = true;
|
|
13474
|
+
console.warn(
|
|
13475
|
+
'[Trustware SDK] `features.swapMode` is deprecated \u2014 use `mode: "swap"` on the top-level config instead.'
|
|
13476
|
+
);
|
|
13477
|
+
}
|
|
13478
|
+
function resolveMode(input) {
|
|
13479
|
+
if (input.mode === "swap") return "swap";
|
|
13480
|
+
if (input.mode === "deposit") return "deposit";
|
|
13481
|
+
if (input.features?.swapMode) {
|
|
13482
|
+
warnDeprecatedSwapModeFlag();
|
|
13483
|
+
return "swap";
|
|
13484
|
+
}
|
|
13485
|
+
return "deposit";
|
|
13486
|
+
}
|
|
13433
13487
|
function resolveConfig(input) {
|
|
13434
13488
|
if (!input?.apiKey) {
|
|
13435
|
-
throw new
|
|
13489
|
+
throw new TrustwareError({
|
|
13490
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13491
|
+
message: "TrustwareConfig: 'apiKey' is required.",
|
|
13492
|
+
userMessage: "Missing required API key configuration."
|
|
13493
|
+
});
|
|
13436
13494
|
}
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13495
|
+
const mode = resolveMode(input);
|
|
13496
|
+
if (mode === "deposit" && (!input.routes?.toChain || !input.routes?.toToken)) {
|
|
13497
|
+
throw new TrustwareError({
|
|
13498
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13499
|
+
message: "TrustwareConfig: 'routes.toChain' and 'routes.toToken' are required in deposit mode.",
|
|
13500
|
+
userMessage: "Missing required destination chain/token configuration."
|
|
13501
|
+
});
|
|
13441
13502
|
}
|
|
13442
|
-
const toChain = input.routes
|
|
13443
|
-
if (input.routes
|
|
13503
|
+
const toChain = input.routes?.toChain;
|
|
13504
|
+
if (input.routes?.toAddress && toChain) {
|
|
13444
13505
|
const result = validateAddressForChain(input.routes.toAddress, toChain);
|
|
13445
13506
|
if (!result.isValid) {
|
|
13446
13507
|
console.error(`[Trustware SDK] Invalid toAddress: ${result.error}`);
|
|
13447
|
-
throw new
|
|
13508
|
+
throw new TrustwareError({
|
|
13509
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13510
|
+
message: `Invalid toAddress: ${result.error}`,
|
|
13511
|
+
userMessage: "The configured destination address is invalid."
|
|
13512
|
+
});
|
|
13448
13513
|
}
|
|
13449
13514
|
}
|
|
13450
|
-
if (input.routes
|
|
13451
|
-
const
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13515
|
+
if (input.routes?.fromAddress) {
|
|
13516
|
+
const fromChain = input.routes.fromChain ?? toChain;
|
|
13517
|
+
if (fromChain) {
|
|
13518
|
+
const result = validateAddressForChain(
|
|
13519
|
+
input.routes.fromAddress,
|
|
13520
|
+
fromChain
|
|
13521
|
+
);
|
|
13522
|
+
if (!result.isValid) {
|
|
13523
|
+
console.error(`[Trustware SDK] Invalid fromAddress: ${result.error}`);
|
|
13524
|
+
throw new TrustwareError({
|
|
13525
|
+
code: "INVALID_CONFIG" /* INVALID_CONFIG */,
|
|
13526
|
+
message: `Invalid fromAddress: ${result.error}`,
|
|
13527
|
+
userMessage: "The configured source address is invalid."
|
|
13528
|
+
});
|
|
13529
|
+
}
|
|
13458
13530
|
}
|
|
13459
13531
|
}
|
|
13460
13532
|
const autoDetectProvider = typeof input.autoDetectProvider === "boolean" ? input.autoDetectProvider : DEFAULT_AUTO_DETECT_PROVIDER;
|
|
13461
13533
|
const routes = {
|
|
13462
|
-
toChain: input.routes
|
|
13463
|
-
toToken: input.routes
|
|
13464
|
-
fromToken: input.routes
|
|
13465
|
-
fromAddress: input.routes
|
|
13466
|
-
fromChain: input.routes
|
|
13467
|
-
toAddress: input.routes
|
|
13534
|
+
toChain: input.routes?.toChain ?? "",
|
|
13535
|
+
toToken: input.routes?.toToken ?? "",
|
|
13536
|
+
fromToken: input.routes?.fromToken,
|
|
13537
|
+
fromAddress: input.routes?.fromAddress,
|
|
13538
|
+
fromChain: input.routes?.fromChain,
|
|
13539
|
+
toAddress: input.routes?.toAddress,
|
|
13468
13540
|
defaultSlippage: normalizeSlippage(
|
|
13469
|
-
input.routes
|
|
13541
|
+
input.routes?.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
13470
13542
|
),
|
|
13471
13543
|
options: {
|
|
13472
|
-
...input.routes
|
|
13544
|
+
...input.routes?.options
|
|
13473
13545
|
}
|
|
13474
13546
|
};
|
|
13475
13547
|
const theme = input.theme ?? "system";
|
|
@@ -13488,13 +13560,16 @@ function resolveConfig(input) {
|
|
|
13488
13560
|
tokensPagination: input.features?.tokensPagination ?? DEFAULT_FEATURE_FLAGS.tokensPagination,
|
|
13489
13561
|
balanceStreaming: input.features?.balanceStreaming ?? DEFAULT_FEATURE_FLAGS.balanceStreaming,
|
|
13490
13562
|
shouldAllowGA4: input.features?.shouldAllowGA4 ?? DEFAULT_FEATURE_FLAGS.shouldAllowGA4,
|
|
13491
|
-
|
|
13563
|
+
// Always mirrors the canonical `mode`, however the caller set it (new `mode` field
|
|
13564
|
+
// or the deprecated `features.swapMode` flag).
|
|
13565
|
+
swapMode: mode === "swap",
|
|
13492
13566
|
swapDefaultDestToken: input.features?.swapDefaultDestToken ?? DEFAULT_FEATURE_FLAGS.swapDefaultDestToken,
|
|
13493
13567
|
swapLockDestToken: input.features?.swapLockDestToken ?? DEFAULT_FEATURE_FLAGS.swapLockDestToken,
|
|
13494
13568
|
swapAllowedDestTokens: input.features?.swapAllowedDestTokens ?? DEFAULT_FEATURE_FLAGS.swapAllowedDestTokens
|
|
13495
13569
|
};
|
|
13496
13570
|
return {
|
|
13497
13571
|
apiKey: input.apiKey,
|
|
13572
|
+
mode,
|
|
13498
13573
|
routes,
|
|
13499
13574
|
autoDetectProvider,
|
|
13500
13575
|
theme,
|
|
@@ -13507,12 +13582,15 @@ function resolveConfig(input) {
|
|
|
13507
13582
|
onEvent: input.onEvent
|
|
13508
13583
|
};
|
|
13509
13584
|
}
|
|
13585
|
+
var hasWarnedDeprecatedSwapModeFlag;
|
|
13510
13586
|
var init_merge = __esm({
|
|
13511
13587
|
"src/config/merge.ts"() {
|
|
13512
13588
|
"use strict";
|
|
13513
13589
|
init_defaults3();
|
|
13514
13590
|
init_config();
|
|
13515
13591
|
init_index();
|
|
13592
|
+
init_TrustwareError();
|
|
13593
|
+
hasWarnedDeprecatedSwapModeFlag = false;
|
|
13516
13594
|
}
|
|
13517
13595
|
});
|
|
13518
13596
|
|
|
@@ -14629,7 +14707,7 @@ async function sendRouteAsUserOperation(params) {
|
|
|
14629
14707
|
);
|
|
14630
14708
|
}
|
|
14631
14709
|
console.debug("[send] UserOp included", { userOpHash, txHash });
|
|
14632
|
-
await submitReceipt(intentId, txHash, getSponsorshipRequestId());
|
|
14710
|
+
await submitReceipt(intentId, txHash, getSponsorshipRequestId(), eoaAddress);
|
|
14633
14711
|
return { userOpHash, txHash, intentId };
|
|
14634
14712
|
}
|
|
14635
14713
|
var NATIVE_ADDRS;
|