@bit-buccaneers/wallet-abstraction 0.0.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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/dev.js +1287 -0
- package/dist/dev.jsx +1323 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1282 -0
- package/dist/index.jsx +1318 -0
- package/dist/lib/connectors/binance.d.ts +4 -0
- package/dist/lib/connectors/exodus.d.ts +4 -0
- package/dist/lib/connectors/index.d.ts +7 -0
- package/dist/lib/connectors/metamask.d.ts +4 -0
- package/dist/lib/connectors/phantom.d.ts +10 -0
- package/dist/lib/connectors/rainbow.d.ts +2 -0
- package/dist/lib/connectors/shared/constants.d.ts +22 -0
- package/dist/lib/connectors/shared/deeplink.d.ts +67 -0
- package/dist/lib/connectors/shared/index.d.ts +7 -0
- package/dist/lib/connectors/shared/injected.d.ts +4 -0
- package/dist/lib/connectors/shared/parsers.d.ts +23 -0
- package/dist/lib/connectors/shared/utils.d.ts +24 -0
- package/dist/lib/connectors/shared/walletconnect.d.ts +12 -0
- package/dist/lib/connectors/shared/wc-connector-factory.d.ts +10 -0
- package/dist/lib/connectors/solflare.d.ts +11 -0
- package/dist/lib/connectors/trust.d.ts +4 -0
- package/dist/lib/context/WalletContext.d.ts +23 -0
- package/dist/lib/context/hooks/index.d.ts +3 -0
- package/dist/lib/context/hooks/useEvmWallet.d.ts +14 -0
- package/dist/lib/context/hooks/useSolanaWallet.d.ts +11 -0
- package/dist/lib/context/hooks/useWalletConnect.d.ts +16 -0
- package/dist/lib/context/index.d.ts +1 -0
- package/dist/lib/core/constants.d.ts +3 -0
- package/dist/lib/core/helpers.d.ts +7 -0
- package/dist/lib/core/index.d.ts +5 -0
- package/dist/lib/core/storage.d.ts +8 -0
- package/dist/lib/core/types.d.ts +37 -0
- package/dist/lib/core/utils.d.ts +8 -0
- package/dist/lib/evm/config.d.ts +6 -0
- package/dist/lib/evm/connection.d.ts +2 -0
- package/dist/lib/evm/connectors.d.ts +2 -0
- package/dist/lib/evm/index.d.ts +4 -0
- package/dist/lib/evm/types.d.ts +12 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/solana/connection.d.ts +5 -0
- package/dist/lib/solana/connectors.d.ts +4 -0
- package/dist/lib/solana/index.d.ts +4 -0
- package/dist/lib/solana/reconnect.d.ts +3 -0
- package/dist/lib/solana/types.d.ts +16 -0
- package/dist/lib/walletconnect/client.d.ts +31 -0
- package/dist/lib/walletconnect/index.d.ts +1 -0
- package/dist/lib/wallets/config.d.ts +7 -0
- package/dist/lib/wallets/index.d.ts +2 -0
- package/dist/lib/wallets/mappers.d.ts +2 -0
- package/package.json +111 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EvmWalletConnector } from '../evm';
|
|
2
|
+
import type { SolanaWalletConnector } from '../solana';
|
|
3
|
+
export declare const createExodusEvmMobileConnector: () => EvmWalletConnector;
|
|
4
|
+
export declare const createExodusSolanaMobileConnector: () => SolanaWalletConnector;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createPhantomEvmConnector, createPhantomSolanaConnector, isPhantomMobilePending, handlePhantomMobileCallback, restorePhantomMobileSession, isPhantomSignPending, handlePhantomSignCallback, } from './phantom';
|
|
2
|
+
export { createMetaMaskEvmConnector, createMetaMaskSolanaConnector } from './metamask';
|
|
3
|
+
export { createSolflareSolanaMobileConnector, isSolflareMobilePending, handleSolflareMobileCallback, restoreSolflareMobileSession, isSolflareSignPending, handleSolflareSignCallback, } from './solflare';
|
|
4
|
+
export { createTrustEvmMobileConnector, createTrustSolanaMobileConnector } from './trust';
|
|
5
|
+
export { createRainbowEvmMobileConnector } from './rainbow';
|
|
6
|
+
export { createExodusEvmMobileConnector, createExodusSolanaMobileConnector } from './exodus';
|
|
7
|
+
export { createBinanceEvmConnector, createBinanceSolanaConnector } from './binance';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ConnectedResult } from '../core';
|
|
2
|
+
import type { EvmWalletConnector } from '../evm';
|
|
3
|
+
import type { SolanaWalletConnector } from '../solana';
|
|
4
|
+
export declare const createPhantomEvmConnector: () => EvmWalletConnector;
|
|
5
|
+
export declare const createPhantomSolanaConnector: () => SolanaWalletConnector;
|
|
6
|
+
export declare const isPhantomMobilePending: () => boolean;
|
|
7
|
+
export declare const handlePhantomMobileCallback: () => ConnectedResult | null;
|
|
8
|
+
export declare const restorePhantomMobileSession: () => ConnectedResult | null;
|
|
9
|
+
export declare const isPhantomSignPending: () => boolean;
|
|
10
|
+
export declare const handlePhantomSignCallback: () => string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const WC_CHAINS: {
|
|
2
|
+
readonly EVM_MAINNET: "eip155:1";
|
|
3
|
+
readonly SOLANA_MAINNET: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
4
|
+
};
|
|
5
|
+
export declare const WC_METHODS: {
|
|
6
|
+
readonly EVM: readonly ["eth_sendTransaction", "personal_sign", "eth_signTypedData"];
|
|
7
|
+
readonly SOLANA: readonly ["solana_signTransaction", "solana_signMessage"];
|
|
8
|
+
};
|
|
9
|
+
export declare const WC_EVENTS: {
|
|
10
|
+
readonly EVM: readonly ["chainChanged", "accountsChanged"];
|
|
11
|
+
readonly SOLANA: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const EVM_WC_CONFIG: {
|
|
14
|
+
readonly chains: readonly ["eip155:1"];
|
|
15
|
+
readonly methods: readonly ["eth_sendTransaction", "personal_sign", "eth_signTypedData"];
|
|
16
|
+
readonly events: readonly ["chainChanged", "accountsChanged"];
|
|
17
|
+
};
|
|
18
|
+
export declare const SOLANA_WC_CONFIG: {
|
|
19
|
+
readonly chains: readonly ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];
|
|
20
|
+
readonly methods: readonly ["solana_signTransaction", "solana_signMessage"];
|
|
21
|
+
readonly events: string[];
|
|
22
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import nacl from 'tweetnacl';
|
|
2
|
+
import type { ConnectedResult } from '../../core';
|
|
3
|
+
export interface DeeplinkConfig {
|
|
4
|
+
connectUrl: string;
|
|
5
|
+
storageKeyPrefix: string;
|
|
6
|
+
encryptionKeyParam: string;
|
|
7
|
+
callbackParam: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DeeplinkSession {
|
|
10
|
+
publicKey: string;
|
|
11
|
+
session: string;
|
|
12
|
+
sharedSecret: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface StoredSession {
|
|
15
|
+
publicKey: string;
|
|
16
|
+
session: string;
|
|
17
|
+
sharedSecret: number[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get or create dApp keypair for encryption
|
|
21
|
+
*/
|
|
22
|
+
export declare const getDappKeyPair: (storageKey: string) => nacl.BoxKeyPair;
|
|
23
|
+
/**
|
|
24
|
+
* Clear dApp keypair from storage
|
|
25
|
+
*/
|
|
26
|
+
export declare const clearDappKeyPair: (storageKey: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Build connect URL with encryption params
|
|
29
|
+
*/
|
|
30
|
+
export declare const buildConnectUrl: (config: DeeplinkConfig, params: {
|
|
31
|
+
appUrl: string;
|
|
32
|
+
redirectUrl: string;
|
|
33
|
+
cluster?: string;
|
|
34
|
+
chain?: string;
|
|
35
|
+
}) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Parse encrypted connect response from URL params
|
|
38
|
+
*/
|
|
39
|
+
export declare const parseConnectResponse: (urlParams: URLSearchParams, config: DeeplinkConfig) => DeeplinkSession | null;
|
|
40
|
+
/**
|
|
41
|
+
* Check if URL params contain a wallet response
|
|
42
|
+
*/
|
|
43
|
+
export declare const isWalletResponse: (urlParams: URLSearchParams, encryptionKeyParam: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Handle mobile callback and return connected result
|
|
46
|
+
*/
|
|
47
|
+
export declare const handleMobileCallback: (config: DeeplinkConfig, pendingKey: string, sessionKey: string) => ConnectedResult | null;
|
|
48
|
+
/**
|
|
49
|
+
* Restore session from storage
|
|
50
|
+
*/
|
|
51
|
+
export declare const restoreMobileSession: (sessionKey: string) => ConnectedResult | null;
|
|
52
|
+
/**
|
|
53
|
+
* Clear mobile session
|
|
54
|
+
*/
|
|
55
|
+
export declare const clearMobileSession: (pendingKey: string, sessionKey: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Get stored session with sharedSecret
|
|
58
|
+
*/
|
|
59
|
+
export declare const getStoredSession: (sessionKey: string) => StoredSession | null;
|
|
60
|
+
/**
|
|
61
|
+
* Build signMessage URL with encrypted payload
|
|
62
|
+
*/
|
|
63
|
+
export declare const buildSignMessageUrl: (signUrl: string, config: DeeplinkConfig, sessionKey: string, message: string, redirectUrl: string) => string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Parse signMessage response from URL params
|
|
66
|
+
*/
|
|
67
|
+
export declare const parseSignMessageResponse: (config: DeeplinkConfig, sessionKey: string) => string | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ConnectedResult } from '../../core';
|
|
2
|
+
export declare const connectEvmInjected: () => Promise<ConnectedResult>;
|
|
3
|
+
export declare const connectSolanaInjected: () => Promise<ConnectedResult>;
|
|
4
|
+
export declare const signSolanaInjected: (message: string) => Promise<string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ConnectedResult } from '../../core';
|
|
2
|
+
/**
|
|
3
|
+
* Parse EVM account from WalletConnect namespace format
|
|
4
|
+
* Format: "eip155:chainId:address"
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseEvmAccount: (account: string) => ConnectedResult;
|
|
7
|
+
/**
|
|
8
|
+
* Parse Solana account from WalletConnect namespace format
|
|
9
|
+
* Format: "solana:cluster:address"
|
|
10
|
+
*/
|
|
11
|
+
export declare const parseSolanaAccount: (account: string) => Promise<ConnectedResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Extract EVM account from WalletConnect session namespaces
|
|
14
|
+
*/
|
|
15
|
+
export declare const getEvmAccountFromSession: (namespaces: Record<string, {
|
|
16
|
+
accounts?: string[];
|
|
17
|
+
}>) => ConnectedResult;
|
|
18
|
+
/**
|
|
19
|
+
* Extract Solana account from WalletConnect session namespaces
|
|
20
|
+
*/
|
|
21
|
+
export declare const getSolanaAccountFromSession: (namespaces: Record<string, {
|
|
22
|
+
accounts?: string[];
|
|
23
|
+
}>) => Promise<ConnectedResult>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if current device is mobile
|
|
3
|
+
*/
|
|
4
|
+
export declare const isMobile: () => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Check if running inside a wallet's in-app browser
|
|
7
|
+
*/
|
|
8
|
+
export declare const isInWalletBrowser: (key: string) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get current page URL for redirect callbacks
|
|
11
|
+
*/
|
|
12
|
+
export declare const getCurrentUrl: () => string;
|
|
13
|
+
/**
|
|
14
|
+
* Open deeplink via anchor click (avoids page unload on mobile)
|
|
15
|
+
*/
|
|
16
|
+
export declare const openDeeplink: (url: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Create in-app browser deeplink URL
|
|
19
|
+
*/
|
|
20
|
+
export declare const createInAppBrowserUrl: (baseUrl: string, targetUrl?: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Wait for a value to become available (polling)
|
|
23
|
+
*/
|
|
24
|
+
export declare const waitForValue: <T>(getValue: () => T | null | undefined) => Promise<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConnectedResult, ConnectResult } from '../../core';
|
|
2
|
+
export interface WcConnectConfig {
|
|
3
|
+
chains: readonly string[];
|
|
4
|
+
methods: readonly string[];
|
|
5
|
+
events: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Connect via WalletConnect with QR code and optional mobile deeplink
|
|
9
|
+
*/
|
|
10
|
+
export declare const connectViaWalletConnect: (wcConfig: WcConnectConfig, parseSession: (namespaces: Record<string, {
|
|
11
|
+
accounts?: string[];
|
|
12
|
+
}>) => ConnectedResult | Promise<ConnectedResult>, getDeeplink?: (uri: string) => string) => Promise<ConnectResult>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EvmWalletConnector } from '../../evm';
|
|
2
|
+
import type { SolanaWalletConnector } from '../../solana';
|
|
3
|
+
import { type WalletId } from '../../wallets';
|
|
4
|
+
export interface WcWalletConfig {
|
|
5
|
+
walletId: WalletId;
|
|
6
|
+
wcDeeplink: string;
|
|
7
|
+
injectedKey: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const createWcEvmConnector: (config: WcWalletConfig) => EvmWalletConnector;
|
|
10
|
+
export declare const createWcSolanaConnector: (config: WcWalletConfig) => SolanaWalletConnector;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ConnectedResult } from '../core';
|
|
2
|
+
import type { SolanaWalletConnector } from '../solana';
|
|
3
|
+
import { type StoredSession } from './shared';
|
|
4
|
+
export declare const createSolflareSolanaMobileConnector: () => SolanaWalletConnector;
|
|
5
|
+
export declare const isSolflareMobilePending: () => boolean;
|
|
6
|
+
export declare const handleSolflareMobileCallback: () => ConnectedResult | null;
|
|
7
|
+
export declare const getSolflareMobileSession: () => StoredSession | null;
|
|
8
|
+
export declare const restoreSolflareMobileSession: () => ConnectedResult | null;
|
|
9
|
+
export declare const clearSolflareMobileSession: () => void;
|
|
10
|
+
export declare const isSolflareSignPending: () => boolean;
|
|
11
|
+
export declare const handleSolflareSignCallback: () => string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Accessor, type ParentProps } from 'solid-js';
|
|
2
|
+
import { type ChainType, type ConnectedResult, type ConnectResult, type GroupedWallet } from '../core';
|
|
3
|
+
import { type EvmChains, type EvmWalletConnector } from '../evm';
|
|
4
|
+
import { type SolanaWalletConnector } from '../solana';
|
|
5
|
+
import { type WalletConnectConfig } from '../walletconnect';
|
|
6
|
+
export interface WalletContextValue {
|
|
7
|
+
evmConnectors: Accessor<EvmWalletConnector[]>;
|
|
8
|
+
evmConnection: Accessor<ConnectedResult | null>;
|
|
9
|
+
solanaConnectors: Accessor<SolanaWalletConnector[]>;
|
|
10
|
+
solanaConnection: Accessor<ConnectedResult | null>;
|
|
11
|
+
groupedWallets: Accessor<GroupedWallet[]>;
|
|
12
|
+
connectEvm: (connector: EvmWalletConnector) => Promise<ConnectResult>;
|
|
13
|
+
disconnectEvm: () => Promise<void>;
|
|
14
|
+
connectSolana: (connector: SolanaWalletConnector) => Promise<ConnectResult>;
|
|
15
|
+
disconnectSolana: () => Promise<void>;
|
|
16
|
+
signMessage: (chainType: ChainType, message: string) => Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
export interface WalletProviderProps {
|
|
19
|
+
evmChains: EvmChains;
|
|
20
|
+
walletConnect?: WalletConnectConfig;
|
|
21
|
+
}
|
|
22
|
+
export declare const WalletProvider: (props: ParentProps<WalletProviderProps>) => import("solid-js").JSX.Element;
|
|
23
|
+
export declare function useWallet(): WalletContextValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ConnectedResult, type ConnectResult } from '../../core';
|
|
2
|
+
import { type EvmChains, type EvmWalletConnector } from '../../evm';
|
|
3
|
+
export interface UseEvmWalletOptions {
|
|
4
|
+
chains: EvmChains;
|
|
5
|
+
}
|
|
6
|
+
export interface UseEvmWalletReturn {
|
|
7
|
+
evmConnectors: () => EvmWalletConnector[];
|
|
8
|
+
evmConnection: () => ConnectedResult | null;
|
|
9
|
+
setEvmConnection: (connection: ConnectedResult | null) => void;
|
|
10
|
+
connectEvm: (connector: EvmWalletConnector) => Promise<ConnectResult>;
|
|
11
|
+
disconnectEvm: () => Promise<void>;
|
|
12
|
+
connectedEvmConnector: () => EvmWalletConnector | null;
|
|
13
|
+
}
|
|
14
|
+
export declare const useEvmWallet: (options: UseEvmWalletOptions) => UseEvmWalletReturn;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ConnectedResult, type ConnectResult } from '../../core';
|
|
2
|
+
import { type SolanaWalletConnector } from '../../solana';
|
|
3
|
+
export interface UseSolanaWalletReturn {
|
|
4
|
+
solanaConnectors: () => SolanaWalletConnector[];
|
|
5
|
+
solanaConnection: () => ConnectedResult | null;
|
|
6
|
+
setSolanaConnection: (connection: ConnectedResult | null) => void;
|
|
7
|
+
connectSolana: (connector: SolanaWalletConnector) => Promise<ConnectResult>;
|
|
8
|
+
disconnectSolana: () => Promise<void>;
|
|
9
|
+
connectedSolanaConnector: () => SolanaWalletConnector | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const useSolanaWallet: () => UseSolanaWalletReturn;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConnectedResult } from '../../core';
|
|
2
|
+
import { type WalletConnectConfig } from '../../walletconnect';
|
|
3
|
+
export interface UseWalletConnectOptions {
|
|
4
|
+
config?: WalletConnectConfig;
|
|
5
|
+
onEvmConnection?: (connection: ConnectedResult) => void;
|
|
6
|
+
onSolanaConnection?: (connection: ConnectedResult) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface UseWalletConnectReturn {
|
|
9
|
+
disconnectWcEvm: () => Promise<void>;
|
|
10
|
+
disconnectWcSolana: () => Promise<void>;
|
|
11
|
+
hasWcEvmSession: () => boolean;
|
|
12
|
+
hasWcSolanaSession: () => boolean;
|
|
13
|
+
signWcEvmMessage: (message: string) => Promise<string>;
|
|
14
|
+
signWcSolanaMessage: (message: string) => Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export declare const useWalletConnect: (options: UseWalletConnectOptions) => UseWalletConnectReturn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WalletProvider, useWallet, type WalletContextValue, type WalletProviderProps } from './WalletContext';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConnectedResult, PendingResult, QRCodeResult } from './types';
|
|
2
|
+
export declare const connectedResult: (address: string, options?: {
|
|
3
|
+
chainId?: number;
|
|
4
|
+
publicKey?: Uint8Array;
|
|
5
|
+
}) => ConnectedResult;
|
|
6
|
+
export declare const qrcodeResult: (uri: string, wait: () => Promise<ConnectedResult>) => QRCodeResult;
|
|
7
|
+
export declare const pendingResult: () => PendingResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const storage: {
|
|
2
|
+
get: <T>(key: string) => T | null;
|
|
3
|
+
getString: (key: string) => string | null;
|
|
4
|
+
set: <T>(key: string, value: T) => void;
|
|
5
|
+
setString: (key: string, value: string) => void;
|
|
6
|
+
remove: (key: string) => void;
|
|
7
|
+
has: (key: string) => boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EvmWalletConnector } from '../evm';
|
|
2
|
+
import { SolanaWalletConnector } from '../solana';
|
|
3
|
+
export type ChainType = 'evm' | 'solana';
|
|
4
|
+
export interface ConnectedResult {
|
|
5
|
+
status: 'connected';
|
|
6
|
+
address: string;
|
|
7
|
+
chainId?: number;
|
|
8
|
+
publicKey?: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export interface QRCodeResult {
|
|
11
|
+
status: 'qrcode';
|
|
12
|
+
uri: string;
|
|
13
|
+
wait: () => Promise<ConnectedResult>;
|
|
14
|
+
}
|
|
15
|
+
export interface PendingResult {
|
|
16
|
+
status: 'pending';
|
|
17
|
+
}
|
|
18
|
+
export type ConnectResult = ConnectedResult | QRCodeResult | PendingResult;
|
|
19
|
+
export interface Wallet {
|
|
20
|
+
connect: () => Promise<ConnectResult>;
|
|
21
|
+
disconnect: () => Promise<void>;
|
|
22
|
+
signMessage: (message: string) => Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface WalletConnector {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
type: ChainType;
|
|
29
|
+
installed?: boolean;
|
|
30
|
+
wallet: Wallet;
|
|
31
|
+
}
|
|
32
|
+
export interface GroupedWallet {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
evm?: EvmWalletConnector;
|
|
36
|
+
solana?: SolanaWalletConnector;
|
|
37
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Config } from '@wagmi/core';
|
|
2
|
+
import { type Chain } from 'viem';
|
|
3
|
+
export type EvmChains = readonly [Chain, ...Chain[]];
|
|
4
|
+
export declare const createEvmConfig: (chains?: EvmChains) => Config;
|
|
5
|
+
export declare const getEvmConfig: () => Config;
|
|
6
|
+
export type { Config };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Connector as WagmiConnector } from '@wagmi/core';
|
|
2
|
+
import type { ConnectResult, WalletConnector } from '../core';
|
|
3
|
+
export interface EvmWallet {
|
|
4
|
+
connect: () => Promise<ConnectResult>;
|
|
5
|
+
disconnect: () => Promise<void>;
|
|
6
|
+
signMessage: (message: string) => Promise<string>;
|
|
7
|
+
_connector: WagmiConnector;
|
|
8
|
+
}
|
|
9
|
+
export interface EvmWalletConnector extends Omit<WalletConnector, 'wallet'> {
|
|
10
|
+
type: 'evm';
|
|
11
|
+
wallet: EvmWallet;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { type ChainType, type ConnectResult, type GroupedWallet, type Wallet, type WalletConnector, } from './core';
|
|
2
|
+
export { createEvmConfig, getEvmConfig, getEvmConnectors, watchEvmConnections, type Config, type EvmChains, type EvmWallet, type EvmWalletConnector, } from './evm';
|
|
3
|
+
export { getSolanaWallets, onSolanaWalletsChange, reconnectSolana, watchSolanaConnection, checkPhantomSignCallback, checkSolflareSignCallback, type SolanaConnection, type SolanaWallet, type SolanaWalletConnector, } from './solana';
|
|
4
|
+
export { useWallet, WalletProvider, type WalletContextValue } from './context';
|
|
5
|
+
export { WALLETS, type WalletConfig } from './wallets';
|
|
6
|
+
export { initWalletConnect, type WalletConnectConfig } from './walletconnect';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ConnectedResult } from '../core';
|
|
2
|
+
import type { SolanaConnection, SolanaWalletConnector } from './types';
|
|
3
|
+
export declare const setConnection: (connection: ConnectedResult | null, connector: SolanaWalletConnector | null) => void;
|
|
4
|
+
export declare const getConnection: () => SolanaConnection;
|
|
5
|
+
export declare const watchSolanaConnection: (onChange: (state: SolanaConnection) => void) => (() => void);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SolanaWalletConnector } from './types';
|
|
2
|
+
export declare const createSolanaMobileConnector: (connector: SolanaWalletConnector) => SolanaWalletConnector;
|
|
3
|
+
export declare const getSolanaWallets: () => SolanaWalletConnector[];
|
|
4
|
+
export declare const onSolanaWalletsChange: (callback: (wallets: SolanaWalletConnector[]) => void) => (() => void);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { setConnection, getConnection, watchSolanaConnection } from './connection';
|
|
2
|
+
export { getSolanaWallets, onSolanaWalletsChange, createSolanaMobileConnector } from './connectors';
|
|
3
|
+
export { reconnectSolana, checkPhantomSignCallback, checkSolflareSignCallback } from './reconnect';
|
|
4
|
+
export type { SolanaWallet, SolanaWalletConnector, SolanaConnection } from './types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WalletAdapterCompatibleStandardWallet } from '@solana/wallet-adapter-base';
|
|
2
|
+
import type { ConnectedResult, ConnectResult, WalletConnector } from '../core';
|
|
3
|
+
export interface SolanaWallet {
|
|
4
|
+
connect: () => Promise<ConnectResult>;
|
|
5
|
+
disconnect: () => Promise<void>;
|
|
6
|
+
signMessage: (message: string) => Promise<string>;
|
|
7
|
+
_provider: WalletAdapterCompatibleStandardWallet;
|
|
8
|
+
}
|
|
9
|
+
export interface SolanaWalletConnector extends Omit<WalletConnector, 'wallet'> {
|
|
10
|
+
type: 'solana';
|
|
11
|
+
wallet: SolanaWallet;
|
|
12
|
+
}
|
|
13
|
+
export interface SolanaConnection {
|
|
14
|
+
connection: ConnectedResult | null;
|
|
15
|
+
connector: SolanaWalletConnector | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SignClient } from '@walletconnect/sign-client';
|
|
2
|
+
import type { SessionTypes } from '@walletconnect/types';
|
|
3
|
+
export interface WalletConnectConfig {
|
|
4
|
+
projectId: string;
|
|
5
|
+
metadata: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
url: string;
|
|
9
|
+
icons: string[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface WalletConnectSession {
|
|
13
|
+
topic: string;
|
|
14
|
+
namespaces: SessionTypes.Namespaces;
|
|
15
|
+
}
|
|
16
|
+
type SessionChangeCallback = (session: WalletConnectSession | null) => void;
|
|
17
|
+
export declare const onWalletConnectSessionChange: (callback: SessionChangeCallback) => (() => void);
|
|
18
|
+
export declare const initWalletConnect: (config: WalletConnectConfig) => Promise<void>;
|
|
19
|
+
export declare const getSignClient: () => InstanceType<typeof SignClient> | null;
|
|
20
|
+
export declare const getCurrentSession: () => WalletConnectSession | null;
|
|
21
|
+
export declare const setCurrentSession: (session: WalletConnectSession | null) => void;
|
|
22
|
+
export interface ConnectOptions {
|
|
23
|
+
chains: string[];
|
|
24
|
+
methods: string[];
|
|
25
|
+
events: string[];
|
|
26
|
+
onQRCode?: (uri: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare const connectWalletConnect: (options: ConnectOptions) => Promise<WalletConnectSession>;
|
|
29
|
+
export declare const disconnectWalletConnect: () => Promise<void>;
|
|
30
|
+
export declare const requestWalletConnect: <T>(method: string, params: unknown, chainId: string) => Promise<T>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { connectWalletConnect, type ConnectOptions, disconnectWalletConnect, getCurrentSession, getSignClient, initWalletConnect, onWalletConnectSessionChange, requestWalletConnect, setCurrentSession, type WalletConnectConfig, type WalletConnectSession, } from './client';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const WALLET_IDS: readonly ["metamask", "phantom", "okx", "coinbase", "binance", "bitget", "solflare", "trust", "rabby", "rainbow", "exodus"];
|
|
2
|
+
export type WalletId = (typeof WALLET_IDS)[number];
|
|
3
|
+
export interface WalletConfig {
|
|
4
|
+
id: WalletId;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const WALLETS: WalletConfig[];
|