@orderly.network/wallet-connector-privy 2.8.1 → 2.8.2-alpha.0
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/index.js +98 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -50,11 +50,11 @@ var Network = /* @__PURE__ */ ((Network3) => {
|
|
|
50
50
|
Network3["testnet"] = "testnet";
|
|
51
51
|
return Network3;
|
|
52
52
|
})(Network || {});
|
|
53
|
-
var WalletType = /* @__PURE__ */ ((
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
53
|
+
var WalletType = /* @__PURE__ */ ((WalletType4) => {
|
|
54
|
+
WalletType4["EVM"] = "EVM";
|
|
55
|
+
WalletType4["SOL"] = "SOL";
|
|
56
|
+
WalletType4["ABSTRACT"] = "Abstract";
|
|
57
|
+
return WalletType4;
|
|
58
58
|
})(WalletType || {});
|
|
59
59
|
var WalletConnectType = /* @__PURE__ */ ((WalletConnectType2) => {
|
|
60
60
|
WalletConnectType2["EVM"] = "EVM";
|
|
@@ -1647,7 +1647,24 @@ function EVMConnectArea({
|
|
|
1647
1647
|
// src/components/renderConnector/index.tsx
|
|
1648
1648
|
function RenderConnector() {
|
|
1649
1649
|
const { connect } = useWallet2();
|
|
1650
|
-
const {
|
|
1650
|
+
const {
|
|
1651
|
+
setOpenConnectDrawer,
|
|
1652
|
+
connectorWalletType,
|
|
1653
|
+
walletChainTypeConfig,
|
|
1654
|
+
targetWalletType
|
|
1655
|
+
} = useWalletConnectorPrivy();
|
|
1656
|
+
const { storageChain } = hooks.useStorageChain();
|
|
1657
|
+
const selectedWalletType = (() => {
|
|
1658
|
+
if (targetWalletType)
|
|
1659
|
+
return targetWalletType;
|
|
1660
|
+
if (!storageChain?.chainId)
|
|
1661
|
+
return void 0;
|
|
1662
|
+
try {
|
|
1663
|
+
return getChainType(parseInt(storageChain.chainId));
|
|
1664
|
+
} catch {
|
|
1665
|
+
return void 0;
|
|
1666
|
+
}
|
|
1667
|
+
})();
|
|
1651
1668
|
const handleConnect = (params) => {
|
|
1652
1669
|
connect(params);
|
|
1653
1670
|
if (params.walletType === "privy" /* PRIVY */) {
|
|
@@ -1716,7 +1733,30 @@ function RenderConnector() {
|
|
|
1716
1733
|
}
|
|
1717
1734
|
);
|
|
1718
1735
|
};
|
|
1719
|
-
|
|
1736
|
+
const walletOrder = ["evm", "sol", "abstract"];
|
|
1737
|
+
const typeToKey = {
|
|
1738
|
+
["EVM" /* EVM */]: "evm",
|
|
1739
|
+
["SOL" /* SOL */]: "sol",
|
|
1740
|
+
["Abstract" /* ABSTRACT */]: "abstract"
|
|
1741
|
+
};
|
|
1742
|
+
const prioritizedKey = selectedWalletType ? typeToKey[selectedWalletType] : void 0;
|
|
1743
|
+
const orderedWalletKeys = prioritizedKey ? [
|
|
1744
|
+
prioritizedKey,
|
|
1745
|
+
...walletOrder.filter((k) => k !== prioritizedKey)
|
|
1746
|
+
] : walletOrder;
|
|
1747
|
+
const renderByKey = (key) => {
|
|
1748
|
+
switch (key) {
|
|
1749
|
+
case "evm":
|
|
1750
|
+
return renderWagmiConnectArea();
|
|
1751
|
+
case "sol":
|
|
1752
|
+
return renderSolanaConnectArea();
|
|
1753
|
+
case "abstract":
|
|
1754
|
+
return renderAbstractConnectArea();
|
|
1755
|
+
default:
|
|
1756
|
+
return null;
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
return /* @__PURE__ */ React19__default.default.createElement(ui.ScrollArea, { className: "oui-flex oui-grow oui-shrik oui-basis-auto oui-custom-scrollbar" }, /* @__PURE__ */ React19__default.default.createElement("div", { className: ui.cn("oui-flex oui-flex-col oui-gap-4", "md:oui-gap-5") }, renderPrivyConnectArea(), orderedWalletKeys.map((key) => /* @__PURE__ */ React19__default.default.createElement(React19__default.default.Fragment, { key }, renderByKey(key)))));
|
|
1720
1760
|
}
|
|
1721
1761
|
function SwitchNetworkTips({
|
|
1722
1762
|
tipsContent
|
|
@@ -3148,19 +3188,6 @@ var WagmiWallet = (props) => {
|
|
|
3148
3188
|
};
|
|
3149
3189
|
|
|
3150
3190
|
// src/provider.tsx
|
|
3151
|
-
var commonSwrOpts = {
|
|
3152
|
-
revalidateIfStale: false,
|
|
3153
|
-
revalidateOnFocus: false,
|
|
3154
|
-
revalidateOnReconnect: false,
|
|
3155
|
-
// If false, undefined data gets cached against the key.
|
|
3156
|
-
revalidateOnMount: true,
|
|
3157
|
-
// don't duplicate a request with the same key for 1hr
|
|
3158
|
-
dedupingInterval: 36e5
|
|
3159
|
-
};
|
|
3160
|
-
types.TesntTokenFallback([
|
|
3161
|
-
types.ArbitrumSepoliaTokenInfo,
|
|
3162
|
-
types.SolanaDevnetTokenInfo
|
|
3163
|
-
]);
|
|
3164
3191
|
var testnetChainFallback = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
|
|
3165
3192
|
var formatSwapChainInfo = (data = {}) => {
|
|
3166
3193
|
return Object.keys(data).map((key) => {
|
|
@@ -3245,7 +3272,18 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3245
3272
|
const [initChains, setInitChains] = React19.useState([]);
|
|
3246
3273
|
const [mainnetChains, setMainnetChains] = React19.useState([]);
|
|
3247
3274
|
const [testnetChains, setTestnetChains] = React19.useState([]);
|
|
3248
|
-
const
|
|
3275
|
+
const [mainnetChainInfos, setMainnetChainInfos] = React19.useState(null);
|
|
3276
|
+
const [testChainInfos, setTestChainInfos] = React19.useState(
|
|
3277
|
+
null
|
|
3278
|
+
);
|
|
3279
|
+
const fetchMainChains = hooks.useMainnetChainsStore((state) => state.fetchData);
|
|
3280
|
+
const fetchTestChains = hooks.useTestnetChainsStore((state) => state.fetchData);
|
|
3281
|
+
const mainnetChainInfosFromStore = hooks.useMainnetChainsStore(
|
|
3282
|
+
(state) => state.data
|
|
3283
|
+
);
|
|
3284
|
+
const testChainInfosFromStore = hooks.useTestnetChainsStore((state) => state.data);
|
|
3285
|
+
const hasCustomChains = Array.isArray(props.customChains) && props.customChains.length > 0;
|
|
3286
|
+
const initRef = React19.useRef(hasCustomChains);
|
|
3249
3287
|
const [openConnectDrawer, setOpenConnectDrawer] = React19.useState(false);
|
|
3250
3288
|
const [targetWalletType, setTargetWalletType] = React19.useState();
|
|
3251
3289
|
const [privyConfig, setPrivyConfig] = React19.useState({
|
|
@@ -3290,24 +3328,24 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3290
3328
|
});
|
|
3291
3329
|
return chainTypeObj;
|
|
3292
3330
|
}, [initChains]);
|
|
3293
|
-
const {
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
);
|
|
3298
|
-
|
|
3299
|
-
!props.
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
);
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
}
|
|
3310
|
-
);
|
|
3331
|
+
const {
|
|
3332
|
+
data: swapChainInfoRes,
|
|
3333
|
+
// loading: swapLoading,
|
|
3334
|
+
fetchData: fetchSwapData
|
|
3335
|
+
} = hooks.useSwapSupportStore();
|
|
3336
|
+
React19.useEffect(() => {
|
|
3337
|
+
if (!props.enableSwapDeposit || !!props.customChains)
|
|
3338
|
+
return;
|
|
3339
|
+
fetchSwapData();
|
|
3340
|
+
}, [props.enableSwapDeposit, props.customChains]);
|
|
3341
|
+
React19.useEffect(() => {
|
|
3342
|
+
fetchMainChains().then((data) => {
|
|
3343
|
+
setMainnetChainInfos(data);
|
|
3344
|
+
});
|
|
3345
|
+
fetchTestChains().then((data) => {
|
|
3346
|
+
setTestChainInfos(data);
|
|
3347
|
+
});
|
|
3348
|
+
}, []);
|
|
3311
3349
|
const handleCustomerChains = () => {
|
|
3312
3350
|
const testChains = processChainInfo(
|
|
3313
3351
|
props.customChains.testnet?.map((item) => item.network_infos)
|
|
@@ -3390,21 +3428,33 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3390
3428
|
]
|
|
3391
3429
|
);
|
|
3392
3430
|
React19.useEffect(() => {
|
|
3393
|
-
if (
|
|
3431
|
+
if (initRef.current)
|
|
3432
|
+
return;
|
|
3433
|
+
if (hasCustomChains) {
|
|
3394
3434
|
return;
|
|
3395
3435
|
}
|
|
3396
|
-
|
|
3436
|
+
const hasStoreData = mainnetChainInfosFromStore && testChainInfosFromStore;
|
|
3437
|
+
const hasApiData = mainnetChainInfos && testChainInfos;
|
|
3438
|
+
if (!hasStoreData && !hasApiData) {
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
if (!swapChainInfoRes) {
|
|
3397
3442
|
return;
|
|
3398
3443
|
}
|
|
3399
3444
|
let testChainsList = [];
|
|
3400
3445
|
let mainnetChainsList = [];
|
|
3401
3446
|
try {
|
|
3402
|
-
|
|
3403
|
-
|
|
3447
|
+
if (hasStoreData) {
|
|
3448
|
+
testChainsList = testChainInfosFromStore;
|
|
3449
|
+
mainnetChainsList = mainnetChainInfosFromStore;
|
|
3450
|
+
} else {
|
|
3451
|
+
testChainsList = testChainInfos || testnetChainFallback;
|
|
3452
|
+
mainnetChainsList = mainnetChainInfos || [];
|
|
3453
|
+
}
|
|
3404
3454
|
const testChains = processChainInfo(testChainsList);
|
|
3405
3455
|
const mainnetChains2 = processChainInfo(mainnetChainsList);
|
|
3406
3456
|
const swapChains = processChainInfo(
|
|
3407
|
-
formatSwapChainInfo(swapChainInfoRes
|
|
3457
|
+
formatSwapChainInfo(swapChainInfoRes || {})
|
|
3408
3458
|
);
|
|
3409
3459
|
const chains = [...testChains, ...mainnetChains2];
|
|
3410
3460
|
const filterSwapChains = swapChains.filter(
|
|
@@ -3422,8 +3472,10 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3422
3472
|
props.customChains,
|
|
3423
3473
|
mainnetChainInfos,
|
|
3424
3474
|
testChainInfos,
|
|
3425
|
-
|
|
3426
|
-
|
|
3475
|
+
mainnetChainInfosFromStore,
|
|
3476
|
+
testChainInfosFromStore,
|
|
3477
|
+
swapChainInfoRes
|
|
3478
|
+
// swapLoading,
|
|
3427
3479
|
]);
|
|
3428
3480
|
React19.useEffect(() => {
|
|
3429
3481
|
if (props.customChains) {
|