@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/core.mjs CHANGED
@@ -61,7 +61,7 @@ var init_constants = __esm({
61
61
  "src/constants.ts"() {
62
62
  "use strict";
63
63
  SDK_NAME = "@trustware/sdk";
64
- SDK_VERSION = "1.1.12-staging.3";
64
+ SDK_VERSION = "1.1.12-staging.4";
65
65
  API_ROOT = "https://bv-staging-api.trustware.io";
66
66
  API_PREFIX = "/api";
67
67
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
@@ -220,6 +220,7 @@ function inferChainTypeFromValue(normalized) {
220
220
  if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
221
221
  return normalized;
222
222
  }
223
+ if (normalized === SOLANA_CHAIN_ID) return "solana";
223
224
  if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
224
225
  return "evm";
225
226
  }
@@ -266,12 +267,13 @@ function isZeroAddressLike(address, chainType) {
266
267
  const normalized = normalizeAddress(address, chainType);
267
268
  return normalized === normalizeAddress(getNativeTokenAddress(chainType), chainType) || normalized === "0x0000000000000000000000000000000000000000";
268
269
  }
269
- var NATIVE_EVM, NATIVE_SOLANA, CHAIN_TYPE_ALIASES;
270
+ var NATIVE_EVM, NATIVE_SOLANA, SOLANA_CHAIN_ID, CHAIN_TYPE_ALIASES;
270
271
  var init_chains = __esm({
271
272
  "src/utils/chains.ts"() {
272
273
  "use strict";
273
274
  NATIVE_EVM = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
274
275
  NATIVE_SOLANA = "So11111111111111111111111111111111111111111";
276
+ SOLANA_CHAIN_ID = "1151111081099710";
275
277
  CHAIN_TYPE_ALIASES = {
276
278
  btc: "bitcoin",
277
279
  bitcoin: "bitcoin",
@@ -3984,7 +3986,90 @@ var init_wallets = __esm({
3984
3986
  }
3985
3987
  });
3986
3988
 
3989
+ // src/widget/helpers/chainHelpers.ts
3990
+ function normalizeChainKey2(id) {
3991
+ if (id === void 0 || id === null) return "";
3992
+ return String(id).trim().toLowerCase();
3993
+ }
3994
+ function isSolanaNativeTokenAlias2(address) {
3995
+ if (!address) return false;
3996
+ const trimmed = address.trim();
3997
+ if (!trimmed) return false;
3998
+ return trimmed === NATIVE_SOLANA2 || trimmed.toLowerCase() === NATIVE_EVM2;
3999
+ }
4000
+ function inferChainTypeFromValue2(normalized) {
4001
+ if (!normalized) return void 0;
4002
+ const aliased = CHAIN_TYPE_ALIASES2[normalized];
4003
+ if (aliased) return aliased;
4004
+ if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
4005
+ return normalized;
4006
+ }
4007
+ if (normalized === SOLANA_CHAIN_ID2) return "solana";
4008
+ if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
4009
+ return "evm";
4010
+ }
4011
+ if (normalized.startsWith("solana:") || normalized.includes("solana")) {
4012
+ return "solana";
4013
+ }
4014
+ if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
4015
+ return "cosmos";
4016
+ }
4017
+ return void 0;
4018
+ }
4019
+ function normalizeChainType2(chain) {
4020
+ if (!chain) return void 0;
4021
+ const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
4022
+ if (!raw) return void 0;
4023
+ const normalized = String(raw).trim().toLowerCase();
4024
+ return inferChainTypeFromValue2(normalized) ?? normalized;
4025
+ }
4026
+ function canonicalChainKeyForLink(chain) {
4027
+ const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
4028
+ if (seiKey) return seiKey;
4029
+ return normalizeChainKey2(
4030
+ chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
4031
+ );
4032
+ }
4033
+ function canonicalSeiChainKey(chainId) {
4034
+ const normalized = normalizeChainKey2(chainId);
4035
+ if (!normalized) return null;
4036
+ if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
4037
+ if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
4038
+ return null;
4039
+ }
4040
+ var NATIVE_EVM2, NATIVE_SOLANA2, SOLANA_CHAIN_ID2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
4041
+ var init_chainHelpers = __esm({
4042
+ "src/widget/helpers/chainHelpers.ts"() {
4043
+ "use strict";
4044
+ NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
4045
+ NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
4046
+ SOLANA_CHAIN_ID2 = "1151111081099710";
4047
+ CHAIN_TYPE_ALIASES2 = {
4048
+ btc: "bitcoin",
4049
+ bitcoin: "bitcoin",
4050
+ sei: "cosmos",
4051
+ "pacific-1": "cosmos",
4052
+ nibiru: "cosmos",
4053
+ "cataclysm-1": "cosmos"
4054
+ };
4055
+ SEI_EVM_CHAIN_ID = "1329";
4056
+ SEI_COSMOS_CHAIN_ID = "pacific-1";
4057
+ }
4058
+ });
4059
+
3987
4060
  // src/core/routes.ts
4061
+ function canonicalRouteToken(address, chain) {
4062
+ const chainType = normalizeChainType2(
4063
+ chain === void 0 || chain === null ? void 0 : String(chain)
4064
+ );
4065
+ if (chainType !== "solana") return address ?? "";
4066
+ if (!address) return SOLANA_NATIVE_ROUTE_TOKEN;
4067
+ const trimmed = address.trim();
4068
+ if (isSolanaNativeTokenAlias2(trimmed) || trimmed === "0x0000000000000000000000000000000000000000") {
4069
+ return SOLANA_NATIVE_ROUTE_TOKEN;
4070
+ }
4071
+ return trimmed;
4072
+ }
3988
4073
  function assertValidPostHook(hooks) {
3989
4074
  const postHook = hooks?.postHook;
3990
4075
  if (!postHook) return;
@@ -4029,6 +4114,8 @@ async function buildRoute(body, signal) {
4029
4114
  const url = `${apiBase()}/v1/routes/route`;
4030
4115
  const payload = {
4031
4116
  ...body,
4117
+ fromToken: canonicalRouteToken(body.fromToken, body.fromChain),
4118
+ toToken: canonicalRouteToken(body.toToken, body.toChain),
4032
4119
  slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
4033
4120
  fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
4034
4121
  };
@@ -4068,6 +4155,8 @@ async function buildDepositAddress(body, signal) {
4068
4155
  const url = `${apiBase()}/v1/routes/deposit-address`;
4069
4156
  const payload = {
4070
4157
  ...body,
4158
+ fromToken: canonicalRouteToken(body.fromToken, body.fromChain),
4159
+ toToken: canonicalRouteToken(body.toToken, body.toChain),
4071
4160
  slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
4072
4161
  fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
4073
4162
  };
@@ -4166,13 +4255,15 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
4166
4255
  await new Promise((r) => setTimeout(r, intervalMs));
4167
4256
  }
4168
4257
  }
4169
- var STATUS_WIRE_TO_CAMEL;
4258
+ var SOLANA_NATIVE_ROUTE_TOKEN, STATUS_WIRE_TO_CAMEL;
4170
4259
  var init_routes = __esm({
4171
4260
  "src/core/routes.ts"() {
4172
4261
  "use strict";
4173
4262
  init_http();
4174
4263
  init_store();
4175
4264
  init_address();
4265
+ init_chainHelpers();
4266
+ SOLANA_NATIVE_ROUTE_TOKEN = "So11111111111111111111111111111111111111112";
4176
4267
  STATUS_WIRE_TO_CAMEL = {
4177
4268
  intent_id: "intentId",
4178
4269
  from_address: "fromAddress",
@@ -4233,69 +4324,6 @@ var init_registryClient = __esm({
4233
4324
  }
4234
4325
  });
4235
4326
 
4236
- // src/widget/helpers/chainHelpers.ts
4237
- function normalizeChainKey2(id) {
4238
- if (id === void 0 || id === null) return "";
4239
- return String(id).trim().toLowerCase();
4240
- }
4241
- function inferChainTypeFromValue2(normalized) {
4242
- if (!normalized) return void 0;
4243
- const aliased = CHAIN_TYPE_ALIASES2[normalized];
4244
- if (aliased) return aliased;
4245
- if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
4246
- return normalized;
4247
- }
4248
- if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
4249
- return "evm";
4250
- }
4251
- if (normalized.startsWith("solana:") || normalized.includes("solana")) {
4252
- return "solana";
4253
- }
4254
- if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
4255
- return "cosmos";
4256
- }
4257
- return void 0;
4258
- }
4259
- function normalizeChainType2(chain) {
4260
- if (!chain) return void 0;
4261
- const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
4262
- if (!raw) return void 0;
4263
- const normalized = String(raw).trim().toLowerCase();
4264
- return inferChainTypeFromValue2(normalized) ?? normalized;
4265
- }
4266
- function canonicalChainKeyForLink(chain) {
4267
- const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
4268
- if (seiKey) return seiKey;
4269
- return normalizeChainKey2(
4270
- chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
4271
- );
4272
- }
4273
- function canonicalSeiChainKey(chainId) {
4274
- const normalized = normalizeChainKey2(chainId);
4275
- if (!normalized) return null;
4276
- if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
4277
- if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
4278
- return null;
4279
- }
4280
- var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
4281
- var init_chainHelpers = __esm({
4282
- "src/widget/helpers/chainHelpers.ts"() {
4283
- "use strict";
4284
- NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
4285
- NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
4286
- CHAIN_TYPE_ALIASES2 = {
4287
- btc: "bitcoin",
4288
- bitcoin: "bitcoin",
4289
- sei: "cosmos",
4290
- "pacific-1": "cosmos",
4291
- nibiru: "cosmos",
4292
- "cataclysm-1": "cosmos"
4293
- };
4294
- SEI_EVM_CHAIN_ID = "1329";
4295
- SEI_COSMOS_CHAIN_ID = "pacific-1";
4296
- }
4297
- });
4298
-
4299
4327
  // src/utils/index.ts
4300
4328
  function resolveChainLabel(chain) {
4301
4329
  return chain.networkName || chain.axelarChainName || (chain.id != null ? String(chain.id) : void 0) || (chain.chainId != null ? String(chain.chainId) : void 0) || chain.networkIdentifier || "Chain";