@coin-voyage/crypto 2.2.2 → 2.2.3-beta.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/evm/create-default-evm-config.js +1 -1
- package/dist/evm/utils.d.ts +1 -1
- package/dist/evm/utils.js +1 -1
- package/dist/hooks/use-account-disconnect.js +4 -3
- package/dist/hooks/use-account.d.ts +1 -1
- package/dist/hooks/use-account.js +29 -17
- package/dist/hooks/use-connect-callback.d.ts +2 -2
- package/dist/hooks/use-installed-wallets.d.ts +1 -1
- package/dist/hooks/use-installed-wallets.js +35 -49
- package/dist/hooks/use-last-connector.d.ts +8 -2
- package/dist/hooks/use-last-connector.js +20 -9
- package/dist/hooks/use-prepare-transaction.d.ts +1 -1
- package/dist/hooks/use-prepare-transaction.js +1 -1
- package/dist/hooks/use-universal-connect.js +21 -21
- package/dist/lib/utils/connector.d.ts +1 -1
- package/dist/lib/utils/get-wallet-priority.js +1 -1
- package/dist/types/wallet.d.ts +1 -1
- package/dist/utxo/send-btc.js +1 -1
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ export function createDefaultEVMConfig(props) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
if (isWalletInstalled("app.phantom.ethereum")) {
|
|
38
|
-
connectors.push(extendConnector(injected({ target: "phantom" }), "phantom", "Phantom"));
|
|
38
|
+
connectors.push(extendConnector(injected({ target: "phantom" }), "app.phantom", "Phantom"));
|
|
39
39
|
}
|
|
40
40
|
if (!isWalletInstalled("coinbase")) {
|
|
41
41
|
const coinbase = createCoinbaseConnector(props?.coinbase ?? {
|
package/dist/evm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainId } from "@coin-voyage/shared/
|
|
1
|
+
import { ChainId } from "@coin-voyage/shared/types";
|
|
2
2
|
import type { Connector, CreateConnectorFn } from "wagmi";
|
|
3
3
|
import { BaseConnector } from "../types/base-connector";
|
|
4
4
|
import type { CreateConnectorFnExtended } from "./types";
|
package/dist/evm/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainId } from "@coin-voyage/shared/
|
|
1
|
+
import { ChainId } from "@coin-voyage/shared/types";
|
|
2
2
|
import { getWalletIcon } from "../assets/icons";
|
|
3
3
|
export const ALCHEMY_KEY = "kikl1LthkvlPnpk8Y2eY3vqGSKVoRGFj";
|
|
4
4
|
export const extendConnector = (connector, id, name) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { disconnect as utxoDisconnect } from "@bigmi/client";
|
|
2
2
|
import { useConfig as useBigmiConfig } from "@bigmi/react";
|
|
3
|
-
import { ChainType } from "@coin-voyage/shared/
|
|
3
|
+
import { ChainType } from "@coin-voyage/shared/types";
|
|
4
4
|
import { useDisconnectWallet } from "@mysten/dapp-kit";
|
|
5
5
|
import { useWallet } from "@solana/wallet-adapter-react";
|
|
6
6
|
import { useDisconnect } from "wagmi";
|
|
@@ -26,13 +26,14 @@ export const useAccountDisconnect = () => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
return async (account) => {
|
|
29
|
-
if (account) {
|
|
29
|
+
if (account?.isConnected) {
|
|
30
30
|
return disconnect(account.chainType);
|
|
31
31
|
}
|
|
32
32
|
// Disconnect all accounts if no specific account is provided
|
|
33
33
|
for (const acc of accounts) {
|
|
34
|
+
if (!acc.isConnected)
|
|
35
|
+
continue;
|
|
34
36
|
await disconnect(acc.chainType);
|
|
35
|
-
console.log(`Disconnected account on ${acc.chainType}`);
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connector as UTXOConnector } from "@bigmi/client";
|
|
2
2
|
import { Account as BTCAccount } from "@bigmi/core";
|
|
3
|
-
import { ChainType } from "@coin-voyage/shared/
|
|
3
|
+
import { ChainType } from "@coin-voyage/shared/types";
|
|
4
4
|
import type { Connector } from "wagmi";
|
|
5
5
|
import type { WalletAdapterExtended } from "../solana/types";
|
|
6
6
|
import type { WalletProps } from "../types/wallet";
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getAccount as getBtcAccount, watchAccount as watchBtcAccount, } from "@bigmi/client";
|
|
2
|
+
import { useConfig as useBigmiConfig } from "@bigmi/react";
|
|
3
|
+
import { ChainId, ChainType } from "@coin-voyage/shared/types";
|
|
3
4
|
import { useCurrentAccount, useCurrentWallet } from "@mysten/dapp-kit";
|
|
4
5
|
import { useWallet } from "@solana/wallet-adapter-react";
|
|
6
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
5
7
|
import { useAccount as useAccountInternal } from "wagmi";
|
|
6
8
|
import { getConnector } from "../lib/utils/connector";
|
|
7
9
|
import { extendsWalletAdapter } from "../solana/utils";
|
|
10
|
+
import { useLastConnector } from "./use-last-connector";
|
|
8
11
|
const defaultAccount = {
|
|
9
12
|
chainType: ChainType.EVM,
|
|
10
13
|
isConnected: false,
|
|
@@ -108,35 +111,44 @@ const buildUtxoAccount = (btcAccount) => {
|
|
|
108
111
|
* @bigmi/react for Bitcoin, and @mysten/dapp-kit for Sui) and normalizes their responses into a unified Account type.
|
|
109
112
|
*/
|
|
110
113
|
export const useAccount = (args) => {
|
|
111
|
-
const
|
|
112
|
-
const btcAccount = useBtcAccount({ config: btcConfig });
|
|
114
|
+
const { lastConnector } = useLastConnector();
|
|
113
115
|
const wagmiAccount = useAccountInternal();
|
|
114
116
|
const { wallet } = useWallet();
|
|
115
117
|
const suiWallet = useCurrentWallet();
|
|
116
118
|
const suiAccount = useCurrentAccount();
|
|
119
|
+
const btcConfig = useBigmiConfig();
|
|
120
|
+
const btcSnapshotCache = useRef(getBtcAccount(btcConfig));
|
|
121
|
+
const btcSubscribe = useCallback((onChange) => watchBtcAccount(btcConfig, {
|
|
122
|
+
onChange: () => {
|
|
123
|
+
btcSnapshotCache.current = getBtcAccount(btcConfig);
|
|
124
|
+
onChange();
|
|
125
|
+
},
|
|
126
|
+
}), [btcConfig]);
|
|
127
|
+
const btcGetSnapshot = useCallback(() => btcSnapshotCache.current, []);
|
|
128
|
+
const btcAccount = useSyncExternalStore(btcSubscribe, btcGetSnapshot, btcGetSnapshot);
|
|
117
129
|
const lastConnectedAccount = args?.selectedWallet
|
|
118
|
-
? getConnector(args?.selectedWallet.connectors, args?.chainType)
|
|
130
|
+
? getConnector(args?.selectedWallet.connectors, args.chainType ?? lastConnector?.chainType)
|
|
119
131
|
: undefined;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
const accounts = [
|
|
133
|
+
buildEvmAccount(wagmiAccount),
|
|
134
|
+
buildSolanaAccount(wallet),
|
|
135
|
+
buildSuiAccount(suiWallet, suiAccount),
|
|
136
|
+
buildUtxoAccount(btcAccount),
|
|
137
|
+
];
|
|
125
138
|
const connectedAccounts = accounts.filter((account) => account.isConnected);
|
|
126
139
|
const selectedChainTypeAccount = args?.chainType
|
|
127
|
-
? connectedAccounts.find((account) => account.chainType === args
|
|
140
|
+
? connectedAccounts.find((account) => account.chainType === args.chainType)
|
|
128
141
|
: undefined;
|
|
129
142
|
// If lastConnectedAccount exists, attempt to find a connected account with a matching connector ID or name.
|
|
130
143
|
// If no matching account is found, fallback to the first connected account.
|
|
131
144
|
// If lastConnectedAccount is not present, simply select the first connected account.
|
|
132
145
|
const selectedAccount = lastConnectedAccount
|
|
133
146
|
? connectedAccounts.find((account) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
: connectedAccounts[0];
|
|
147
|
+
return (account.chainType === args?.chainType &&
|
|
148
|
+
(account.connector?.id === lastConnectedAccount?.id ||
|
|
149
|
+
account.connector?.name === lastConnectedAccount?.name));
|
|
150
|
+
}) || connectedAccounts.find((account) => account.chainType === args?.chainType)
|
|
151
|
+
: connectedAccounts.find((account) => account.chainType === args?.chainType) || connectedAccounts[0];
|
|
140
152
|
return {
|
|
141
153
|
account: selectedChainTypeAccount || selectedAccount || defaultAccount,
|
|
142
154
|
accounts: connectedAccounts,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ChainId, ChainType } from "@coin-voyage/shared/
|
|
1
|
+
import { ChainId, ChainType } from "@coin-voyage/shared/types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export type useConnectCallbackProps = {
|
|
4
4
|
onConnect?: ({ address, chainId, connectorId, type, }: {
|
|
5
5
|
address: string;
|
|
6
|
-
chainId?:
|
|
6
|
+
chainId?: ChainId;
|
|
7
7
|
connectorId?: string;
|
|
8
8
|
type: ChainType;
|
|
9
9
|
}) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useConfig as useBigmiConfig } from "@bigmi/react";
|
|
2
|
-
import { ChainType } from "@coin-voyage/shared/
|
|
2
|
+
import { ChainType } from "@coin-voyage/shared/types";
|
|
3
3
|
import { useWallets } from "@mysten/dapp-kit";
|
|
4
4
|
import { WalletReadyState } from "@solana/wallet-adapter-base";
|
|
5
5
|
import { useWallet } from "@solana/wallet-adapter-react";
|
|
@@ -9,7 +9,18 @@ import { getConnectorIcon } from "../lib/utils/get-connector-icon";
|
|
|
9
9
|
import { getWalletPriority } from "../lib/utils/get-wallet-priority";
|
|
10
10
|
import { isWalletInstalled } from "../lib/utils/is-wallet-installed";
|
|
11
11
|
import { extendsWalletAdapter } from "../solana/utils";
|
|
12
|
-
|
|
12
|
+
// canonical wallet ID for multi-chain wallets
|
|
13
|
+
const getCanonicalWalletId = (idOrName) => {
|
|
14
|
+
const lower = idOrName.toLowerCase();
|
|
15
|
+
// Explicit multi-chain wallet mapping
|
|
16
|
+
if (lower.includes("phantom"))
|
|
17
|
+
return "app.phantom";
|
|
18
|
+
if (lower.includes("rainbow"))
|
|
19
|
+
return "me.rainbow";
|
|
20
|
+
if (lower.includes("metamask"))
|
|
21
|
+
return "io.metamask";
|
|
22
|
+
return lower.split(" ")[0];
|
|
23
|
+
};
|
|
13
24
|
export const useInstalledWallets = (filterChainType) => {
|
|
14
25
|
const bigmiConfig = useBigmiConfig?.() ?? null;
|
|
15
26
|
const wagmiConfig = useContext(WagmiContext) ?? null;
|
|
@@ -18,7 +29,7 @@ export const useInstalledWallets = (filterChainType) => {
|
|
|
18
29
|
return useMemo(() => {
|
|
19
30
|
const shouldInclude = (chainType) => !filterChainType || filterChainType === chainType;
|
|
20
31
|
const installedUTXO = shouldInclude(ChainType.UTXO)
|
|
21
|
-
?
|
|
32
|
+
? bigmiConfig?.connectors.filter((c) => isWalletInstalled(c.id)) ?? []
|
|
22
33
|
: [];
|
|
23
34
|
const installedEVM = shouldInclude(ChainType.EVM)
|
|
24
35
|
? Array.from(wagmiConfig?.connectors ?? []).filter((c) => isWalletInstalled(c.id))
|
|
@@ -27,62 +38,38 @@ export const useInstalledWallets = (filterChainType) => {
|
|
|
27
38
|
? solanaWallets.filter((w) => [WalletReadyState.Installed, WalletReadyState.Loadable].includes(w.adapter.readyState))
|
|
28
39
|
: [];
|
|
29
40
|
const installedSui = shouldInclude(ChainType.SUI) && suiWallets ? suiWallets : [];
|
|
30
|
-
return combineWalletLists(installedUTXO, installedEVM, installedSol, installedSui);
|
|
41
|
+
return combineWalletLists(installedUTXO, installedEVM, installedSol, installedSui, filterChainType);
|
|
31
42
|
}, [bigmiConfig?.connectors, wagmiConfig?.connectors, solanaWallets, suiWallets, filterChainType]);
|
|
32
43
|
};
|
|
33
|
-
const combineWalletLists = (utxoConnectorList, evmConnectorList, solanaWalletList, suiWalletList) => {
|
|
44
|
+
const combineWalletLists = (utxoConnectorList, evmConnectorList, solanaWalletList, suiWalletList, filterChainType) => {
|
|
34
45
|
const walletMap = new Map();
|
|
46
|
+
const addConnector = (rawId, displayName, icon, connector) => {
|
|
47
|
+
const walletId = getCanonicalWalletId(rawId);
|
|
48
|
+
if (filterChainType && connector.chainType !== filterChainType)
|
|
49
|
+
return;
|
|
50
|
+
const existing = walletMap.get(walletId);
|
|
51
|
+
if (existing) {
|
|
52
|
+
existing.connectors.push(connector);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
walletMap.set(walletId, { id: walletId, name: displayName, icon, connectors: [connector] });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
35
58
|
utxoConnectorList.forEach((utxo) => {
|
|
36
|
-
|
|
37
|
-
const normalizedName = normalizeName(utxoName);
|
|
38
|
-
const existing = walletMap.get(normalizedName) || {
|
|
39
|
-
id: utxo.id,
|
|
40
|
-
name: utxoName,
|
|
41
|
-
icon: getConnectorIcon(utxo),
|
|
42
|
-
connectors: [],
|
|
43
|
-
};
|
|
44
|
-
existing.connectors.push({ connector: utxo, chainType: ChainType.UTXO });
|
|
45
|
-
walletMap.set(normalizedName, existing);
|
|
59
|
+
addConnector(utxo.id, utxo.name, getConnectorIcon(utxo), { connector: utxo, chainType: ChainType.UTXO });
|
|
46
60
|
});
|
|
47
61
|
evmConnectorList.forEach((evm) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const existing = walletMap.get(normalizedName) || {
|
|
51
|
-
id: evm.id,
|
|
52
|
-
name: evmName,
|
|
53
|
-
icon: getConnectorIcon(evm),
|
|
54
|
-
connectors: [],
|
|
55
|
-
};
|
|
56
|
-
existing.connectors.push({ connector: evm, chainType: ChainType.EVM });
|
|
57
|
-
walletMap.set(normalizedName, existing);
|
|
62
|
+
const name = evm?.displayName || evm?.name;
|
|
63
|
+
addConnector(evm.id, name, getConnectorIcon(evm), { connector: evm, chainType: ChainType.EVM });
|
|
58
64
|
});
|
|
59
65
|
solanaWalletList.forEach((svm) => {
|
|
60
|
-
|
|
61
|
-
const existing = walletMap.get(normalizedName) || {
|
|
62
|
-
id: svm.adapter.name,
|
|
63
|
-
name: svm.adapter.name,
|
|
64
|
-
icon: svm.adapter.icon,
|
|
65
|
-
connectors: [],
|
|
66
|
-
};
|
|
67
|
-
existing.connectors.push({
|
|
66
|
+
addConnector(svm.adapter.name, svm.adapter.name, svm.adapter.icon, {
|
|
68
67
|
connector: extendsWalletAdapter(svm.adapter, svm.adapter.name),
|
|
69
68
|
chainType: ChainType.SOL,
|
|
70
69
|
});
|
|
71
|
-
walletMap.set(normalizedName, existing);
|
|
72
70
|
});
|
|
73
71
|
suiWalletList.forEach((moveVM) => {
|
|
74
|
-
|
|
75
|
-
const existing = walletMap.get(normalizedName) || {
|
|
76
|
-
id: moveVM.name,
|
|
77
|
-
name: moveVM.name,
|
|
78
|
-
icon: moveVM.icon,
|
|
79
|
-
connectors: [],
|
|
80
|
-
};
|
|
81
|
-
existing.connectors.push({
|
|
82
|
-
connector: moveVM,
|
|
83
|
-
chainType: ChainType.SUI,
|
|
84
|
-
});
|
|
85
|
-
walletMap.set(normalizedName, existing);
|
|
72
|
+
addConnector(moveVM.name, moveVM.name, moveVM.icon, { connector: moveVM, chainType: ChainType.SUI });
|
|
86
73
|
});
|
|
87
74
|
const combinedWallets = Array.from(walletMap.values());
|
|
88
75
|
combinedWallets.sort(walletComparator);
|
|
@@ -91,8 +78,7 @@ const combineWalletLists = (utxoConnectorList, evmConnectorList, solanaWalletLis
|
|
|
91
78
|
const walletComparator = (a, b) => {
|
|
92
79
|
const priorityA = getWalletPriority(a.id);
|
|
93
80
|
const priorityB = getWalletPriority(b.id);
|
|
94
|
-
if (priorityA !== priorityB)
|
|
81
|
+
if (priorityA !== priorityB)
|
|
95
82
|
return priorityA - priorityB;
|
|
96
|
-
|
|
97
|
-
return a.id?.localeCompare(b.id);
|
|
83
|
+
return a.id.localeCompare(b.id);
|
|
98
84
|
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import type { ChainType } from "@coin-voyage/shared/types";
|
|
2
|
+
import type { WalletConnector } from "../types/wallet-connector";
|
|
1
3
|
export declare const useLastConnector: () => {
|
|
2
|
-
lastConnectorId: string |
|
|
3
|
-
|
|
4
|
+
lastConnectorId: string | undefined;
|
|
5
|
+
lastConnector: {
|
|
6
|
+
id: string;
|
|
7
|
+
chainType: ChainType;
|
|
8
|
+
} | null;
|
|
9
|
+
updateLastConnectorId: (connector: WalletConnector, chainType: ChainType) => void;
|
|
4
10
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { getValue, setValue } from "@coin-voyage/shared/common";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { getConnectorId } from "../lib/utils/connector";
|
|
3
4
|
export const useLastConnector = () => {
|
|
4
|
-
const [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return id ?? "";
|
|
5
|
+
const [lastConnectorIdWithChain, setLastConnectorIdWithChain] = useState(() => {
|
|
6
|
+
const stored = getValue("@coin-voyage/recentConnectorId");
|
|
7
|
+
return stored ?? null;
|
|
8
8
|
});
|
|
9
|
-
const updateLastConnectorId = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const updateLastConnectorId = useCallback((connector, chainType) => {
|
|
10
|
+
const idWithChain = `${getConnectorId(connector)}-${chainType}`;
|
|
11
|
+
setValue("@coin-voyage/recentConnectorId", idWithChain);
|
|
12
|
+
setLastConnectorIdWithChain(idWithChain);
|
|
13
|
+
}, []);
|
|
14
|
+
// Parse into ID + chainType for easy access
|
|
15
|
+
const lastConnector = lastConnectorIdWithChain
|
|
16
|
+
? (() => {
|
|
17
|
+
const split = lastConnectorIdWithChain.split("-");
|
|
18
|
+
const id = split[0];
|
|
19
|
+
const chainType = split[1];
|
|
20
|
+
return { id, chainType };
|
|
21
|
+
})()
|
|
22
|
+
: null;
|
|
23
|
+
return { lastConnectorId: lastConnector?.id, lastConnector, updateLastConnectorId };
|
|
13
24
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainType } from "@coin-voyage/shared/
|
|
1
|
+
import { ChainType } from "@coin-voyage/shared/types";
|
|
2
2
|
import { ExecuteTransaction } from "../types/transaction";
|
|
3
3
|
export declare function usePrepareTransaction(chainType?: ChainType): {
|
|
4
4
|
execute: (params: ExecuteTransaction) => Promise<string | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainType } from "@coin-voyage/shared/
|
|
1
|
+
import { ChainType } from "@coin-voyage/shared/types";
|
|
2
2
|
import { useEVMTransaction } from "../evm/use-evm-transaction";
|
|
3
3
|
import { useSolanaTransaction } from "../solana/use-solana-transaction";
|
|
4
4
|
import { useSUITransaction } from "../sui/use-sui-transaction";
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { useConfig as useBigmiConfig, useConnect as useUTXOConnect } from "@bigmi/react";
|
|
2
|
-
import { ChainId, ChainType } from "@coin-voyage/shared/
|
|
2
|
+
import { ChainId, ChainType } from "@coin-voyage/shared/types";
|
|
3
3
|
import { useConnectWallet } from "@mysten/dapp-kit";
|
|
4
4
|
import { useWallet } from "@solana/wallet-adapter-react";
|
|
5
|
+
import { useCallback } from "react";
|
|
5
6
|
import { useConfig as useWagmiConfig, useConnect as useWagmiConnect } from "wagmi";
|
|
6
|
-
import { getConnectorId } from "../lib/utils/connector";
|
|
7
7
|
import { useLastConnector } from "./use-last-connector";
|
|
8
|
-
import { useCallback } from "react";
|
|
9
8
|
export const useUniversalConnect = (props) => {
|
|
10
9
|
const utxoConfig = useBigmiConfig();
|
|
11
10
|
const evmConfig = useWagmiConfig();
|
|
12
11
|
const { updateLastConnectorId } = useLastConnector();
|
|
13
12
|
const { select, disconnect, connected } = useWallet();
|
|
14
13
|
const { mutateAsync: suiConnectAsync } = useConnectWallet();
|
|
14
|
+
const { onError, onSuccess, onSettled, onMutate } = props || {};
|
|
15
15
|
const { connectAsync } = useWagmiConnect({
|
|
16
16
|
config: evmConfig,
|
|
17
17
|
mutation: {
|
|
18
18
|
...props,
|
|
19
19
|
onSuccess(data, variables) {
|
|
20
20
|
const connector = variables.connector || variables.connector;
|
|
21
|
-
updateLastConnectorId(
|
|
22
|
-
|
|
21
|
+
updateLastConnectorId(connector, ChainType.EVM);
|
|
22
|
+
onSuccess?.(data, {
|
|
23
23
|
chainId: variables?.chainId,
|
|
24
24
|
connector,
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
|
-
onError
|
|
27
|
+
onError,
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
const { connectAsync: utxoConnectAsync } = useUTXOConnect({
|
|
@@ -33,18 +33,18 @@ export const useUniversalConnect = (props) => {
|
|
|
33
33
|
...props,
|
|
34
34
|
onSuccess(data, variables) {
|
|
35
35
|
const connector = variables.connector;
|
|
36
|
-
updateLastConnectorId(
|
|
37
|
-
|
|
36
|
+
updateLastConnectorId(connector, ChainType.UTXO);
|
|
37
|
+
onSuccess?.(data, {
|
|
38
38
|
chainId: ChainId.BTC,
|
|
39
39
|
connector,
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
|
-
onError
|
|
42
|
+
onError,
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
const connect = useCallback(async ({ walletConnector }) => {
|
|
46
46
|
const { connector, chainType } = walletConnector;
|
|
47
|
-
|
|
47
|
+
onMutate?.({ connector });
|
|
48
48
|
try {
|
|
49
49
|
switch (chainType) {
|
|
50
50
|
case ChainType.EVM:
|
|
@@ -82,20 +82,20 @@ export const useUniversalConnect = (props) => {
|
|
|
82
82
|
walletAdapter.connect().catch(handleError);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
updateLastConnectorId(
|
|
86
|
-
|
|
85
|
+
updateLastConnectorId(connector, ChainType.SOL);
|
|
86
|
+
onSuccess?.(undefined, { connector: walletAdapter });
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
case ChainType.SUI:
|
|
90
90
|
await suiConnectAsync({
|
|
91
91
|
wallet: connector,
|
|
92
92
|
}, {
|
|
93
|
-
onError
|
|
93
|
+
onError,
|
|
94
94
|
onSuccess: async (data) => {
|
|
95
|
-
updateLastConnectorId(
|
|
96
|
-
|
|
95
|
+
updateLastConnectorId(connector, ChainType.SUI);
|
|
96
|
+
onSuccess?.(data, { connector });
|
|
97
97
|
},
|
|
98
|
-
onSettled:
|
|
98
|
+
onSettled: onSettled,
|
|
99
99
|
});
|
|
100
100
|
break;
|
|
101
101
|
default:
|
|
@@ -103,7 +103,7 @@ export const useUniversalConnect = (props) => {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
catch (err) {
|
|
106
|
-
|
|
106
|
+
onError?.(err);
|
|
107
107
|
}
|
|
108
108
|
}, [
|
|
109
109
|
connectAsync,
|
|
@@ -113,10 +113,10 @@ export const useUniversalConnect = (props) => {
|
|
|
113
113
|
disconnect,
|
|
114
114
|
select,
|
|
115
115
|
updateLastConnectorId,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
onError,
|
|
117
|
+
onSuccess,
|
|
118
|
+
onSettled,
|
|
119
|
+
onMutate,
|
|
120
120
|
]);
|
|
121
121
|
return { connect };
|
|
122
122
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChainType } from "@coin-voyage/shared/
|
|
1
|
+
import type { ChainType } from "@coin-voyage/shared/types";
|
|
2
2
|
import type { ChainTypeWalletConnector } from "../../types/wallet";
|
|
3
3
|
import type { WalletConnector } from "../../types/wallet-connector";
|
|
4
4
|
export declare const getConnectorId: (connector: WalletConnector) => string;
|
package/dist/types/wallet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChainId, ChainType } from "@coin-voyage/shared/
|
|
1
|
+
import type { ChainId, ChainType } from "@coin-voyage/shared/types";
|
|
2
2
|
import type { WalletProviderProps as SuiWalletProviderProps } from "@mysten/dapp-kit";
|
|
3
3
|
import type { WalletProviderProps } from "@solana/wallet-adapter-react";
|
|
4
4
|
import type { EVMConfiguration } from "../evm/create-default-evm-config";
|
package/dist/utxo/send-btc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sendUTXOTransaction } from "@bigmi/core";
|
|
2
|
-
import { ChainId } from "@coin-voyage/shared/
|
|
2
|
+
import { ChainId } from "@coin-voyage/shared/types";
|
|
3
3
|
import { Psbt } from "bitcoinjs-lib";
|
|
4
4
|
import { createUnsecuredToken } from "jsontokens";
|
|
5
5
|
import { withTimeout } from "viem";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coin-voyage/crypto",
|
|
3
3
|
"description": "Crypto utilities for Coin Voyage",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.3-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "Lars <lars@coinvoyage.io>",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@solana/wallet-adapter-walletconnect": "0.1.21",
|
|
51
51
|
"@solana/wallet-adapter-base": "0.9.27",
|
|
52
52
|
"@solana/wallet-adapter-coinbase": "0.1.23",
|
|
53
|
-
"@coin-voyage/shared": "2.2.
|
|
53
|
+
"@coin-voyage/shared": "2.2.5-beta.8"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/elliptic": "6.4.18"
|