@trustware/sdk-staging 1.1.4-staging.50 → 1.1.5-staging.1
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 +555 -350
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +476 -271
- package/dist/index.mjs.map +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +555 -350
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +476 -271
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -225,7 +225,7 @@ var init_constants = __esm({
|
|
|
225
225
|
"src/constants.ts"() {
|
|
226
226
|
"use strict";
|
|
227
227
|
SDK_NAME = "@trustware/sdk";
|
|
228
|
-
SDK_VERSION = "1.1.
|
|
228
|
+
SDK_VERSION = "1.1.5-staging.1";
|
|
229
229
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
230
230
|
GTM_ID = "GTM-TZDGNCXB";
|
|
231
231
|
API_PREFIX = "/api";
|
|
@@ -785,15 +785,15 @@ __export(ConfettiEffect_exports, {
|
|
|
785
785
|
ConfettiEffect: () => ConfettiEffect,
|
|
786
786
|
default: () => ConfettiEffect_default
|
|
787
787
|
});
|
|
788
|
-
import { useEffect as
|
|
788
|
+
import { useEffect as useEffect14, useState as useState16 } from "react";
|
|
789
789
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
790
790
|
function ConfettiEffect({
|
|
791
791
|
isActive,
|
|
792
792
|
clearDelay = 3e3,
|
|
793
793
|
pieceCount = 50
|
|
794
794
|
}) {
|
|
795
|
-
const [pieces, setPieces] =
|
|
796
|
-
|
|
795
|
+
const [pieces, setPieces] = useState16([]);
|
|
796
|
+
useEffect14(() => {
|
|
797
797
|
if (isActive) {
|
|
798
798
|
const colors2 = [
|
|
799
799
|
"#10b981",
|
|
@@ -4270,10 +4270,10 @@ init_http();
|
|
|
4270
4270
|
|
|
4271
4271
|
// src/widget/TrustwareWidgetV2.tsx
|
|
4272
4272
|
import {
|
|
4273
|
-
useState as
|
|
4274
|
-
useEffect as
|
|
4273
|
+
useState as useState24,
|
|
4274
|
+
useEffect as useEffect28,
|
|
4275
4275
|
useRef as useRef13,
|
|
4276
|
-
useCallback as
|
|
4276
|
+
useCallback as useCallback16,
|
|
4277
4277
|
useImperativeHandle,
|
|
4278
4278
|
forwardRef
|
|
4279
4279
|
} from "react";
|
|
@@ -4756,7 +4756,7 @@ var ANIMATION_CLASSES = `
|
|
|
4756
4756
|
var ALL_ANIMATION_STYLES = KEYFRAMES + ANIMATION_CLASSES;
|
|
4757
4757
|
|
|
4758
4758
|
// src/widget/context/DepositContext.tsx
|
|
4759
|
-
import React2, { createContext as createContext2, useContext as useContext2, useState as
|
|
4759
|
+
import React2, { createContext as createContext2, useContext as useContext2, useState as useState14, useMemo as useMemo7 } from "react";
|
|
4760
4760
|
|
|
4761
4761
|
// src/provider.tsx
|
|
4762
4762
|
import {
|
|
@@ -6145,6 +6145,316 @@ function mapWalletTokens(balances, chains, tokens) {
|
|
|
6145
6145
|
});
|
|
6146
6146
|
}
|
|
6147
6147
|
|
|
6148
|
+
// src/widget/state/deposit/useWalletConnect.ts
|
|
6149
|
+
init_config2();
|
|
6150
|
+
import { useCallback as useCallback8, useEffect as useEffect13, useState as useState13 } from "react";
|
|
6151
|
+
|
|
6152
|
+
// src/config/walletconnect.ts
|
|
6153
|
+
init_store();
|
|
6154
|
+
init_constants();
|
|
6155
|
+
import { UniversalConnector } from "@reown/appkit-universal-connector";
|
|
6156
|
+
var solanaMainnet = {
|
|
6157
|
+
id: 900,
|
|
6158
|
+
chainNamespace: "solana",
|
|
6159
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
|
|
6160
|
+
name: "Solana Mainnet",
|
|
6161
|
+
nativeCurrency: {
|
|
6162
|
+
name: "Solana",
|
|
6163
|
+
symbol: "SOL",
|
|
6164
|
+
decimals: 9
|
|
6165
|
+
},
|
|
6166
|
+
rpcUrls: {
|
|
6167
|
+
default: {
|
|
6168
|
+
http: ["https://api.mainnet-beta.solana.com"]
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
};
|
|
6172
|
+
var bitcoinMainnet = {
|
|
6173
|
+
id: 8333,
|
|
6174
|
+
chainNamespace: "bip122",
|
|
6175
|
+
caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
|
|
6176
|
+
name: "Bitcoin Mainnet",
|
|
6177
|
+
nativeCurrency: {
|
|
6178
|
+
name: "Bitcoin",
|
|
6179
|
+
symbol: "BTC",
|
|
6180
|
+
decimals: 8
|
|
6181
|
+
},
|
|
6182
|
+
rpcUrls: {
|
|
6183
|
+
default: {
|
|
6184
|
+
http: ["https://api.blockcypher.com/v1/btc/main"]
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
};
|
|
6188
|
+
var ethereumMainnet = {
|
|
6189
|
+
id: 1,
|
|
6190
|
+
chainNamespace: "eip155",
|
|
6191
|
+
caipNetworkId: "eip155:1",
|
|
6192
|
+
name: "Ethereum Mainnet",
|
|
6193
|
+
nativeCurrency: {
|
|
6194
|
+
name: "Ether",
|
|
6195
|
+
symbol: "ETH",
|
|
6196
|
+
decimals: 18
|
|
6197
|
+
},
|
|
6198
|
+
rpcUrls: {
|
|
6199
|
+
default: {
|
|
6200
|
+
http: ["https://rpc.ankr.com/eth"]
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6203
|
+
};
|
|
6204
|
+
var seiMainnet = {
|
|
6205
|
+
id: 1329,
|
|
6206
|
+
chainNamespace: "eip155",
|
|
6207
|
+
caipNetworkId: "eip155:1329",
|
|
6208
|
+
name: "Sei Mainnet",
|
|
6209
|
+
nativeCurrency: {
|
|
6210
|
+
name: "Sei",
|
|
6211
|
+
symbol: "SEI",
|
|
6212
|
+
decimals: 18
|
|
6213
|
+
},
|
|
6214
|
+
rpcUrls: {
|
|
6215
|
+
default: {
|
|
6216
|
+
http: ["https://evm-rpc.sei-apis.com"]
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
};
|
|
6220
|
+
var solanaChains = [solanaMainnet];
|
|
6221
|
+
var evmChains = [ethereumMainnet, seiMainnet];
|
|
6222
|
+
var bitcoinChains = [bitcoinMainnet];
|
|
6223
|
+
var networks = [
|
|
6224
|
+
// ...solanaChains,
|
|
6225
|
+
// ...bitcoinChains,
|
|
6226
|
+
...evmChains
|
|
6227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6228
|
+
];
|
|
6229
|
+
var namespaceConfig = [
|
|
6230
|
+
{
|
|
6231
|
+
namespace: "solana",
|
|
6232
|
+
chains: solanaChains,
|
|
6233
|
+
methods: ["solana_signMessage", "solana_signTransaction"],
|
|
6234
|
+
events: []
|
|
6235
|
+
},
|
|
6236
|
+
{
|
|
6237
|
+
namespace: "eip155",
|
|
6238
|
+
chains: evmChains,
|
|
6239
|
+
methods: [
|
|
6240
|
+
"eth_sendTransaction",
|
|
6241
|
+
"eth_signTransaction",
|
|
6242
|
+
"eth_sign",
|
|
6243
|
+
"personal_sign",
|
|
6244
|
+
"eth_signTypedData_v4"
|
|
6245
|
+
],
|
|
6246
|
+
events: ["accountsChanged", "chainChanged"]
|
|
6247
|
+
},
|
|
6248
|
+
{
|
|
6249
|
+
namespace: "bip122",
|
|
6250
|
+
chains: bitcoinChains,
|
|
6251
|
+
// FIX 8: Use the standard WalletConnect BIP-122 method name, not the
|
|
6252
|
+
// non-standard "btc_signMessage" prefix that most wallets reject.
|
|
6253
|
+
methods: ["signMessage", "sendTransfer"],
|
|
6254
|
+
events: []
|
|
6255
|
+
}
|
|
6256
|
+
];
|
|
6257
|
+
function resolvedMetadata() {
|
|
6258
|
+
const cfg = TrustwareConfigStore.peek();
|
|
6259
|
+
const walletConnect = cfg ? cfg?.walletConnect : void 0;
|
|
6260
|
+
const configured = walletConnect?.metadata;
|
|
6261
|
+
const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
|
|
6262
|
+
if (!pageUrl) {
|
|
6263
|
+
console.warn(
|
|
6264
|
+
"[Trustware SDK] WalletConnect metadata.url could not be determined from window.location or config. Falling back to 'https://trustware.io'. Pass metadata.url explicitly in your WalletConnectConfig to avoid domain verification failures in production."
|
|
6265
|
+
);
|
|
6266
|
+
}
|
|
6267
|
+
return {
|
|
6268
|
+
name: configured?.name ?? "Trustware",
|
|
6269
|
+
description: configured?.description ?? "Cross-chain bridge & top-up",
|
|
6270
|
+
url: pageUrl ?? "https://trustware.io",
|
|
6271
|
+
icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
|
|
6272
|
+
};
|
|
6273
|
+
}
|
|
6274
|
+
var universalConnectorPromise = null;
|
|
6275
|
+
var initializedProjectId = null;
|
|
6276
|
+
async function getUniversalConnector(walletCfg) {
|
|
6277
|
+
const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
|
|
6278
|
+
if (universalConnectorPromise && initializedProjectId !== projectId) {
|
|
6279
|
+
console.warn(
|
|
6280
|
+
"[Trustware SDK] projectId changed since last init \u2014 reinitializing WalletConnect connector."
|
|
6281
|
+
);
|
|
6282
|
+
universalConnectorPromise = null;
|
|
6283
|
+
initializedProjectId = null;
|
|
6284
|
+
}
|
|
6285
|
+
if (!universalConnectorPromise) {
|
|
6286
|
+
initializedProjectId = projectId;
|
|
6287
|
+
universalConnectorPromise = UniversalConnector.init({
|
|
6288
|
+
projectId,
|
|
6289
|
+
metadata: resolvedMetadata(),
|
|
6290
|
+
networks: namespaceConfig
|
|
6291
|
+
}).catch((error) => {
|
|
6292
|
+
universalConnectorPromise = null;
|
|
6293
|
+
initializedProjectId = null;
|
|
6294
|
+
console.error(
|
|
6295
|
+
"[Trustware SDK] Failed to initialize WalletConnect:",
|
|
6296
|
+
error
|
|
6297
|
+
);
|
|
6298
|
+
throw error;
|
|
6299
|
+
});
|
|
6300
|
+
}
|
|
6301
|
+
return universalConnectorPromise;
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
// src/widget/state/deposit/useWalletConnect.ts
|
|
6305
|
+
function getEvmAccount(session) {
|
|
6306
|
+
const account = session?.namespaces?.eip155?.accounts?.[0];
|
|
6307
|
+
const [, chainId, address] = account?.split(":") ?? [];
|
|
6308
|
+
if (!chainId || !address) {
|
|
6309
|
+
return null;
|
|
6310
|
+
}
|
|
6311
|
+
return {
|
|
6312
|
+
address,
|
|
6313
|
+
chainId: Number(chainId)
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6316
|
+
function toHexChainId(chainId) {
|
|
6317
|
+
return `0x${chainId.toString(16)}`;
|
|
6318
|
+
}
|
|
6319
|
+
function useWalletConnect({
|
|
6320
|
+
setWalletType,
|
|
6321
|
+
setCurrentStep
|
|
6322
|
+
}) {
|
|
6323
|
+
const [universalConnector, setUniversalConnector] = useState13();
|
|
6324
|
+
const [walletConnectAddress, setWalletConnectAddress] = useState13(null);
|
|
6325
|
+
useEffect13(() => {
|
|
6326
|
+
if (typeof window === "undefined") {
|
|
6327
|
+
return;
|
|
6328
|
+
}
|
|
6329
|
+
const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
|
|
6330
|
+
getUniversalConnector(walletConnect).then(
|
|
6331
|
+
setUniversalConnector
|
|
6332
|
+
);
|
|
6333
|
+
}, [TrustwareConfigStore.peek()?.walletConnect]);
|
|
6334
|
+
useEffect13(() => {
|
|
6335
|
+
return () => {
|
|
6336
|
+
universalConnector?.disconnect();
|
|
6337
|
+
};
|
|
6338
|
+
}, [universalConnector]);
|
|
6339
|
+
const attachWalletConnectWallet = useCallback8(
|
|
6340
|
+
(connector, session) => {
|
|
6341
|
+
const account = getEvmAccount(session);
|
|
6342
|
+
if (!account) {
|
|
6343
|
+
return null;
|
|
6344
|
+
}
|
|
6345
|
+
const activeAddress = account.address;
|
|
6346
|
+
let activeChainId = account.chainId;
|
|
6347
|
+
connector.provider.setDefaultChain(`eip155:${activeChainId}`);
|
|
6348
|
+
const wallet = {
|
|
6349
|
+
ecosystem: "evm",
|
|
6350
|
+
type: "eip1193",
|
|
6351
|
+
async getAddress() {
|
|
6352
|
+
return activeAddress;
|
|
6353
|
+
},
|
|
6354
|
+
async getChainId() {
|
|
6355
|
+
return activeChainId;
|
|
6356
|
+
},
|
|
6357
|
+
async switchChain(chainId) {
|
|
6358
|
+
connector.provider.setDefaultChain(`eip155:${chainId}`);
|
|
6359
|
+
await connector.provider.request(
|
|
6360
|
+
{
|
|
6361
|
+
method: "wallet_switchEthereumChain",
|
|
6362
|
+
params: [{ chainId: toHexChainId(chainId) }]
|
|
6363
|
+
},
|
|
6364
|
+
`eip155:${chainId}`
|
|
6365
|
+
);
|
|
6366
|
+
activeChainId = chainId;
|
|
6367
|
+
},
|
|
6368
|
+
async request(args) {
|
|
6369
|
+
const tx = Array.isArray(args.params) ? args.params[0] : void 0;
|
|
6370
|
+
const requestedChainId = typeof tx?.chainId === "string" ? Number.parseInt(tx.chainId, 16) : activeChainId;
|
|
6371
|
+
const chain = Number.isFinite(requestedChainId) ? `eip155:${requestedChainId}` : `eip155:${activeChainId}`;
|
|
6372
|
+
connector.provider.setDefaultChain(chain);
|
|
6373
|
+
return connector.provider.request(args, chain);
|
|
6374
|
+
},
|
|
6375
|
+
async disconnect() {
|
|
6376
|
+
await connector.disconnect();
|
|
6377
|
+
}
|
|
6378
|
+
};
|
|
6379
|
+
walletManager.attachWallet(wallet);
|
|
6380
|
+
setWalletConnectAddress(activeAddress);
|
|
6381
|
+
return activeAddress;
|
|
6382
|
+
},
|
|
6383
|
+
[]
|
|
6384
|
+
);
|
|
6385
|
+
const getAddrAndRedirect = useCallback8(
|
|
6386
|
+
(connector, session) => {
|
|
6387
|
+
const adr = attachWalletConnectWallet(connector, session);
|
|
6388
|
+
if (!adr) return null;
|
|
6389
|
+
setCurrentStep("crypto-pay");
|
|
6390
|
+
console.log({ adr });
|
|
6391
|
+
return adr;
|
|
6392
|
+
},
|
|
6393
|
+
[attachWalletConnectWallet, setCurrentStep]
|
|
6394
|
+
);
|
|
6395
|
+
const WalletConnect = useCallback8(
|
|
6396
|
+
async function() {
|
|
6397
|
+
console.log("got called");
|
|
6398
|
+
if (!universalConnector) {
|
|
6399
|
+
return;
|
|
6400
|
+
}
|
|
6401
|
+
setWalletType("walletconnect");
|
|
6402
|
+
const session = universalConnector.provider.session;
|
|
6403
|
+
const nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
6404
|
+
const isActive = session && session.expiry > nowInSeconds;
|
|
6405
|
+
console.log({ isActive, session });
|
|
6406
|
+
if (isActive && session) {
|
|
6407
|
+
getAddrAndRedirect(universalConnector, session);
|
|
6408
|
+
return;
|
|
6409
|
+
}
|
|
6410
|
+
const { session: providerSession } = await universalConnector.connect();
|
|
6411
|
+
if (providerSession) {
|
|
6412
|
+
getAddrAndRedirect(universalConnector, providerSession);
|
|
6413
|
+
return;
|
|
6414
|
+
}
|
|
6415
|
+
},
|
|
6416
|
+
[getAddrAndRedirect, setWalletType, universalConnector]
|
|
6417
|
+
);
|
|
6418
|
+
const disconnectWalletConnect = async () => {
|
|
6419
|
+
if (universalConnector) {
|
|
6420
|
+
await walletManager.disconnect();
|
|
6421
|
+
setWalletType("other");
|
|
6422
|
+
setCurrentStep("home");
|
|
6423
|
+
}
|
|
6424
|
+
};
|
|
6425
|
+
useEffect13(() => {
|
|
6426
|
+
const provider = universalConnector?.provider;
|
|
6427
|
+
if (!provider) {
|
|
6428
|
+
return;
|
|
6429
|
+
}
|
|
6430
|
+
const handleSessionUpdate = ({
|
|
6431
|
+
session
|
|
6432
|
+
}) => {
|
|
6433
|
+
console.log("session_update");
|
|
6434
|
+
if (session) {
|
|
6435
|
+
attachWalletConnectWallet(universalConnector, session);
|
|
6436
|
+
}
|
|
6437
|
+
};
|
|
6438
|
+
const handleSessionDelete = () => {
|
|
6439
|
+
console.log("session_delete");
|
|
6440
|
+
setWalletConnectAddress(null);
|
|
6441
|
+
void walletManager.disconnect();
|
|
6442
|
+
};
|
|
6443
|
+
provider.on("session_update", handleSessionUpdate);
|
|
6444
|
+
provider.on("session_delete", handleSessionDelete);
|
|
6445
|
+
return () => {
|
|
6446
|
+
provider.off("session_update", handleSessionUpdate);
|
|
6447
|
+
provider.off("session_delete", handleSessionDelete);
|
|
6448
|
+
};
|
|
6449
|
+
}, [attachWalletConnectWallet, universalConnector]);
|
|
6450
|
+
return {
|
|
6451
|
+
universalConnector,
|
|
6452
|
+
walletConnectAddress,
|
|
6453
|
+
WalletConnect,
|
|
6454
|
+
disconnectWalletConnect
|
|
6455
|
+
};
|
|
6456
|
+
}
|
|
6457
|
+
|
|
6148
6458
|
// src/widget/context/DepositContext.tsx
|
|
6149
6459
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
6150
6460
|
var DepositContext = createContext2(
|
|
@@ -6172,17 +6482,33 @@ function DepositProvider({
|
|
|
6172
6482
|
const { resolvedTheme, toggleTheme } = useThemePreference();
|
|
6173
6483
|
const {
|
|
6174
6484
|
selectedWallet,
|
|
6175
|
-
walletAddress,
|
|
6485
|
+
walletAddress: otherWalletAddress,
|
|
6176
6486
|
walletStatus,
|
|
6177
6487
|
connectWallet,
|
|
6178
6488
|
disconnectWallet
|
|
6179
6489
|
} = useWalletSessionState();
|
|
6180
|
-
const [amountInputMode, setAmountInputMode] =
|
|
6490
|
+
const [amountInputMode, setAmountInputMode] = useState14(
|
|
6181
6491
|
"usd"
|
|
6182
6492
|
);
|
|
6183
|
-
const [
|
|
6184
|
-
|
|
6185
|
-
|
|
6493
|
+
const [walletType, setWalletType] = useState14(
|
|
6494
|
+
"other"
|
|
6495
|
+
);
|
|
6496
|
+
const {
|
|
6497
|
+
universalConnector,
|
|
6498
|
+
walletConnectAddress,
|
|
6499
|
+
WalletConnect,
|
|
6500
|
+
disconnectWalletConnect
|
|
6501
|
+
} = useWalletConnect({
|
|
6502
|
+
setWalletType,
|
|
6503
|
+
setCurrentStep
|
|
6504
|
+
});
|
|
6505
|
+
const [selectedToken, setSelectedToken] = useState14(null);
|
|
6506
|
+
const [selectedChain, setSelectedChain] = useState14(null);
|
|
6507
|
+
const [amount, setAmount] = useState14("");
|
|
6508
|
+
const walletAddress = useMemo7(
|
|
6509
|
+
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
6510
|
+
[walletType, walletConnectAddress, otherWalletAddress]
|
|
6511
|
+
);
|
|
6186
6512
|
const {
|
|
6187
6513
|
yourWalletTokens,
|
|
6188
6514
|
setYourWalletTokens,
|
|
@@ -6195,11 +6521,11 @@ function DepositProvider({
|
|
|
6195
6521
|
selectedToken,
|
|
6196
6522
|
setSelectedToken
|
|
6197
6523
|
});
|
|
6198
|
-
const [transactionStatus, setTransactionStatus] =
|
|
6199
|
-
const [transactionHash, setTransactionHash] =
|
|
6200
|
-
const [errorMessage, setErrorMessage] =
|
|
6201
|
-
const [intentId, setIntentId] =
|
|
6202
|
-
const [paymentMethod, setPaymentMethod] =
|
|
6524
|
+
const [transactionStatus, setTransactionStatus] = useState14("idle");
|
|
6525
|
+
const [transactionHash, setTransactionHash] = useState14(null);
|
|
6526
|
+
const [errorMessage, setErrorMessage] = useState14(null);
|
|
6527
|
+
const [intentId, setIntentId] = useState14(null);
|
|
6528
|
+
const [paymentMethod, setPaymentMethod] = useState14("crypto");
|
|
6203
6529
|
const resetState = React2.useCallback(() => {
|
|
6204
6530
|
resetNavigation();
|
|
6205
6531
|
setSelectedToken(null);
|
|
@@ -6242,15 +6568,26 @@ function DepositProvider({
|
|
|
6242
6568
|
disconnectWallet,
|
|
6243
6569
|
yourWalletTokens,
|
|
6244
6570
|
setYourWalletTokens,
|
|
6245
|
-
yourWalletTokensLoading
|
|
6571
|
+
yourWalletTokensLoading,
|
|
6572
|
+
universalConnector,
|
|
6573
|
+
walletConnectAddress,
|
|
6574
|
+
WalletConnect,
|
|
6575
|
+
disconnectWalletConnect,
|
|
6576
|
+
setWalletType,
|
|
6577
|
+
walletType
|
|
6246
6578
|
}),
|
|
6247
6579
|
[
|
|
6580
|
+
WalletConnect,
|
|
6248
6581
|
connectWallet,
|
|
6249
6582
|
disconnectWallet,
|
|
6583
|
+
disconnectWalletConnect,
|
|
6250
6584
|
selectedWallet,
|
|
6251
6585
|
setYourWalletTokens,
|
|
6586
|
+
universalConnector,
|
|
6252
6587
|
walletAddress,
|
|
6588
|
+
walletConnectAddress,
|
|
6253
6589
|
walletStatus,
|
|
6590
|
+
walletType,
|
|
6254
6591
|
yourWalletTokens,
|
|
6255
6592
|
yourWalletTokensLoading
|
|
6256
6593
|
]
|
|
@@ -6333,7 +6670,7 @@ function useDepositUi() {
|
|
|
6333
6670
|
}
|
|
6334
6671
|
|
|
6335
6672
|
// src/widget/components/AmountSlider.tsx
|
|
6336
|
-
import { useCallback as
|
|
6673
|
+
import { useCallback as useCallback9, useMemo as useMemo8 } from "react";
|
|
6337
6674
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
6338
6675
|
var roundToNiceNumber = (value, range) => {
|
|
6339
6676
|
let roundingFactor;
|
|
@@ -6383,7 +6720,7 @@ function AmountSlider({
|
|
|
6383
6720
|
style,
|
|
6384
6721
|
disabled = false
|
|
6385
6722
|
}) {
|
|
6386
|
-
const generateTickMarks =
|
|
6723
|
+
const generateTickMarks = useCallback9(
|
|
6387
6724
|
(minValue, maxValue) => {
|
|
6388
6725
|
const range = maxValue - minValue;
|
|
6389
6726
|
if (range <= 0) {
|
|
@@ -6435,21 +6772,21 @@ function AmountSlider({
|
|
|
6435
6772
|
() => generateTickMarks(min, max),
|
|
6436
6773
|
[generateTickMarks, min, max]
|
|
6437
6774
|
);
|
|
6438
|
-
const getPercentage =
|
|
6775
|
+
const getPercentage = useCallback9(() => {
|
|
6439
6776
|
const range = max - min;
|
|
6440
6777
|
if (range <= 0) return 0;
|
|
6441
6778
|
const clampedValue = Math.min(Math.max(value, min), max);
|
|
6442
6779
|
return (clampedValue - min) / range * 100;
|
|
6443
6780
|
}, [max, min, value]);
|
|
6444
6781
|
const percentage = useMemo8(() => getPercentage(), [getPercentage]);
|
|
6445
|
-
const handleChange =
|
|
6782
|
+
const handleChange = useCallback9(
|
|
6446
6783
|
(e2) => {
|
|
6447
6784
|
const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
|
|
6448
6785
|
onChange(newValue);
|
|
6449
6786
|
},
|
|
6450
6787
|
[onChange, min, max]
|
|
6451
6788
|
);
|
|
6452
|
-
const handleTickClick =
|
|
6789
|
+
const handleTickClick = useCallback9(
|
|
6453
6790
|
(tickValue) => {
|
|
6454
6791
|
if (disabled) return;
|
|
6455
6792
|
onChange(tickValue);
|
|
@@ -6667,7 +7004,7 @@ function AmountSlider({
|
|
|
6667
7004
|
}
|
|
6668
7005
|
|
|
6669
7006
|
// src/widget/components/AmountInputDisplay.tsx
|
|
6670
|
-
import { useRef as useRef5, useState as
|
|
7007
|
+
import { useRef as useRef5, useState as useState15 } from "react";
|
|
6671
7008
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
6672
7009
|
function formatDisplayAmount(value) {
|
|
6673
7010
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -6706,7 +7043,7 @@ function AmountInputDisplay({
|
|
|
6706
7043
|
style,
|
|
6707
7044
|
inputAriaLabel = "Deposit amount"
|
|
6708
7045
|
}) {
|
|
6709
|
-
const [isEditing, setIsEditing] =
|
|
7046
|
+
const [isEditing, setIsEditing] = useState15(false);
|
|
6710
7047
|
const inputRef = useRef5(null);
|
|
6711
7048
|
const handleAmountClick = () => {
|
|
6712
7049
|
if (isFixedAmount) return;
|
|
@@ -6922,7 +7259,7 @@ function CircularProgress({
|
|
|
6922
7259
|
}
|
|
6923
7260
|
|
|
6924
7261
|
// src/widget/components/Dialog.tsx
|
|
6925
|
-
import { useEffect as
|
|
7262
|
+
import { useEffect as useEffect15, useRef as useRef6 } from "react";
|
|
6926
7263
|
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
6927
7264
|
var Dialog = ({
|
|
6928
7265
|
open,
|
|
@@ -6938,7 +7275,7 @@ var Dialog = ({
|
|
|
6938
7275
|
const overlayRef = useRef6(null);
|
|
6939
7276
|
const firstButtonRef = useRef6(null);
|
|
6940
7277
|
const lastButtonRef = useRef6(null);
|
|
6941
|
-
|
|
7278
|
+
useEffect15(() => {
|
|
6942
7279
|
const handleEscape = (e2) => {
|
|
6943
7280
|
if (e2.key === "Escape" && open) {
|
|
6944
7281
|
e2.preventDefault();
|
|
@@ -6952,7 +7289,7 @@ var Dialog = ({
|
|
|
6952
7289
|
document.removeEventListener("keydown", handleEscape);
|
|
6953
7290
|
};
|
|
6954
7291
|
}, [open, onCancel]);
|
|
6955
|
-
|
|
7292
|
+
useEffect15(() => {
|
|
6956
7293
|
const handleTabKey = (e2) => {
|
|
6957
7294
|
if (!open) return;
|
|
6958
7295
|
if (e2.key === "Tab") {
|
|
@@ -6976,7 +7313,7 @@ var Dialog = ({
|
|
|
6976
7313
|
document.removeEventListener("keydown", handleTabKey);
|
|
6977
7314
|
};
|
|
6978
7315
|
}, [open]);
|
|
6979
|
-
|
|
7316
|
+
useEffect15(() => {
|
|
6980
7317
|
if (open) {
|
|
6981
7318
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
6982
7319
|
document.body.style.overflow = "hidden";
|
|
@@ -7274,7 +7611,7 @@ function TransactionHashLink({
|
|
|
7274
7611
|
}
|
|
7275
7612
|
|
|
7276
7613
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
7277
|
-
import { useState as
|
|
7614
|
+
import { useState as useState17, useRef as useRef7, useCallback as useCallback10, useEffect as useEffect16 } from "react";
|
|
7278
7615
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
7279
7616
|
function SwipeToConfirmTokens({
|
|
7280
7617
|
fromToken,
|
|
@@ -7289,13 +7626,13 @@ function SwipeToConfirmTokens({
|
|
|
7289
7626
|
style,
|
|
7290
7627
|
text
|
|
7291
7628
|
}) {
|
|
7292
|
-
const [dragX, setDragX] =
|
|
7293
|
-
const [isDragging, setIsDragging] =
|
|
7294
|
-
const [isComplete, setIsComplete] =
|
|
7629
|
+
const [dragX, setDragX] = useState17(0);
|
|
7630
|
+
const [isDragging, setIsDragging] = useState17(false);
|
|
7631
|
+
const [isComplete, setIsComplete] = useState17(false);
|
|
7295
7632
|
const trackRef = useRef7(null);
|
|
7296
7633
|
const thumbRef = useRef7(null);
|
|
7297
|
-
const [isLongPressing, setIsLongPressing] =
|
|
7298
|
-
const [longPressProgress, setLongPressProgress] =
|
|
7634
|
+
const [isLongPressing, setIsLongPressing] = useState17(false);
|
|
7635
|
+
const [longPressProgress, setLongPressProgress] = useState17(0);
|
|
7299
7636
|
const longPressTimerRef = useRef7(null);
|
|
7300
7637
|
const longPressStartRef = useRef7(null);
|
|
7301
7638
|
const longPressAnimationRef = useRef7(null);
|
|
@@ -7303,19 +7640,19 @@ function SwipeToConfirmTokens({
|
|
|
7303
7640
|
const thumbSize = 48;
|
|
7304
7641
|
const padding = 4;
|
|
7305
7642
|
const threshold = 0.8;
|
|
7306
|
-
const getMaxDrag =
|
|
7643
|
+
const getMaxDrag = useCallback10(() => {
|
|
7307
7644
|
if (!trackRef.current) return 0;
|
|
7308
7645
|
return trackRef.current.offsetWidth - thumbSize - padding * 2;
|
|
7309
7646
|
}, []);
|
|
7310
|
-
const getProgress =
|
|
7647
|
+
const getProgress = useCallback10(() => {
|
|
7311
7648
|
const maxDrag = getMaxDrag();
|
|
7312
7649
|
return maxDrag > 0 ? dragX / maxDrag : 0;
|
|
7313
7650
|
}, [dragX, getMaxDrag]);
|
|
7314
|
-
const handleDragStart =
|
|
7651
|
+
const handleDragStart = useCallback10(() => {
|
|
7315
7652
|
if (disabled || isComplete) return;
|
|
7316
7653
|
setIsDragging(true);
|
|
7317
7654
|
}, [disabled, isComplete]);
|
|
7318
|
-
const handleDragMove =
|
|
7655
|
+
const handleDragMove = useCallback10(
|
|
7319
7656
|
(clientX) => {
|
|
7320
7657
|
if (!isDragging || !trackRef.current || isComplete) return;
|
|
7321
7658
|
const rect = trackRef.current.getBoundingClientRect();
|
|
@@ -7326,7 +7663,7 @@ function SwipeToConfirmTokens({
|
|
|
7326
7663
|
},
|
|
7327
7664
|
[isDragging, isComplete, getMaxDrag]
|
|
7328
7665
|
);
|
|
7329
|
-
const handleDragEnd =
|
|
7666
|
+
const handleDragEnd = useCallback10(() => {
|
|
7330
7667
|
if (!isDragging) return;
|
|
7331
7668
|
setIsDragging(false);
|
|
7332
7669
|
const progress2 = getProgress();
|
|
@@ -7339,14 +7676,14 @@ function SwipeToConfirmTokens({
|
|
|
7339
7676
|
setDragX(0);
|
|
7340
7677
|
}
|
|
7341
7678
|
}, [isDragging, getProgress, getMaxDrag, onConfirm]);
|
|
7342
|
-
const triggerConfirmation =
|
|
7679
|
+
const triggerConfirmation = useCallback10(() => {
|
|
7343
7680
|
if (isComplete) return;
|
|
7344
7681
|
setDragX(getMaxDrag());
|
|
7345
7682
|
setIsComplete(true);
|
|
7346
7683
|
if (navigator.vibrate) navigator.vibrate(50);
|
|
7347
7684
|
setTimeout(() => onConfirm(), 150);
|
|
7348
7685
|
}, [isComplete, getMaxDrag, onConfirm]);
|
|
7349
|
-
const cancelLongPress =
|
|
7686
|
+
const cancelLongPress = useCallback10(() => {
|
|
7350
7687
|
setIsLongPressing(false);
|
|
7351
7688
|
setLongPressProgress(0);
|
|
7352
7689
|
longPressStartRef.current = null;
|
|
@@ -7359,7 +7696,7 @@ function SwipeToConfirmTokens({
|
|
|
7359
7696
|
longPressAnimationRef.current = null;
|
|
7360
7697
|
}
|
|
7361
7698
|
}, []);
|
|
7362
|
-
const startLongPress =
|
|
7699
|
+
const startLongPress = useCallback10(() => {
|
|
7363
7700
|
if (disabled || isComplete || isDragging) return;
|
|
7364
7701
|
setIsLongPressing(true);
|
|
7365
7702
|
longPressStartRef.current = Date.now();
|
|
@@ -7377,7 +7714,7 @@ function SwipeToConfirmTokens({
|
|
|
7377
7714
|
};
|
|
7378
7715
|
longPressAnimationRef.current = requestAnimationFrame(animateProgress);
|
|
7379
7716
|
}, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
|
|
7380
|
-
const handleKeyDown =
|
|
7717
|
+
const handleKeyDown = useCallback10(
|
|
7381
7718
|
(e2) => {
|
|
7382
7719
|
if (disabled || isComplete) return;
|
|
7383
7720
|
if (e2.key === "Enter" || e2.key === " ") {
|
|
@@ -7387,7 +7724,7 @@ function SwipeToConfirmTokens({
|
|
|
7387
7724
|
},
|
|
7388
7725
|
[disabled, isComplete, startLongPress]
|
|
7389
7726
|
);
|
|
7390
|
-
const handleKeyUp =
|
|
7727
|
+
const handleKeyUp = useCallback10(
|
|
7391
7728
|
(e2) => {
|
|
7392
7729
|
if (e2.key === "Enter" || e2.key === " ") {
|
|
7393
7730
|
e2.preventDefault();
|
|
@@ -7396,7 +7733,7 @@ function SwipeToConfirmTokens({
|
|
|
7396
7733
|
},
|
|
7397
7734
|
[cancelLongPress]
|
|
7398
7735
|
);
|
|
7399
|
-
|
|
7736
|
+
useEffect16(() => {
|
|
7400
7737
|
return () => {
|
|
7401
7738
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
7402
7739
|
if (longPressAnimationRef.current)
|
|
@@ -7407,15 +7744,15 @@ function SwipeToConfirmTokens({
|
|
|
7407
7744
|
e2.preventDefault();
|
|
7408
7745
|
handleDragStart();
|
|
7409
7746
|
};
|
|
7410
|
-
const handleMouseMove =
|
|
7747
|
+
const handleMouseMove = useCallback10(
|
|
7411
7748
|
(e2) => handleDragMove(e2.clientX),
|
|
7412
7749
|
[handleDragMove]
|
|
7413
7750
|
);
|
|
7414
|
-
const handleMouseUp =
|
|
7751
|
+
const handleMouseUp = useCallback10(() => handleDragEnd(), [handleDragEnd]);
|
|
7415
7752
|
const handleTouchStart = () => handleDragStart();
|
|
7416
7753
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
7417
7754
|
const handleTouchEnd = () => handleDragEnd();
|
|
7418
|
-
|
|
7755
|
+
useEffect16(() => {
|
|
7419
7756
|
if (isDragging) {
|
|
7420
7757
|
window.addEventListener("mousemove", handleMouseMove);
|
|
7421
7758
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -7427,8 +7764,8 @@ function SwipeToConfirmTokens({
|
|
|
7427
7764
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
7428
7765
|
const progress = getProgress();
|
|
7429
7766
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
7430
|
-
const [blinkOpacity, setBlinkOpacity] =
|
|
7431
|
-
|
|
7767
|
+
const [blinkOpacity, setBlinkOpacity] = useState17(1);
|
|
7768
|
+
useEffect16(() => {
|
|
7432
7769
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
7433
7770
|
setBlinkOpacity(1);
|
|
7434
7771
|
return;
|
|
@@ -7878,7 +8215,7 @@ function ThemeToggle({
|
|
|
7878
8215
|
}
|
|
7879
8216
|
|
|
7880
8217
|
// src/widget/components/Toast.tsx
|
|
7881
|
-
import { useEffect as
|
|
8218
|
+
import { useEffect as useEffect17, useState as useState18, useCallback as useCallback11 } from "react";
|
|
7882
8219
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
7883
8220
|
var variantStyles = {
|
|
7884
8221
|
default: {
|
|
@@ -7908,14 +8245,14 @@ function ToastItem({
|
|
|
7908
8245
|
duration = 4e3,
|
|
7909
8246
|
onDismiss
|
|
7910
8247
|
}) {
|
|
7911
|
-
const [isExiting, setIsExiting] =
|
|
7912
|
-
|
|
8248
|
+
const [isExiting, setIsExiting] = useState18(false);
|
|
8249
|
+
useEffect17(() => {
|
|
7913
8250
|
const timer = setTimeout(() => {
|
|
7914
8251
|
setIsExiting(true);
|
|
7915
8252
|
}, duration);
|
|
7916
8253
|
return () => clearTimeout(timer);
|
|
7917
8254
|
}, [duration]);
|
|
7918
|
-
|
|
8255
|
+
useEffect17(() => {
|
|
7919
8256
|
if (isExiting) {
|
|
7920
8257
|
const exitTimer = setTimeout(() => {
|
|
7921
8258
|
onDismiss(id);
|
|
@@ -8119,8 +8456,8 @@ function toast(data) {
|
|
|
8119
8456
|
toast.error = (title, description) => toast({ title, description, variant: "destructive" });
|
|
8120
8457
|
toast.success = (title, description) => toast({ title, description, variant: "success" });
|
|
8121
8458
|
function ToastContainer() {
|
|
8122
|
-
const [activeToasts, setActiveToasts] =
|
|
8123
|
-
|
|
8459
|
+
const [activeToasts, setActiveToasts] = useState18([]);
|
|
8460
|
+
useEffect17(() => {
|
|
8124
8461
|
const listener = (newToasts) => {
|
|
8125
8462
|
setActiveToasts(newToasts);
|
|
8126
8463
|
};
|
|
@@ -8132,7 +8469,7 @@ function ToastContainer() {
|
|
|
8132
8469
|
}
|
|
8133
8470
|
};
|
|
8134
8471
|
}, []);
|
|
8135
|
-
const handleDismiss =
|
|
8472
|
+
const handleDismiss = useCallback11((id) => {
|
|
8136
8473
|
toasts = toasts.filter((t) => t.id !== id);
|
|
8137
8474
|
notifyListeners();
|
|
8138
8475
|
}, []);
|
|
@@ -8170,10 +8507,10 @@ function ToastContainer() {
|
|
|
8170
8507
|
|
|
8171
8508
|
// src/widget/components/TokenSwipePill.tsx
|
|
8172
8509
|
import React9, {
|
|
8173
|
-
useState as
|
|
8510
|
+
useState as useState19,
|
|
8174
8511
|
useRef as useRef8,
|
|
8175
|
-
useCallback as
|
|
8176
|
-
useEffect as
|
|
8512
|
+
useCallback as useCallback12,
|
|
8513
|
+
useEffect as useEffect18,
|
|
8177
8514
|
useMemo as useMemo9
|
|
8178
8515
|
} from "react";
|
|
8179
8516
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
@@ -8187,8 +8524,8 @@ function TokenSwipePill({
|
|
|
8187
8524
|
walletAddress,
|
|
8188
8525
|
style
|
|
8189
8526
|
}) {
|
|
8190
|
-
const [isDragging, setIsDragging] =
|
|
8191
|
-
const [dragOffset, setDragOffset] =
|
|
8527
|
+
const [isDragging, setIsDragging] = useState19(false);
|
|
8528
|
+
const [dragOffset, setDragOffset] = useState19(0);
|
|
8192
8529
|
const startXRef = useRef8(0);
|
|
8193
8530
|
const containerRef = useRef8(null);
|
|
8194
8531
|
const currentIndex = tokens.findIndex(
|
|
@@ -8211,11 +8548,11 @@ function TokenSwipePill({
|
|
|
8211
8548
|
}
|
|
8212
8549
|
return pos;
|
|
8213
8550
|
};
|
|
8214
|
-
const handleDragStart =
|
|
8551
|
+
const handleDragStart = useCallback12((clientX) => {
|
|
8215
8552
|
setIsDragging(true);
|
|
8216
8553
|
startXRef.current = clientX;
|
|
8217
8554
|
}, []);
|
|
8218
|
-
const handleDragMove =
|
|
8555
|
+
const handleDragMove = useCallback12(
|
|
8219
8556
|
(clientX) => {
|
|
8220
8557
|
if (!isDragging) return;
|
|
8221
8558
|
const delta = startXRef.current - clientX;
|
|
@@ -8223,7 +8560,7 @@ function TokenSwipePill({
|
|
|
8223
8560
|
},
|
|
8224
8561
|
[isDragging]
|
|
8225
8562
|
);
|
|
8226
|
-
const handleDragEnd =
|
|
8563
|
+
const handleDragEnd = useCallback12(() => {
|
|
8227
8564
|
if (!isDragging) return;
|
|
8228
8565
|
setIsDragging(false);
|
|
8229
8566
|
if (Math.abs(dragOffset) > swipeThreshold) {
|
|
@@ -8241,13 +8578,13 @@ function TokenSwipePill({
|
|
|
8241
8578
|
e2.preventDefault();
|
|
8242
8579
|
handleDragStart(e2.clientX);
|
|
8243
8580
|
};
|
|
8244
|
-
const handleMouseMove =
|
|
8581
|
+
const handleMouseMove = useCallback12(
|
|
8245
8582
|
(e2) => {
|
|
8246
8583
|
handleDragMove(e2.clientX);
|
|
8247
8584
|
},
|
|
8248
8585
|
[handleDragMove]
|
|
8249
8586
|
);
|
|
8250
|
-
const handleMouseUp =
|
|
8587
|
+
const handleMouseUp = useCallback12(() => {
|
|
8251
8588
|
handleDragEnd();
|
|
8252
8589
|
}, [handleDragEnd]);
|
|
8253
8590
|
const handleTouchStart = (e2) => {
|
|
@@ -8261,7 +8598,7 @@ function TokenSwipePill({
|
|
|
8261
8598
|
const handleTouchEnd = () => {
|
|
8262
8599
|
handleDragEnd();
|
|
8263
8600
|
};
|
|
8264
|
-
|
|
8601
|
+
useEffect18(() => {
|
|
8265
8602
|
if (isDragging) {
|
|
8266
8603
|
window.addEventListener("mousemove", handleMouseMove);
|
|
8267
8604
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -8949,7 +9286,7 @@ function TransactionSteps({
|
|
|
8949
9286
|
}
|
|
8950
9287
|
|
|
8951
9288
|
// src/widget/components/WidgetContainer.tsx
|
|
8952
|
-
import { useEffect as
|
|
9289
|
+
import { useEffect as useEffect19, useState as useState20 } from "react";
|
|
8953
9290
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
8954
9291
|
var INJECTED_STYLES = ALL_THEME_STYLES + ALL_ANIMATION_STYLES;
|
|
8955
9292
|
function WidgetContainer({
|
|
@@ -8958,8 +9295,8 @@ function WidgetContainer({
|
|
|
8958
9295
|
className,
|
|
8959
9296
|
style
|
|
8960
9297
|
}) {
|
|
8961
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
8962
|
-
|
|
9298
|
+
const [resolvedTheme, setResolvedTheme] = useState20("light");
|
|
9299
|
+
useEffect19(() => {
|
|
8963
9300
|
if (theme === "system") {
|
|
8964
9301
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
8965
9302
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -9203,7 +9540,7 @@ function WidgetSecurityFooter({
|
|
|
9203
9540
|
}
|
|
9204
9541
|
|
|
9205
9542
|
// src/widget/components/ImageLoader.tsx
|
|
9206
|
-
import { useEffect as
|
|
9543
|
+
import { useEffect as useEffect20, useMemo as useMemo11, useRef as useRef9, useState as useState21 } from "react";
|
|
9207
9544
|
import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
9208
9545
|
function Skeleton({
|
|
9209
9546
|
background,
|
|
@@ -9233,12 +9570,12 @@ function ImageLoader({
|
|
|
9233
9570
|
onLoad,
|
|
9234
9571
|
onError
|
|
9235
9572
|
}) {
|
|
9236
|
-
const [status, setStatus] =
|
|
9237
|
-
const [attempt, setAttempt] =
|
|
9238
|
-
const [srcIsEmpty, setSrcIsEmpty] =
|
|
9573
|
+
const [status, setStatus] = useState21("idle");
|
|
9574
|
+
const [attempt, setAttempt] = useState21(0);
|
|
9575
|
+
const [srcIsEmpty, setSrcIsEmpty] = useState21(false);
|
|
9239
9576
|
const imgRef = useRef9(null);
|
|
9240
9577
|
const observerRef = useRef9(null);
|
|
9241
|
-
|
|
9578
|
+
useEffect20(() => {
|
|
9242
9579
|
if (status === "error" && attempt < retry) {
|
|
9243
9580
|
const timer = setTimeout(() => {
|
|
9244
9581
|
setAttempt((prev) => prev + 1);
|
|
@@ -9264,7 +9601,7 @@ function ImageLoader({
|
|
|
9264
9601
|
onError?.();
|
|
9265
9602
|
};
|
|
9266
9603
|
};
|
|
9267
|
-
|
|
9604
|
+
useEffect20(() => {
|
|
9268
9605
|
if (!lazy2) {
|
|
9269
9606
|
setTimeout(() => {
|
|
9270
9607
|
loadImage();
|
|
@@ -10775,7 +11112,7 @@ function TokenSelectorPanel({
|
|
|
10775
11112
|
}
|
|
10776
11113
|
|
|
10777
11114
|
// src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
|
|
10778
|
-
import { useCallback as
|
|
11115
|
+
import { useCallback as useCallback13, useMemo as useMemo12 } from "react";
|
|
10779
11116
|
function useOrderedWalletTokens({
|
|
10780
11117
|
amount,
|
|
10781
11118
|
amountInputMode,
|
|
@@ -10784,7 +11121,7 @@ function useOrderedWalletTokens({
|
|
|
10784
11121
|
setSelectedToken,
|
|
10785
11122
|
yourWalletTokens
|
|
10786
11123
|
}) {
|
|
10787
|
-
const handleTokenChange =
|
|
11124
|
+
const handleTokenChange = useCallback13(
|
|
10788
11125
|
async (token) => {
|
|
10789
11126
|
if (token) {
|
|
10790
11127
|
setSelectedToken(token);
|
|
@@ -10862,7 +11199,7 @@ function filterTokenAmountCompatibleTokens(tokens, parsedAmount) {
|
|
|
10862
11199
|
}
|
|
10863
11200
|
|
|
10864
11201
|
// src/widget/features/token-selection/hooks/useSelectTokenModel.ts
|
|
10865
|
-
import { useCallback as
|
|
11202
|
+
import { useCallback as useCallback14, useMemo as useMemo13 } from "react";
|
|
10866
11203
|
function useSelectTokenModel({
|
|
10867
11204
|
goBack,
|
|
10868
11205
|
searchQuery,
|
|
@@ -10886,7 +11223,7 @@ function useSelectTokenModel({
|
|
|
10886
11223
|
explorerUrl: chain.blockExplorerUrls?.[0]
|
|
10887
11224
|
});
|
|
10888
11225
|
};
|
|
10889
|
-
const handleTokenSelect =
|
|
11226
|
+
const handleTokenSelect = useCallback14(
|
|
10890
11227
|
async (token) => {
|
|
10891
11228
|
if (token.balance !== void 0) {
|
|
10892
11229
|
setSelectedToken(token);
|
|
@@ -10910,7 +11247,7 @@ function useSelectTokenModel({
|
|
|
10910
11247
|
},
|
|
10911
11248
|
[goBack, selectedChain, setSelectedToken, walletAddress]
|
|
10912
11249
|
);
|
|
10913
|
-
const handleYourTokenSelect =
|
|
11250
|
+
const handleYourTokenSelect = useCallback14(
|
|
10914
11251
|
(token) => {
|
|
10915
11252
|
setSelectedToken(token);
|
|
10916
11253
|
setSelectedChain(token.chainData);
|
|
@@ -11404,7 +11741,7 @@ function CryptoPayAmountSection({
|
|
|
11404
11741
|
}
|
|
11405
11742
|
|
|
11406
11743
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
11407
|
-
import { useEffect as
|
|
11744
|
+
import { useEffect as useEffect21, useMemo as useMemo14 } from "react";
|
|
11408
11745
|
var BALANCE_TOLERANCE = 1e-9;
|
|
11409
11746
|
function useDepositAmountModel({
|
|
11410
11747
|
amount,
|
|
@@ -11426,7 +11763,7 @@ function useDepositAmountModel({
|
|
|
11426
11763
|
);
|
|
11427
11764
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
11428
11765
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
11429
|
-
|
|
11766
|
+
useEffect21(() => {
|
|
11430
11767
|
if (fixedFromAmountString) return;
|
|
11431
11768
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
11432
11769
|
setAmountInputMode("token");
|
|
@@ -11438,7 +11775,7 @@ function useDepositAmountModel({
|
|
|
11438
11775
|
isReady,
|
|
11439
11776
|
setAmountInputMode
|
|
11440
11777
|
]);
|
|
11441
|
-
|
|
11778
|
+
useEffect21(() => {
|
|
11442
11779
|
if (!fixedFromAmountString) return;
|
|
11443
11780
|
if (amount !== fixedFromAmountString) {
|
|
11444
11781
|
setAmount(fixedFromAmountString);
|
|
@@ -11605,7 +11942,7 @@ function useDepositAmountModel({
|
|
|
11605
11942
|
}
|
|
11606
11943
|
|
|
11607
11944
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
11608
|
-
import { useEffect as
|
|
11945
|
+
import { useEffect as useEffect22, useMemo as useMemo15 } from "react";
|
|
11609
11946
|
function useHomeAmountModel({
|
|
11610
11947
|
amount,
|
|
11611
11948
|
setAmount,
|
|
@@ -11616,7 +11953,7 @@ function useHomeAmountModel({
|
|
|
11616
11953
|
minAmountUsd,
|
|
11617
11954
|
maxAmountUsd
|
|
11618
11955
|
}) {
|
|
11619
|
-
|
|
11956
|
+
useEffect22(() => {
|
|
11620
11957
|
if (!fixedFromAmountString) return;
|
|
11621
11958
|
if (amount !== fixedFromAmountString) {
|
|
11622
11959
|
setAmount(fixedFromAmountString);
|
|
@@ -11844,7 +12181,7 @@ function WalletConnectRow({
|
|
|
11844
12181
|
PaymentOptionRow,
|
|
11845
12182
|
{
|
|
11846
12183
|
onClick: () => void onClick(),
|
|
11847
|
-
label: "WalletConnect",
|
|
12184
|
+
label: "WalletConnect(EVM)",
|
|
11848
12185
|
icon: /* @__PURE__ */ jsx32("div", { style: walletActionIconBoxStyle, children: /* @__PURE__ */ jsx32(
|
|
11849
12186
|
"svg",
|
|
11850
12187
|
{
|
|
@@ -12357,152 +12694,20 @@ function HomePaymentOptions({
|
|
|
12357
12694
|
}
|
|
12358
12695
|
|
|
12359
12696
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
12360
|
-
import { useEffect as
|
|
12361
|
-
|
|
12362
|
-
// src/config/walletconnect.ts
|
|
12363
|
-
init_store();
|
|
12364
|
-
init_constants();
|
|
12365
|
-
import { UniversalConnector } from "@reown/appkit-universal-connector";
|
|
12366
|
-
var solanaMainnet = {
|
|
12367
|
-
id: 1,
|
|
12368
|
-
chainNamespace: "solana",
|
|
12369
|
-
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
|
|
12370
|
-
name: "Solana Mainnet",
|
|
12371
|
-
nativeCurrency: {
|
|
12372
|
-
name: "Solana",
|
|
12373
|
-
symbol: "SOL",
|
|
12374
|
-
decimals: 9
|
|
12375
|
-
},
|
|
12376
|
-
rpcUrls: {
|
|
12377
|
-
default: {
|
|
12378
|
-
http: ["https://api.mainnet-beta.solana.com"]
|
|
12379
|
-
}
|
|
12380
|
-
}
|
|
12381
|
-
};
|
|
12382
|
-
var bitcoinMainnet = {
|
|
12383
|
-
id: 0,
|
|
12384
|
-
chainNamespace: "bip122",
|
|
12385
|
-
caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
|
|
12386
|
-
name: "Bitcoin Mainnet",
|
|
12387
|
-
nativeCurrency: {
|
|
12388
|
-
name: "Bitcoin",
|
|
12389
|
-
symbol: "BTC",
|
|
12390
|
-
decimals: 8
|
|
12391
|
-
},
|
|
12392
|
-
rpcUrls: {
|
|
12393
|
-
default: {
|
|
12394
|
-
http: ["https://api.blockcypher.com/v1/btc/main"]
|
|
12395
|
-
}
|
|
12396
|
-
}
|
|
12397
|
-
};
|
|
12398
|
-
var ethereumMainnet = {
|
|
12399
|
-
id: 1,
|
|
12400
|
-
chainNamespace: "eip155",
|
|
12401
|
-
caipNetworkId: "eip155:1",
|
|
12402
|
-
name: "Ethereum Mainnet",
|
|
12403
|
-
nativeCurrency: {
|
|
12404
|
-
name: "Ether",
|
|
12405
|
-
symbol: "ETH",
|
|
12406
|
-
decimals: 18
|
|
12407
|
-
},
|
|
12408
|
-
rpcUrls: {
|
|
12409
|
-
default: {
|
|
12410
|
-
http: ["https://rpc.ankr.com/eth"]
|
|
12411
|
-
}
|
|
12412
|
-
}
|
|
12413
|
-
};
|
|
12414
|
-
var seiMainnet = {
|
|
12415
|
-
id: 1329,
|
|
12416
|
-
chainNamespace: "eip155",
|
|
12417
|
-
caipNetworkId: "eip155:1329",
|
|
12418
|
-
name: "Sei Mainnet",
|
|
12419
|
-
nativeCurrency: {
|
|
12420
|
-
name: "Sei",
|
|
12421
|
-
symbol: "SEI",
|
|
12422
|
-
decimals: 18
|
|
12423
|
-
},
|
|
12424
|
-
rpcUrls: {
|
|
12425
|
-
default: {
|
|
12426
|
-
http: ["https://evm-rpc.sei-apis.com"]
|
|
12427
|
-
}
|
|
12428
|
-
}
|
|
12429
|
-
};
|
|
12430
|
-
var universalConnectorPromise = null;
|
|
12431
|
-
function resolvedMetadata() {
|
|
12432
|
-
const cfg = TrustwareConfigStore.peek();
|
|
12433
|
-
const walletConnect = cfg ? cfg?.walletConnect : void 0;
|
|
12434
|
-
const configured = walletConnect?.metadata;
|
|
12435
|
-
const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
|
|
12436
|
-
return {
|
|
12437
|
-
name: configured?.name ?? "Trustware",
|
|
12438
|
-
description: configured?.description ?? "Cross-chain bridge & top-up",
|
|
12439
|
-
url: pageUrl ?? "https://trustware.io",
|
|
12440
|
-
icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
|
|
12441
|
-
};
|
|
12442
|
-
}
|
|
12443
|
-
async function getUniversalConnector(walletCfg) {
|
|
12444
|
-
const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
|
|
12445
|
-
if (!projectId) {
|
|
12446
|
-
console.warn(
|
|
12447
|
-
"[Trustware SDK] WalletConnect disabled: no projectId. Set TRUSTWARE_WALLETCONNECT_PROJECT_ID at build time or pass walletConnect.projectId in config."
|
|
12448
|
-
);
|
|
12449
|
-
return void 0;
|
|
12450
|
-
}
|
|
12451
|
-
if (!universalConnectorPromise) {
|
|
12452
|
-
universalConnectorPromise = UniversalConnector.init({
|
|
12453
|
-
projectId,
|
|
12454
|
-
metadata: resolvedMetadata(),
|
|
12455
|
-
networks: [
|
|
12456
|
-
{
|
|
12457
|
-
namespace: "solana",
|
|
12458
|
-
chains: [solanaMainnet],
|
|
12459
|
-
methods: ["solana_signMessage", "solana_signTransaction"],
|
|
12460
|
-
events: []
|
|
12461
|
-
},
|
|
12462
|
-
{
|
|
12463
|
-
namespace: "eip155",
|
|
12464
|
-
chains: [ethereumMainnet, seiMainnet],
|
|
12465
|
-
methods: ["eth_sendTransaction", "eth_sign", "personal_sign"],
|
|
12466
|
-
events: ["accountsChanged", "chainChanged"]
|
|
12467
|
-
},
|
|
12468
|
-
{
|
|
12469
|
-
namespace: "bip122",
|
|
12470
|
-
chains: [bitcoinMainnet],
|
|
12471
|
-
methods: ["btc_signMessage"],
|
|
12472
|
-
events: []
|
|
12473
|
-
}
|
|
12474
|
-
]
|
|
12475
|
-
}).catch((error) => {
|
|
12476
|
-
universalConnectorPromise = null;
|
|
12477
|
-
throw error;
|
|
12478
|
-
});
|
|
12479
|
-
}
|
|
12480
|
-
return universalConnectorPromise;
|
|
12481
|
-
}
|
|
12482
|
-
|
|
12483
|
-
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
12484
|
-
init_config2();
|
|
12697
|
+
import { useEffect as useEffect23, useRef as useRef10, useState as useState22 } from "react";
|
|
12485
12698
|
function useHomeWalletActions({
|
|
12486
12699
|
connectWallet,
|
|
12487
12700
|
detectedWallets,
|
|
12488
|
-
setCurrentStep
|
|
12701
|
+
setCurrentStep,
|
|
12702
|
+
setWalletType,
|
|
12703
|
+
WalletConnect
|
|
12489
12704
|
// setCurrentStepInternal,
|
|
12490
12705
|
}) {
|
|
12491
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] =
|
|
12492
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] =
|
|
12493
|
-
const [universalConnector, setUniversalConnector] = useState21();
|
|
12706
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = useState22(false);
|
|
12707
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = useState22(false);
|
|
12494
12708
|
const cryptoDropdownRef = useRef10(null);
|
|
12495
12709
|
const fiatDropdownRef = useRef10(null);
|
|
12496
|
-
|
|
12497
|
-
if (typeof window === "undefined") {
|
|
12498
|
-
return;
|
|
12499
|
-
}
|
|
12500
|
-
const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
|
|
12501
|
-
getUniversalConnector(walletConnect).then(
|
|
12502
|
-
setUniversalConnector
|
|
12503
|
-
);
|
|
12504
|
-
}, [TrustwareConfigStore.peek()?.walletConnect]);
|
|
12505
|
-
useEffect22(() => {
|
|
12710
|
+
useEffect23(() => {
|
|
12506
12711
|
const handleClickOutside = (event) => {
|
|
12507
12712
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
12508
12713
|
setIsCryptoDropdownOpen(false);
|
|
@@ -12518,6 +12723,7 @@ function useHomeWalletActions({
|
|
|
12518
12723
|
const handleWalletSelect = async (wallet) => {
|
|
12519
12724
|
setIsCryptoDropdownOpen(false);
|
|
12520
12725
|
try {
|
|
12726
|
+
setWalletType("other");
|
|
12521
12727
|
const { error } = await connectWallet(wallet);
|
|
12522
12728
|
if (error) {
|
|
12523
12729
|
resetNavigation();
|
|
@@ -12532,13 +12738,7 @@ function useHomeWalletActions({
|
|
|
12532
12738
|
setIsFiatDropdownOpen(false);
|
|
12533
12739
|
};
|
|
12534
12740
|
const handleWalletConnect = async () => {
|
|
12535
|
-
|
|
12536
|
-
return;
|
|
12537
|
-
}
|
|
12538
|
-
const { session: providerSession } = await universalConnector.connect();
|
|
12539
|
-
if (providerSession) {
|
|
12540
|
-
setCurrentStep("select-token");
|
|
12541
|
-
}
|
|
12741
|
+
WalletConnect().catch(() => resetNavigation());
|
|
12542
12742
|
};
|
|
12543
12743
|
const browserWallets = detectedWallets.filter(
|
|
12544
12744
|
(wallet) => wallet.meta.id !== "walletconnect"
|
|
@@ -12562,7 +12762,7 @@ import { jsx as jsx42, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
|
12562
12762
|
function Home({ style: _style }) {
|
|
12563
12763
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
12564
12764
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
12565
|
-
const { connectWallet } = useDepositWallet();
|
|
12765
|
+
const { connectWallet, WalletConnect, setWalletType } = useDepositWallet();
|
|
12566
12766
|
const { resolvedTheme } = useDepositUi();
|
|
12567
12767
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
12568
12768
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -12591,7 +12791,9 @@ function Home({ style: _style }) {
|
|
|
12591
12791
|
connectWallet,
|
|
12592
12792
|
detectedWallets,
|
|
12593
12793
|
setCurrentStep,
|
|
12594
|
-
setCurrentStepInternal
|
|
12794
|
+
setCurrentStepInternal,
|
|
12795
|
+
WalletConnect,
|
|
12796
|
+
setWalletType
|
|
12595
12797
|
});
|
|
12596
12798
|
return /* @__PURE__ */ jsxs33(
|
|
12597
12799
|
"div",
|
|
@@ -12872,7 +13074,7 @@ function SelectToken({ style }) {
|
|
|
12872
13074
|
}
|
|
12873
13075
|
|
|
12874
13076
|
// src/widget/pages/CryptoPay/index.tsx
|
|
12875
|
-
import { useEffect as
|
|
13077
|
+
import { useEffect as useEffect25, useMemo as useMemo18 } from "react";
|
|
12876
13078
|
|
|
12877
13079
|
// src/widget/features/route-preview/hooks/useRoutePreviewModel.ts
|
|
12878
13080
|
import { useMemo as useMemo16 } from "react";
|
|
@@ -12888,6 +13090,7 @@ function useRoutePreviewModel({
|
|
|
12888
13090
|
walletAddress
|
|
12889
13091
|
}) {
|
|
12890
13092
|
const { chains } = useChains();
|
|
13093
|
+
console.log({ walletAddress });
|
|
12891
13094
|
const destinationConfig = useMemo16(
|
|
12892
13095
|
() => ({
|
|
12893
13096
|
dappName: config.messages?.title || "DApp",
|
|
@@ -13375,7 +13578,7 @@ function SuccessSummaryCard({
|
|
|
13375
13578
|
}
|
|
13376
13579
|
|
|
13377
13580
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
13378
|
-
import { useCallback as
|
|
13581
|
+
import { useCallback as useCallback15, useEffect as useEffect24, useMemo as useMemo17, useRef as useRef11, useState as useState23 } from "react";
|
|
13379
13582
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
13380
13583
|
init_constants();
|
|
13381
13584
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
@@ -13433,11 +13636,11 @@ function useTransactionActionModel({
|
|
|
13433
13636
|
const addr = txReq?.to ?? txReq?.target;
|
|
13434
13637
|
return addr ?? null;
|
|
13435
13638
|
}, [routeResult?.txReq]);
|
|
13436
|
-
const [allowanceWei, setAllowanceWei] =
|
|
13437
|
-
const [isReadingAllowance, setIsReadingAllowance] =
|
|
13438
|
-
const [isApproving, setIsApproving] =
|
|
13439
|
-
const [gasReservationWei, setGasReservationWei] =
|
|
13440
|
-
const readAllowance =
|
|
13639
|
+
const [allowanceWei, setAllowanceWei] = useState23(0n);
|
|
13640
|
+
const [isReadingAllowance, setIsReadingAllowance] = useState23(false);
|
|
13641
|
+
const [isApproving, setIsApproving] = useState23(false);
|
|
13642
|
+
const [gasReservationWei, setGasReservationWei] = useState23(0n);
|
|
13643
|
+
const readAllowance = useCallback15(async () => {
|
|
13441
13644
|
if (!isEvm || isNativeSelected || !backendChainId2 || !walletAddress || !spender || !selectedToken?.address) {
|
|
13442
13645
|
setAllowanceWei(0n);
|
|
13443
13646
|
return;
|
|
@@ -13464,11 +13667,11 @@ function useTransactionActionModel({
|
|
|
13464
13667
|
spender,
|
|
13465
13668
|
walletAddress
|
|
13466
13669
|
]);
|
|
13467
|
-
|
|
13670
|
+
useEffect24(() => {
|
|
13468
13671
|
void readAllowance();
|
|
13469
13672
|
}, [readAllowance]);
|
|
13470
13673
|
const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
13471
|
-
const waitForApprovalConfirmation =
|
|
13674
|
+
const waitForApprovalConfirmation = useCallback15(
|
|
13472
13675
|
async (chainId, txHash) => {
|
|
13473
13676
|
const timeoutMs = 12e4;
|
|
13474
13677
|
const intervalMs = 2e3;
|
|
@@ -13487,7 +13690,7 @@ function useTransactionActionModel({
|
|
|
13487
13690
|
},
|
|
13488
13691
|
[]
|
|
13489
13692
|
);
|
|
13490
|
-
const handleApproveExact =
|
|
13693
|
+
const handleApproveExact = useCallback15(async () => {
|
|
13491
13694
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
13492
13695
|
return;
|
|
13493
13696
|
}
|
|
@@ -13575,7 +13778,7 @@ function useTransactionActionModel({
|
|
|
13575
13778
|
waitForApprovalConfirmation,
|
|
13576
13779
|
walletAddress
|
|
13577
13780
|
]);
|
|
13578
|
-
const getCachedFeeData =
|
|
13781
|
+
const getCachedFeeData = useCallback15(async () => {
|
|
13579
13782
|
if (!backendChainId2) return {};
|
|
13580
13783
|
const now = Date.now();
|
|
13581
13784
|
const cache = feeDataCacheRef.current;
|
|
@@ -13598,7 +13801,7 @@ function useTransactionActionModel({
|
|
|
13598
13801
|
}
|
|
13599
13802
|
return cache.inflight;
|
|
13600
13803
|
}, [backendChainId2]);
|
|
13601
|
-
const estimateGasReservationWei =
|
|
13804
|
+
const estimateGasReservationWei = useCallback15(async () => {
|
|
13602
13805
|
if (!isNativeSelected) {
|
|
13603
13806
|
setGasReservationWei(0n);
|
|
13604
13807
|
return 0n;
|
|
@@ -13662,12 +13865,12 @@ function useTransactionActionModel({
|
|
|
13662
13865
|
routeResult?.txReq,
|
|
13663
13866
|
walletAddress
|
|
13664
13867
|
]);
|
|
13665
|
-
|
|
13868
|
+
useEffect24(() => {
|
|
13666
13869
|
if (routeResult) {
|
|
13667
13870
|
void estimateGasReservationWei();
|
|
13668
13871
|
}
|
|
13669
13872
|
}, [estimateGasReservationWei, routeResult]);
|
|
13670
|
-
const handleConfirm =
|
|
13873
|
+
const handleConfirm = useCallback15(async () => {
|
|
13671
13874
|
if (!routeResult) {
|
|
13672
13875
|
return;
|
|
13673
13876
|
}
|
|
@@ -13690,7 +13893,7 @@ function useTransactionActionModel({
|
|
|
13690
13893
|
submitTransaction,
|
|
13691
13894
|
trackEvent
|
|
13692
13895
|
]);
|
|
13693
|
-
const handleSwipeConfirm =
|
|
13896
|
+
const handleSwipeConfirm = useCallback15(async () => {
|
|
13694
13897
|
if (needsApproval) {
|
|
13695
13898
|
await handleApproveExact();
|
|
13696
13899
|
return;
|
|
@@ -13913,6 +14116,7 @@ function CryptoPay({ style: _style }) {
|
|
|
13913
14116
|
} = useDepositForm();
|
|
13914
14117
|
const {
|
|
13915
14118
|
walletAddress,
|
|
14119
|
+
walletType,
|
|
13916
14120
|
walletStatus,
|
|
13917
14121
|
yourWalletTokens,
|
|
13918
14122
|
yourWalletTokensLoading
|
|
@@ -13992,6 +14196,7 @@ function CryptoPay({ style: _style }) {
|
|
|
13992
14196
|
selectedChain,
|
|
13993
14197
|
selectedToken,
|
|
13994
14198
|
walletAddress,
|
|
14199
|
+
walletType,
|
|
13995
14200
|
walletStatus
|
|
13996
14201
|
});
|
|
13997
14202
|
const { handleTokenChange, orderedTokens } = useOrderedWalletTokens({
|
|
@@ -14004,7 +14209,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14004
14209
|
});
|
|
14005
14210
|
const { emitError } = useTrustware();
|
|
14006
14211
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
14007
|
-
|
|
14212
|
+
useEffect25(() => {
|
|
14008
14213
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
14009
14214
|
emitError?.(
|
|
14010
14215
|
new TrustwareError({
|
|
@@ -14099,7 +14304,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14099
14304
|
isApproving,
|
|
14100
14305
|
isLoadingRoute,
|
|
14101
14306
|
isReadingAllowance,
|
|
14102
|
-
isWalletConnected,
|
|
14307
|
+
isWalletConnected: isWalletConnected ? isWalletConnected : walletAddress !== null && walletType == "walletconnect" ? true : false,
|
|
14103
14308
|
needsApproval,
|
|
14104
14309
|
selectedToken: readySelectedToken,
|
|
14105
14310
|
swipeResetKey
|
|
@@ -14115,7 +14320,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14115
14320
|
}
|
|
14116
14321
|
|
|
14117
14322
|
// src/widget/pages/Processing.tsx
|
|
14118
|
-
import { useEffect as
|
|
14323
|
+
import { useEffect as useEffect26, useMemo as useMemo19, useRef as useRef12 } from "react";
|
|
14119
14324
|
import { jsx as jsx49, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
14120
14325
|
function getProgressFromStatus(status) {
|
|
14121
14326
|
switch (status) {
|
|
@@ -14155,12 +14360,12 @@ function Processing({ style }) {
|
|
|
14155
14360
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
14156
14361
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
14157
14362
|
const hasStartedPolling = useRef12(false);
|
|
14158
|
-
|
|
14363
|
+
useEffect26(() => {
|
|
14159
14364
|
return () => {
|
|
14160
14365
|
hasStartedPolling.current = false;
|
|
14161
14366
|
};
|
|
14162
14367
|
}, []);
|
|
14163
|
-
|
|
14368
|
+
useEffect26(() => {
|
|
14164
14369
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
14165
14370
|
hasStartedPolling.current = true;
|
|
14166
14371
|
startPolling(intentId, transactionHash);
|
|
@@ -14383,7 +14588,7 @@ function Success({ style }) {
|
|
|
14383
14588
|
}
|
|
14384
14589
|
|
|
14385
14590
|
// src/widget/pages/Error.tsx
|
|
14386
|
-
import { useMemo as useMemo21, useEffect as
|
|
14591
|
+
import { useMemo as useMemo21, useEffect as useEffect27 } from "react";
|
|
14387
14592
|
init_store();
|
|
14388
14593
|
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
14389
14594
|
function categorizeError(errorMessage) {
|
|
@@ -14485,7 +14690,7 @@ function Error2({ style }) {
|
|
|
14485
14690
|
[errorCategory]
|
|
14486
14691
|
);
|
|
14487
14692
|
const retryStep = useMemo21(() => getRetryStep(errorCategory), [errorCategory]);
|
|
14488
|
-
|
|
14693
|
+
useEffect27(() => {
|
|
14489
14694
|
if (errorMessage) {
|
|
14490
14695
|
try {
|
|
14491
14696
|
const config = TrustwareConfigStore.get();
|
|
@@ -14686,7 +14891,7 @@ function WidgetContent({
|
|
|
14686
14891
|
const { amount, selectedChain, selectedToken } = useDepositForm();
|
|
14687
14892
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
14688
14893
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
14689
|
-
|
|
14894
|
+
useEffect28(() => {
|
|
14690
14895
|
const state = {
|
|
14691
14896
|
currentStep,
|
|
14692
14897
|
amount,
|
|
@@ -14729,8 +14934,8 @@ function WidgetInner({
|
|
|
14729
14934
|
const { transactionStatus } = useDepositTransaction();
|
|
14730
14935
|
const { resolvedTheme } = useDepositUi();
|
|
14731
14936
|
const { status, revalidate } = useTrustware();
|
|
14732
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
14733
|
-
const handleCloseRequest =
|
|
14937
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState24(false);
|
|
14938
|
+
const handleCloseRequest = useCallback16(() => {
|
|
14734
14939
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
14735
14940
|
setShowConfirmDialog(true);
|
|
14736
14941
|
} else {
|
|
@@ -14741,20 +14946,20 @@ function WidgetInner({
|
|
|
14741
14946
|
onClose?.();
|
|
14742
14947
|
}
|
|
14743
14948
|
}, [transactionStatus, onClose, resetState]);
|
|
14744
|
-
|
|
14949
|
+
useEffect28(() => {
|
|
14745
14950
|
closeRequestRef.current = handleCloseRequest;
|
|
14746
14951
|
}, [handleCloseRequest, closeRequestRef]);
|
|
14747
|
-
const handleConfirmClose =
|
|
14952
|
+
const handleConfirmClose = useCallback16(() => {
|
|
14748
14953
|
setShowConfirmDialog(false);
|
|
14749
14954
|
onClose?.();
|
|
14750
14955
|
}, [onClose]);
|
|
14751
|
-
const handleCancelClose =
|
|
14956
|
+
const handleCancelClose = useCallback16(() => {
|
|
14752
14957
|
setShowConfirmDialog(false);
|
|
14753
14958
|
}, []);
|
|
14754
14959
|
const effectiveTheme = resolvedTheme;
|
|
14755
14960
|
const isRefreshing = status === "initializing";
|
|
14756
14961
|
const initBlocked = status === "error";
|
|
14757
|
-
const handleRefresh =
|
|
14962
|
+
const handleRefresh = useCallback16(() => {
|
|
14758
14963
|
revalidate?.();
|
|
14759
14964
|
}, [revalidate]);
|
|
14760
14965
|
return /* @__PURE__ */ jsxs42(Fragment7, { children: [
|
|
@@ -14796,14 +15001,14 @@ var TrustwareWidgetV2 = forwardRef(function TrustwareWidgetV22({
|
|
|
14796
15001
|
onOpen,
|
|
14797
15002
|
showThemeToggle = true
|
|
14798
15003
|
}, ref) {
|
|
14799
|
-
const [isOpen, setIsOpen] =
|
|
15004
|
+
const [isOpen, setIsOpen] = useState24(defaultOpen);
|
|
14800
15005
|
const closeRequestRef = useRef13(null);
|
|
14801
15006
|
const effectiveInitialStep = initialStep;
|
|
14802
|
-
const open =
|
|
15007
|
+
const open = useCallback16(() => {
|
|
14803
15008
|
setIsOpen(true);
|
|
14804
15009
|
onOpen?.();
|
|
14805
15010
|
}, [onOpen]);
|
|
14806
|
-
const close =
|
|
15011
|
+
const close = useCallback16(() => {
|
|
14807
15012
|
if (closeRequestRef.current) {
|
|
14808
15013
|
closeRequestRef.current();
|
|
14809
15014
|
} else {
|
|
@@ -14811,7 +15016,7 @@ var TrustwareWidgetV2 = forwardRef(function TrustwareWidgetV22({
|
|
|
14811
15016
|
onClose?.();
|
|
14812
15017
|
}
|
|
14813
15018
|
}, [onClose]);
|
|
14814
|
-
const handleClose =
|
|
15019
|
+
const handleClose = useCallback16(() => {
|
|
14815
15020
|
setIsOpen(false);
|
|
14816
15021
|
onClose?.();
|
|
14817
15022
|
}, [onClose]);
|