@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.
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +24 -8
- package/dist/index.mjs.map +1 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +24 -8
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +24 -8
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -571,7 +571,7 @@ var init_constants = __esm({
|
|
|
571
571
|
"src/constants.ts"() {
|
|
572
572
|
"use strict";
|
|
573
573
|
SDK_NAME = "@trustware/sdk";
|
|
574
|
-
SDK_VERSION = "1.1.12-staging.
|
|
574
|
+
SDK_VERSION = "1.1.12-staging.3";
|
|
575
575
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
576
576
|
GTM_ID = "GTM-TZDGNCXB";
|
|
577
577
|
API_PREFIX = "/api";
|
|
@@ -3207,6 +3207,15 @@ function isNativeTokenAddress(address, chainType) {
|
|
|
3207
3207
|
if (!chainType) return false;
|
|
3208
3208
|
return normalizeAddress2(address, chainType) === normalizeAddress2(getNativeTokenAddress2(chainType), chainType);
|
|
3209
3209
|
}
|
|
3210
|
+
function isEvmAddress2(value) {
|
|
3211
|
+
return !!value && EVM_ADDRESS_RE.test(value);
|
|
3212
|
+
}
|
|
3213
|
+
function needsErc20Approval(tokenAddress, chainType) {
|
|
3214
|
+
if (!isEvmAddress2(tokenAddress)) return false;
|
|
3215
|
+
const normalizedType = normalizeChainType2(chainType ?? void 0);
|
|
3216
|
+
if (normalizedType && NON_EVM_CHAIN_TYPES.has(normalizedType)) return false;
|
|
3217
|
+
return !isNativeTokenAddress(tokenAddress, chainType) && !isZeroAddrLike(tokenAddress, chainType);
|
|
3218
|
+
}
|
|
3210
3219
|
function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
|
|
3211
3220
|
const chainType = normalizeChainType2(chain);
|
|
3212
3221
|
const rawAddress = (address ?? "").trim();
|
|
@@ -3229,7 +3238,7 @@ function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
|
|
|
3229
3238
|
}
|
|
3230
3239
|
return lowerAddress;
|
|
3231
3240
|
}
|
|
3232
|
-
var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID;
|
|
3241
|
+
var NATIVE_EVM2, NATIVE_SOLANA2, CHAIN_TYPE_ALIASES2, SEI_EVM_CHAIN_ID, SEI_COSMOS_CHAIN_ID, EVM_ADDRESS_RE, NON_EVM_CHAIN_TYPES;
|
|
3233
3242
|
var init_chainHelpers = __esm({
|
|
3234
3243
|
"src/widget/helpers/chainHelpers.ts"() {
|
|
3235
3244
|
"use strict";
|
|
@@ -3245,6 +3254,8 @@ var init_chainHelpers = __esm({
|
|
|
3245
3254
|
};
|
|
3246
3255
|
SEI_EVM_CHAIN_ID = "1329";
|
|
3247
3256
|
SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
3257
|
+
EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
3258
|
+
NON_EVM_CHAIN_TYPES = /* @__PURE__ */ new Set(["solana", "bitcoin", "btc"]);
|
|
3248
3259
|
}
|
|
3249
3260
|
});
|
|
3250
3261
|
|
|
@@ -33621,8 +33632,7 @@ function useSwapExecution(fromChain) {
|
|
|
33621
33632
|
return;
|
|
33622
33633
|
}
|
|
33623
33634
|
const chainType = normalizeChainType2(fromChain);
|
|
33624
|
-
|
|
33625
|
-
if (isNative) {
|
|
33635
|
+
if (!needsErc20Approval(fromTokenAddress, chainType)) {
|
|
33626
33636
|
setState((p) => ({ ...p, allowanceStatus: "sufficient" }));
|
|
33627
33637
|
return;
|
|
33628
33638
|
}
|
|
@@ -33636,7 +33646,7 @@ function useSwapExecution(fromChain) {
|
|
|
33636
33646
|
BigInt(a.amount || "0"),
|
|
33637
33647
|
amountWei
|
|
33638
33648
|
);
|
|
33639
|
-
if (!token || !a.spender) return [];
|
|
33649
|
+
if (!isEvmAddress2(token) || !isEvmAddress2(a.spender)) return [];
|
|
33640
33650
|
return [
|
|
33641
33651
|
{
|
|
33642
33652
|
chainId: a.chainId || chainIdStr,
|
|
@@ -33784,7 +33794,8 @@ function useSwapExecution(fromChain) {
|
|
|
33784
33794
|
const requiredApprovals = plannedApprovals.length ? plannedApprovals.flatMap((a, index) => {
|
|
33785
33795
|
const token = a.tokenAddress ?? fromTokenAddress;
|
|
33786
33796
|
const approvalSpender = a.spender;
|
|
33787
|
-
if (!token || !approvalSpender)
|
|
33797
|
+
if (!isEvmAddress2(token) || !isEvmAddress2(approvalSpender))
|
|
33798
|
+
return [];
|
|
33788
33799
|
const amountWei = requiredApprovalAmount(
|
|
33789
33800
|
BigInt(a.amount || "0"),
|
|
33790
33801
|
fromAmountWei
|
|
@@ -33807,7 +33818,8 @@ function useSwapExecution(fromChain) {
|
|
|
33807
33818
|
chainId: chainIdStr
|
|
33808
33819
|
}
|
|
33809
33820
|
] : [];
|
|
33810
|
-
const
|
|
33821
|
+
const coversEveryPlannedApproval = plannedApprovals.length === 0 || requiredApprovals.length === plannedApprovals.length;
|
|
33822
|
+
const ownsApprovals = coversEveryPlannedApproval && needsErc20Approval(fromTokenAddress, chainType) && !!walletAddress && !!chainIdStr;
|
|
33811
33823
|
const activeAddress = ownsApprovals ? await requireActiveAddress(wallet, walletAddress) : void 0;
|
|
33812
33824
|
for (const required of requiredApprovals) {
|
|
33813
33825
|
if (!ownsApprovals) break;
|
|
@@ -35995,6 +36007,10 @@ function SwapMode({
|
|
|
35995
36007
|
}, [lockDestToken, fromToken, fromChain, toToken, toChain, route, emitEvent]);
|
|
35996
36008
|
const fromChainType = normalizeChainType2(fromChain);
|
|
35997
36009
|
const toChainType = normalizeChainType2(toChain);
|
|
36010
|
+
const canSetMaxApproval = needsErc20Approval(
|
|
36011
|
+
fromToken?.address,
|
|
36012
|
+
fromChainType
|
|
36013
|
+
);
|
|
35998
36014
|
const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
|
|
35999
36015
|
const isValidDestAddress = !needsDestAddress || validateDestAddress(destAddress, toChainType ?? "");
|
|
36000
36016
|
const handleReview = useCallback22(async () => {
|
|
@@ -38215,7 +38231,7 @@ function SwapMode({
|
|
|
38215
38231
|
}
|
|
38216
38232
|
)
|
|
38217
38233
|
] }),
|
|
38218
|
-
/* @__PURE__ */ jsx59("div", { style: { marginBottom: spacing[4] }, children: /* @__PURE__ */ jsxs47(
|
|
38234
|
+
canSetMaxApproval && /* @__PURE__ */ jsx59("div", { style: { marginBottom: spacing[4] }, children: /* @__PURE__ */ jsxs47(
|
|
38219
38235
|
"div",
|
|
38220
38236
|
{
|
|
38221
38237
|
style: {
|