@orderly.network/wallet-connector-privy 2.4.2-alpha.0 → 2.5.0-alpha.2
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 +77 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var React19 = require('react');
|
|
4
4
|
var viemExport = require('viem');
|
|
5
5
|
var chains = require('viem/chains');
|
|
6
|
+
var hooks = require('@orderly.network/hooks');
|
|
6
7
|
var types = require('@orderly.network/types');
|
|
7
8
|
var ui = require('@orderly.network/ui');
|
|
8
|
-
var hooks = require('@orderly.network/hooks');
|
|
9
9
|
var i18n = require('@orderly.network/i18n');
|
|
10
10
|
var agwReact = require('@abstract-foundation/agw-react');
|
|
11
11
|
var WagmiExport = require('wagmi');
|
|
@@ -2749,12 +2749,30 @@ function WagmiWallet(props) {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
|
|
2751
2751
|
// src/provider.tsx
|
|
2752
|
-
var
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2752
|
+
var commonSwrOpts = {
|
|
2753
|
+
revalidateIfStale: false,
|
|
2754
|
+
revalidateOnFocus: false,
|
|
2755
|
+
revalidateOnReconnect: false,
|
|
2756
|
+
// If false, undefined data gets cached against the key.
|
|
2757
|
+
revalidateOnMount: true,
|
|
2758
|
+
// don't duplicate a request with the same key for 1hr
|
|
2759
|
+
dedupingInterval: 36e5
|
|
2760
|
+
};
|
|
2761
|
+
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
2762
|
+
var formatSwapChainInfo = (data = {}) => {
|
|
2763
|
+
return Object.keys(data).map((key) => {
|
|
2764
|
+
const chain = data[key];
|
|
2765
|
+
const { network_infos, token_infos } = chain;
|
|
2766
|
+
const nativeToken = token_infos.find(
|
|
2767
|
+
(item) => item.symbol === network_infos.currency_symbol
|
|
2768
|
+
);
|
|
2769
|
+
if (nativeToken) {
|
|
2770
|
+
network_infos.currency_decimal = nativeToken.decimals;
|
|
2771
|
+
} else {
|
|
2772
|
+
network_infos.currency_decimal = 18;
|
|
2773
|
+
}
|
|
2774
|
+
return network_infos;
|
|
2775
|
+
});
|
|
2758
2776
|
};
|
|
2759
2777
|
var processChainInfo = (chainInfo) => chainInfo.map(
|
|
2760
2778
|
(row) => viemExport.defineChain({
|
|
@@ -2869,33 +2887,21 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2869
2887
|
});
|
|
2870
2888
|
return chainTypeObj;
|
|
2871
2889
|
}, [initChains]);
|
|
2872
|
-
const
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
);
|
|
2888
|
-
mainnetChainsList = mainnetChainInfoRes.data.rows;
|
|
2889
|
-
} catch (error) {
|
|
2890
|
-
mainnetChainsList = [];
|
|
2891
|
-
}
|
|
2892
|
-
const testChains = processChainInfo(testChainsList);
|
|
2893
|
-
const mainnetChains2 = processChainInfo(mainnetChainsList);
|
|
2894
|
-
setTestnetChains(testChains);
|
|
2895
|
-
setMainnetChains(mainnetChains2);
|
|
2896
|
-
setInitChains([...testChains, ...mainnetChains2]);
|
|
2897
|
-
initRef.current = true;
|
|
2898
|
-
};
|
|
2890
|
+
const { data: mainnetChainInfoRes } = hooks.useSWR(
|
|
2891
|
+
!props.customChains ? "https://api.orderly.org/v1/public/chain_info" : null,
|
|
2892
|
+
fetcher,
|
|
2893
|
+
commonSwrOpts
|
|
2894
|
+
);
|
|
2895
|
+
const { data: testChainInfoRes } = hooks.useSWR(
|
|
2896
|
+
!props.customChains ? "https://testnet-api.orderly.org/v1/public/chain_info" : null,
|
|
2897
|
+
fetcher,
|
|
2898
|
+
commonSwrOpts
|
|
2899
|
+
);
|
|
2900
|
+
const { data: swapChainInfoRes } = hooks.useSWR(
|
|
2901
|
+
!props.customChains ? "https://fi-api.woo.org/swap_support" : null,
|
|
2902
|
+
fetcher,
|
|
2903
|
+
commonSwrOpts
|
|
2904
|
+
);
|
|
2899
2905
|
const handleCustomerChains = () => {
|
|
2900
2906
|
const testChains = processChainInfo(
|
|
2901
2907
|
props.customChains.testnet?.map((item) => item.network_infos)
|
|
@@ -2978,11 +2984,45 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2978
2984
|
]
|
|
2979
2985
|
);
|
|
2980
2986
|
React19.useEffect(() => {
|
|
2981
|
-
if (
|
|
2982
|
-
fetchAllChains();
|
|
2987
|
+
if (props.customChains) {
|
|
2983
2988
|
return;
|
|
2984
2989
|
}
|
|
2985
|
-
|
|
2990
|
+
if (!mainnetChainInfoRes || !testChainInfoRes || !swapChainInfoRes) {
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
let testChainsList = [];
|
|
2994
|
+
let mainnetChainsList = [];
|
|
2995
|
+
try {
|
|
2996
|
+
testChainsList = testChainInfoRes?.data?.rows;
|
|
2997
|
+
testChainsList.push(types.AbstractTestnetChainInfo);
|
|
2998
|
+
mainnetChainsList = mainnetChainInfoRes?.data?.rows;
|
|
2999
|
+
const testChains = processChainInfo(testChainsList);
|
|
3000
|
+
const mainnetChains2 = processChainInfo(mainnetChainsList);
|
|
3001
|
+
const swapChains = processChainInfo(
|
|
3002
|
+
formatSwapChainInfo(swapChainInfoRes?.data)
|
|
3003
|
+
);
|
|
3004
|
+
const chains = [...testChains, ...mainnetChains2];
|
|
3005
|
+
const filterSwapChains = swapChains.filter(
|
|
3006
|
+
(item) => !chains.some((chain) => chain.id === item.id)
|
|
3007
|
+
);
|
|
3008
|
+
setTestnetChains(testChains);
|
|
3009
|
+
setMainnetChains(mainnetChains2);
|
|
3010
|
+
setInitChains([...chains, ...filterSwapChains]);
|
|
3011
|
+
} catch (error) {
|
|
3012
|
+
testChainsList = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
|
|
3013
|
+
mainnetChainsList = [];
|
|
3014
|
+
}
|
|
3015
|
+
initRef.current = true;
|
|
3016
|
+
}, [
|
|
3017
|
+
props.customChains,
|
|
3018
|
+
mainnetChainInfoRes,
|
|
3019
|
+
testChainInfoRes,
|
|
3020
|
+
swapChainInfoRes
|
|
3021
|
+
]);
|
|
3022
|
+
React19.useEffect(() => {
|
|
3023
|
+
if (props.customChains) {
|
|
3024
|
+
handleCustomerChains();
|
|
3025
|
+
}
|
|
2986
3026
|
}, [props.customChains]);
|
|
2987
3027
|
if (!initRef.current) {
|
|
2988
3028
|
return null;
|