@coin-voyage/crypto 2.4.5-beta.0 → 2.4.6

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.
@@ -4,4 +4,5 @@ export * from "./use-installed-wallets";
4
4
  export * from "./use-connect-callback";
5
5
  export * from "./use-last-connector";
6
6
  export * from "./use-prepare-transaction";
7
+ export * from "./use-sui-ns-name";
7
8
  export * from "./use-universal-connect";
@@ -4,4 +4,5 @@ export * from "./use-installed-wallets";
4
4
  export * from "./use-connect-callback";
5
5
  export * from "./use-last-connector";
6
6
  export * from "./use-prepare-transaction";
7
+ export * from "./use-sui-ns-name";
7
8
  export * from "./use-universal-connect";
@@ -1,7 +1,7 @@
1
1
  import { disconnect as utxoDisconnect } from "@bigmi/client";
2
2
  import { useConfig as useBigmiConfig } from "@bigmi/react";
3
3
  import { ChainType } from "@coin-voyage/shared/types";
4
- import { useDisconnectWallet } from "@mysten/dapp-kit";
4
+ import { useDAppKit } from "@mysten/dapp-kit-react";
5
5
  import { useWallet } from "@solana/wallet-adapter-react";
6
6
  import { useDisconnect } from "wagmi";
7
7
  import { useAccount } from "./use-account";
@@ -10,7 +10,7 @@ export const useAccountDisconnect = () => {
10
10
  const bigmiConfig = useBigmiConfig();
11
11
  const { disconnectAsync } = useDisconnect();
12
12
  const { disconnect: solanaDisconnect } = useWallet();
13
- const { mutateAsync: suiDisconnect } = useDisconnectWallet();
13
+ const { disconnectWallet } = useDAppKit();
14
14
  const disconnect = async (chainType) => {
15
15
  switch (chainType) {
16
16
  case ChainType.EVM:
@@ -20,7 +20,7 @@ export const useAccountDisconnect = () => {
20
20
  case ChainType.SOL:
21
21
  return solanaDisconnect();
22
22
  case ChainType.SUI:
23
- return suiDisconnect();
23
+ return disconnectWallet();
24
24
  default:
25
25
  return Promise.resolve();
26
26
  }
@@ -4,7 +4,7 @@ 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";
7
- import { SuiConnector } from "../types/wallet-connector";
7
+ import type { SuiConnector } from "../types/wallet-connector";
8
8
  interface AccountBase<CT extends ChainType, ConnectorType = undefined> {
9
9
  address?: string;
10
10
  addresses?: readonly string[];
@@ -63,7 +63,7 @@ interface UseAccountArgs {
63
63
  * 4. Falls back to a default disconnected account if no accounts are connected
64
64
  *
65
65
  * The hook internally queries all chain-specific wallet providers (wagmi for EVM, @solana/wallet-adapter-react for Solana,
66
- * @bigmi/react for Bitcoin, and @mysten/dapp-kit for Sui) and normalizes their responses into a unified Account type.
66
+ * @bigmi/react for Bitcoin, and @mysten/dapp-kit-react for Sui) and normalizes their responses into a unified Account type.
67
67
  */
68
68
  export declare const useAccount: (args?: UseAccountArgs) => {
69
69
  account: Account;
@@ -1,12 +1,10 @@
1
- import { getAccount as getBtcAccount, watchAccount as watchBtcAccount, } from "@bigmi/client";
2
- import { useConfig as useBigmiConfig } from "@bigmi/react";
1
+ import { useAccount as useBTCAccount } from "@bigmi/react";
3
2
  import { ChainId, ChainType } from "@coin-voyage/shared/types";
4
- import { useCurrentAccount, useCurrentWallet } from "@mysten/dapp-kit";
3
+ import { useWalletConnection } from "@mysten/dapp-kit-react";
5
4
  import { useWallet } from "@solana/wallet-adapter-react";
6
- import { useCallback, useRef, useSyncExternalStore } from "react";
7
5
  import { useAccount as useAccountInternal } from "wagmi";
8
- import { getConnector } from "../utils/connector";
9
6
  import { extendsWalletAdapter } from "../solana/utils";
7
+ import { getConnector } from "../utils";
10
8
  import { useLastConnector } from "./use-last-connector";
11
9
  const defaultAccount = {
12
10
  chainType: ChainType.EVM,
@@ -39,13 +37,13 @@ const buildSolanaAccount = (wallet) => {
39
37
  status: wallet?.adapter.connecting ? "connecting" : "disconnected",
40
38
  };
41
39
  };
42
- const buildSuiAccount = (suiWallet, suiAccount) => {
43
- if (suiAccount && suiWallet.isConnected) {
40
+ const buildSuiAccount = (suiConnection) => {
41
+ if (suiConnection && suiConnection.isConnected) {
44
42
  return {
45
- address: suiAccount.address,
43
+ address: suiConnection.account.address,
46
44
  chainId: ChainId.SUI,
47
45
  chainType: ChainType.SUI,
48
- connector: suiWallet.currentWallet ?? undefined,
46
+ connector: suiConnection.wallet,
49
47
  isConnected: true,
50
48
  isConnecting: false,
51
49
  isReconnecting: false,
@@ -56,10 +54,10 @@ const buildSuiAccount = (suiWallet, suiAccount) => {
56
54
  return {
57
55
  chainType: ChainType.SUI,
58
56
  isConnected: false,
59
- isConnecting: suiWallet.connectionStatus === "connecting",
60
- isReconnecting: false,
61
- isDisconnected: true,
62
- status: suiWallet.connectionStatus === "connecting" ? "connecting" : "disconnected",
57
+ isConnecting: suiConnection.isConnecting,
58
+ isReconnecting: suiConnection.isReconnecting,
59
+ isDisconnected: suiConnection.isDisconnected,
60
+ status: suiConnection.status,
63
61
  };
64
62
  };
65
63
  const buildEvmAccount = (wagmiAccount) => {
@@ -108,31 +106,21 @@ const buildUtxoAccount = (btcAccount) => {
108
106
  * 4. Falls back to a default disconnected account if no accounts are connected
109
107
  *
110
108
  * The hook internally queries all chain-specific wallet providers (wagmi for EVM, @solana/wallet-adapter-react for Solana,
111
- * @bigmi/react for Bitcoin, and @mysten/dapp-kit for Sui) and normalizes their responses into a unified Account type.
109
+ * @bigmi/react for Bitcoin, and @mysten/dapp-kit-react for Sui) and normalizes their responses into a unified Account type.
112
110
  */
113
111
  export const useAccount = (args) => {
114
112
  const { lastConnector } = useLastConnector();
115
113
  const wagmiAccount = useAccountInternal();
116
114
  const { wallet } = useWallet();
117
- const suiWallet = useCurrentWallet();
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);
115
+ const suiConnection = useWalletConnection();
116
+ const btcAccount = useBTCAccount();
129
117
  const lastConnectedAccount = args?.selectedWallet
130
118
  ? getConnector(args?.selectedWallet.connectors, args.chainType ?? lastConnector?.chainType)
131
119
  : undefined;
132
120
  const accounts = [
133
121
  buildEvmAccount(wagmiAccount),
134
122
  buildSolanaAccount(wallet),
135
- buildSuiAccount(suiWallet, suiAccount),
123
+ buildSuiAccount(suiConnection),
136
124
  buildUtxoAccount(btcAccount),
137
125
  ];
138
126
  const connectedAccounts = accounts.filter((account) => account.isConnected);
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import { useAccount } from "./use-account";
3
+ import { getConnectorId } from "../utils";
3
4
  export const useConnectCallback = ({ onConnect, onDisconnect, onConnectValidation, setAllowedWallets, }) => {
4
5
  const { account } = useAccount();
5
6
  const address = account?.address;
6
7
  const chainId = account?.chainId;
7
8
  const chainType = account?.chainType;
8
- const connectorId = account?.connector?.id;
9
+ const connectorId = getConnectorId(account?.connector);
9
10
  const isConnected = !!account?.isConnected;
10
11
  const activeAccountRef = useRef(null);
11
12
  // keep stable references for callbacks
@@ -1,15 +1,15 @@
1
1
  import { useConfig as useBigmiConfig } from "@bigmi/react";
2
2
  import { ChainType } from "@coin-voyage/shared/types";
3
- import { useWallets } from "@mysten/dapp-kit";
3
+ import { useWallets } from "@mysten/dapp-kit-react";
4
4
  import { WalletReadyState } from "@solana/wallet-adapter-base";
5
5
  import { useWallet } from "@solana/wallet-adapter-react";
6
6
  import { useContext, useMemo } from "react";
7
7
  import { WagmiContext } from "wagmi";
8
+ import { extendsWalletAdapter } from "../solana/utils";
8
9
  import { getConnectorIcon } from "../utils/get-connector-icon";
9
10
  import { getWalletPriority } from "../utils/get-wallet-priority";
10
11
  import { isWalletInstalled } from "../utils/is-wallet-installed";
11
- import { extendsWalletAdapter } from "../solana/utils";
12
- // canonical wallet ID for multi-chain wallets
12
+ // canonical wallet ID for multi-chain wallets
13
13
  const getCanonicalWalletId = (idOrName) => {
14
14
  const lower = idOrName.toLowerCase();
15
15
  // Explicit multi-chain wallet mapping
@@ -24,12 +24,12 @@ const getCanonicalWalletId = (idOrName) => {
24
24
  export const useInstalledWallets = (filterChainType) => {
25
25
  const bigmiConfig = useBigmiConfig?.() ?? null;
26
26
  const wagmiConfig = useContext(WagmiContext) ?? null;
27
- const suiWallets = useWallets?.();
27
+ const suiWallets = useWallets();
28
28
  const solanaWallets = useWallet()?.wallets;
29
29
  return useMemo(() => {
30
30
  const shouldInclude = (chainType) => !filterChainType || filterChainType === chainType;
31
31
  const installedUTXO = shouldInclude(ChainType.UTXO)
32
- ? bigmiConfig?.connectors.filter((c) => isWalletInstalled(c.id)) ?? []
32
+ ? (bigmiConfig?.connectors.filter((c) => isWalletInstalled(c.id)) ?? [])
33
33
  : [];
34
34
  const installedEVM = shouldInclude(ChainType.EVM)
35
35
  ? Array.from(wagmiConfig?.connectors ?? []).filter((c) => isWalletInstalled(c.id))
@@ -56,7 +56,10 @@ const combineWalletLists = (utxoConnectorList, evmConnectorList, solanaWalletLis
56
56
  }
57
57
  };
58
58
  utxoConnectorList.forEach((utxo) => {
59
- addConnector(utxo.id, utxo.name, getConnectorIcon(utxo), { connector: utxo, chainType: ChainType.UTXO });
59
+ addConnector(utxo.id, utxo.name, getConnectorIcon(utxo), {
60
+ connector: utxo,
61
+ chainType: ChainType.UTXO,
62
+ });
60
63
  });
61
64
  evmConnectorList.forEach((evm) => {
62
65
  const name = evm?.displayName || evm?.name;
@@ -0,0 +1,3 @@
1
+ export declare function useSuiNSName(address?: string, options?: {
2
+ enabled?: boolean;
3
+ }): import("@tanstack/react-query").UseQueryResult<string | null, Error>;
@@ -0,0 +1,18 @@
1
+ import { useCurrentClient } from "@mysten/dapp-kit-react";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ export function useSuiNSName(address, options) {
4
+ const client = useCurrentClient();
5
+ return useQuery({
6
+ queryKey: ["sui-default-name", client.network, address],
7
+ queryFn: async ({ signal }) => {
8
+ if (!address)
9
+ return null;
10
+ const result = await client.core.defaultNameServiceName({
11
+ address,
12
+ signal,
13
+ });
14
+ return result.data.name;
15
+ },
16
+ enabled: (options?.enabled ?? true) && Boolean(address),
17
+ });
18
+ }
@@ -1,6 +1,6 @@
1
1
  import { useConfig as useBigmiConfig, useConnect as useUTXOConnect } from "@bigmi/react";
2
2
  import { ChainId, ChainType } from "@coin-voyage/shared/types";
3
- import { useConnectWallet } from "@mysten/dapp-kit";
3
+ import { useDAppKit } from "@mysten/dapp-kit-react";
4
4
  import { useWallet } from "@solana/wallet-adapter-react";
5
5
  import { useCallback } from "react";
6
6
  import { useConfig as useWagmiConfig, useConnect as useWagmiConnect } from "wagmi";
@@ -10,7 +10,7 @@ export const useUniversalConnect = (props) => {
10
10
  const evmConfig = useWagmiConfig();
11
11
  const { updateLastConnectorId } = useLastConnector();
12
12
  const { select, disconnect, connected } = useWallet();
13
- const { mutateAsync: suiConnectAsync } = useConnectWallet();
13
+ const { connectWallet } = useDAppKit();
14
14
  const { onError, onSuccess, onSettled, onMutate } = props || {};
15
15
  const { connectAsync } = useWagmiConnect({
16
16
  config: evmConfig,
@@ -86,18 +86,15 @@ export const useUniversalConnect = (props) => {
86
86
  onSuccess?.(undefined, { connector: walletAdapter });
87
87
  break;
88
88
  }
89
- case ChainType.SUI:
90
- await suiConnectAsync({
89
+ case ChainType.SUI: {
90
+ const data = await connectWallet({
91
91
  wallet: connector,
92
- }, {
93
- onError,
94
- onSuccess: async (data) => {
95
- updateLastConnectorId(connector, ChainType.SUI);
96
- onSuccess?.(data, { connector });
97
- },
98
- onSettled: onSettled,
99
92
  });
93
+ updateLastConnectorId(connector, ChainType.SUI);
94
+ onSuccess?.(data, { connector });
95
+ onSettled?.(data);
100
96
  break;
97
+ }
101
98
  default:
102
99
  throw new Error(`Unsupported chain type: ${chainType}`);
103
100
  }
@@ -108,7 +105,7 @@ export const useUniversalConnect = (props) => {
108
105
  }, [
109
106
  connectAsync,
110
107
  utxoConnectAsync,
111
- suiConnectAsync,
108
+ connectWallet,
112
109
  connected,
113
110
  disconnect,
114
111
  select,
@@ -1,6 +1,6 @@
1
- export * from "./client";
2
1
  export * from "./constants";
3
2
  export * from "./use-sign-in-with-sui";
4
3
  export * from "./use-sui-transaction";
5
4
  export * from "./verify-message";
6
5
  export * from "./provider/provider";
6
+ export * from "./provider/dapp-kit";
package/dist/sui/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./client";
2
1
  export * from "./constants";
3
2
  export * from "./use-sign-in-with-sui";
4
3
  export * from "./use-sui-transaction";
5
4
  export * from "./verify-message";
6
5
  export * from "./provider/provider";
6
+ export * from "./provider/dapp-kit";
@@ -1,10 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { SuiClientProvider, WalletProvider } from "@mysten/dapp-kit";
2
+ import { DAppKitProvider } from "@mysten/dapp-kit-react";
3
3
  import { useMemo } from "react";
4
+ import { createCoinVoyageDAppKit, dAppKit as defaultDAppKit } from "./dapp-kit";
4
5
  export function SuiBaseProvider({ children, config, }) {
5
- const suiConfig = useMemo(() => config, [config]);
6
- return (_jsx(SuiClientProvider, { networks: {
7
- mainnet: { url: config?.rpcUrl ?? "https://fullnode.mainnet.sui.io:443" },
8
- devnet: { url: "https://fullnode.devnet.sui.io:443" },
9
- }, defaultNetwork: "mainnet", children: _jsx(WalletProvider, { ...suiConfig?.walletConfiguration, storageKey: suiConfig?.walletConfiguration?.storageKey || "@coin-voyage/sui-wallet", autoConnect: suiConfig?.walletConfiguration?.autoConnect, children: children }) }));
6
+ const dAppKit = useMemo(() => (config ? createCoinVoyageDAppKit(config) : defaultDAppKit), [config]);
7
+ return _jsx(DAppKitProvider, { dAppKit: dAppKit, children: children });
10
8
  }
@@ -0,0 +1,9 @@
1
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
2
+ import type { SuiConfiguration } from "../../types/wallet";
3
+ export declare function createCoinVoyageDAppKit(config?: SuiConfiguration): import("@mysten/dapp-kit-react").DAppKit<("mainnet" | "devnet")[], SuiGrpcClient>;
4
+ export declare const dAppKit: import("@mysten/dapp-kit-react").DAppKit<("mainnet" | "devnet")[], SuiGrpcClient>;
5
+ declare module "@mysten/dapp-kit-react" {
6
+ interface Register {
7
+ dAppKit: typeof dAppKit;
8
+ }
9
+ }
@@ -0,0 +1,28 @@
1
+ import { createDAppKit } from "@mysten/dapp-kit-react";
2
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
3
+ const DEFAULT_STORAGE_KEY = "@coin-voyage/sui-wallet";
4
+ const GRPC_URLS = {
5
+ mainnet: "https://fullnode.mainnet.sui.io:443",
6
+ devnet: "https://fullnode.devnet.sui.io:443",
7
+ };
8
+ export function createCoinVoyageDAppKit(config) {
9
+ const walletConfiguration = config?.walletConfiguration;
10
+ const grpcUrls = {
11
+ ...GRPC_URLS,
12
+ ...(config?.grpcUrl ? { mainnet: config.grpcUrl } : {}),
13
+ };
14
+ return createDAppKit({
15
+ networks: ["mainnet", "devnet"],
16
+ defaultNetwork: "mainnet",
17
+ createClient(network) {
18
+ return new SuiGrpcClient({ network, baseUrl: grpcUrls[network] });
19
+ },
20
+ autoConnect: walletConfiguration?.autoConnect ?? false,
21
+ enableBurnerWallet: walletConfiguration?.enableBurnerWallet,
22
+ slushWalletConfig: walletConfiguration?.slushWalletConfig,
23
+ storage: walletConfiguration?.storage,
24
+ storageKey: walletConfiguration?.storageKey ?? DEFAULT_STORAGE_KEY,
25
+ walletInitializers: walletConfiguration?.walletInitializers,
26
+ });
27
+ }
28
+ export const dAppKit = createCoinVoyageDAppKit();
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useSuiClientContext } from "@mysten/dapp-kit";
2
+ import { useDAppKit } from "@mysten/dapp-kit-react";
3
3
  import { SuiBaseProvider } from "./base-provider";
4
4
  import { SuiExternalContext } from "./external-context";
5
5
  export function useInSuiContext() {
6
6
  try {
7
- const externalSuiContext = useSuiClientContext();
8
- return Boolean(externalSuiContext.config);
7
+ useDAppKit();
8
+ return true;
9
9
  }
10
10
  catch {
11
11
  return false;
@@ -1,11 +1,15 @@
1
- import { useConnectWallet, useCurrentWallet, useSignPersonalMessage, useWallets } from "@mysten/dapp-kit";
1
+ import { getWalletUniqueIdentifier, useCurrentAccount, useCurrentWallet, useDAppKit, useWalletConnection, useWallets, } from "@mysten/dapp-kit-react";
2
2
  import { toMessage } from "../utils/message";
3
3
  import { generateNonce as generateDefaultNonce } from "../utils/nonce";
4
4
  export function useSignInWithSui({ signIn, onError, generateNonce }) {
5
- const { mutate: connect } = useConnectWallet();
6
- const { currentWallet, isConnected } = useCurrentWallet();
7
- const { mutate: signPersonalMessage } = useSignPersonalMessage();
5
+ const dAppKit = useDAppKit();
6
+ const currentWallet = useCurrentWallet();
7
+ const currentAccount = useCurrentAccount();
8
+ const connection = useWalletConnection();
8
9
  const wallets = useWallets();
10
+ const handleError = (error) => {
11
+ onError?.(error instanceof Error ? error : new Error(String(error)));
12
+ };
9
13
  const handleSignature = async (address) => {
10
14
  const nonce = generateNonce ? await generateNonce() : generateDefaultNonce();
11
15
  const msg = {
@@ -17,32 +21,44 @@ export function useSignInWithSui({ signIn, onError, generateNonce }) {
17
21
  version: "1",
18
22
  };
19
23
  const message = toMessage(msg, "Sui");
20
- signPersonalMessage({ message: new TextEncoder().encode(message) }, {
21
- onSuccess: (result) => {
22
- signIn({
23
- address,
24
- message,
25
- domain: window.location.host,
26
- signature: result.signature,
27
- });
28
- },
29
- onError,
30
- });
24
+ try {
25
+ const result = await dAppKit.signPersonalMessage({ message: new TextEncoder().encode(message) });
26
+ signIn({
27
+ address,
28
+ message,
29
+ domain: window.location.host,
30
+ signature: result.signature,
31
+ });
32
+ }
33
+ catch (error) {
34
+ handleError(error);
35
+ }
31
36
  };
32
37
  const onSelect = async (id) => {
33
- const selectedWallet = wallets.find((w) => w.id === id);
38
+ const selectedWallet = wallets.find((w) => getWalletUniqueIdentifier(w) === id);
34
39
  if (!selectedWallet)
35
40
  return;
36
- if (currentWallet?.id === selectedWallet.id && isConnected && currentWallet.accounts[0]?.address) {
37
- await handleSignature(currentWallet.accounts[0].address);
41
+ if (currentWallet &&
42
+ getWalletUniqueIdentifier(currentWallet) === getWalletUniqueIdentifier(selectedWallet) &&
43
+ connection.isConnected &&
44
+ currentAccount?.address) {
45
+ await handleSignature(currentAccount.address);
38
46
  return;
39
47
  }
40
- connect({ wallet: selectedWallet }, {
41
- onSuccess: (res) => handleSignature(res.accounts[0].address),
42
- });
48
+ try {
49
+ const res = await dAppKit.connectWallet({ wallet: selectedWallet });
50
+ const address = res.accounts[0]?.address;
51
+ if (!address) {
52
+ throw new Error("No Sui account returned from wallet connection");
53
+ }
54
+ await handleSignature(address);
55
+ }
56
+ catch (error) {
57
+ handleError(error);
58
+ }
43
59
  };
44
60
  const toBaseConnector = (wallet) => ({
45
- id: wallet.id ?? wallet.name,
61
+ id: getWalletUniqueIdentifier(wallet),
46
62
  name: wallet.name,
47
63
  icon: wallet.icon,
48
64
  });
@@ -1,32 +1,29 @@
1
- import { useReportTransactionEffects, useSignTransaction, useSuiClient } from "@mysten/dapp-kit";
1
+ import { useCurrentClient, useDAppKit } from "@mysten/dapp-kit-react";
2
2
  import { Transaction } from "@mysten/sui/transactions";
3
+ import { fromBase64 } from "@mysten/sui/utils";
3
4
  import { SUI_PACKAGE_IDS } from "./constants";
4
5
  export function useSUITransaction() {
5
- const client = useSuiClient();
6
- const { mutateAsync: signTransaction } = useSignTransaction();
7
- const { mutate: reportTransactionEffects } = useReportTransactionEffects();
6
+ const client = useCurrentClient();
7
+ const { signTransaction } = useDAppKit();
8
+ const executeSignedTransaction = async ({ bytes, signature }) => {
9
+ const executeResult = await client.core.executeTransaction({
10
+ transaction: fromBase64(bytes),
11
+ signatures: [signature],
12
+ });
13
+ return executeResult.$kind === "Transaction"
14
+ ? executeResult.Transaction.digest
15
+ : executeResult.FailedTransaction.digest;
16
+ };
8
17
  const execute = async (params) => {
9
18
  const preparedPayment = params.paymentData?.sui;
10
19
  if (preparedPayment) {
11
20
  const transaction = typeof preparedPayment.transaction === "string"
12
21
  ? preparedPayment.transaction
13
22
  : Transaction.from(preparedPayment.transaction);
14
- const { bytes, signature } = await signTransaction({
23
+ const signedTransaction = await signTransaction({
15
24
  transaction,
16
25
  });
17
- const executeResult = await client.executeTransactionBlock({
18
- transactionBlock: bytes,
19
- signature,
20
- options: {
21
- showRawEffects: true,
22
- },
23
- });
24
- if (executeResult.rawEffects) {
25
- reportTransactionEffects({
26
- effects: executeResult.rawEffects,
27
- });
28
- }
29
- return executeResult.digest;
26
+ return executeSignedTransaction(signedTransaction);
30
27
  }
31
28
  const { from: owner, to, amount, token } = params;
32
29
  if (!to || amount == undefined) {
@@ -37,25 +34,25 @@ export function useSUITransaction() {
37
34
  const tx = new Transaction();
38
35
  const value = BigInt(amount);
39
36
  if (isNative) {
40
- const balance = await client.getBalance({
37
+ const balanceResponse = await client.core.getBalance({
41
38
  owner,
42
39
  coinType: SUI_PACKAGE_IDS["sui"],
43
40
  });
44
- if (BigInt(balance.totalBalance) < value) {
45
- throw new Error(`[CHECKOUT] Insufficient balance: ${balance}`);
41
+ if (BigInt(balanceResponse.balance.balance) < value) {
42
+ throw new Error(`[CHECKOUT] Insufficient balance: ${balanceResponse.balance.balance}`);
46
43
  }
47
44
  const [coin] = tx.splitCoins(tx.gas, [value]);
48
45
  tx.transferObjects([coin], to);
49
46
  }
50
47
  else {
51
- const coins = await client.getCoins({
48
+ const coins = await client.core.listCoins({
52
49
  owner,
53
50
  coinType: tokenAddress,
54
51
  });
55
52
  let total = BigInt(0);
56
53
  const coinInputs = [];
57
- for (const c of coins.data) {
58
- coinInputs.push(tx.object(c.coinObjectId));
54
+ for (const c of coins.objects) {
55
+ coinInputs.push(tx.object(c.objectId));
59
56
  total += BigInt(c.balance);
60
57
  if (total >= value)
61
58
  break;
@@ -63,30 +60,20 @@ export function useSUITransaction() {
63
60
  if (total < value)
64
61
  throw new Error("Insufficient balance");
65
62
  const coinInput = coinInputs[0];
63
+ if (!coinInput)
64
+ throw new Error("Insufficient balance");
66
65
  if (coinInputs.length > 1) {
67
66
  tx.mergeCoins(coinInput, coinInputs.slice(1));
68
67
  }
69
68
  const [paymentCoin] = tx.splitCoins(coinInput, [value]);
70
69
  tx.transferObjects([paymentCoin], to);
71
70
  }
72
- const gasPrice = await client.getReferenceGasPrice();
73
- tx.setGasPrice(gasPrice);
74
- const { bytes, signature } = await signTransaction({
71
+ const gasPrice = await client.core.getReferenceGasPrice();
72
+ tx.setGasPrice(gasPrice.referenceGasPrice);
73
+ const signedTransaction = await signTransaction({
75
74
  transaction: tx,
76
75
  });
77
- const executeResult = await client.executeTransactionBlock({
78
- transactionBlock: bytes,
79
- signature,
80
- options: {
81
- showRawEffects: true,
82
- },
83
- });
84
- if (executeResult.rawEffects) {
85
- reportTransactionEffects({
86
- effects: executeResult.rawEffects,
87
- });
88
- }
89
- return executeResult.digest;
76
+ return executeSignedTransaction(signedTransaction);
90
77
  };
91
78
  return { execute };
92
79
  }
@@ -1,7 +1,7 @@
1
1
  import type { Connector as UTXOConnector } from "@bigmi/client";
2
- import type { WalletWithRequiredFeatures } from "@mysten/wallet-standard";
2
+ import type { UiWallet } from "@mysten/dapp-kit-react";
3
3
  import type { Connector } from "wagmi";
4
4
  import { CreateConnectorFnExtended } from "../evm/types";
5
5
  import type { WalletAdapterExtended } from "../solana/types";
6
- export type SuiConnector = WalletWithRequiredFeatures;
6
+ export type SuiConnector = UiWallet;
7
7
  export type WalletConnector = Connector | UTXOConnector | WalletAdapterExtended | CreateConnectorFnExtended | SuiConnector;
@@ -1,5 +1,5 @@
1
1
  import type { ChainId, ChainType } from "@coin-voyage/shared/types";
2
- import type { WalletProviderProps as SuiWalletProviderProps } from "@mysten/dapp-kit";
2
+ import type { createDAppKit } from "@mysten/dapp-kit-react";
3
3
  import type { WalletProviderProps } from "@solana/wallet-adapter-react";
4
4
  import type { EVMConfiguration } from "../evm/create-default-evm-config";
5
5
  import type { UTXOConfiguration } from "../utxo/create-default-utxo-config";
@@ -26,9 +26,11 @@ export type SolanaConfiguration = {
26
26
  rpcUrl?: string;
27
27
  walletConfiguration?: Omit<WalletProviderProps, "children">;
28
28
  };
29
+ type SuiDAppKitOptions = Parameters<typeof createDAppKit>[0];
30
+ export type SuiDAppKitConfiguration = Pick<SuiDAppKitOptions, "autoConnect" | "enableBurnerWallet" | "slushWalletConfig" | "storage" | "storageKey" | "walletInitializers">;
29
31
  export type SuiConfiguration = {
30
- rpcUrl?: string;
31
- walletConfiguration?: Omit<SuiWalletProviderProps, "children">;
32
+ grpcUrl?: string;
33
+ walletConfiguration?: SuiDAppKitConfiguration;
32
34
  };
33
35
  export type ChainTypeWalletConnector = {
34
36
  connector: WalletConnector;
@@ -74,3 +76,4 @@ export type WalletPermission = {
74
76
  chainType: ChainType;
75
77
  allowed: boolean;
76
78
  };
79
+ export {};
@@ -1,5 +1,5 @@
1
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
- export declare const getConnectorId: (connector: WalletConnector) => string;
4
+ export declare const getConnectorId: (connector?: WalletConnector) => string | undefined;
5
5
  export declare const getConnector: (walletConnector: ChainTypeWalletConnector[], chainType?: ChainType) => WalletConnector;
@@ -1,8 +1,7 @@
1
1
  export const getConnectorId = (connector) => {
2
- if ("id" in connector) {
3
- return connector.id ?? connector.name;
4
- }
5
- return connector.name;
2
+ if (!connector)
3
+ return undefined;
4
+ return "id" in connector ? connector.id : connector.name;
6
5
  };
7
6
  export const getConnector = (walletConnector, chainType) => {
8
7
  let connector = walletConnector[0];
@@ -3,4 +3,4 @@ export interface UTXORpcConfig {
3
3
  url?: string | undefined;
4
4
  config?: HttpTransportConfig;
5
5
  }
6
- export declare function createUTXOTransport(rpcConfig?: UTXORpcConfig): import("@bigmi/core").FallbackTransport<readonly [import("@bigmi/core").HttpTransport<undefined, false>, import("@bigmi/core").HttpTransport<import("@bigmi/core").RpcSchema, false>, import("@bigmi/core").HttpTransport<undefined, false>, import("@bigmi/core").HttpTransport<undefined, false>, import("@bigmi/core").HttpTransport<undefined, false>, import("@bigmi/core").HttpTransport<undefined, false>]>;
6
+ export declare function createUTXOTransport(rpcConfig?: UTXORpcConfig): import("@bigmi/core").FallbackTransport<readonly [import("@bigmi/core").HttpTransport<undefined, false>, import("@bigmi/core").HttpTransport<import("@bigmi/core").RpcSchema, false>, import("@bigmi/core").HttpTransport, import("@bigmi/core").HttpTransport, import("@bigmi/core").HttpTransport, import("@bigmi/core").HttpTransport]>;
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.4.5-beta.0",
4
+ "version": "2.4.6",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "author": "Lars <lars@coinvoyage.io>",
@@ -93,19 +93,18 @@
93
93
  }
94
94
  },
95
95
  "dependencies": {
96
- "@bigmi/client": "0.6.1",
97
- "@bigmi/core": "0.6.1",
96
+ "@bigmi/client": "0.8.0",
97
+ "@bigmi/core": "0.8.0",
98
98
  "@noble/secp256k1": "1.7.1",
99
99
  "@noble/ed25519": "2.3.0",
100
- "@scure/base": "1.1.1",
100
+ "@scure/base": "2.2.0",
101
101
  "@scure/btc-signer": "1.6.0",
102
102
  "@stablelib/random": "2.0.1",
103
103
  "jsontokens": "4.0.1",
104
104
  "bitcoinjs-lib": "6.1.7",
105
105
  "bitcoinjs-message": "2.2.0",
106
106
  "bitcoin-address-validation": "3.0.0",
107
- "@mysten/sui": "1.44.0",
108
- "@mysten/wallet-standard": "0.19.6",
107
+ "@mysten/sui": "2.16.2",
109
108
  "@solana/web3.js": "1.98.4",
110
109
  "@solana/spl-token": "0.4.14",
111
110
  "@solana/wallet-standard-features": "1.3.0",
@@ -113,20 +112,20 @@
113
112
  "@solana/wallet-adapter-walletconnect": "0.1.21",
114
113
  "@solana/wallet-adapter-base": "0.9.27",
115
114
  "@solana/wallet-adapter-coinbase": "0.1.23",
116
- "@coin-voyage/shared": "2.4.5-beta.0"
115
+ "@coin-voyage/shared": "2.4.6"
117
116
  },
118
117
  "devDependencies": {
119
118
  "@types/elliptic": "6.4.18"
120
119
  },
121
120
  "peerDependencies": {
122
- "@bigmi/react": "^0.6.1",
123
- "@mysten/dapp-kit": "^0.19.8",
121
+ "@bigmi/react": "^0.8.0",
122
+ "@mysten/dapp-kit-react": "^2.0.3",
124
123
  "@solana/wallet-adapter-react": "^0.15.39",
125
124
  "@tanstack/react-query": "^5.90.6",
126
125
  "react": "^18 || ^19",
127
126
  "react-dom": "^18 || ^19",
128
- "viem": "^2.41.2",
129
- "wagmi": "^2.19.5"
127
+ "viem": "^2.51.2",
128
+ "wagmi": "^3.6.16"
130
129
  },
131
130
  "overrides": {
132
131
  "@walletconnect/logger": {
@@ -1,2 +0,0 @@
1
- import { SuiClient } from "@mysten/sui/client";
2
- export declare const suiClient: SuiClient;
@@ -1,2 +0,0 @@
1
- import { SuiClient } from "@mysten/sui/client";
2
- export const suiClient = new SuiClient({ url: "https://fullnode.mainnet.sui.io" });