@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.cjs
CHANGED
|
@@ -247,7 +247,7 @@ var init_constants = __esm({
|
|
|
247
247
|
"src/constants.ts"() {
|
|
248
248
|
"use strict";
|
|
249
249
|
SDK_NAME = "@trustware/sdk";
|
|
250
|
-
SDK_VERSION = "1.1.
|
|
250
|
+
SDK_VERSION = "1.1.5-staging.1";
|
|
251
251
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
252
252
|
GTM_ID = "GTM-TZDGNCXB";
|
|
253
253
|
API_PREFIX = "/api";
|
|
@@ -812,8 +812,8 @@ function ConfettiEffect({
|
|
|
812
812
|
clearDelay = 3e3,
|
|
813
813
|
pieceCount = 50
|
|
814
814
|
}) {
|
|
815
|
-
const [pieces, setPieces] = (0,
|
|
816
|
-
(0,
|
|
815
|
+
const [pieces, setPieces] = (0, import_react21.useState)([]);
|
|
816
|
+
(0, import_react21.useEffect)(() => {
|
|
817
817
|
if (isActive) {
|
|
818
818
|
const colors2 = [
|
|
819
819
|
"#10b981",
|
|
@@ -889,11 +889,11 @@ function ConfettiEffect({
|
|
|
889
889
|
}
|
|
890
890
|
);
|
|
891
891
|
}
|
|
892
|
-
var
|
|
892
|
+
var import_react21, import_jsx_runtime6, ConfettiEffect_default;
|
|
893
893
|
var init_ConfettiEffect = __esm({
|
|
894
894
|
"src/widget/components/ConfettiEffect.tsx"() {
|
|
895
895
|
"use strict";
|
|
896
|
-
|
|
896
|
+
import_react21 = require("react");
|
|
897
897
|
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
898
898
|
ConfettiEffect_default = ConfettiEffect;
|
|
899
899
|
}
|
|
@@ -4333,7 +4333,7 @@ var Trustware = {
|
|
|
4333
4333
|
init_http();
|
|
4334
4334
|
|
|
4335
4335
|
// src/widget/TrustwareWidgetV2.tsx
|
|
4336
|
-
var
|
|
4336
|
+
var import_react41 = require("react");
|
|
4337
4337
|
|
|
4338
4338
|
// src/widget/lib/utils.ts
|
|
4339
4339
|
function mergeStyles(...styles) {
|
|
@@ -4813,7 +4813,7 @@ var ANIMATION_CLASSES = `
|
|
|
4813
4813
|
var ALL_ANIMATION_STYLES = KEYFRAMES + ANIMATION_CLASSES;
|
|
4814
4814
|
|
|
4815
4815
|
// src/widget/context/DepositContext.tsx
|
|
4816
|
-
var
|
|
4816
|
+
var import_react18 = __toESM(require("react"), 1);
|
|
4817
4817
|
|
|
4818
4818
|
// src/provider.tsx
|
|
4819
4819
|
var import_react5 = require("react");
|
|
@@ -6195,16 +6195,326 @@ function mapWalletTokens(balances, chains, tokens) {
|
|
|
6195
6195
|
});
|
|
6196
6196
|
}
|
|
6197
6197
|
|
|
6198
|
+
// src/widget/state/deposit/useWalletConnect.ts
|
|
6199
|
+
var import_react17 = require("react");
|
|
6200
|
+
init_config2();
|
|
6201
|
+
|
|
6202
|
+
// src/config/walletconnect.ts
|
|
6203
|
+
var import_appkit_universal_connector = require("@reown/appkit-universal-connector");
|
|
6204
|
+
init_store();
|
|
6205
|
+
init_constants();
|
|
6206
|
+
var solanaMainnet = {
|
|
6207
|
+
id: 900,
|
|
6208
|
+
chainNamespace: "solana",
|
|
6209
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
|
|
6210
|
+
name: "Solana Mainnet",
|
|
6211
|
+
nativeCurrency: {
|
|
6212
|
+
name: "Solana",
|
|
6213
|
+
symbol: "SOL",
|
|
6214
|
+
decimals: 9
|
|
6215
|
+
},
|
|
6216
|
+
rpcUrls: {
|
|
6217
|
+
default: {
|
|
6218
|
+
http: ["https://api.mainnet-beta.solana.com"]
|
|
6219
|
+
}
|
|
6220
|
+
}
|
|
6221
|
+
};
|
|
6222
|
+
var bitcoinMainnet = {
|
|
6223
|
+
id: 8333,
|
|
6224
|
+
chainNamespace: "bip122",
|
|
6225
|
+
caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
|
|
6226
|
+
name: "Bitcoin Mainnet",
|
|
6227
|
+
nativeCurrency: {
|
|
6228
|
+
name: "Bitcoin",
|
|
6229
|
+
symbol: "BTC",
|
|
6230
|
+
decimals: 8
|
|
6231
|
+
},
|
|
6232
|
+
rpcUrls: {
|
|
6233
|
+
default: {
|
|
6234
|
+
http: ["https://api.blockcypher.com/v1/btc/main"]
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
};
|
|
6238
|
+
var ethereumMainnet = {
|
|
6239
|
+
id: 1,
|
|
6240
|
+
chainNamespace: "eip155",
|
|
6241
|
+
caipNetworkId: "eip155:1",
|
|
6242
|
+
name: "Ethereum Mainnet",
|
|
6243
|
+
nativeCurrency: {
|
|
6244
|
+
name: "Ether",
|
|
6245
|
+
symbol: "ETH",
|
|
6246
|
+
decimals: 18
|
|
6247
|
+
},
|
|
6248
|
+
rpcUrls: {
|
|
6249
|
+
default: {
|
|
6250
|
+
http: ["https://rpc.ankr.com/eth"]
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
};
|
|
6254
|
+
var seiMainnet = {
|
|
6255
|
+
id: 1329,
|
|
6256
|
+
chainNamespace: "eip155",
|
|
6257
|
+
caipNetworkId: "eip155:1329",
|
|
6258
|
+
name: "Sei Mainnet",
|
|
6259
|
+
nativeCurrency: {
|
|
6260
|
+
name: "Sei",
|
|
6261
|
+
symbol: "SEI",
|
|
6262
|
+
decimals: 18
|
|
6263
|
+
},
|
|
6264
|
+
rpcUrls: {
|
|
6265
|
+
default: {
|
|
6266
|
+
http: ["https://evm-rpc.sei-apis.com"]
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
};
|
|
6270
|
+
var solanaChains = [solanaMainnet];
|
|
6271
|
+
var evmChains = [ethereumMainnet, seiMainnet];
|
|
6272
|
+
var bitcoinChains = [bitcoinMainnet];
|
|
6273
|
+
var networks = [
|
|
6274
|
+
// ...solanaChains,
|
|
6275
|
+
// ...bitcoinChains,
|
|
6276
|
+
...evmChains
|
|
6277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6278
|
+
];
|
|
6279
|
+
var namespaceConfig = [
|
|
6280
|
+
{
|
|
6281
|
+
namespace: "solana",
|
|
6282
|
+
chains: solanaChains,
|
|
6283
|
+
methods: ["solana_signMessage", "solana_signTransaction"],
|
|
6284
|
+
events: []
|
|
6285
|
+
},
|
|
6286
|
+
{
|
|
6287
|
+
namespace: "eip155",
|
|
6288
|
+
chains: evmChains,
|
|
6289
|
+
methods: [
|
|
6290
|
+
"eth_sendTransaction",
|
|
6291
|
+
"eth_signTransaction",
|
|
6292
|
+
"eth_sign",
|
|
6293
|
+
"personal_sign",
|
|
6294
|
+
"eth_signTypedData_v4"
|
|
6295
|
+
],
|
|
6296
|
+
events: ["accountsChanged", "chainChanged"]
|
|
6297
|
+
},
|
|
6298
|
+
{
|
|
6299
|
+
namespace: "bip122",
|
|
6300
|
+
chains: bitcoinChains,
|
|
6301
|
+
// FIX 8: Use the standard WalletConnect BIP-122 method name, not the
|
|
6302
|
+
// non-standard "btc_signMessage" prefix that most wallets reject.
|
|
6303
|
+
methods: ["signMessage", "sendTransfer"],
|
|
6304
|
+
events: []
|
|
6305
|
+
}
|
|
6306
|
+
];
|
|
6307
|
+
function resolvedMetadata() {
|
|
6308
|
+
const cfg = TrustwareConfigStore.peek();
|
|
6309
|
+
const walletConnect = cfg ? cfg?.walletConnect : void 0;
|
|
6310
|
+
const configured = walletConnect?.metadata;
|
|
6311
|
+
const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
|
|
6312
|
+
if (!pageUrl) {
|
|
6313
|
+
console.warn(
|
|
6314
|
+
"[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."
|
|
6315
|
+
);
|
|
6316
|
+
}
|
|
6317
|
+
return {
|
|
6318
|
+
name: configured?.name ?? "Trustware",
|
|
6319
|
+
description: configured?.description ?? "Cross-chain bridge & top-up",
|
|
6320
|
+
url: pageUrl ?? "https://trustware.io",
|
|
6321
|
+
icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
|
|
6322
|
+
};
|
|
6323
|
+
}
|
|
6324
|
+
var universalConnectorPromise = null;
|
|
6325
|
+
var initializedProjectId = null;
|
|
6326
|
+
async function getUniversalConnector(walletCfg) {
|
|
6327
|
+
const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
|
|
6328
|
+
if (universalConnectorPromise && initializedProjectId !== projectId) {
|
|
6329
|
+
console.warn(
|
|
6330
|
+
"[Trustware SDK] projectId changed since last init \u2014 reinitializing WalletConnect connector."
|
|
6331
|
+
);
|
|
6332
|
+
universalConnectorPromise = null;
|
|
6333
|
+
initializedProjectId = null;
|
|
6334
|
+
}
|
|
6335
|
+
if (!universalConnectorPromise) {
|
|
6336
|
+
initializedProjectId = projectId;
|
|
6337
|
+
universalConnectorPromise = import_appkit_universal_connector.UniversalConnector.init({
|
|
6338
|
+
projectId,
|
|
6339
|
+
metadata: resolvedMetadata(),
|
|
6340
|
+
networks: namespaceConfig
|
|
6341
|
+
}).catch((error) => {
|
|
6342
|
+
universalConnectorPromise = null;
|
|
6343
|
+
initializedProjectId = null;
|
|
6344
|
+
console.error(
|
|
6345
|
+
"[Trustware SDK] Failed to initialize WalletConnect:",
|
|
6346
|
+
error
|
|
6347
|
+
);
|
|
6348
|
+
throw error;
|
|
6349
|
+
});
|
|
6350
|
+
}
|
|
6351
|
+
return universalConnectorPromise;
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6354
|
+
// src/widget/state/deposit/useWalletConnect.ts
|
|
6355
|
+
function getEvmAccount(session) {
|
|
6356
|
+
const account = session?.namespaces?.eip155?.accounts?.[0];
|
|
6357
|
+
const [, chainId, address] = account?.split(":") ?? [];
|
|
6358
|
+
if (!chainId || !address) {
|
|
6359
|
+
return null;
|
|
6360
|
+
}
|
|
6361
|
+
return {
|
|
6362
|
+
address,
|
|
6363
|
+
chainId: Number(chainId)
|
|
6364
|
+
};
|
|
6365
|
+
}
|
|
6366
|
+
function toHexChainId(chainId) {
|
|
6367
|
+
return `0x${chainId.toString(16)}`;
|
|
6368
|
+
}
|
|
6369
|
+
function useWalletConnect({
|
|
6370
|
+
setWalletType,
|
|
6371
|
+
setCurrentStep
|
|
6372
|
+
}) {
|
|
6373
|
+
const [universalConnector, setUniversalConnector] = (0, import_react17.useState)();
|
|
6374
|
+
const [walletConnectAddress, setWalletConnectAddress] = (0, import_react17.useState)(null);
|
|
6375
|
+
(0, import_react17.useEffect)(() => {
|
|
6376
|
+
if (typeof window === "undefined") {
|
|
6377
|
+
return;
|
|
6378
|
+
}
|
|
6379
|
+
const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
|
|
6380
|
+
getUniversalConnector(walletConnect).then(
|
|
6381
|
+
setUniversalConnector
|
|
6382
|
+
);
|
|
6383
|
+
}, [TrustwareConfigStore.peek()?.walletConnect]);
|
|
6384
|
+
(0, import_react17.useEffect)(() => {
|
|
6385
|
+
return () => {
|
|
6386
|
+
universalConnector?.disconnect();
|
|
6387
|
+
};
|
|
6388
|
+
}, [universalConnector]);
|
|
6389
|
+
const attachWalletConnectWallet = (0, import_react17.useCallback)(
|
|
6390
|
+
(connector, session) => {
|
|
6391
|
+
const account = getEvmAccount(session);
|
|
6392
|
+
if (!account) {
|
|
6393
|
+
return null;
|
|
6394
|
+
}
|
|
6395
|
+
const activeAddress = account.address;
|
|
6396
|
+
let activeChainId = account.chainId;
|
|
6397
|
+
connector.provider.setDefaultChain(`eip155:${activeChainId}`);
|
|
6398
|
+
const wallet = {
|
|
6399
|
+
ecosystem: "evm",
|
|
6400
|
+
type: "eip1193",
|
|
6401
|
+
async getAddress() {
|
|
6402
|
+
return activeAddress;
|
|
6403
|
+
},
|
|
6404
|
+
async getChainId() {
|
|
6405
|
+
return activeChainId;
|
|
6406
|
+
},
|
|
6407
|
+
async switchChain(chainId) {
|
|
6408
|
+
connector.provider.setDefaultChain(`eip155:${chainId}`);
|
|
6409
|
+
await connector.provider.request(
|
|
6410
|
+
{
|
|
6411
|
+
method: "wallet_switchEthereumChain",
|
|
6412
|
+
params: [{ chainId: toHexChainId(chainId) }]
|
|
6413
|
+
},
|
|
6414
|
+
`eip155:${chainId}`
|
|
6415
|
+
);
|
|
6416
|
+
activeChainId = chainId;
|
|
6417
|
+
},
|
|
6418
|
+
async request(args) {
|
|
6419
|
+
const tx = Array.isArray(args.params) ? args.params[0] : void 0;
|
|
6420
|
+
const requestedChainId = typeof tx?.chainId === "string" ? Number.parseInt(tx.chainId, 16) : activeChainId;
|
|
6421
|
+
const chain = Number.isFinite(requestedChainId) ? `eip155:${requestedChainId}` : `eip155:${activeChainId}`;
|
|
6422
|
+
connector.provider.setDefaultChain(chain);
|
|
6423
|
+
return connector.provider.request(args, chain);
|
|
6424
|
+
},
|
|
6425
|
+
async disconnect() {
|
|
6426
|
+
await connector.disconnect();
|
|
6427
|
+
}
|
|
6428
|
+
};
|
|
6429
|
+
walletManager.attachWallet(wallet);
|
|
6430
|
+
setWalletConnectAddress(activeAddress);
|
|
6431
|
+
return activeAddress;
|
|
6432
|
+
},
|
|
6433
|
+
[]
|
|
6434
|
+
);
|
|
6435
|
+
const getAddrAndRedirect = (0, import_react17.useCallback)(
|
|
6436
|
+
(connector, session) => {
|
|
6437
|
+
const adr = attachWalletConnectWallet(connector, session);
|
|
6438
|
+
if (!adr) return null;
|
|
6439
|
+
setCurrentStep("crypto-pay");
|
|
6440
|
+
console.log({ adr });
|
|
6441
|
+
return adr;
|
|
6442
|
+
},
|
|
6443
|
+
[attachWalletConnectWallet, setCurrentStep]
|
|
6444
|
+
);
|
|
6445
|
+
const WalletConnect = (0, import_react17.useCallback)(
|
|
6446
|
+
async function() {
|
|
6447
|
+
console.log("got called");
|
|
6448
|
+
if (!universalConnector) {
|
|
6449
|
+
return;
|
|
6450
|
+
}
|
|
6451
|
+
setWalletType("walletconnect");
|
|
6452
|
+
const session = universalConnector.provider.session;
|
|
6453
|
+
const nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
6454
|
+
const isActive = session && session.expiry > nowInSeconds;
|
|
6455
|
+
console.log({ isActive, session });
|
|
6456
|
+
if (isActive && session) {
|
|
6457
|
+
getAddrAndRedirect(universalConnector, session);
|
|
6458
|
+
return;
|
|
6459
|
+
}
|
|
6460
|
+
const { session: providerSession } = await universalConnector.connect();
|
|
6461
|
+
if (providerSession) {
|
|
6462
|
+
getAddrAndRedirect(universalConnector, providerSession);
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
6465
|
+
},
|
|
6466
|
+
[getAddrAndRedirect, setWalletType, universalConnector]
|
|
6467
|
+
);
|
|
6468
|
+
const disconnectWalletConnect = async () => {
|
|
6469
|
+
if (universalConnector) {
|
|
6470
|
+
await walletManager.disconnect();
|
|
6471
|
+
setWalletType("other");
|
|
6472
|
+
setCurrentStep("home");
|
|
6473
|
+
}
|
|
6474
|
+
};
|
|
6475
|
+
(0, import_react17.useEffect)(() => {
|
|
6476
|
+
const provider = universalConnector?.provider;
|
|
6477
|
+
if (!provider) {
|
|
6478
|
+
return;
|
|
6479
|
+
}
|
|
6480
|
+
const handleSessionUpdate = ({
|
|
6481
|
+
session
|
|
6482
|
+
}) => {
|
|
6483
|
+
console.log("session_update");
|
|
6484
|
+
if (session) {
|
|
6485
|
+
attachWalletConnectWallet(universalConnector, session);
|
|
6486
|
+
}
|
|
6487
|
+
};
|
|
6488
|
+
const handleSessionDelete = () => {
|
|
6489
|
+
console.log("session_delete");
|
|
6490
|
+
setWalletConnectAddress(null);
|
|
6491
|
+
void walletManager.disconnect();
|
|
6492
|
+
};
|
|
6493
|
+
provider.on("session_update", handleSessionUpdate);
|
|
6494
|
+
provider.on("session_delete", handleSessionDelete);
|
|
6495
|
+
return () => {
|
|
6496
|
+
provider.off("session_update", handleSessionUpdate);
|
|
6497
|
+
provider.off("session_delete", handleSessionDelete);
|
|
6498
|
+
};
|
|
6499
|
+
}, [attachWalletConnectWallet, universalConnector]);
|
|
6500
|
+
return {
|
|
6501
|
+
universalConnector,
|
|
6502
|
+
walletConnectAddress,
|
|
6503
|
+
WalletConnect,
|
|
6504
|
+
disconnectWalletConnect
|
|
6505
|
+
};
|
|
6506
|
+
}
|
|
6507
|
+
|
|
6198
6508
|
// src/widget/context/DepositContext.tsx
|
|
6199
6509
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
6200
|
-
var DepositContext = (0,
|
|
6510
|
+
var DepositContext = (0, import_react18.createContext)(
|
|
6201
6511
|
void 0
|
|
6202
6512
|
);
|
|
6203
|
-
var DepositNavigationContext = (0,
|
|
6204
|
-
var DepositWalletContext = (0,
|
|
6205
|
-
var DepositFormContext = (0,
|
|
6206
|
-
var DepositTransactionContext = (0,
|
|
6207
|
-
var DepositUiContext = (0,
|
|
6513
|
+
var DepositNavigationContext = (0, import_react18.createContext)(void 0);
|
|
6514
|
+
var DepositWalletContext = (0, import_react18.createContext)(void 0);
|
|
6515
|
+
var DepositFormContext = (0, import_react18.createContext)(void 0);
|
|
6516
|
+
var DepositTransactionContext = (0, import_react18.createContext)(void 0);
|
|
6517
|
+
var DepositUiContext = (0, import_react18.createContext)(void 0);
|
|
6208
6518
|
function DepositProvider({
|
|
6209
6519
|
children,
|
|
6210
6520
|
initialStep = "home"
|
|
@@ -6222,17 +6532,33 @@ function DepositProvider({
|
|
|
6222
6532
|
const { resolvedTheme, toggleTheme } = useThemePreference();
|
|
6223
6533
|
const {
|
|
6224
6534
|
selectedWallet,
|
|
6225
|
-
walletAddress,
|
|
6535
|
+
walletAddress: otherWalletAddress,
|
|
6226
6536
|
walletStatus,
|
|
6227
6537
|
connectWallet,
|
|
6228
6538
|
disconnectWallet
|
|
6229
6539
|
} = useWalletSessionState();
|
|
6230
|
-
const [amountInputMode, setAmountInputMode] = (0,
|
|
6540
|
+
const [amountInputMode, setAmountInputMode] = (0, import_react18.useState)(
|
|
6231
6541
|
"usd"
|
|
6232
6542
|
);
|
|
6233
|
-
const [
|
|
6234
|
-
|
|
6235
|
-
|
|
6543
|
+
const [walletType, setWalletType] = (0, import_react18.useState)(
|
|
6544
|
+
"other"
|
|
6545
|
+
);
|
|
6546
|
+
const {
|
|
6547
|
+
universalConnector,
|
|
6548
|
+
walletConnectAddress,
|
|
6549
|
+
WalletConnect,
|
|
6550
|
+
disconnectWalletConnect
|
|
6551
|
+
} = useWalletConnect({
|
|
6552
|
+
setWalletType,
|
|
6553
|
+
setCurrentStep
|
|
6554
|
+
});
|
|
6555
|
+
const [selectedToken, setSelectedToken] = (0, import_react18.useState)(null);
|
|
6556
|
+
const [selectedChain, setSelectedChain] = (0, import_react18.useState)(null);
|
|
6557
|
+
const [amount, setAmount] = (0, import_react18.useState)("");
|
|
6558
|
+
const walletAddress = (0, import_react18.useMemo)(
|
|
6559
|
+
() => walletType === "walletconnect" ? walletConnectAddress : otherWalletAddress,
|
|
6560
|
+
[walletType, walletConnectAddress, otherWalletAddress]
|
|
6561
|
+
);
|
|
6236
6562
|
const {
|
|
6237
6563
|
yourWalletTokens,
|
|
6238
6564
|
setYourWalletTokens,
|
|
@@ -6245,12 +6571,12 @@ function DepositProvider({
|
|
|
6245
6571
|
selectedToken,
|
|
6246
6572
|
setSelectedToken
|
|
6247
6573
|
});
|
|
6248
|
-
const [transactionStatus, setTransactionStatus] = (0,
|
|
6249
|
-
const [transactionHash, setTransactionHash] = (0,
|
|
6250
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
6251
|
-
const [intentId, setIntentId] = (0,
|
|
6252
|
-
const [paymentMethod, setPaymentMethod] = (0,
|
|
6253
|
-
const resetState =
|
|
6574
|
+
const [transactionStatus, setTransactionStatus] = (0, import_react18.useState)("idle");
|
|
6575
|
+
const [transactionHash, setTransactionHash] = (0, import_react18.useState)(null);
|
|
6576
|
+
const [errorMessage, setErrorMessage] = (0, import_react18.useState)(null);
|
|
6577
|
+
const [intentId, setIntentId] = (0, import_react18.useState)(null);
|
|
6578
|
+
const [paymentMethod, setPaymentMethod] = (0, import_react18.useState)("crypto");
|
|
6579
|
+
const resetState = import_react18.default.useCallback(() => {
|
|
6254
6580
|
resetNavigation();
|
|
6255
6581
|
setSelectedToken(null);
|
|
6256
6582
|
setSelectedChain(null);
|
|
@@ -6263,7 +6589,7 @@ function DepositProvider({
|
|
|
6263
6589
|
setPaymentMethod("crypto");
|
|
6264
6590
|
reloadWalletTokens();
|
|
6265
6591
|
}, [reloadWalletTokens, resetNavigation]);
|
|
6266
|
-
const navigationValue = (0,
|
|
6592
|
+
const navigationValue = (0, import_react18.useMemo)(
|
|
6267
6593
|
() => ({
|
|
6268
6594
|
currentStep,
|
|
6269
6595
|
setCurrentStep,
|
|
@@ -6283,7 +6609,7 @@ function DepositProvider({
|
|
|
6283
6609
|
stepHistory
|
|
6284
6610
|
]
|
|
6285
6611
|
);
|
|
6286
|
-
const walletValue = (0,
|
|
6612
|
+
const walletValue = (0, import_react18.useMemo)(
|
|
6287
6613
|
() => ({
|
|
6288
6614
|
selectedWallet,
|
|
6289
6615
|
walletAddress,
|
|
@@ -6292,20 +6618,31 @@ function DepositProvider({
|
|
|
6292
6618
|
disconnectWallet,
|
|
6293
6619
|
yourWalletTokens,
|
|
6294
6620
|
setYourWalletTokens,
|
|
6295
|
-
yourWalletTokensLoading
|
|
6621
|
+
yourWalletTokensLoading,
|
|
6622
|
+
universalConnector,
|
|
6623
|
+
walletConnectAddress,
|
|
6624
|
+
WalletConnect,
|
|
6625
|
+
disconnectWalletConnect,
|
|
6626
|
+
setWalletType,
|
|
6627
|
+
walletType
|
|
6296
6628
|
}),
|
|
6297
6629
|
[
|
|
6630
|
+
WalletConnect,
|
|
6298
6631
|
connectWallet,
|
|
6299
6632
|
disconnectWallet,
|
|
6633
|
+
disconnectWalletConnect,
|
|
6300
6634
|
selectedWallet,
|
|
6301
6635
|
setYourWalletTokens,
|
|
6636
|
+
universalConnector,
|
|
6302
6637
|
walletAddress,
|
|
6638
|
+
walletConnectAddress,
|
|
6303
6639
|
walletStatus,
|
|
6640
|
+
walletType,
|
|
6304
6641
|
yourWalletTokens,
|
|
6305
6642
|
yourWalletTokensLoading
|
|
6306
6643
|
]
|
|
6307
6644
|
);
|
|
6308
|
-
const formValue = (0,
|
|
6645
|
+
const formValue = (0, import_react18.useMemo)(
|
|
6309
6646
|
() => ({
|
|
6310
6647
|
selectedToken,
|
|
6311
6648
|
setSelectedToken,
|
|
@@ -6327,7 +6664,7 @@ function DepositProvider({
|
|
|
6327
6664
|
setPaymentMethod
|
|
6328
6665
|
]
|
|
6329
6666
|
);
|
|
6330
|
-
const transactionValue = (0,
|
|
6667
|
+
const transactionValue = (0, import_react18.useMemo)(
|
|
6331
6668
|
() => ({
|
|
6332
6669
|
transactionStatus,
|
|
6333
6670
|
setTransactionStatus,
|
|
@@ -6340,14 +6677,14 @@ function DepositProvider({
|
|
|
6340
6677
|
}),
|
|
6341
6678
|
[errorMessage, intentId, transactionHash, transactionStatus]
|
|
6342
6679
|
);
|
|
6343
|
-
const uiValue = (0,
|
|
6680
|
+
const uiValue = (0, import_react18.useMemo)(
|
|
6344
6681
|
() => ({
|
|
6345
6682
|
resolvedTheme,
|
|
6346
6683
|
toggleTheme
|
|
6347
6684
|
}),
|
|
6348
6685
|
[resolvedTheme, toggleTheme]
|
|
6349
6686
|
);
|
|
6350
|
-
const value = (0,
|
|
6687
|
+
const value = (0, import_react18.useMemo)(
|
|
6351
6688
|
() => ({
|
|
6352
6689
|
...navigationValue,
|
|
6353
6690
|
...walletValue,
|
|
@@ -6360,7 +6697,7 @@ function DepositProvider({
|
|
|
6360
6697
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositNavigationContext.Provider, { value: navigationValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositWalletContext.Provider, { value: walletValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositFormContext.Provider, { value: formValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositTransactionContext.Provider, { value: transactionValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositUiContext.Provider, { value: uiValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DepositContext.Provider, { value, children }) }) }) }) }) });
|
|
6361
6698
|
}
|
|
6362
6699
|
function useRequiredContext(context, name) {
|
|
6363
|
-
const value = (0,
|
|
6700
|
+
const value = (0, import_react18.useContext)(context);
|
|
6364
6701
|
if (value === void 0) {
|
|
6365
6702
|
throw new Error(`${name} must be used within a DepositProvider`);
|
|
6366
6703
|
}
|
|
@@ -6383,7 +6720,7 @@ function useDepositUi() {
|
|
|
6383
6720
|
}
|
|
6384
6721
|
|
|
6385
6722
|
// src/widget/components/AmountSlider.tsx
|
|
6386
|
-
var
|
|
6723
|
+
var import_react19 = require("react");
|
|
6387
6724
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6388
6725
|
var roundToNiceNumber = (value, range) => {
|
|
6389
6726
|
let roundingFactor;
|
|
@@ -6433,7 +6770,7 @@ function AmountSlider({
|
|
|
6433
6770
|
style,
|
|
6434
6771
|
disabled = false
|
|
6435
6772
|
}) {
|
|
6436
|
-
const generateTickMarks = (0,
|
|
6773
|
+
const generateTickMarks = (0, import_react19.useCallback)(
|
|
6437
6774
|
(minValue, maxValue) => {
|
|
6438
6775
|
const range = maxValue - minValue;
|
|
6439
6776
|
if (range <= 0) {
|
|
@@ -6481,25 +6818,25 @@ function AmountSlider({
|
|
|
6481
6818
|
},
|
|
6482
6819
|
[]
|
|
6483
6820
|
);
|
|
6484
|
-
const tickMarks = (0,
|
|
6821
|
+
const tickMarks = (0, import_react19.useMemo)(
|
|
6485
6822
|
() => generateTickMarks(min, max),
|
|
6486
6823
|
[generateTickMarks, min, max]
|
|
6487
6824
|
);
|
|
6488
|
-
const getPercentage = (0,
|
|
6825
|
+
const getPercentage = (0, import_react19.useCallback)(() => {
|
|
6489
6826
|
const range = max - min;
|
|
6490
6827
|
if (range <= 0) return 0;
|
|
6491
6828
|
const clampedValue = Math.min(Math.max(value, min), max);
|
|
6492
6829
|
return (clampedValue - min) / range * 100;
|
|
6493
6830
|
}, [max, min, value]);
|
|
6494
|
-
const percentage = (0,
|
|
6495
|
-
const handleChange = (0,
|
|
6831
|
+
const percentage = (0, import_react19.useMemo)(() => getPercentage(), [getPercentage]);
|
|
6832
|
+
const handleChange = (0, import_react19.useCallback)(
|
|
6496
6833
|
(e2) => {
|
|
6497
6834
|
const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
|
|
6498
6835
|
onChange(newValue);
|
|
6499
6836
|
},
|
|
6500
6837
|
[onChange, min, max]
|
|
6501
6838
|
);
|
|
6502
|
-
const handleTickClick = (0,
|
|
6839
|
+
const handleTickClick = (0, import_react19.useCallback)(
|
|
6503
6840
|
(tickValue) => {
|
|
6504
6841
|
if (disabled) return;
|
|
6505
6842
|
onChange(tickValue);
|
|
@@ -6717,7 +7054,7 @@ function AmountSlider({
|
|
|
6717
7054
|
}
|
|
6718
7055
|
|
|
6719
7056
|
// src/widget/components/AmountInputDisplay.tsx
|
|
6720
|
-
var
|
|
7057
|
+
var import_react20 = require("react");
|
|
6721
7058
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
6722
7059
|
function formatDisplayAmount(value) {
|
|
6723
7060
|
if (!Number.isFinite(value) || value <= 0) return "0";
|
|
@@ -6756,8 +7093,8 @@ function AmountInputDisplay({
|
|
|
6756
7093
|
style,
|
|
6757
7094
|
inputAriaLabel = "Deposit amount"
|
|
6758
7095
|
}) {
|
|
6759
|
-
const [isEditing, setIsEditing] = (0,
|
|
6760
|
-
const inputRef = (0,
|
|
7096
|
+
const [isEditing, setIsEditing] = (0, import_react20.useState)(false);
|
|
7097
|
+
const inputRef = (0, import_react20.useRef)(null);
|
|
6761
7098
|
const handleAmountClick = () => {
|
|
6762
7099
|
if (isFixedAmount) return;
|
|
6763
7100
|
const isZeroish = !amount || parseFloat(amount) === 0;
|
|
@@ -6972,7 +7309,7 @@ function CircularProgress({
|
|
|
6972
7309
|
}
|
|
6973
7310
|
|
|
6974
7311
|
// src/widget/components/Dialog.tsx
|
|
6975
|
-
var
|
|
7312
|
+
var import_react22 = require("react");
|
|
6976
7313
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
6977
7314
|
var Dialog = ({
|
|
6978
7315
|
open,
|
|
@@ -6984,11 +7321,11 @@ var Dialog = ({
|
|
|
6984
7321
|
confirmText = "Close Anyway",
|
|
6985
7322
|
isDark = false
|
|
6986
7323
|
}) => {
|
|
6987
|
-
const dialogRef = (0,
|
|
6988
|
-
const overlayRef = (0,
|
|
6989
|
-
const firstButtonRef = (0,
|
|
6990
|
-
const lastButtonRef = (0,
|
|
6991
|
-
(0,
|
|
7324
|
+
const dialogRef = (0, import_react22.useRef)(null);
|
|
7325
|
+
const overlayRef = (0, import_react22.useRef)(null);
|
|
7326
|
+
const firstButtonRef = (0, import_react22.useRef)(null);
|
|
7327
|
+
const lastButtonRef = (0, import_react22.useRef)(null);
|
|
7328
|
+
(0, import_react22.useEffect)(() => {
|
|
6992
7329
|
const handleEscape = (e2) => {
|
|
6993
7330
|
if (e2.key === "Escape" && open) {
|
|
6994
7331
|
e2.preventDefault();
|
|
@@ -7002,7 +7339,7 @@ var Dialog = ({
|
|
|
7002
7339
|
document.removeEventListener("keydown", handleEscape);
|
|
7003
7340
|
};
|
|
7004
7341
|
}, [open, onCancel]);
|
|
7005
|
-
(0,
|
|
7342
|
+
(0, import_react22.useEffect)(() => {
|
|
7006
7343
|
const handleTabKey = (e2) => {
|
|
7007
7344
|
if (!open) return;
|
|
7008
7345
|
if (e2.key === "Tab") {
|
|
@@ -7026,7 +7363,7 @@ var Dialog = ({
|
|
|
7026
7363
|
document.removeEventListener("keydown", handleTabKey);
|
|
7027
7364
|
};
|
|
7028
7365
|
}, [open]);
|
|
7029
|
-
(0,
|
|
7366
|
+
(0, import_react22.useEffect)(() => {
|
|
7030
7367
|
if (open) {
|
|
7031
7368
|
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
7032
7369
|
document.body.style.overflow = "hidden";
|
|
@@ -7324,7 +7661,7 @@ function TransactionHashLink({
|
|
|
7324
7661
|
}
|
|
7325
7662
|
|
|
7326
7663
|
// src/widget/components/SwipeToConfirmTokens.tsx
|
|
7327
|
-
var
|
|
7664
|
+
var import_react23 = require("react");
|
|
7328
7665
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
7329
7666
|
function SwipeToConfirmTokens({
|
|
7330
7667
|
fromToken,
|
|
@@ -7339,33 +7676,33 @@ function SwipeToConfirmTokens({
|
|
|
7339
7676
|
style,
|
|
7340
7677
|
text
|
|
7341
7678
|
}) {
|
|
7342
|
-
const [dragX, setDragX] = (0,
|
|
7343
|
-
const [isDragging, setIsDragging] = (0,
|
|
7344
|
-
const [isComplete, setIsComplete] = (0,
|
|
7345
|
-
const trackRef = (0,
|
|
7346
|
-
const thumbRef = (0,
|
|
7347
|
-
const [isLongPressing, setIsLongPressing] = (0,
|
|
7348
|
-
const [longPressProgress, setLongPressProgress] = (0,
|
|
7349
|
-
const longPressTimerRef = (0,
|
|
7350
|
-
const longPressStartRef = (0,
|
|
7351
|
-
const longPressAnimationRef = (0,
|
|
7679
|
+
const [dragX, setDragX] = (0, import_react23.useState)(0);
|
|
7680
|
+
const [isDragging, setIsDragging] = (0, import_react23.useState)(false);
|
|
7681
|
+
const [isComplete, setIsComplete] = (0, import_react23.useState)(false);
|
|
7682
|
+
const trackRef = (0, import_react23.useRef)(null);
|
|
7683
|
+
const thumbRef = (0, import_react23.useRef)(null);
|
|
7684
|
+
const [isLongPressing, setIsLongPressing] = (0, import_react23.useState)(false);
|
|
7685
|
+
const [longPressProgress, setLongPressProgress] = (0, import_react23.useState)(0);
|
|
7686
|
+
const longPressTimerRef = (0, import_react23.useRef)(null);
|
|
7687
|
+
const longPressStartRef = (0, import_react23.useRef)(null);
|
|
7688
|
+
const longPressAnimationRef = (0, import_react23.useRef)(null);
|
|
7352
7689
|
const LONG_PRESS_DURATION = 1500;
|
|
7353
7690
|
const thumbSize = 48;
|
|
7354
7691
|
const padding = 4;
|
|
7355
7692
|
const threshold = 0.8;
|
|
7356
|
-
const getMaxDrag = (0,
|
|
7693
|
+
const getMaxDrag = (0, import_react23.useCallback)(() => {
|
|
7357
7694
|
if (!trackRef.current) return 0;
|
|
7358
7695
|
return trackRef.current.offsetWidth - thumbSize - padding * 2;
|
|
7359
7696
|
}, []);
|
|
7360
|
-
const getProgress = (0,
|
|
7697
|
+
const getProgress = (0, import_react23.useCallback)(() => {
|
|
7361
7698
|
const maxDrag = getMaxDrag();
|
|
7362
7699
|
return maxDrag > 0 ? dragX / maxDrag : 0;
|
|
7363
7700
|
}, [dragX, getMaxDrag]);
|
|
7364
|
-
const handleDragStart = (0,
|
|
7701
|
+
const handleDragStart = (0, import_react23.useCallback)(() => {
|
|
7365
7702
|
if (disabled || isComplete) return;
|
|
7366
7703
|
setIsDragging(true);
|
|
7367
7704
|
}, [disabled, isComplete]);
|
|
7368
|
-
const handleDragMove = (0,
|
|
7705
|
+
const handleDragMove = (0, import_react23.useCallback)(
|
|
7369
7706
|
(clientX) => {
|
|
7370
7707
|
if (!isDragging || !trackRef.current || isComplete) return;
|
|
7371
7708
|
const rect = trackRef.current.getBoundingClientRect();
|
|
@@ -7376,7 +7713,7 @@ function SwipeToConfirmTokens({
|
|
|
7376
7713
|
},
|
|
7377
7714
|
[isDragging, isComplete, getMaxDrag]
|
|
7378
7715
|
);
|
|
7379
|
-
const handleDragEnd = (0,
|
|
7716
|
+
const handleDragEnd = (0, import_react23.useCallback)(() => {
|
|
7380
7717
|
if (!isDragging) return;
|
|
7381
7718
|
setIsDragging(false);
|
|
7382
7719
|
const progress2 = getProgress();
|
|
@@ -7389,14 +7726,14 @@ function SwipeToConfirmTokens({
|
|
|
7389
7726
|
setDragX(0);
|
|
7390
7727
|
}
|
|
7391
7728
|
}, [isDragging, getProgress, getMaxDrag, onConfirm]);
|
|
7392
|
-
const triggerConfirmation = (0,
|
|
7729
|
+
const triggerConfirmation = (0, import_react23.useCallback)(() => {
|
|
7393
7730
|
if (isComplete) return;
|
|
7394
7731
|
setDragX(getMaxDrag());
|
|
7395
7732
|
setIsComplete(true);
|
|
7396
7733
|
if (navigator.vibrate) navigator.vibrate(50);
|
|
7397
7734
|
setTimeout(() => onConfirm(), 150);
|
|
7398
7735
|
}, [isComplete, getMaxDrag, onConfirm]);
|
|
7399
|
-
const cancelLongPress = (0,
|
|
7736
|
+
const cancelLongPress = (0, import_react23.useCallback)(() => {
|
|
7400
7737
|
setIsLongPressing(false);
|
|
7401
7738
|
setLongPressProgress(0);
|
|
7402
7739
|
longPressStartRef.current = null;
|
|
@@ -7409,7 +7746,7 @@ function SwipeToConfirmTokens({
|
|
|
7409
7746
|
longPressAnimationRef.current = null;
|
|
7410
7747
|
}
|
|
7411
7748
|
}, []);
|
|
7412
|
-
const startLongPress = (0,
|
|
7749
|
+
const startLongPress = (0, import_react23.useCallback)(() => {
|
|
7413
7750
|
if (disabled || isComplete || isDragging) return;
|
|
7414
7751
|
setIsLongPressing(true);
|
|
7415
7752
|
longPressStartRef.current = Date.now();
|
|
@@ -7427,7 +7764,7 @@ function SwipeToConfirmTokens({
|
|
|
7427
7764
|
};
|
|
7428
7765
|
longPressAnimationRef.current = requestAnimationFrame(animateProgress);
|
|
7429
7766
|
}, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
|
|
7430
|
-
const handleKeyDown = (0,
|
|
7767
|
+
const handleKeyDown = (0, import_react23.useCallback)(
|
|
7431
7768
|
(e2) => {
|
|
7432
7769
|
if (disabled || isComplete) return;
|
|
7433
7770
|
if (e2.key === "Enter" || e2.key === " ") {
|
|
@@ -7437,7 +7774,7 @@ function SwipeToConfirmTokens({
|
|
|
7437
7774
|
},
|
|
7438
7775
|
[disabled, isComplete, startLongPress]
|
|
7439
7776
|
);
|
|
7440
|
-
const handleKeyUp = (0,
|
|
7777
|
+
const handleKeyUp = (0, import_react23.useCallback)(
|
|
7441
7778
|
(e2) => {
|
|
7442
7779
|
if (e2.key === "Enter" || e2.key === " ") {
|
|
7443
7780
|
e2.preventDefault();
|
|
@@ -7446,7 +7783,7 @@ function SwipeToConfirmTokens({
|
|
|
7446
7783
|
},
|
|
7447
7784
|
[cancelLongPress]
|
|
7448
7785
|
);
|
|
7449
|
-
(0,
|
|
7786
|
+
(0, import_react23.useEffect)(() => {
|
|
7450
7787
|
return () => {
|
|
7451
7788
|
if (longPressTimerRef.current) clearTimeout(longPressTimerRef.current);
|
|
7452
7789
|
if (longPressAnimationRef.current)
|
|
@@ -7457,15 +7794,15 @@ function SwipeToConfirmTokens({
|
|
|
7457
7794
|
e2.preventDefault();
|
|
7458
7795
|
handleDragStart();
|
|
7459
7796
|
};
|
|
7460
|
-
const handleMouseMove = (0,
|
|
7797
|
+
const handleMouseMove = (0, import_react23.useCallback)(
|
|
7461
7798
|
(e2) => handleDragMove(e2.clientX),
|
|
7462
7799
|
[handleDragMove]
|
|
7463
7800
|
);
|
|
7464
|
-
const handleMouseUp = (0,
|
|
7801
|
+
const handleMouseUp = (0, import_react23.useCallback)(() => handleDragEnd(), [handleDragEnd]);
|
|
7465
7802
|
const handleTouchStart = () => handleDragStart();
|
|
7466
7803
|
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
7467
7804
|
const handleTouchEnd = () => handleDragEnd();
|
|
7468
|
-
(0,
|
|
7805
|
+
(0, import_react23.useEffect)(() => {
|
|
7469
7806
|
if (isDragging) {
|
|
7470
7807
|
window.addEventListener("mousemove", handleMouseMove);
|
|
7471
7808
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -7477,8 +7814,8 @@ function SwipeToConfirmTokens({
|
|
|
7477
7814
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
7478
7815
|
const progress = getProgress();
|
|
7479
7816
|
const effectiveProgress = isLongPressing ? longPressProgress : progress;
|
|
7480
|
-
const [blinkOpacity, setBlinkOpacity] = (0,
|
|
7481
|
-
(0,
|
|
7817
|
+
const [blinkOpacity, setBlinkOpacity] = (0, import_react23.useState)(1);
|
|
7818
|
+
(0, import_react23.useEffect)(() => {
|
|
7482
7819
|
if (disabled || isComplete || isDragging || isLongPressing) {
|
|
7483
7820
|
setBlinkOpacity(1);
|
|
7484
7821
|
return;
|
|
@@ -7928,7 +8265,7 @@ function ThemeToggle({
|
|
|
7928
8265
|
}
|
|
7929
8266
|
|
|
7930
8267
|
// src/widget/components/Toast.tsx
|
|
7931
|
-
var
|
|
8268
|
+
var import_react24 = require("react");
|
|
7932
8269
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
7933
8270
|
var variantStyles = {
|
|
7934
8271
|
default: {
|
|
@@ -7958,14 +8295,14 @@ function ToastItem({
|
|
|
7958
8295
|
duration = 4e3,
|
|
7959
8296
|
onDismiss
|
|
7960
8297
|
}) {
|
|
7961
|
-
const [isExiting, setIsExiting] = (0,
|
|
7962
|
-
(0,
|
|
8298
|
+
const [isExiting, setIsExiting] = (0, import_react24.useState)(false);
|
|
8299
|
+
(0, import_react24.useEffect)(() => {
|
|
7963
8300
|
const timer = setTimeout(() => {
|
|
7964
8301
|
setIsExiting(true);
|
|
7965
8302
|
}, duration);
|
|
7966
8303
|
return () => clearTimeout(timer);
|
|
7967
8304
|
}, [duration]);
|
|
7968
|
-
(0,
|
|
8305
|
+
(0, import_react24.useEffect)(() => {
|
|
7969
8306
|
if (isExiting) {
|
|
7970
8307
|
const exitTimer = setTimeout(() => {
|
|
7971
8308
|
onDismiss(id);
|
|
@@ -8169,8 +8506,8 @@ function toast(data) {
|
|
|
8169
8506
|
toast.error = (title, description) => toast({ title, description, variant: "destructive" });
|
|
8170
8507
|
toast.success = (title, description) => toast({ title, description, variant: "success" });
|
|
8171
8508
|
function ToastContainer() {
|
|
8172
|
-
const [activeToasts, setActiveToasts] = (0,
|
|
8173
|
-
(0,
|
|
8509
|
+
const [activeToasts, setActiveToasts] = (0, import_react24.useState)([]);
|
|
8510
|
+
(0, import_react24.useEffect)(() => {
|
|
8174
8511
|
const listener = (newToasts) => {
|
|
8175
8512
|
setActiveToasts(newToasts);
|
|
8176
8513
|
};
|
|
@@ -8182,7 +8519,7 @@ function ToastContainer() {
|
|
|
8182
8519
|
}
|
|
8183
8520
|
};
|
|
8184
8521
|
}, []);
|
|
8185
|
-
const handleDismiss = (0,
|
|
8522
|
+
const handleDismiss = (0, import_react24.useCallback)((id) => {
|
|
8186
8523
|
toasts = toasts.filter((t) => t.id !== id);
|
|
8187
8524
|
notifyListeners();
|
|
8188
8525
|
}, []);
|
|
@@ -8219,7 +8556,7 @@ function ToastContainer() {
|
|
|
8219
8556
|
}
|
|
8220
8557
|
|
|
8221
8558
|
// src/widget/components/TokenSwipePill.tsx
|
|
8222
|
-
var
|
|
8559
|
+
var import_react25 = __toESM(require("react"), 1);
|
|
8223
8560
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
8224
8561
|
var MAX_VISIBLE_DOTS = 5;
|
|
8225
8562
|
function TokenSwipePill({
|
|
@@ -8231,10 +8568,10 @@ function TokenSwipePill({
|
|
|
8231
8568
|
walletAddress,
|
|
8232
8569
|
style
|
|
8233
8570
|
}) {
|
|
8234
|
-
const [isDragging, setIsDragging] = (0,
|
|
8235
|
-
const [dragOffset, setDragOffset] = (0,
|
|
8236
|
-
const startXRef = (0,
|
|
8237
|
-
const containerRef = (0,
|
|
8571
|
+
const [isDragging, setIsDragging] = (0, import_react25.useState)(false);
|
|
8572
|
+
const [dragOffset, setDragOffset] = (0, import_react25.useState)(0);
|
|
8573
|
+
const startXRef = (0, import_react25.useRef)(0);
|
|
8574
|
+
const containerRef = (0, import_react25.useRef)(null);
|
|
8238
8575
|
const currentIndex = tokens.findIndex(
|
|
8239
8576
|
(t) => normalizeAddress2(
|
|
8240
8577
|
t.address,
|
|
@@ -8255,11 +8592,11 @@ function TokenSwipePill({
|
|
|
8255
8592
|
}
|
|
8256
8593
|
return pos;
|
|
8257
8594
|
};
|
|
8258
|
-
const handleDragStart = (0,
|
|
8595
|
+
const handleDragStart = (0, import_react25.useCallback)((clientX) => {
|
|
8259
8596
|
setIsDragging(true);
|
|
8260
8597
|
startXRef.current = clientX;
|
|
8261
8598
|
}, []);
|
|
8262
|
-
const handleDragMove = (0,
|
|
8599
|
+
const handleDragMove = (0, import_react25.useCallback)(
|
|
8263
8600
|
(clientX) => {
|
|
8264
8601
|
if (!isDragging) return;
|
|
8265
8602
|
const delta = startXRef.current - clientX;
|
|
@@ -8267,7 +8604,7 @@ function TokenSwipePill({
|
|
|
8267
8604
|
},
|
|
8268
8605
|
[isDragging]
|
|
8269
8606
|
);
|
|
8270
|
-
const handleDragEnd = (0,
|
|
8607
|
+
const handleDragEnd = (0, import_react25.useCallback)(() => {
|
|
8271
8608
|
if (!isDragging) return;
|
|
8272
8609
|
setIsDragging(false);
|
|
8273
8610
|
if (Math.abs(dragOffset) > swipeThreshold) {
|
|
@@ -8285,13 +8622,13 @@ function TokenSwipePill({
|
|
|
8285
8622
|
e2.preventDefault();
|
|
8286
8623
|
handleDragStart(e2.clientX);
|
|
8287
8624
|
};
|
|
8288
|
-
const handleMouseMove = (0,
|
|
8625
|
+
const handleMouseMove = (0, import_react25.useCallback)(
|
|
8289
8626
|
(e2) => {
|
|
8290
8627
|
handleDragMove(e2.clientX);
|
|
8291
8628
|
},
|
|
8292
8629
|
[handleDragMove]
|
|
8293
8630
|
);
|
|
8294
|
-
const handleMouseUp = (0,
|
|
8631
|
+
const handleMouseUp = (0, import_react25.useCallback)(() => {
|
|
8295
8632
|
handleDragEnd();
|
|
8296
8633
|
}, [handleDragEnd]);
|
|
8297
8634
|
const handleTouchStart = (e2) => {
|
|
@@ -8305,7 +8642,7 @@ function TokenSwipePill({
|
|
|
8305
8642
|
const handleTouchEnd = () => {
|
|
8306
8643
|
handleDragEnd();
|
|
8307
8644
|
};
|
|
8308
|
-
(0,
|
|
8645
|
+
(0, import_react25.useEffect)(() => {
|
|
8309
8646
|
if (isDragging) {
|
|
8310
8647
|
window.addEventListener("mousemove", handleMouseMove);
|
|
8311
8648
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -8319,7 +8656,7 @@ function TokenSwipePill({
|
|
|
8319
8656
|
const getChainInitials = (chain) => {
|
|
8320
8657
|
return chain?.slice(0, 2).toUpperCase();
|
|
8321
8658
|
};
|
|
8322
|
-
const chainBadge = (0,
|
|
8659
|
+
const chainBadge = (0, import_react25.useMemo)(() => {
|
|
8323
8660
|
const url = selectedToken.chainData?.chainIconURI || selectedToken.chainData?.iconUrl;
|
|
8324
8661
|
return url?.toString();
|
|
8325
8662
|
}, [selectedToken]);
|
|
@@ -8605,7 +8942,7 @@ function TokenSwipePill({
|
|
|
8605
8942
|
const token = tokens[index];
|
|
8606
8943
|
const prevIndex = uniqueIndices[i - 1];
|
|
8607
8944
|
const showGap = i > 0 && index - prevIndex > 1;
|
|
8608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
8945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react25.default.Fragment, { children: [
|
|
8609
8946
|
showGap && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
8610
8947
|
"span",
|
|
8611
8948
|
{
|
|
@@ -8787,7 +9124,7 @@ function TokenSwipePill({
|
|
|
8787
9124
|
}
|
|
8788
9125
|
|
|
8789
9126
|
// src/widget/components/TransactionSteps.tsx
|
|
8790
|
-
var
|
|
9127
|
+
var import_react26 = require("react");
|
|
8791
9128
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
8792
9129
|
var DEFAULT_LABELS = {
|
|
8793
9130
|
confirming: "Confirming in wallet",
|
|
@@ -8827,14 +9164,14 @@ function TransactionSteps({
|
|
|
8827
9164
|
style,
|
|
8828
9165
|
stepLabels
|
|
8829
9166
|
}) {
|
|
8830
|
-
const labels = (0,
|
|
9167
|
+
const labels = (0, import_react26.useMemo)(
|
|
8831
9168
|
() => ({
|
|
8832
9169
|
...DEFAULT_LABELS,
|
|
8833
9170
|
...stepLabels
|
|
8834
9171
|
}),
|
|
8835
9172
|
[stepLabels]
|
|
8836
9173
|
);
|
|
8837
|
-
const steps = (0,
|
|
9174
|
+
const steps = (0, import_react26.useMemo)(
|
|
8838
9175
|
() => getSteps(transactionStatus, labels),
|
|
8839
9176
|
[transactionStatus, labels]
|
|
8840
9177
|
);
|
|
@@ -8993,7 +9330,7 @@ function TransactionSteps({
|
|
|
8993
9330
|
}
|
|
8994
9331
|
|
|
8995
9332
|
// src/widget/components/WidgetContainer.tsx
|
|
8996
|
-
var
|
|
9333
|
+
var import_react27 = require("react");
|
|
8997
9334
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
8998
9335
|
var INJECTED_STYLES = ALL_THEME_STYLES + ALL_ANIMATION_STYLES;
|
|
8999
9336
|
function WidgetContainer({
|
|
@@ -9002,8 +9339,8 @@ function WidgetContainer({
|
|
|
9002
9339
|
className,
|
|
9003
9340
|
style
|
|
9004
9341
|
}) {
|
|
9005
|
-
const [resolvedTheme, setResolvedTheme] = (0,
|
|
9006
|
-
(0,
|
|
9342
|
+
const [resolvedTheme, setResolvedTheme] = (0, import_react27.useState)("light");
|
|
9343
|
+
(0, import_react27.useEffect)(() => {
|
|
9007
9344
|
if (theme === "system") {
|
|
9008
9345
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
9009
9346
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
@@ -9247,7 +9584,7 @@ function WidgetSecurityFooter({
|
|
|
9247
9584
|
}
|
|
9248
9585
|
|
|
9249
9586
|
// src/widget/components/ImageLoader.tsx
|
|
9250
|
-
var
|
|
9587
|
+
var import_react28 = require("react");
|
|
9251
9588
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
9252
9589
|
function Skeleton({
|
|
9253
9590
|
background,
|
|
@@ -9277,12 +9614,12 @@ function ImageLoader({
|
|
|
9277
9614
|
onLoad,
|
|
9278
9615
|
onError
|
|
9279
9616
|
}) {
|
|
9280
|
-
const [status, setStatus] = (0,
|
|
9281
|
-
const [attempt, setAttempt] = (0,
|
|
9282
|
-
const [srcIsEmpty, setSrcIsEmpty] = (0,
|
|
9283
|
-
const imgRef = (0,
|
|
9284
|
-
const observerRef = (0,
|
|
9285
|
-
(0,
|
|
9617
|
+
const [status, setStatus] = (0, import_react28.useState)("idle");
|
|
9618
|
+
const [attempt, setAttempt] = (0, import_react28.useState)(0);
|
|
9619
|
+
const [srcIsEmpty, setSrcIsEmpty] = (0, import_react28.useState)(false);
|
|
9620
|
+
const imgRef = (0, import_react28.useRef)(null);
|
|
9621
|
+
const observerRef = (0, import_react28.useRef)(null);
|
|
9622
|
+
(0, import_react28.useEffect)(() => {
|
|
9286
9623
|
if (status === "error" && attempt < retry) {
|
|
9287
9624
|
const timer = setTimeout(() => {
|
|
9288
9625
|
setAttempt((prev) => prev + 1);
|
|
@@ -9308,7 +9645,7 @@ function ImageLoader({
|
|
|
9308
9645
|
onError?.();
|
|
9309
9646
|
};
|
|
9310
9647
|
};
|
|
9311
|
-
(0,
|
|
9648
|
+
(0, import_react28.useEffect)(() => {
|
|
9312
9649
|
if (!lazy2) {
|
|
9313
9650
|
setTimeout(() => {
|
|
9314
9651
|
loadImage();
|
|
@@ -9331,7 +9668,7 @@ function ImageLoader({
|
|
|
9331
9668
|
}
|
|
9332
9669
|
return () => observerRef.current?.disconnect();
|
|
9333
9670
|
}, [lazy2, src, loadImage]);
|
|
9334
|
-
const showFallback = (0,
|
|
9671
|
+
const showFallback = (0, import_react28.useMemo)(() => {
|
|
9335
9672
|
return (status === "error" && attempt >= retry || srcIsEmpty) && Fallback;
|
|
9336
9673
|
}, [status, attempt, retry, srcIsEmpty, Fallback]);
|
|
9337
9674
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: imgRef, style: { position: "relative" }, children: [
|
|
@@ -9567,7 +9904,7 @@ function InitErrorOverlay({
|
|
|
9567
9904
|
}
|
|
9568
9905
|
|
|
9569
9906
|
// src/widget/app/WidgetRouter.tsx
|
|
9570
|
-
var
|
|
9907
|
+
var import_react40 = require("react");
|
|
9571
9908
|
|
|
9572
9909
|
// src/widget/helpers/tokenAmount.ts
|
|
9573
9910
|
function rawToDecimal(rawAmount, decimals) {
|
|
@@ -10819,7 +11156,7 @@ function TokenSelectorPanel({
|
|
|
10819
11156
|
}
|
|
10820
11157
|
|
|
10821
11158
|
// src/widget/features/token-selection/hooks/useOrderedWalletTokens.ts
|
|
10822
|
-
var
|
|
11159
|
+
var import_react29 = require("react");
|
|
10823
11160
|
function useOrderedWalletTokens({
|
|
10824
11161
|
amount,
|
|
10825
11162
|
amountInputMode,
|
|
@@ -10828,7 +11165,7 @@ function useOrderedWalletTokens({
|
|
|
10828
11165
|
setSelectedToken,
|
|
10829
11166
|
yourWalletTokens
|
|
10830
11167
|
}) {
|
|
10831
|
-
const handleTokenChange = (0,
|
|
11168
|
+
const handleTokenChange = (0, import_react29.useCallback)(
|
|
10832
11169
|
async (token) => {
|
|
10833
11170
|
if (token) {
|
|
10834
11171
|
setSelectedToken(token);
|
|
@@ -10837,7 +11174,7 @@ function useOrderedWalletTokens({
|
|
|
10837
11174
|
},
|
|
10838
11175
|
[setSelectedChain, setSelectedToken]
|
|
10839
11176
|
);
|
|
10840
|
-
const orderedTokens = (0,
|
|
11177
|
+
const orderedTokens = (0, import_react29.useMemo)(() => {
|
|
10841
11178
|
const selectedTokenChainType = selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType;
|
|
10842
11179
|
const index = yourWalletTokens.findIndex(
|
|
10843
11180
|
(token) => normalizeAddress2(
|
|
@@ -10906,7 +11243,7 @@ function filterTokenAmountCompatibleTokens(tokens, parsedAmount) {
|
|
|
10906
11243
|
}
|
|
10907
11244
|
|
|
10908
11245
|
// src/widget/features/token-selection/hooks/useSelectTokenModel.ts
|
|
10909
|
-
var
|
|
11246
|
+
var import_react30 = require("react");
|
|
10910
11247
|
function useSelectTokenModel({
|
|
10911
11248
|
goBack,
|
|
10912
11249
|
searchQuery,
|
|
@@ -10930,7 +11267,7 @@ function useSelectTokenModel({
|
|
|
10930
11267
|
explorerUrl: chain.blockExplorerUrls?.[0]
|
|
10931
11268
|
});
|
|
10932
11269
|
};
|
|
10933
|
-
const handleTokenSelect = (0,
|
|
11270
|
+
const handleTokenSelect = (0, import_react30.useCallback)(
|
|
10934
11271
|
async (token) => {
|
|
10935
11272
|
if (token.balance !== void 0) {
|
|
10936
11273
|
setSelectedToken(token);
|
|
@@ -10954,7 +11291,7 @@ function useSelectTokenModel({
|
|
|
10954
11291
|
},
|
|
10955
11292
|
[goBack, selectedChain, setSelectedToken, walletAddress]
|
|
10956
11293
|
);
|
|
10957
|
-
const handleYourTokenSelect = (0,
|
|
11294
|
+
const handleYourTokenSelect = (0, import_react30.useCallback)(
|
|
10958
11295
|
(token) => {
|
|
10959
11296
|
setSelectedToken(token);
|
|
10960
11297
|
setSelectedChain(token.chainData);
|
|
@@ -10976,7 +11313,7 @@ function useSelectTokenModel({
|
|
|
10976
11313
|
const address = token.address?.toLowerCase() ?? "";
|
|
10977
11314
|
return symbol.includes(normalizedSearchQuery) || name.includes(normalizedSearchQuery) || address.includes(normalizedSearchQuery);
|
|
10978
11315
|
};
|
|
10979
|
-
const filteredWalletTokens = (0,
|
|
11316
|
+
const filteredWalletTokens = (0, import_react30.useMemo)(() => {
|
|
10980
11317
|
if (!selectedChain?.chainId) {
|
|
10981
11318
|
return [];
|
|
10982
11319
|
}
|
|
@@ -11448,7 +11785,7 @@ function CryptoPayAmountSection({
|
|
|
11448
11785
|
}
|
|
11449
11786
|
|
|
11450
11787
|
// src/widget/features/amount/hooks/useDepositAmountModel.ts
|
|
11451
|
-
var
|
|
11788
|
+
var import_react31 = require("react");
|
|
11452
11789
|
var BALANCE_TOLERANCE = 1e-9;
|
|
11453
11790
|
function useDepositAmountModel({
|
|
11454
11791
|
amount,
|
|
@@ -11463,14 +11800,14 @@ function useDepositAmountModel({
|
|
|
11463
11800
|
}) {
|
|
11464
11801
|
const tokenPriceUSD = typeof selectedToken?.usdPrice === "number" && Number.isFinite(selectedToken.usdPrice) && selectedToken.usdPrice > 0 ? selectedToken.usdPrice : 0;
|
|
11465
11802
|
const hasUsdPrice = typeof tokenPriceUSD === "number" && Number.isFinite(tokenPriceUSD) && tokenPriceUSD > 0;
|
|
11466
|
-
const normalizedTokenBalance = (0,
|
|
11803
|
+
const normalizedTokenBalance = (0, import_react31.useMemo)(() => {
|
|
11467
11804
|
if (!selectedToken?.balance) return 0;
|
|
11468
11805
|
const normalized = Number(
|
|
11469
11806
|
rawToDecimal(selectedToken.balance, selectedToken.decimals ?? 18)
|
|
11470
11807
|
);
|
|
11471
11808
|
return Number.isFinite(normalized) ? normalized : 0;
|
|
11472
11809
|
}, [selectedToken?.balance, selectedToken?.decimals]);
|
|
11473
|
-
(0,
|
|
11810
|
+
(0, import_react31.useEffect)(() => {
|
|
11474
11811
|
if (fixedFromAmountString) return;
|
|
11475
11812
|
if (isReady && !hasUsdPrice && amountInputMode === "usd") {
|
|
11476
11813
|
setAmountInputMode("token");
|
|
@@ -11482,7 +11819,7 @@ function useDepositAmountModel({
|
|
|
11482
11819
|
isReady,
|
|
11483
11820
|
setAmountInputMode
|
|
11484
11821
|
]);
|
|
11485
|
-
(0,
|
|
11822
|
+
(0, import_react31.useEffect)(() => {
|
|
11486
11823
|
if (!fixedFromAmountString) return;
|
|
11487
11824
|
if (amount !== fixedFromAmountString) {
|
|
11488
11825
|
setAmount(fixedFromAmountString);
|
|
@@ -11497,7 +11834,7 @@ function useDepositAmountModel({
|
|
|
11497
11834
|
setAmount,
|
|
11498
11835
|
setAmountInputMode
|
|
11499
11836
|
]);
|
|
11500
|
-
const amountComputation = (0,
|
|
11837
|
+
const amountComputation = (0, import_react31.useMemo)(() => {
|
|
11501
11838
|
const rawAmount = (fixedFromAmountString ?? amount)?.trim();
|
|
11502
11839
|
if (!rawAmount) {
|
|
11503
11840
|
return {
|
|
@@ -11564,11 +11901,11 @@ function useDepositAmountModel({
|
|
|
11564
11901
|
selectedToken?.decimals,
|
|
11565
11902
|
tokenPriceUSD
|
|
11566
11903
|
]);
|
|
11567
|
-
const requestedTokenAmount = (0,
|
|
11904
|
+
const requestedTokenAmount = (0, import_react31.useMemo)(() => {
|
|
11568
11905
|
const tokenAmount = Number(amountComputation.tokenAmount);
|
|
11569
11906
|
return Number.isFinite(tokenAmount) ? tokenAmount : 0;
|
|
11570
11907
|
}, [amountComputation.tokenAmount]);
|
|
11571
|
-
const amountValidationError = (0,
|
|
11908
|
+
const amountValidationError = (0, import_react31.useMemo)(() => {
|
|
11572
11909
|
if (amountComputation.parseError) {
|
|
11573
11910
|
return amountComputation.parseError;
|
|
11574
11911
|
}
|
|
@@ -11601,15 +11938,15 @@ function useDepositAmountModel({
|
|
|
11601
11938
|
]);
|
|
11602
11939
|
const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
|
|
11603
11940
|
const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
|
|
11604
|
-
const maxTokenAmount = (0,
|
|
11941
|
+
const maxTokenAmount = (0, import_react31.useMemo)(
|
|
11605
11942
|
() => Math.min(normalizedTokenBalance, 1e4),
|
|
11606
11943
|
[normalizedTokenBalance]
|
|
11607
11944
|
);
|
|
11608
|
-
const maxUsdAmount = (0,
|
|
11945
|
+
const maxUsdAmount = (0, import_react31.useMemo)(() => {
|
|
11609
11946
|
if (!hasUsdPrice) return void 0;
|
|
11610
11947
|
return Math.min(maxTokenAmount * tokenPriceUSD, 1e4);
|
|
11611
11948
|
}, [hasUsdPrice, maxTokenAmount, tokenPriceUSD]);
|
|
11612
|
-
const minAmountForMode = (0,
|
|
11949
|
+
const minAmountForMode = (0, import_react31.useMemo)(() => {
|
|
11613
11950
|
if (minAmountUsd == null) return 0;
|
|
11614
11951
|
if (amountInputMode === "usd") {
|
|
11615
11952
|
return minAmountUsd;
|
|
@@ -11618,11 +11955,11 @@ function useDepositAmountModel({
|
|
|
11618
11955
|
return minAmountUsd / tokenPriceUSD;
|
|
11619
11956
|
}, [amountInputMode, hasUsdPrice, minAmountUsd, tokenPriceUSD]);
|
|
11620
11957
|
const sliderMax = amountInputMode === "usd" ? maxUsdAmount : maxTokenAmount;
|
|
11621
|
-
const effectiveSliderMax = (0,
|
|
11958
|
+
const effectiveSliderMax = (0, import_react31.useMemo)(() => {
|
|
11622
11959
|
if (sliderMax == null || !Number.isFinite(sliderMax)) return void 0;
|
|
11623
11960
|
return Math.max(sliderMax, 0);
|
|
11624
11961
|
}, [sliderMax]);
|
|
11625
|
-
const effectiveSliderMin = (0,
|
|
11962
|
+
const effectiveSliderMin = (0, import_react31.useMemo)(() => {
|
|
11626
11963
|
if (effectiveSliderMax == null || !Number.isFinite(effectiveSliderMax) || effectiveSliderMax <= 0) {
|
|
11627
11964
|
return 0;
|
|
11628
11965
|
}
|
|
@@ -11649,7 +11986,7 @@ function useDepositAmountModel({
|
|
|
11649
11986
|
}
|
|
11650
11987
|
|
|
11651
11988
|
// src/widget/features/amount/hooks/useHomeAmountModel.ts
|
|
11652
|
-
var
|
|
11989
|
+
var import_react32 = require("react");
|
|
11653
11990
|
function useHomeAmountModel({
|
|
11654
11991
|
amount,
|
|
11655
11992
|
setAmount,
|
|
@@ -11660,7 +11997,7 @@ function useHomeAmountModel({
|
|
|
11660
11997
|
minAmountUsd,
|
|
11661
11998
|
maxAmountUsd
|
|
11662
11999
|
}) {
|
|
11663
|
-
(0,
|
|
12000
|
+
(0, import_react32.useEffect)(() => {
|
|
11664
12001
|
if (!fixedFromAmountString) return;
|
|
11665
12002
|
if (amount !== fixedFromAmountString) {
|
|
11666
12003
|
setAmount(fixedFromAmountString);
|
|
@@ -11676,7 +12013,7 @@ function useHomeAmountModel({
|
|
|
11676
12013
|
setAmountInputMode
|
|
11677
12014
|
]);
|
|
11678
12015
|
const parsedAmount = parseFloat(fixedFromAmountString ?? amount) || 0;
|
|
11679
|
-
const amountValidationMessage = (0,
|
|
12016
|
+
const amountValidationMessage = (0, import_react32.useMemo)(() => {
|
|
11680
12017
|
const rawAmount = (fixedFromAmountString ?? amount)?.trim();
|
|
11681
12018
|
if (!rawAmount) return null;
|
|
11682
12019
|
if (!/^\d*\.?\d*$/.test(rawAmount)) {
|
|
@@ -11888,7 +12225,7 @@ function WalletConnectRow({
|
|
|
11888
12225
|
PaymentOptionRow,
|
|
11889
12226
|
{
|
|
11890
12227
|
onClick: () => void onClick(),
|
|
11891
|
-
label: "WalletConnect",
|
|
12228
|
+
label: "WalletConnect(EVM)",
|
|
11892
12229
|
icon: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { style: walletActionIconBoxStyle, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11893
12230
|
"svg",
|
|
11894
12231
|
{
|
|
@@ -12401,152 +12738,20 @@ function HomePaymentOptions({
|
|
|
12401
12738
|
}
|
|
12402
12739
|
|
|
12403
12740
|
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
12404
|
-
var
|
|
12405
|
-
|
|
12406
|
-
// src/config/walletconnect.ts
|
|
12407
|
-
var import_appkit_universal_connector = require("@reown/appkit-universal-connector");
|
|
12408
|
-
init_store();
|
|
12409
|
-
init_constants();
|
|
12410
|
-
var solanaMainnet = {
|
|
12411
|
-
id: 1,
|
|
12412
|
-
chainNamespace: "solana",
|
|
12413
|
-
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqAQ3H1FQ",
|
|
12414
|
-
name: "Solana Mainnet",
|
|
12415
|
-
nativeCurrency: {
|
|
12416
|
-
name: "Solana",
|
|
12417
|
-
symbol: "SOL",
|
|
12418
|
-
decimals: 9
|
|
12419
|
-
},
|
|
12420
|
-
rpcUrls: {
|
|
12421
|
-
default: {
|
|
12422
|
-
http: ["https://api.mainnet-beta.solana.com"]
|
|
12423
|
-
}
|
|
12424
|
-
}
|
|
12425
|
-
};
|
|
12426
|
-
var bitcoinMainnet = {
|
|
12427
|
-
id: 0,
|
|
12428
|
-
chainNamespace: "bip122",
|
|
12429
|
-
caipNetworkId: "bip122:000000000019d6689c085ae165831e93",
|
|
12430
|
-
name: "Bitcoin Mainnet",
|
|
12431
|
-
nativeCurrency: {
|
|
12432
|
-
name: "Bitcoin",
|
|
12433
|
-
symbol: "BTC",
|
|
12434
|
-
decimals: 8
|
|
12435
|
-
},
|
|
12436
|
-
rpcUrls: {
|
|
12437
|
-
default: {
|
|
12438
|
-
http: ["https://api.blockcypher.com/v1/btc/main"]
|
|
12439
|
-
}
|
|
12440
|
-
}
|
|
12441
|
-
};
|
|
12442
|
-
var ethereumMainnet = {
|
|
12443
|
-
id: 1,
|
|
12444
|
-
chainNamespace: "eip155",
|
|
12445
|
-
caipNetworkId: "eip155:1",
|
|
12446
|
-
name: "Ethereum Mainnet",
|
|
12447
|
-
nativeCurrency: {
|
|
12448
|
-
name: "Ether",
|
|
12449
|
-
symbol: "ETH",
|
|
12450
|
-
decimals: 18
|
|
12451
|
-
},
|
|
12452
|
-
rpcUrls: {
|
|
12453
|
-
default: {
|
|
12454
|
-
http: ["https://rpc.ankr.com/eth"]
|
|
12455
|
-
}
|
|
12456
|
-
}
|
|
12457
|
-
};
|
|
12458
|
-
var seiMainnet = {
|
|
12459
|
-
id: 1329,
|
|
12460
|
-
chainNamespace: "eip155",
|
|
12461
|
-
caipNetworkId: "eip155:1329",
|
|
12462
|
-
name: "Sei Mainnet",
|
|
12463
|
-
nativeCurrency: {
|
|
12464
|
-
name: "Sei",
|
|
12465
|
-
symbol: "SEI",
|
|
12466
|
-
decimals: 18
|
|
12467
|
-
},
|
|
12468
|
-
rpcUrls: {
|
|
12469
|
-
default: {
|
|
12470
|
-
http: ["https://evm-rpc.sei-apis.com"]
|
|
12471
|
-
}
|
|
12472
|
-
}
|
|
12473
|
-
};
|
|
12474
|
-
var universalConnectorPromise = null;
|
|
12475
|
-
function resolvedMetadata() {
|
|
12476
|
-
const cfg = TrustwareConfigStore.peek();
|
|
12477
|
-
const walletConnect = cfg ? cfg?.walletConnect : void 0;
|
|
12478
|
-
const configured = walletConnect?.metadata;
|
|
12479
|
-
const pageUrl = typeof window !== "undefined" && window.location?.origin ? window.location.origin : configured?.url;
|
|
12480
|
-
return {
|
|
12481
|
-
name: configured?.name ?? "Trustware",
|
|
12482
|
-
description: configured?.description ?? "Cross-chain bridge & top-up",
|
|
12483
|
-
url: pageUrl ?? "https://trustware.io",
|
|
12484
|
-
icons: configured?.icons?.length ? configured.icons : ["https://app.trustware.io/icon.png"]
|
|
12485
|
-
};
|
|
12486
|
-
}
|
|
12487
|
-
async function getUniversalConnector(walletCfg) {
|
|
12488
|
-
const projectId = walletCfg?.projectId ?? WALLETCONNECT_PROJECT_ID;
|
|
12489
|
-
if (!projectId) {
|
|
12490
|
-
console.warn(
|
|
12491
|
-
"[Trustware SDK] WalletConnect disabled: no projectId. Set TRUSTWARE_WALLETCONNECT_PROJECT_ID at build time or pass walletConnect.projectId in config."
|
|
12492
|
-
);
|
|
12493
|
-
return void 0;
|
|
12494
|
-
}
|
|
12495
|
-
if (!universalConnectorPromise) {
|
|
12496
|
-
universalConnectorPromise = import_appkit_universal_connector.UniversalConnector.init({
|
|
12497
|
-
projectId,
|
|
12498
|
-
metadata: resolvedMetadata(),
|
|
12499
|
-
networks: [
|
|
12500
|
-
{
|
|
12501
|
-
namespace: "solana",
|
|
12502
|
-
chains: [solanaMainnet],
|
|
12503
|
-
methods: ["solana_signMessage", "solana_signTransaction"],
|
|
12504
|
-
events: []
|
|
12505
|
-
},
|
|
12506
|
-
{
|
|
12507
|
-
namespace: "eip155",
|
|
12508
|
-
chains: [ethereumMainnet, seiMainnet],
|
|
12509
|
-
methods: ["eth_sendTransaction", "eth_sign", "personal_sign"],
|
|
12510
|
-
events: ["accountsChanged", "chainChanged"]
|
|
12511
|
-
},
|
|
12512
|
-
{
|
|
12513
|
-
namespace: "bip122",
|
|
12514
|
-
chains: [bitcoinMainnet],
|
|
12515
|
-
methods: ["btc_signMessage"],
|
|
12516
|
-
events: []
|
|
12517
|
-
}
|
|
12518
|
-
]
|
|
12519
|
-
}).catch((error) => {
|
|
12520
|
-
universalConnectorPromise = null;
|
|
12521
|
-
throw error;
|
|
12522
|
-
});
|
|
12523
|
-
}
|
|
12524
|
-
return universalConnectorPromise;
|
|
12525
|
-
}
|
|
12526
|
-
|
|
12527
|
-
// src/widget/features/wallet/hooks/useHomeWalletActions.ts
|
|
12528
|
-
init_config2();
|
|
12741
|
+
var import_react33 = require("react");
|
|
12529
12742
|
function useHomeWalletActions({
|
|
12530
12743
|
connectWallet,
|
|
12531
12744
|
detectedWallets,
|
|
12532
|
-
setCurrentStep
|
|
12745
|
+
setCurrentStep,
|
|
12746
|
+
setWalletType,
|
|
12747
|
+
WalletConnect
|
|
12533
12748
|
// setCurrentStepInternal,
|
|
12534
12749
|
}) {
|
|
12535
|
-
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0,
|
|
12536
|
-
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0,
|
|
12537
|
-
const
|
|
12538
|
-
const
|
|
12539
|
-
|
|
12540
|
-
(0, import_react32.useEffect)(() => {
|
|
12541
|
-
if (typeof window === "undefined") {
|
|
12542
|
-
return;
|
|
12543
|
-
}
|
|
12544
|
-
const walletConnect = TrustwareConfigStore.peek()?.walletConnect;
|
|
12545
|
-
getUniversalConnector(walletConnect).then(
|
|
12546
|
-
setUniversalConnector
|
|
12547
|
-
);
|
|
12548
|
-
}, [TrustwareConfigStore.peek()?.walletConnect]);
|
|
12549
|
-
(0, import_react32.useEffect)(() => {
|
|
12750
|
+
const [isCryptoDropdownOpen, setIsCryptoDropdownOpen] = (0, import_react33.useState)(false);
|
|
12751
|
+
const [isFiatDropdownOpen, setIsFiatDropdownOpen] = (0, import_react33.useState)(false);
|
|
12752
|
+
const cryptoDropdownRef = (0, import_react33.useRef)(null);
|
|
12753
|
+
const fiatDropdownRef = (0, import_react33.useRef)(null);
|
|
12754
|
+
(0, import_react33.useEffect)(() => {
|
|
12550
12755
|
const handleClickOutside = (event) => {
|
|
12551
12756
|
if (cryptoDropdownRef.current && !cryptoDropdownRef.current.contains(event.target)) {
|
|
12552
12757
|
setIsCryptoDropdownOpen(false);
|
|
@@ -12562,6 +12767,7 @@ function useHomeWalletActions({
|
|
|
12562
12767
|
const handleWalletSelect = async (wallet) => {
|
|
12563
12768
|
setIsCryptoDropdownOpen(false);
|
|
12564
12769
|
try {
|
|
12770
|
+
setWalletType("other");
|
|
12565
12771
|
const { error } = await connectWallet(wallet);
|
|
12566
12772
|
if (error) {
|
|
12567
12773
|
resetNavigation();
|
|
@@ -12576,13 +12782,7 @@ function useHomeWalletActions({
|
|
|
12576
12782
|
setIsFiatDropdownOpen(false);
|
|
12577
12783
|
};
|
|
12578
12784
|
const handleWalletConnect = async () => {
|
|
12579
|
-
|
|
12580
|
-
return;
|
|
12581
|
-
}
|
|
12582
|
-
const { session: providerSession } = await universalConnector.connect();
|
|
12583
|
-
if (providerSession) {
|
|
12584
|
-
setCurrentStep("select-token");
|
|
12585
|
-
}
|
|
12785
|
+
WalletConnect().catch(() => resetNavigation());
|
|
12586
12786
|
};
|
|
12587
12787
|
const browserWallets = detectedWallets.filter(
|
|
12588
12788
|
(wallet) => wallet.meta.id !== "walletconnect"
|
|
@@ -12606,7 +12806,7 @@ var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
|
12606
12806
|
function Home({ style: _style }) {
|
|
12607
12807
|
const { amount, setAmount, amountInputMode, setAmountInputMode } = useDepositForm();
|
|
12608
12808
|
const { setCurrentStep, setCurrentStepInternal } = useDepositNavigation();
|
|
12609
|
-
const { connectWallet } = useDepositWallet();
|
|
12809
|
+
const { connectWallet, WalletConnect, setWalletType } = useDepositWallet();
|
|
12610
12810
|
const { resolvedTheme } = useDepositUi();
|
|
12611
12811
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
12612
12812
|
const { detected: detectedWallets } = useWalletDetection();
|
|
@@ -12635,7 +12835,9 @@ function Home({ style: _style }) {
|
|
|
12635
12835
|
connectWallet,
|
|
12636
12836
|
detectedWallets,
|
|
12637
12837
|
setCurrentStep,
|
|
12638
|
-
setCurrentStepInternal
|
|
12838
|
+
setCurrentStepInternal,
|
|
12839
|
+
WalletConnect,
|
|
12840
|
+
setWalletType
|
|
12639
12841
|
});
|
|
12640
12842
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
12641
12843
|
"div",
|
|
@@ -12916,10 +13118,10 @@ function SelectToken({ style }) {
|
|
|
12916
13118
|
}
|
|
12917
13119
|
|
|
12918
13120
|
// src/widget/pages/CryptoPay/index.tsx
|
|
12919
|
-
var
|
|
13121
|
+
var import_react36 = require("react");
|
|
12920
13122
|
|
|
12921
13123
|
// src/widget/features/route-preview/hooks/useRoutePreviewModel.ts
|
|
12922
|
-
var
|
|
13124
|
+
var import_react34 = require("react");
|
|
12923
13125
|
function useRoutePreviewModel({
|
|
12924
13126
|
amountUsd,
|
|
12925
13127
|
amountValidationError,
|
|
@@ -12932,7 +13134,8 @@ function useRoutePreviewModel({
|
|
|
12932
13134
|
walletAddress
|
|
12933
13135
|
}) {
|
|
12934
13136
|
const { chains } = useChains();
|
|
12935
|
-
|
|
13137
|
+
console.log({ walletAddress });
|
|
13138
|
+
const destinationConfig = (0, import_react34.useMemo)(
|
|
12936
13139
|
() => ({
|
|
12937
13140
|
dappName: config.messages?.title || "DApp",
|
|
12938
13141
|
toChain: config.routes.toChain,
|
|
@@ -12946,7 +13149,7 @@ function useRoutePreviewModel({
|
|
|
12946
13149
|
config.routes.toToken
|
|
12947
13150
|
]
|
|
12948
13151
|
);
|
|
12949
|
-
const routeConfig = (0,
|
|
13152
|
+
const routeConfig = (0, import_react34.useMemo)(() => {
|
|
12950
13153
|
const toChainId = config.routes.toChain;
|
|
12951
13154
|
const toChainKey = normalizeChainKey2(toChainId);
|
|
12952
13155
|
const toChain = toChainKey ? chains.find(
|
|
@@ -12980,7 +13183,7 @@ function useRoutePreviewModel({
|
|
|
12980
13183
|
walletAddress
|
|
12981
13184
|
]);
|
|
12982
13185
|
const routeBuilderState = useRouteBuilder(routeConfig);
|
|
12983
|
-
const routePrerequisiteError = (0,
|
|
13186
|
+
const routePrerequisiteError = (0, import_react34.useMemo)(() => {
|
|
12984
13187
|
if (!isReady) return;
|
|
12985
13188
|
if (!selectedChain) {
|
|
12986
13189
|
return "Select a source chain to fetch a route.";
|
|
@@ -13419,7 +13622,7 @@ function SuccessSummaryCard({
|
|
|
13419
13622
|
}
|
|
13420
13623
|
|
|
13421
13624
|
// src/widget/features/transaction/hooks/useTransactionActionModel.ts
|
|
13422
|
-
var
|
|
13625
|
+
var import_react35 = require("react");
|
|
13423
13626
|
var import_viem2 = require("viem");
|
|
13424
13627
|
init_constants();
|
|
13425
13628
|
function normalizeTokenAddressForCompare(chain, addr) {
|
|
@@ -13442,7 +13645,7 @@ function useTransactionActionModel({
|
|
|
13442
13645
|
walletAddress,
|
|
13443
13646
|
walletStatus
|
|
13444
13647
|
}) {
|
|
13445
|
-
const feeDataCacheRef = (0,
|
|
13648
|
+
const feeDataCacheRef = (0, import_react35.useRef)({});
|
|
13446
13649
|
const { isSubmitting, submitTransaction } = useTransactionSubmit();
|
|
13447
13650
|
const { trackEvent } = useGTM(GTM_ID);
|
|
13448
13651
|
const destinationConfig = (() => {
|
|
@@ -13455,7 +13658,7 @@ function useTransactionActionModel({
|
|
|
13455
13658
|
const chainType = selectedChain?.type ?? selectedChain?.chainType;
|
|
13456
13659
|
const chainTypeNormalized = (chainType ?? "").toLowerCase();
|
|
13457
13660
|
const isEvm = chainTypeNormalized === "evm";
|
|
13458
|
-
const backendChainId2 = (0,
|
|
13661
|
+
const backendChainId2 = (0, import_react35.useMemo)(() => {
|
|
13459
13662
|
const chainRef = routeResult?.txReq?.chainId ?? selectedChain?.networkIdentifier ?? selectedChain?.chainId ?? selectedChain?.id;
|
|
13460
13663
|
if (chainRef == null) return null;
|
|
13461
13664
|
return String(chainRef);
|
|
@@ -13465,23 +13668,23 @@ function useTransactionActionModel({
|
|
|
13465
13668
|
selectedChain?.id,
|
|
13466
13669
|
selectedChain?.networkIdentifier
|
|
13467
13670
|
]);
|
|
13468
|
-
const isNativeSelected = (0,
|
|
13671
|
+
const isNativeSelected = (0, import_react35.useMemo)(() => {
|
|
13469
13672
|
const address = selectedToken?.address;
|
|
13470
13673
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
13471
13674
|
selectedChain,
|
|
13472
13675
|
getNativeTokenAddress2(chainType)
|
|
13473
13676
|
);
|
|
13474
13677
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
13475
|
-
const spender = (0,
|
|
13678
|
+
const spender = (0, import_react35.useMemo)(() => {
|
|
13476
13679
|
const txReq = routeResult?.txReq;
|
|
13477
13680
|
const addr = txReq?.to ?? txReq?.target;
|
|
13478
13681
|
return addr ?? null;
|
|
13479
13682
|
}, [routeResult?.txReq]);
|
|
13480
|
-
const [allowanceWei, setAllowanceWei] = (0,
|
|
13481
|
-
const [isReadingAllowance, setIsReadingAllowance] = (0,
|
|
13482
|
-
const [isApproving, setIsApproving] = (0,
|
|
13483
|
-
const [gasReservationWei, setGasReservationWei] = (0,
|
|
13484
|
-
const readAllowance = (0,
|
|
13683
|
+
const [allowanceWei, setAllowanceWei] = (0, import_react35.useState)(0n);
|
|
13684
|
+
const [isReadingAllowance, setIsReadingAllowance] = (0, import_react35.useState)(false);
|
|
13685
|
+
const [isApproving, setIsApproving] = (0, import_react35.useState)(false);
|
|
13686
|
+
const [gasReservationWei, setGasReservationWei] = (0, import_react35.useState)(0n);
|
|
13687
|
+
const readAllowance = (0, import_react35.useCallback)(async () => {
|
|
13485
13688
|
if (!isEvm || isNativeSelected || !backendChainId2 || !walletAddress || !spender || !selectedToken?.address) {
|
|
13486
13689
|
setAllowanceWei(0n);
|
|
13487
13690
|
return;
|
|
@@ -13508,11 +13711,11 @@ function useTransactionActionModel({
|
|
|
13508
13711
|
spender,
|
|
13509
13712
|
walletAddress
|
|
13510
13713
|
]);
|
|
13511
|
-
(0,
|
|
13714
|
+
(0, import_react35.useEffect)(() => {
|
|
13512
13715
|
void readAllowance();
|
|
13513
13716
|
}, [readAllowance]);
|
|
13514
13717
|
const needsApproval = isEvm && !isNativeSelected && !!walletAddress && !!spender && amountWei > 0n && allowanceWei < amountWei;
|
|
13515
|
-
const waitForApprovalConfirmation = (0,
|
|
13718
|
+
const waitForApprovalConfirmation = (0, import_react35.useCallback)(
|
|
13516
13719
|
async (chainId, txHash) => {
|
|
13517
13720
|
const timeoutMs = 12e4;
|
|
13518
13721
|
const intervalMs = 2e3;
|
|
@@ -13531,7 +13734,7 @@ function useTransactionActionModel({
|
|
|
13531
13734
|
},
|
|
13532
13735
|
[]
|
|
13533
13736
|
);
|
|
13534
|
-
const handleApproveExact = (0,
|
|
13737
|
+
const handleApproveExact = (0, import_react35.useCallback)(async () => {
|
|
13535
13738
|
if (isApproving || amountWei <= 0n || !walletAddress || !spender || !selectedToken?.address) {
|
|
13536
13739
|
return;
|
|
13537
13740
|
}
|
|
@@ -13619,7 +13822,7 @@ function useTransactionActionModel({
|
|
|
13619
13822
|
waitForApprovalConfirmation,
|
|
13620
13823
|
walletAddress
|
|
13621
13824
|
]);
|
|
13622
|
-
const getCachedFeeData = (0,
|
|
13825
|
+
const getCachedFeeData = (0, import_react35.useCallback)(async () => {
|
|
13623
13826
|
if (!backendChainId2) return {};
|
|
13624
13827
|
const now = Date.now();
|
|
13625
13828
|
const cache = feeDataCacheRef.current;
|
|
@@ -13642,7 +13845,7 @@ function useTransactionActionModel({
|
|
|
13642
13845
|
}
|
|
13643
13846
|
return cache.inflight;
|
|
13644
13847
|
}, [backendChainId2]);
|
|
13645
|
-
const estimateGasReservationWei = (0,
|
|
13848
|
+
const estimateGasReservationWei = (0, import_react35.useCallback)(async () => {
|
|
13646
13849
|
if (!isNativeSelected) {
|
|
13647
13850
|
setGasReservationWei(0n);
|
|
13648
13851
|
return 0n;
|
|
@@ -13706,12 +13909,12 @@ function useTransactionActionModel({
|
|
|
13706
13909
|
routeResult?.txReq,
|
|
13707
13910
|
walletAddress
|
|
13708
13911
|
]);
|
|
13709
|
-
(0,
|
|
13912
|
+
(0, import_react35.useEffect)(() => {
|
|
13710
13913
|
if (routeResult) {
|
|
13711
13914
|
void estimateGasReservationWei();
|
|
13712
13915
|
}
|
|
13713
13916
|
}, [estimateGasReservationWei, routeResult]);
|
|
13714
|
-
const handleConfirm = (0,
|
|
13917
|
+
const handleConfirm = (0, import_react35.useCallback)(async () => {
|
|
13715
13918
|
if (!routeResult) {
|
|
13716
13919
|
return;
|
|
13717
13920
|
}
|
|
@@ -13734,7 +13937,7 @@ function useTransactionActionModel({
|
|
|
13734
13937
|
submitTransaction,
|
|
13735
13938
|
trackEvent
|
|
13736
13939
|
]);
|
|
13737
|
-
const handleSwipeConfirm = (0,
|
|
13940
|
+
const handleSwipeConfirm = (0, import_react35.useCallback)(async () => {
|
|
13738
13941
|
if (needsApproval) {
|
|
13739
13942
|
await handleApproveExact();
|
|
13740
13943
|
return;
|
|
@@ -13743,7 +13946,7 @@ function useTransactionActionModel({
|
|
|
13743
13946
|
}, [handleApproveExact, handleConfirm, needsApproval]);
|
|
13744
13947
|
const isWalletConnected = walletStatus === "connected";
|
|
13745
13948
|
const canSwipe = parsedAmount > 0 && !!selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
13746
|
-
const swipeResetKey = (0,
|
|
13949
|
+
const swipeResetKey = (0, import_react35.useMemo)(() => {
|
|
13747
13950
|
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
13748
13951
|
selectedToken.address,
|
|
13749
13952
|
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
@@ -13957,6 +14160,7 @@ function CryptoPay({ style: _style }) {
|
|
|
13957
14160
|
} = useDepositForm();
|
|
13958
14161
|
const {
|
|
13959
14162
|
walletAddress,
|
|
14163
|
+
walletType,
|
|
13960
14164
|
walletStatus,
|
|
13961
14165
|
yourWalletTokens,
|
|
13962
14166
|
yourWalletTokensLoading
|
|
@@ -13964,17 +14168,17 @@ function CryptoPay({ style: _style }) {
|
|
|
13964
14168
|
const { goBack, setCurrentStep, currentStep } = useDepositNavigation();
|
|
13965
14169
|
const config = useTrustwareConfig();
|
|
13966
14170
|
const { fixedFromAmountString, isFixedAmount, minAmountUsd, maxAmountUsd } = useAmountConstraints();
|
|
13967
|
-
const routeRefreshMs = (0,
|
|
14171
|
+
const routeRefreshMs = (0, import_react36.useMemo)(() => {
|
|
13968
14172
|
const raw = config.routes?.options?.routeRefreshMs;
|
|
13969
14173
|
const n = Number(raw);
|
|
13970
14174
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
13971
14175
|
}, [config.routes?.options?.routeRefreshMs]);
|
|
13972
14176
|
const IsPos = (x) => x !== null && x !== void 0 && x.balance !== "0";
|
|
13973
|
-
const showDefaultCryptoPay = (0,
|
|
14177
|
+
const showDefaultCryptoPay = (0, import_react36.useMemo)(() => {
|
|
13974
14178
|
const nonZer0Tks = (yourWalletTokens ?? []).filter(IsPos);
|
|
13975
14179
|
return !yourWalletTokensLoading && nonZer0Tks.length === 0 && yourWalletTokens.length > 0;
|
|
13976
14180
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
13977
|
-
const showSkeleton = (0,
|
|
14181
|
+
const showSkeleton = (0, import_react36.useMemo)(() => {
|
|
13978
14182
|
return yourWalletTokensLoading || (yourWalletTokens ?? []).length === 0;
|
|
13979
14183
|
}, [yourWalletTokens, yourWalletTokensLoading]);
|
|
13980
14184
|
const isReady = !yourWalletTokensLoading && selectedToken != null && selectedToken?.chainData !== void 0 && !showDefaultCryptoPay && !showSkeleton;
|
|
@@ -14036,6 +14240,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14036
14240
|
selectedChain,
|
|
14037
14241
|
selectedToken,
|
|
14038
14242
|
walletAddress,
|
|
14243
|
+
walletType,
|
|
14039
14244
|
walletStatus
|
|
14040
14245
|
});
|
|
14041
14246
|
const { handleTokenChange, orderedTokens } = useOrderedWalletTokens({
|
|
@@ -14048,7 +14253,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14048
14253
|
});
|
|
14049
14254
|
const { emitError } = useTrustware();
|
|
14050
14255
|
const readySelectedToken = isReady ? selectedToken : null;
|
|
14051
|
-
(0,
|
|
14256
|
+
(0, import_react36.useEffect)(() => {
|
|
14052
14257
|
if (currentStep !== "crypto-pay" || !actionErrorMessage) return;
|
|
14053
14258
|
emitError?.(
|
|
14054
14259
|
new TrustwareError({
|
|
@@ -14143,7 +14348,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14143
14348
|
isApproving,
|
|
14144
14349
|
isLoadingRoute,
|
|
14145
14350
|
isReadingAllowance,
|
|
14146
|
-
isWalletConnected,
|
|
14351
|
+
isWalletConnected: isWalletConnected ? isWalletConnected : walletAddress !== null && walletType == "walletconnect" ? true : false,
|
|
14147
14352
|
needsApproval,
|
|
14148
14353
|
selectedToken: readySelectedToken,
|
|
14149
14354
|
swipeResetKey
|
|
@@ -14159,7 +14364,7 @@ function CryptoPay({ style: _style }) {
|
|
|
14159
14364
|
}
|
|
14160
14365
|
|
|
14161
14366
|
// src/widget/pages/Processing.tsx
|
|
14162
|
-
var
|
|
14367
|
+
var import_react37 = require("react");
|
|
14163
14368
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
14164
14369
|
function getProgressFromStatus(status) {
|
|
14165
14370
|
switch (status) {
|
|
@@ -14198,27 +14403,27 @@ function Processing({ style }) {
|
|
|
14198
14403
|
const { resetState, setCurrentStep } = useDepositNavigation();
|
|
14199
14404
|
const { transactionStatus, transactionHash, intentId } = useDepositTransaction();
|
|
14200
14405
|
const { transaction, startPolling, isPolling } = useTransactionPolling();
|
|
14201
|
-
const hasStartedPolling = (0,
|
|
14202
|
-
(0,
|
|
14406
|
+
const hasStartedPolling = (0, import_react37.useRef)(false);
|
|
14407
|
+
(0, import_react37.useEffect)(() => {
|
|
14203
14408
|
return () => {
|
|
14204
14409
|
hasStartedPolling.current = false;
|
|
14205
14410
|
};
|
|
14206
14411
|
}, []);
|
|
14207
|
-
(0,
|
|
14412
|
+
(0, import_react37.useEffect)(() => {
|
|
14208
14413
|
if (intentId && transactionHash && !isPolling && !hasStartedPolling.current && transactionStatus !== "success" && transactionStatus !== "error") {
|
|
14209
14414
|
hasStartedPolling.current = true;
|
|
14210
14415
|
startPolling(intentId, transactionHash);
|
|
14211
14416
|
}
|
|
14212
14417
|
}, [intentId, transactionHash, isPolling, transactionStatus, startPolling]);
|
|
14213
|
-
const progress = (0,
|
|
14418
|
+
const progress = (0, import_react37.useMemo)(
|
|
14214
14419
|
() => getProgressFromStatus(transactionStatus),
|
|
14215
14420
|
[transactionStatus]
|
|
14216
14421
|
);
|
|
14217
|
-
const stepText = (0,
|
|
14422
|
+
const stepText = (0, import_react37.useMemo)(
|
|
14218
14423
|
() => getStepText(transactionStatus),
|
|
14219
14424
|
[transactionStatus]
|
|
14220
14425
|
);
|
|
14221
|
-
const explorerUrl = (0,
|
|
14426
|
+
const explorerUrl = (0, import_react37.useMemo)(() => {
|
|
14222
14427
|
if (transaction?.fromChainTxUrl) {
|
|
14223
14428
|
return transaction.fromChainTxUrl;
|
|
14224
14429
|
}
|
|
@@ -14355,16 +14560,16 @@ function Processing({ style }) {
|
|
|
14355
14560
|
}
|
|
14356
14561
|
|
|
14357
14562
|
// src/widget/pages/Success.tsx
|
|
14358
|
-
var
|
|
14563
|
+
var import_react38 = require("react");
|
|
14359
14564
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
14360
|
-
var ConfettiEffect2 = (0,
|
|
14565
|
+
var ConfettiEffect2 = (0, import_react38.lazy)(() => Promise.resolve().then(() => (init_ConfettiEffect(), ConfettiEffect_exports)));
|
|
14361
14566
|
function Success({ style }) {
|
|
14362
14567
|
const { selectedToken, selectedChain, amount } = useDepositForm();
|
|
14363
14568
|
const { resetState } = useDepositNavigation();
|
|
14364
14569
|
const { transactionHash } = useDepositTransaction();
|
|
14365
14570
|
const { transaction } = useTransactionPolling();
|
|
14366
|
-
const parsedAmount = (0,
|
|
14367
|
-
const explorerUrl = (0,
|
|
14571
|
+
const parsedAmount = (0, import_react38.useMemo)(() => parseFloat(amount) || 0, [amount]);
|
|
14572
|
+
const explorerUrl = (0, import_react38.useMemo)(() => {
|
|
14368
14573
|
if (transaction?.toChainTxUrl) {
|
|
14369
14574
|
return transaction.toChainTxUrl;
|
|
14370
14575
|
}
|
|
@@ -14392,7 +14597,7 @@ function Success({ style }) {
|
|
|
14392
14597
|
...style
|
|
14393
14598
|
},
|
|
14394
14599
|
children: [
|
|
14395
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
14600
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_react38.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ConfettiEffect2, { isActive: true, pieceCount: 60, clearDelay: 4e3 }) }),
|
|
14396
14601
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(WidgetPageHeader, { title: "Deposit Complete" }),
|
|
14397
14602
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
14398
14603
|
"div",
|
|
@@ -14427,7 +14632,7 @@ function Success({ style }) {
|
|
|
14427
14632
|
}
|
|
14428
14633
|
|
|
14429
14634
|
// src/widget/pages/Error.tsx
|
|
14430
|
-
var
|
|
14635
|
+
var import_react39 = require("react");
|
|
14431
14636
|
init_store();
|
|
14432
14637
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
14433
14638
|
function categorizeError(errorMessage) {
|
|
@@ -14516,20 +14721,20 @@ function Error2({ style }) {
|
|
|
14516
14721
|
setErrorMessage,
|
|
14517
14722
|
transactionHash
|
|
14518
14723
|
} = useDepositTransaction();
|
|
14519
|
-
const errorCategory = (0,
|
|
14724
|
+
const errorCategory = (0, import_react39.useMemo)(
|
|
14520
14725
|
() => categorizeError(errorMessage),
|
|
14521
14726
|
[errorMessage]
|
|
14522
14727
|
);
|
|
14523
|
-
const errorTitle = (0,
|
|
14728
|
+
const errorTitle = (0, import_react39.useMemo)(
|
|
14524
14729
|
() => getErrorTitle(errorCategory),
|
|
14525
14730
|
[errorCategory]
|
|
14526
14731
|
);
|
|
14527
|
-
const errorSuggestion = (0,
|
|
14732
|
+
const errorSuggestion = (0, import_react39.useMemo)(
|
|
14528
14733
|
() => getErrorSuggestion(errorCategory),
|
|
14529
14734
|
[errorCategory]
|
|
14530
14735
|
);
|
|
14531
|
-
const retryStep = (0,
|
|
14532
|
-
(0,
|
|
14736
|
+
const retryStep = (0, import_react39.useMemo)(() => getRetryStep(errorCategory), [errorCategory]);
|
|
14737
|
+
(0, import_react39.useEffect)(() => {
|
|
14533
14738
|
if (errorMessage) {
|
|
14534
14739
|
try {
|
|
14535
14740
|
const config = TrustwareConfigStore.get();
|
|
@@ -14551,7 +14756,7 @@ function Error2({ style }) {
|
|
|
14551
14756
|
const handleStartOver = () => {
|
|
14552
14757
|
resetState();
|
|
14553
14758
|
};
|
|
14554
|
-
const explorerUrl = (0,
|
|
14759
|
+
const explorerUrl = (0, import_react39.useMemo)(() => {
|
|
14555
14760
|
if (transactionHash && selectedChain?.blockExplorerUrls?.length) {
|
|
14556
14761
|
return `${selectedChain.blockExplorerUrls[0].replace(/\/+$/, "")}/tx/${transactionHash}`;
|
|
14557
14762
|
}
|
|
@@ -14689,11 +14894,11 @@ function WidgetRouter({
|
|
|
14689
14894
|
navigationDirection,
|
|
14690
14895
|
stepHistory
|
|
14691
14896
|
}) {
|
|
14692
|
-
const PageComponent = (0,
|
|
14897
|
+
const PageComponent = (0, import_react40.useMemo)(
|
|
14693
14898
|
() => PAGE_COMPONENTS[currentStep],
|
|
14694
14899
|
[currentStep]
|
|
14695
14900
|
);
|
|
14696
|
-
const animationClass = (0,
|
|
14901
|
+
const animationClass = (0, import_react40.useMemo)(() => {
|
|
14697
14902
|
return navigationDirection === "forward" ? "tw-animate-slide-in-right" : "tw-animate-slide-in-left";
|
|
14698
14903
|
}, [navigationDirection]);
|
|
14699
14904
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
@@ -14730,7 +14935,7 @@ function WidgetContent({
|
|
|
14730
14935
|
const { amount, selectedChain, selectedToken } = useDepositForm();
|
|
14731
14936
|
const { transactionHash, transactionStatus } = useDepositTransaction();
|
|
14732
14937
|
const { resolvedTheme, toggleTheme } = useDepositUi();
|
|
14733
|
-
(0,
|
|
14938
|
+
(0, import_react41.useEffect)(() => {
|
|
14734
14939
|
const state = {
|
|
14735
14940
|
currentStep,
|
|
14736
14941
|
amount,
|
|
@@ -14773,8 +14978,8 @@ function WidgetInner({
|
|
|
14773
14978
|
const { transactionStatus } = useDepositTransaction();
|
|
14774
14979
|
const { resolvedTheme } = useDepositUi();
|
|
14775
14980
|
const { status, revalidate } = useTrustware();
|
|
14776
|
-
const [showConfirmDialog, setShowConfirmDialog] = (0,
|
|
14777
|
-
const handleCloseRequest = (0,
|
|
14981
|
+
const [showConfirmDialog, setShowConfirmDialog] = (0, import_react41.useState)(false);
|
|
14982
|
+
const handleCloseRequest = (0, import_react41.useCallback)(() => {
|
|
14778
14983
|
if (ACTIVE_TRANSACTION_STATUSES.includes(transactionStatus)) {
|
|
14779
14984
|
setShowConfirmDialog(true);
|
|
14780
14985
|
} else {
|
|
@@ -14785,20 +14990,20 @@ function WidgetInner({
|
|
|
14785
14990
|
onClose?.();
|
|
14786
14991
|
}
|
|
14787
14992
|
}, [transactionStatus, onClose, resetState]);
|
|
14788
|
-
(0,
|
|
14993
|
+
(0, import_react41.useEffect)(() => {
|
|
14789
14994
|
closeRequestRef.current = handleCloseRequest;
|
|
14790
14995
|
}, [handleCloseRequest, closeRequestRef]);
|
|
14791
|
-
const handleConfirmClose = (0,
|
|
14996
|
+
const handleConfirmClose = (0, import_react41.useCallback)(() => {
|
|
14792
14997
|
setShowConfirmDialog(false);
|
|
14793
14998
|
onClose?.();
|
|
14794
14999
|
}, [onClose]);
|
|
14795
|
-
const handleCancelClose = (0,
|
|
15000
|
+
const handleCancelClose = (0, import_react41.useCallback)(() => {
|
|
14796
15001
|
setShowConfirmDialog(false);
|
|
14797
15002
|
}, []);
|
|
14798
15003
|
const effectiveTheme = resolvedTheme;
|
|
14799
15004
|
const isRefreshing = status === "initializing";
|
|
14800
15005
|
const initBlocked = status === "error";
|
|
14801
|
-
const handleRefresh = (0,
|
|
15006
|
+
const handleRefresh = (0, import_react41.useCallback)(() => {
|
|
14802
15007
|
revalidate?.();
|
|
14803
15008
|
}, [revalidate]);
|
|
14804
15009
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
@@ -14831,7 +15036,7 @@ function WidgetInner({
|
|
|
14831
15036
|
)
|
|
14832
15037
|
] });
|
|
14833
15038
|
}
|
|
14834
|
-
var TrustwareWidgetV2 = (0,
|
|
15039
|
+
var TrustwareWidgetV2 = (0, import_react41.forwardRef)(function TrustwareWidgetV22({
|
|
14835
15040
|
theme = "system",
|
|
14836
15041
|
style,
|
|
14837
15042
|
initialStep = "home",
|
|
@@ -14840,14 +15045,14 @@ var TrustwareWidgetV2 = (0, import_react40.forwardRef)(function TrustwareWidgetV
|
|
|
14840
15045
|
onOpen,
|
|
14841
15046
|
showThemeToggle = true
|
|
14842
15047
|
}, ref) {
|
|
14843
|
-
const [isOpen, setIsOpen] = (0,
|
|
14844
|
-
const closeRequestRef = (0,
|
|
15048
|
+
const [isOpen, setIsOpen] = (0, import_react41.useState)(defaultOpen);
|
|
15049
|
+
const closeRequestRef = (0, import_react41.useRef)(null);
|
|
14845
15050
|
const effectiveInitialStep = initialStep;
|
|
14846
|
-
const open = (0,
|
|
15051
|
+
const open = (0, import_react41.useCallback)(() => {
|
|
14847
15052
|
setIsOpen(true);
|
|
14848
15053
|
onOpen?.();
|
|
14849
15054
|
}, [onOpen]);
|
|
14850
|
-
const close = (0,
|
|
15055
|
+
const close = (0, import_react41.useCallback)(() => {
|
|
14851
15056
|
if (closeRequestRef.current) {
|
|
14852
15057
|
closeRequestRef.current();
|
|
14853
15058
|
} else {
|
|
@@ -14855,11 +15060,11 @@ var TrustwareWidgetV2 = (0, import_react40.forwardRef)(function TrustwareWidgetV
|
|
|
14855
15060
|
onClose?.();
|
|
14856
15061
|
}
|
|
14857
15062
|
}, [onClose]);
|
|
14858
|
-
const handleClose = (0,
|
|
15063
|
+
const handleClose = (0, import_react41.useCallback)(() => {
|
|
14859
15064
|
setIsOpen(false);
|
|
14860
15065
|
onClose?.();
|
|
14861
15066
|
}, [onClose]);
|
|
14862
|
-
(0,
|
|
15067
|
+
(0, import_react41.useImperativeHandle)(
|
|
14863
15068
|
ref,
|
|
14864
15069
|
() => ({
|
|
14865
15070
|
open,
|