@trustware/sdk-staging 1.1.12-staging.3 → 1.1.12-staging.4
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/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +94 -66
- package/dist/core.cjs.map +1 -1
- package/dist/core.mjs +94 -66
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +225 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +225 -176
- package/dist/index.mjs.map +1 -1
- package/dist/smart-account.cjs +4 -2
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +4 -2
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +4 -2
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.mjs +4 -2
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +225 -176
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +225 -176
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
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.12-staging.
|
|
33
|
+
var SDK_VERSION = "1.1.12-staging.4";
|
|
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
package/dist/core.cjs
CHANGED
|
@@ -83,7 +83,7 @@ var init_constants = __esm({
|
|
|
83
83
|
"src/constants.ts"() {
|
|
84
84
|
"use strict";
|
|
85
85
|
SDK_NAME = "@trustware/sdk";
|
|
86
|
-
SDK_VERSION = "1.1.12-staging.
|
|
86
|
+
SDK_VERSION = "1.1.12-staging.4";
|
|
87
87
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
88
88
|
API_PREFIX = "/api";
|
|
89
89
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -242,6 +242,7 @@ function inferChainTypeFromValue(normalized) {
|
|
|
242
242
|
if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
|
|
243
243
|
return normalized;
|
|
244
244
|
}
|
|
245
|
+
if (normalized === SOLANA_CHAIN_ID) return "solana";
|
|
245
246
|
if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
|
|
246
247
|
return "evm";
|
|
247
248
|
}
|
|
@@ -288,12 +289,13 @@ function isZeroAddressLike(address, chainType) {
|
|
|
288
289
|
const normalized = normalizeAddress(address, chainType);
|
|
289
290
|
return normalized === normalizeAddress(getNativeTokenAddress(chainType), chainType) || normalized === "0x0000000000000000000000000000000000000000";
|
|
290
291
|
}
|
|
291
|
-
var NATIVE_EVM, NATIVE_SOLANA, CHAIN_TYPE_ALIASES;
|
|
292
|
+
var NATIVE_EVM, NATIVE_SOLANA, SOLANA_CHAIN_ID, CHAIN_TYPE_ALIASES;
|
|
292
293
|
var init_chains = __esm({
|
|
293
294
|
"src/utils/chains.ts"() {
|
|
294
295
|
"use strict";
|
|
295
296
|
NATIVE_EVM = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
296
297
|
NATIVE_SOLANA = "So11111111111111111111111111111111111111111";
|
|
298
|
+
SOLANA_CHAIN_ID = "1151111081099710";
|
|
297
299
|
CHAIN_TYPE_ALIASES = {
|
|
298
300
|
btc: "bitcoin",
|
|
299
301
|
bitcoin: "bitcoin",
|
|
@@ -4006,7 +4008,90 @@ var init_wallets = __esm({
|
|
|
4006
4008
|
}
|
|
4007
4009
|
});
|
|
4008
4010
|
|
|
4011
|
+
// src/widget/helpers/chainHelpers.ts
|
|
4012
|
+
function normalizeChainKey2(id) {
|
|
4013
|
+
if (id === void 0 || id === null) return "";
|
|
4014
|
+
return String(id).trim().toLowerCase();
|
|
4015
|
+
}
|
|
4016
|
+
function isSolanaNativeTokenAlias2(address) {
|
|
4017
|
+
if (!address) return false;
|
|
4018
|
+
const trimmed = address.trim();
|
|
4019
|
+
if (!trimmed) return false;
|
|
4020
|
+
return trimmed === NATIVE_SOLANA2 || trimmed.toLowerCase() === NATIVE_EVM2;
|
|
4021
|
+
}
|
|
4022
|
+
function inferChainTypeFromValue2(normalized) {
|
|
4023
|
+
if (!normalized) return void 0;
|
|
4024
|
+
const aliased = CHAIN_TYPE_ALIASES2[normalized];
|
|
4025
|
+
if (aliased) return aliased;
|
|
4026
|
+
if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
|
|
4027
|
+
return normalized;
|
|
4028
|
+
}
|
|
4029
|
+
if (normalized === SOLANA_CHAIN_ID2) return "solana";
|
|
4030
|
+
if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
|
|
4031
|
+
return "evm";
|
|
4032
|
+
}
|
|
4033
|
+
if (normalized.startsWith("solana:") || normalized.includes("solana")) {
|
|
4034
|
+
return "solana";
|
|
4035
|
+
}
|
|
4036
|
+
if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
|
|
4037
|
+
return "cosmos";
|
|
4038
|
+
}
|
|
4039
|
+
return void 0;
|
|
4040
|
+
}
|
|
4041
|
+
function normalizeChainType2(chain) {
|
|
4042
|
+
if (!chain) return void 0;
|
|
4043
|
+
const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
|
|
4044
|
+
if (!raw) return void 0;
|
|
4045
|
+
const normalized = String(raw).trim().toLowerCase();
|
|
4046
|
+
return inferChainTypeFromValue2(normalized) ?? normalized;
|
|
4047
|
+
}
|
|
4048
|
+
function canonicalChainKeyForLink(chain) {
|
|
4049
|
+
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
4050
|
+
if (seiKey) return seiKey;
|
|
4051
|
+
return normalizeChainKey2(
|
|
4052
|
+
chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
|
|
4053
|
+
);
|
|
4054
|
+
}
|
|
4055
|
+
function canonicalSeiChainKey(chainId) {
|
|
4056
|
+
const normalized = normalizeChainKey2(chainId);
|
|
4057
|
+
if (!normalized) return null;
|
|
4058
|
+
if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
|
|
4059
|
+
if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
|
|
4060
|
+
return null;
|
|
4061
|
+
}
|
|
4062
|
+
var NATIVE_EVM2, NATIVE_SOLANA2, SOLANA_CHAIN_ID2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
|
|
4063
|
+
var init_chainHelpers = __esm({
|
|
4064
|
+
"src/widget/helpers/chainHelpers.ts"() {
|
|
4065
|
+
"use strict";
|
|
4066
|
+
NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
4067
|
+
NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
|
|
4068
|
+
SOLANA_CHAIN_ID2 = "1151111081099710";
|
|
4069
|
+
CHAIN_TYPE_ALIASES2 = {
|
|
4070
|
+
btc: "bitcoin",
|
|
4071
|
+
bitcoin: "bitcoin",
|
|
4072
|
+
sei: "cosmos",
|
|
4073
|
+
"pacific-1": "cosmos",
|
|
4074
|
+
nibiru: "cosmos",
|
|
4075
|
+
"cataclysm-1": "cosmos"
|
|
4076
|
+
};
|
|
4077
|
+
SEI_EVM_CHAIN_ID = "1329";
|
|
4078
|
+
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
4079
|
+
}
|
|
4080
|
+
});
|
|
4081
|
+
|
|
4009
4082
|
// src/core/routes.ts
|
|
4083
|
+
function canonicalRouteToken(address, chain) {
|
|
4084
|
+
const chainType = normalizeChainType2(
|
|
4085
|
+
chain === void 0 || chain === null ? void 0 : String(chain)
|
|
4086
|
+
);
|
|
4087
|
+
if (chainType !== "solana") return address ?? "";
|
|
4088
|
+
if (!address) return SOLANA_NATIVE_ROUTE_TOKEN;
|
|
4089
|
+
const trimmed = address.trim();
|
|
4090
|
+
if (isSolanaNativeTokenAlias2(trimmed) || trimmed === "0x0000000000000000000000000000000000000000") {
|
|
4091
|
+
return SOLANA_NATIVE_ROUTE_TOKEN;
|
|
4092
|
+
}
|
|
4093
|
+
return trimmed;
|
|
4094
|
+
}
|
|
4010
4095
|
function assertValidPostHook(hooks) {
|
|
4011
4096
|
const postHook = hooks?.postHook;
|
|
4012
4097
|
if (!postHook) return;
|
|
@@ -4051,6 +4136,8 @@ async function buildRoute(body, signal) {
|
|
|
4051
4136
|
const url = `${apiBase()}/v1/routes/route`;
|
|
4052
4137
|
const payload = {
|
|
4053
4138
|
...body,
|
|
4139
|
+
fromToken: canonicalRouteToken(body.fromToken, body.fromChain),
|
|
4140
|
+
toToken: canonicalRouteToken(body.toToken, body.toChain),
|
|
4054
4141
|
slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
|
|
4055
4142
|
fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
|
|
4056
4143
|
};
|
|
@@ -4090,6 +4177,8 @@ async function buildDepositAddress(body, signal) {
|
|
|
4090
4177
|
const url = `${apiBase()}/v1/routes/deposit-address`;
|
|
4091
4178
|
const payload = {
|
|
4092
4179
|
...body,
|
|
4180
|
+
fromToken: canonicalRouteToken(body.fromToken, body.fromChain),
|
|
4181
|
+
toToken: canonicalRouteToken(body.toToken, body.toChain),
|
|
4093
4182
|
slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
|
|
4094
4183
|
fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
|
|
4095
4184
|
};
|
|
@@ -4188,13 +4277,15 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
|
|
|
4188
4277
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
4189
4278
|
}
|
|
4190
4279
|
}
|
|
4191
|
-
var STATUS_WIRE_TO_CAMEL;
|
|
4280
|
+
var SOLANA_NATIVE_ROUTE_TOKEN, STATUS_WIRE_TO_CAMEL;
|
|
4192
4281
|
var init_routes = __esm({
|
|
4193
4282
|
"src/core/routes.ts"() {
|
|
4194
4283
|
"use strict";
|
|
4195
4284
|
init_http();
|
|
4196
4285
|
init_store();
|
|
4197
4286
|
init_address();
|
|
4287
|
+
init_chainHelpers();
|
|
4288
|
+
SOLANA_NATIVE_ROUTE_TOKEN = "So11111111111111111111111111111111111111112";
|
|
4198
4289
|
STATUS_WIRE_TO_CAMEL = {
|
|
4199
4290
|
intent_id: "intentId",
|
|
4200
4291
|
from_address: "fromAddress",
|
|
@@ -4255,69 +4346,6 @@ var init_registryClient = __esm({
|
|
|
4255
4346
|
}
|
|
4256
4347
|
});
|
|
4257
4348
|
|
|
4258
|
-
// src/widget/helpers/chainHelpers.ts
|
|
4259
|
-
function normalizeChainKey2(id) {
|
|
4260
|
-
if (id === void 0 || id === null) return "";
|
|
4261
|
-
return String(id).trim().toLowerCase();
|
|
4262
|
-
}
|
|
4263
|
-
function inferChainTypeFromValue2(normalized) {
|
|
4264
|
-
if (!normalized) return void 0;
|
|
4265
|
-
const aliased = CHAIN_TYPE_ALIASES2[normalized];
|
|
4266
|
-
if (aliased) return aliased;
|
|
4267
|
-
if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
|
|
4268
|
-
return normalized;
|
|
4269
|
-
}
|
|
4270
|
-
if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
|
|
4271
|
-
return "evm";
|
|
4272
|
-
}
|
|
4273
|
-
if (normalized.startsWith("solana:") || normalized.includes("solana")) {
|
|
4274
|
-
return "solana";
|
|
4275
|
-
}
|
|
4276
|
-
if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
|
|
4277
|
-
return "cosmos";
|
|
4278
|
-
}
|
|
4279
|
-
return void 0;
|
|
4280
|
-
}
|
|
4281
|
-
function normalizeChainType2(chain) {
|
|
4282
|
-
if (!chain) return void 0;
|
|
4283
|
-
const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
|
|
4284
|
-
if (!raw) return void 0;
|
|
4285
|
-
const normalized = String(raw).trim().toLowerCase();
|
|
4286
|
-
return inferChainTypeFromValue2(normalized) ?? normalized;
|
|
4287
|
-
}
|
|
4288
|
-
function canonicalChainKeyForLink(chain) {
|
|
4289
|
-
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
4290
|
-
if (seiKey) return seiKey;
|
|
4291
|
-
return normalizeChainKey2(
|
|
4292
|
-
chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
|
|
4293
|
-
);
|
|
4294
|
-
}
|
|
4295
|
-
function canonicalSeiChainKey(chainId) {
|
|
4296
|
-
const normalized = normalizeChainKey2(chainId);
|
|
4297
|
-
if (!normalized) return null;
|
|
4298
|
-
if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
|
|
4299
|
-
if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
|
|
4300
|
-
return null;
|
|
4301
|
-
}
|
|
4302
|
-
var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
|
|
4303
|
-
var init_chainHelpers = __esm({
|
|
4304
|
-
"src/widget/helpers/chainHelpers.ts"() {
|
|
4305
|
-
"use strict";
|
|
4306
|
-
NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
4307
|
-
NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
|
|
4308
|
-
CHAIN_TYPE_ALIASES2 = {
|
|
4309
|
-
btc: "bitcoin",
|
|
4310
|
-
bitcoin: "bitcoin",
|
|
4311
|
-
sei: "cosmos",
|
|
4312
|
-
"pacific-1": "cosmos",
|
|
4313
|
-
nibiru: "cosmos",
|
|
4314
|
-
"cataclysm-1": "cosmos"
|
|
4315
|
-
};
|
|
4316
|
-
SEI_EVM_CHAIN_ID = "1329";
|
|
4317
|
-
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
4318
|
-
}
|
|
4319
|
-
});
|
|
4320
|
-
|
|
4321
4349
|
// src/utils/index.ts
|
|
4322
4350
|
function resolveChainLabel(chain) {
|
|
4323
4351
|
return chain.networkName || chain.axelarChainName || (chain.id != null ? String(chain.id) : void 0) || (chain.chainId != null ? String(chain.chainId) : void 0) || chain.networkIdentifier || "Chain";
|