@trustware/sdk-staging 1.1.12-staging.2 → 1.1.12-staging.3

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.
@@ -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.12-staging.2";
12268
+ SDK_VERSION = "1.1.12-staging.3";
12269
12269
  API_ROOT = "https://bv-staging-api.trustware.io";
12270
12270
  API_PREFIX = "/api";
12271
12271
  }
@@ -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.12-staging.2";
12244
+ SDK_VERSION = "1.1.12-staging.3";
12245
12245
  API_ROOT = "https://bv-staging-api.trustware.io";
12246
12246
  API_PREFIX = "/api";
12247
12247
  }
package/dist/wallet.cjs CHANGED
@@ -264,7 +264,7 @@ var init_constants = __esm({
264
264
  "src/constants.ts"() {
265
265
  "use strict";
266
266
  SDK_NAME = "@trustware/sdk";
267
- SDK_VERSION = "1.1.12-staging.2";
267
+ SDK_VERSION = "1.1.12-staging.3";
268
268
  API_ROOT = "https://bv-staging-api.trustware.io";
269
269
  API_PREFIX = "/api";
270
270
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
package/dist/wallet.mjs CHANGED
@@ -238,7 +238,7 @@ var init_constants = __esm({
238
238
  "src/constants.ts"() {
239
239
  "use strict";
240
240
  SDK_NAME = "@trustware/sdk";
241
- SDK_VERSION = "1.1.12-staging.2";
241
+ SDK_VERSION = "1.1.12-staging.3";
242
242
  API_ROOT = "https://bv-staging-api.trustware.io";
243
243
  API_PREFIX = "/api";
244
244
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
package/dist/widget.cjs CHANGED
@@ -593,7 +593,7 @@ var init_constants = __esm({
593
593
  "src/constants.ts"() {
594
594
  "use strict";
595
595
  SDK_NAME = "@trustware/sdk";
596
- SDK_VERSION = "1.1.12-staging.2";
596
+ SDK_VERSION = "1.1.12-staging.3";
597
597
  API_ROOT = "https://bv-staging-api.trustware.io";
598
598
  GTM_ID = "GTM-TZDGNCXB";
599
599
  API_PREFIX = "/api";
@@ -3232,6 +3232,15 @@ function isNativeTokenAddress(address, chainType) {
3232
3232
  if (!chainType) return false;
3233
3233
  return normalizeAddress2(address, chainType) === normalizeAddress2(getNativeTokenAddress2(chainType), chainType);
3234
3234
  }
3235
+ function isEvmAddress2(value) {
3236
+ return !!value && EVM_ADDRESS_RE.test(value);
3237
+ }
3238
+ function needsErc20Approval(tokenAddress, chainType) {
3239
+ if (!isEvmAddress2(tokenAddress)) return false;
3240
+ const normalizedType = normalizeChainType2(chainType ?? void 0);
3241
+ if (normalizedType && NON_EVM_CHAIN_TYPES.has(normalizedType)) return false;
3242
+ return !isNativeTokenAddress(tokenAddress, chainType) && !isZeroAddrLike(tokenAddress, chainType);
3243
+ }
3235
3244
  function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
3236
3245
  const chainType = normalizeChainType2(chain);
3237
3246
  const rawAddress = (address ?? "").trim();
@@ -3254,7 +3263,7 @@ function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
3254
3263
  }
3255
3264
  return lowerAddress;
3256
3265
  }
3257
- var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
3266
+ var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID, EVM_ADDRESS_RE, NON_EVM_CHAIN_TYPES;
3258
3267
  var init_chainHelpers = __esm({
3259
3268
  "src/widget/helpers/chainHelpers.ts"() {
3260
3269
  "use strict";
@@ -3270,6 +3279,8 @@ var init_chainHelpers = __esm({
3270
3279
  };
3271
3280
  SEI_EVM_CHAIN_ID = "1329";
3272
3281
  SEI_COSMOS_CHAIN_ID = "pacific-1";
3282
+ EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
3283
+ NON_EVM_CHAIN_TYPES = /* @__PURE__ */ new Set(["solana", "bitcoin", "btc"]);
3273
3284
  }
3274
3285
  });
3275
3286
 
@@ -33678,8 +33689,7 @@ function useSwapExecution(fromChain) {
33678
33689
  return;
33679
33690
  }
33680
33691
  const chainType = normalizeChainType2(fromChain);
33681
- const isNative = !fromTokenAddress || isNativeTokenAddress(fromTokenAddress, chainType) || isZeroAddrLike(fromTokenAddress, chainType);
33682
- if (isNative) {
33692
+ if (!needsErc20Approval(fromTokenAddress, chainType)) {
33683
33693
  setState((p) => ({ ...p, allowanceStatus: "sufficient" }));
33684
33694
  return;
33685
33695
  }
@@ -33693,7 +33703,7 @@ function useSwapExecution(fromChain) {
33693
33703
  BigInt(a.amount || "0"),
33694
33704
  amountWei
33695
33705
  );
33696
- if (!token || !a.spender) return [];
33706
+ if (!isEvmAddress2(token) || !isEvmAddress2(a.spender)) return [];
33697
33707
  return [
33698
33708
  {
33699
33709
  chainId: a.chainId || chainIdStr,
@@ -33841,7 +33851,8 @@ function useSwapExecution(fromChain) {
33841
33851
  const requiredApprovals = plannedApprovals.length ? plannedApprovals.flatMap((a, index) => {
33842
33852
  const token = a.tokenAddress ?? fromTokenAddress;
33843
33853
  const approvalSpender = a.spender;
33844
- if (!token || !approvalSpender) return [];
33854
+ if (!isEvmAddress2(token) || !isEvmAddress2(approvalSpender))
33855
+ return [];
33845
33856
  const amountWei = requiredApprovalAmount(
33846
33857
  BigInt(a.amount || "0"),
33847
33858
  fromAmountWei
@@ -33864,7 +33875,8 @@ function useSwapExecution(fromChain) {
33864
33875
  chainId: chainIdStr
33865
33876
  }
33866
33877
  ] : [];
33867
- const ownsApprovals = !isNative && !!walletAddress && !!chainIdStr;
33878
+ const coversEveryPlannedApproval = plannedApprovals.length === 0 || requiredApprovals.length === plannedApprovals.length;
33879
+ const ownsApprovals = coversEveryPlannedApproval && needsErc20Approval(fromTokenAddress, chainType) && !!walletAddress && !!chainIdStr;
33868
33880
  const activeAddress = ownsApprovals ? await requireActiveAddress(wallet, walletAddress) : void 0;
33869
33881
  for (const required of requiredApprovals) {
33870
33882
  if (!ownsApprovals) break;
@@ -36045,6 +36057,10 @@ function SwapMode({
36045
36057
  }, [lockDestToken, fromToken, fromChain, toToken, toChain, route, emitEvent]);
36046
36058
  const fromChainType = normalizeChainType2(fromChain);
36047
36059
  const toChainType = normalizeChainType2(toChain);
36060
+ const canSetMaxApproval = needsErc20Approval(
36061
+ fromToken?.address,
36062
+ fromChainType
36063
+ );
36048
36064
  const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
36049
36065
  const isValidDestAddress = !needsDestAddress || validateDestAddress(destAddress, toChainType ?? "");
36050
36066
  const handleReview = (0, import_react50.useCallback)(async () => {
@@ -38265,7 +38281,7 @@ function SwapMode({
38265
38281
  }
38266
38282
  )
38267
38283
  ] }),
38268
- /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { style: { marginBottom: spacing[4] }, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
38284
+ canSetMaxApproval && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { style: { marginBottom: spacing[4] }, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
38269
38285
  "div",
38270
38286
  {
38271
38287
  style: {