@orderly.network/wallet-connector-privy 2.9.1 → 2.10.0-alpha.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/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +41 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -125,7 +125,6 @@ interface WalletConnectorPrivyProps extends PropsWithChildren {
|
|
|
125
125
|
headerProps?: {
|
|
126
126
|
mobile: React.ReactNode;
|
|
127
127
|
};
|
|
128
|
-
enableSwapDeposit?: boolean;
|
|
129
128
|
}
|
|
130
129
|
declare function WalletConnectorPrivyProvider(props: WalletConnectorPrivyProps): React.JSX.Element | null;
|
|
131
130
|
|
package/dist/index.d.ts
CHANGED
|
@@ -125,7 +125,6 @@ interface WalletConnectorPrivyProps extends PropsWithChildren {
|
|
|
125
125
|
headerProps?: {
|
|
126
126
|
mobile: React.ReactNode;
|
|
127
127
|
};
|
|
128
|
-
enableSwapDeposit?: boolean;
|
|
129
128
|
}
|
|
130
129
|
declare function WalletConnectorPrivyProvider(props: WalletConnectorPrivyProps): React.JSX.Element | null;
|
|
131
130
|
|
package/dist/index.js
CHANGED
|
@@ -529,6 +529,7 @@ var defaultUseSolanaWallet = {
|
|
|
529
529
|
connect: () => Promise.resolve(),
|
|
530
530
|
wallet: null,
|
|
531
531
|
publicKey: null,
|
|
532
|
+
connecting: false,
|
|
532
533
|
signMessage: () => Promise.resolve(),
|
|
533
534
|
signTransaction: () => Promise.resolve(),
|
|
534
535
|
sendTransaction: () => Promise.resolve(),
|
|
@@ -548,6 +549,7 @@ var SolanaWalletProvider = ({
|
|
|
548
549
|
connect: connectSolana,
|
|
549
550
|
wallet: walletSolana,
|
|
550
551
|
publicKey,
|
|
552
|
+
connecting,
|
|
551
553
|
signMessage,
|
|
552
554
|
signTransaction,
|
|
553
555
|
sendTransaction,
|
|
@@ -611,6 +613,7 @@ var SolanaWalletProvider = ({
|
|
|
611
613
|
connectSolana,
|
|
612
614
|
walletSolana,
|
|
613
615
|
publicKey,
|
|
616
|
+
connecting,
|
|
614
617
|
signMessage,
|
|
615
618
|
signTransaction,
|
|
616
619
|
sendTransaction,
|
|
@@ -623,6 +626,7 @@ var SolanaWalletProvider = ({
|
|
|
623
626
|
connectSolana,
|
|
624
627
|
walletSolana,
|
|
625
628
|
publicKey,
|
|
629
|
+
connecting,
|
|
626
630
|
signMessage,
|
|
627
631
|
signTransaction,
|
|
628
632
|
sendTransaction,
|
|
@@ -630,9 +634,18 @@ var SolanaWalletProvider = ({
|
|
|
630
634
|
network,
|
|
631
635
|
solanaInfo
|
|
632
636
|
]);
|
|
637
|
+
const dedupedWallets = React19.useMemo(() => {
|
|
638
|
+
const seen = /* @__PURE__ */ new Set();
|
|
639
|
+
return wallets.filter((w) => {
|
|
640
|
+
const name = w?.adapter?.name?.toLowerCase?.();
|
|
641
|
+
if (!name || seen.has(name)) return !name;
|
|
642
|
+
seen.add(name);
|
|
643
|
+
return true;
|
|
644
|
+
});
|
|
645
|
+
}, [wallets]);
|
|
633
646
|
const value = React19.useMemo(
|
|
634
647
|
() => ({
|
|
635
|
-
wallets,
|
|
648
|
+
wallets: dedupedWallets,
|
|
636
649
|
connectedChain: publicKey ? {
|
|
637
650
|
id: SolanaChainsMap.get(network),
|
|
638
651
|
namespace: types.ChainNamespace.solana
|
|
@@ -642,7 +655,7 @@ var SolanaWalletProvider = ({
|
|
|
642
655
|
disconnect: disconnectWallet,
|
|
643
656
|
isConnected: !!publicKey
|
|
644
657
|
}),
|
|
645
|
-
[
|
|
658
|
+
[dedupedWallets, publicKey, wallet, network]
|
|
646
659
|
);
|
|
647
660
|
return /* @__PURE__ */ React19__default.default.createElement(SolanaWalletContext.Provider, { value }, children);
|
|
648
661
|
};
|
|
@@ -1009,6 +1022,7 @@ var getChainType = (chainId) => {
|
|
|
1009
1022
|
// src/hooks/useWallet.tsx
|
|
1010
1023
|
function useWallet2() {
|
|
1011
1024
|
const { track } = hooks.useTrack();
|
|
1025
|
+
const ee = hooks.useEventEmitter();
|
|
1012
1026
|
const { walletChainTypeConfig, initChains, network } = useWalletConnectorPrivy();
|
|
1013
1027
|
const [connectorKey, setConnectorKey] = hooks.useLocalStorage(types.ConnectorKey, "");
|
|
1014
1028
|
const {
|
|
@@ -1073,7 +1087,15 @@ function useWallet2() {
|
|
|
1073
1087
|
}
|
|
1074
1088
|
if (params.walletType === "SOL" /* SOL */) {
|
|
1075
1089
|
setConnectorKey("SOL" /* SOL */);
|
|
1076
|
-
connectSOL(params.walletAdapter.name).
|
|
1090
|
+
connectSOL(params.walletAdapter.name).catch((err) => {
|
|
1091
|
+
const message = String(err?.message ?? "").toLowerCase();
|
|
1092
|
+
if (message === "wallet not connected") {
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
ee.emit("wallet:connect-error", {
|
|
1096
|
+
message: err?.message || "Please switch to a wallet with Solana address."
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1077
1099
|
}
|
|
1078
1100
|
if (params.walletType === "privy" /* PRIVY */) {
|
|
1079
1101
|
setConnectorKey("privy" /* PRIVY */);
|
|
@@ -3145,6 +3167,7 @@ function InitSolanaProvider({
|
|
|
3145
3167
|
onError,
|
|
3146
3168
|
children
|
|
3147
3169
|
}) {
|
|
3170
|
+
const ee = hooks.useEventEmitter();
|
|
3148
3171
|
const { network, setSolanaInfo, connectorWalletType } = useWalletConnectorPrivy();
|
|
3149
3172
|
if (connectorWalletType.disableSolana) {
|
|
3150
3173
|
return children;
|
|
@@ -3164,7 +3187,19 @@ function InitSolanaProvider({
|
|
|
3164
3187
|
network: network === "mainnet" ? walletAdapterBase.WalletAdapterNetwork.Mainnet : walletAdapterBase.WalletAdapterNetwork.Devnet
|
|
3165
3188
|
});
|
|
3166
3189
|
}, [network, mainnetRpc, devnetRpc, setSolanaInfo]);
|
|
3167
|
-
|
|
3190
|
+
const handleOnError = React19.useCallback(
|
|
3191
|
+
(error, adapter) => {
|
|
3192
|
+
if (error.name === "WalletAccountError") {
|
|
3193
|
+
ee.emit("wallet:connect-error", {
|
|
3194
|
+
message: "Please switch to a wallet with Solana address."
|
|
3195
|
+
});
|
|
3196
|
+
return;
|
|
3197
|
+
}
|
|
3198
|
+
onError?.(error, adapter);
|
|
3199
|
+
},
|
|
3200
|
+
[ee, onError]
|
|
3201
|
+
);
|
|
3202
|
+
return /* @__PURE__ */ React19__default.default.createElement(walletAdapterReact.WalletProvider, { wallets, onError: handleOnError, autoConnect: true }, children);
|
|
3168
3203
|
}
|
|
3169
3204
|
|
|
3170
3205
|
// src/providers/solana/index.tsx
|
|
@@ -3220,21 +3255,6 @@ var WagmiWallet = (props) => {
|
|
|
3220
3255
|
|
|
3221
3256
|
// src/provider.tsx
|
|
3222
3257
|
var testnetChainFallback = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
|
|
3223
|
-
var formatSwapChainInfo = (data = {}) => {
|
|
3224
|
-
return Object.keys(data).map((key) => {
|
|
3225
|
-
const chain = data[key];
|
|
3226
|
-
const { network_infos, token_infos } = chain;
|
|
3227
|
-
const nativeToken = token_infos.find(
|
|
3228
|
-
(item) => item.symbol === network_infos.currency_symbol
|
|
3229
|
-
);
|
|
3230
|
-
if (nativeToken) {
|
|
3231
|
-
network_infos.currency_decimal = nativeToken.decimals;
|
|
3232
|
-
} else {
|
|
3233
|
-
network_infos.currency_decimal = 18;
|
|
3234
|
-
}
|
|
3235
|
-
return network_infos;
|
|
3236
|
-
});
|
|
3237
|
-
};
|
|
3238
3258
|
var processChainInfo = (chainInfo) => chainInfo.map(
|
|
3239
3259
|
(row) => viemExport.defineChain({
|
|
3240
3260
|
id: Number(row.chain_id),
|
|
@@ -3363,15 +3383,6 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3363
3383
|
});
|
|
3364
3384
|
return chainTypeObj;
|
|
3365
3385
|
}, [initChains]);
|
|
3366
|
-
const {
|
|
3367
|
-
data: swapChainInfoRes,
|
|
3368
|
-
// loading: swapLoading,
|
|
3369
|
-
fetchData: fetchSwapData
|
|
3370
|
-
} = hooks.useSwapSupportStore();
|
|
3371
|
-
React19.useEffect(() => {
|
|
3372
|
-
if (!props.enableSwapDeposit || !!props.customChains) return;
|
|
3373
|
-
fetchSwapData();
|
|
3374
|
-
}, [props.enableSwapDeposit, props.customChains]);
|
|
3375
3386
|
React19.useEffect(() => {
|
|
3376
3387
|
if (!mainnetChainsHydrated || !testChainsHydrated) return;
|
|
3377
3388
|
if (Array.isArray(hooks.useMainnetChainsStore.getState().data) && hooks.useTestnetChainsStore.getState().data) {
|
|
@@ -3475,9 +3486,6 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3475
3486
|
if (!hasStoreData && !hasApiData) {
|
|
3476
3487
|
return;
|
|
3477
3488
|
}
|
|
3478
|
-
if (props.enableSwapDeposit && !swapChainInfoRes) {
|
|
3479
|
-
return;
|
|
3480
|
-
}
|
|
3481
3489
|
let testChainsList = [];
|
|
3482
3490
|
let mainnetChainsList = [];
|
|
3483
3491
|
try {
|
|
@@ -3490,16 +3498,10 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3490
3498
|
}
|
|
3491
3499
|
const testChains = processChainInfo(testChainsList);
|
|
3492
3500
|
const mainnetChains2 = processChainInfo(mainnetChainsList);
|
|
3493
|
-
const swapChains = processChainInfo(
|
|
3494
|
-
formatSwapChainInfo(swapChainInfoRes || {})
|
|
3495
|
-
);
|
|
3496
3501
|
const chains = [...testChains, ...mainnetChains2];
|
|
3497
|
-
const filterSwapChains = swapChains.filter(
|
|
3498
|
-
(item) => !chains.some((chain) => chain.id === item.id)
|
|
3499
|
-
);
|
|
3500
3502
|
setTestnetChains(testChains);
|
|
3501
3503
|
setMainnetChains(mainnetChains2);
|
|
3502
|
-
setInitChains(
|
|
3504
|
+
setInitChains(chains);
|
|
3503
3505
|
} catch (error) {
|
|
3504
3506
|
testChainsList = [types.ArbitrumSepoliaChainInfo, types.SolanaDevnetChainInfo];
|
|
3505
3507
|
mainnetChainsList = [];
|
|
@@ -3510,10 +3512,7 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
3510
3512
|
mainnetChainInfos,
|
|
3511
3513
|
testChainInfos,
|
|
3512
3514
|
mainnetChainInfosFromStore,
|
|
3513
|
-
testChainInfosFromStore
|
|
3514
|
-
swapChainInfoRes,
|
|
3515
|
-
props.enableSwapDeposit
|
|
3516
|
-
// swapLoading,
|
|
3515
|
+
testChainInfosFromStore
|
|
3517
3516
|
]);
|
|
3518
3517
|
React19.useEffect(() => {
|
|
3519
3518
|
if (props.customChains) {
|