decane-connect-kit 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/README.md +583 -0
- package/dist/index.cjs +2339 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +275 -0
- package/dist/index.d.ts +275 -0
- package/dist/index.js +2296 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type ChainType = "evm" | "solana";
|
|
4
|
+
type ChainSupport = ["evm"] | ["solana"] | ["evm", "solana"];
|
|
5
|
+
interface ChainDescriptor {
|
|
6
|
+
id: string;
|
|
7
|
+
type: ChainType;
|
|
8
|
+
name: string;
|
|
9
|
+
nativeCurrency: {
|
|
10
|
+
name: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
decimals: number;
|
|
13
|
+
};
|
|
14
|
+
rpcUrl?: string;
|
|
15
|
+
blockExplorerUrl?: string;
|
|
16
|
+
iconUrl?: string;
|
|
17
|
+
chainId?: number;
|
|
18
|
+
isCustom?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface UnifiedWalletAccount {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
icon: string;
|
|
24
|
+
rdns?: string;
|
|
25
|
+
chainSupport: ChainSupport;
|
|
26
|
+
evmProvider?: EIP1193Provider;
|
|
27
|
+
solanaProvider?: StandardWallet;
|
|
28
|
+
}
|
|
29
|
+
type CAIP25Method = "wallet_requestPermissions" | "wallet_revokePermissions" | "wallet_getPermissions" | "wallet_sendTransaction" | "wallet_signMessage" | "wallet_signTypedData";
|
|
30
|
+
interface ChainScope {
|
|
31
|
+
methods: CAIP25Method[];
|
|
32
|
+
accounts: string[];
|
|
33
|
+
events?: string[];
|
|
34
|
+
}
|
|
35
|
+
interface CAIP25SessionRequest {
|
|
36
|
+
requiredScopes: Partial<Record<string, ChainScope>>;
|
|
37
|
+
optionalScopes: Partial<Record<string, ChainScope>>;
|
|
38
|
+
}
|
|
39
|
+
interface CAIP25SessionResult {
|
|
40
|
+
sessionId: string;
|
|
41
|
+
grantedScopes: Partial<Record<string, ChainScope>>;
|
|
42
|
+
}
|
|
43
|
+
interface ActiveSession {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
grantedScopes: Partial<Record<string, ChainScope>>;
|
|
46
|
+
walletId: string;
|
|
47
|
+
walletType: ChainType | "multi";
|
|
48
|
+
createdAt: number;
|
|
49
|
+
}
|
|
50
|
+
interface DecaneProvider {
|
|
51
|
+
request(args: {
|
|
52
|
+
method: string;
|
|
53
|
+
params?: unknown[];
|
|
54
|
+
}): Promise<unknown>;
|
|
55
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
56
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
57
|
+
readonly wallets: UnifiedWalletAccount[];
|
|
58
|
+
readonly evmWallets: UnifiedWalletAccount[];
|
|
59
|
+
readonly solanaWallets: UnifiedWalletAccount[];
|
|
60
|
+
readonly multiChainWallets: UnifiedWalletAccount[];
|
|
61
|
+
connect(wallet: UnifiedWalletAccount, preferredChain?: ChainType): Promise<void>;
|
|
62
|
+
disconnect(): Promise<void>;
|
|
63
|
+
addChain(chain: ChainDescriptor): void;
|
|
64
|
+
removeChain(chainId: string): void;
|
|
65
|
+
getChain(chainId: string): ChainDescriptor | undefined;
|
|
66
|
+
readonly chains: ChainDescriptor[];
|
|
67
|
+
readonly connectedWallet: UnifiedWalletAccount | null;
|
|
68
|
+
readonly activeSession: ActiveSession | null;
|
|
69
|
+
readonly activeChain: string | null;
|
|
70
|
+
}
|
|
71
|
+
interface DecaneConfig {
|
|
72
|
+
chains?: ChainDescriptor[];
|
|
73
|
+
supportedChainIds?: string[];
|
|
74
|
+
networks?: "evm" | "solana" | "all";
|
|
75
|
+
defaultChain?: string;
|
|
76
|
+
theme?: "light" | "dark" | "auto";
|
|
77
|
+
}
|
|
78
|
+
interface EIP1193Provider {
|
|
79
|
+
request(args: {
|
|
80
|
+
method: string;
|
|
81
|
+
params?: unknown[];
|
|
82
|
+
}): Promise<unknown>;
|
|
83
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
84
|
+
removeListener(event: string, handler: (...args: unknown[]) => void): void;
|
|
85
|
+
}
|
|
86
|
+
interface StandardWallet {
|
|
87
|
+
name: string;
|
|
88
|
+
icon: string;
|
|
89
|
+
features: Record<string, unknown>;
|
|
90
|
+
accounts: StandardWalletAccount[];
|
|
91
|
+
}
|
|
92
|
+
interface StandardWalletAccount {
|
|
93
|
+
address: string;
|
|
94
|
+
publicKey: Uint8Array;
|
|
95
|
+
chains: string[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare function createDecane(config?: DecaneConfig): DecaneProvider;
|
|
99
|
+
|
|
100
|
+
declare class DecaneError extends Error {
|
|
101
|
+
code: DecaneErrorCode;
|
|
102
|
+
constructor(code: DecaneErrorCode, message: string);
|
|
103
|
+
}
|
|
104
|
+
declare enum DecaneErrorCode {
|
|
105
|
+
USER_REJECTED = 4001,
|
|
106
|
+
UNAUTHORIZED = 4100,
|
|
107
|
+
NO_ACTIVE_SESSION = 5001,
|
|
108
|
+
SCOPE_MISMATCH = 5002,
|
|
109
|
+
SESSION_EXPIRED = 5003,
|
|
110
|
+
UNSUPPORTED_CHAIN = 5010,
|
|
111
|
+
CHAIN_NOT_IN_SCOPE = 5011,
|
|
112
|
+
INVALID_CHAIN_CONFIG = 5012,
|
|
113
|
+
NO_WALLET_CONNECTED = 5020,
|
|
114
|
+
WALLET_DISCONNECTED = 5021,
|
|
115
|
+
PROVIDER_ERROR = 5022,
|
|
116
|
+
METHOD_NOT_SUPPORTED = 5030,
|
|
117
|
+
EVM_ONLY_METHOD = 5031
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare const BUILT_IN_CHAINS: ChainDescriptor[];
|
|
121
|
+
declare const CHAINS: {
|
|
122
|
+
readonly ETHEREUM: "eip155:1";
|
|
123
|
+
readonly BASE: "eip155:8453";
|
|
124
|
+
readonly ARBITRUM: "eip155:42161";
|
|
125
|
+
readonly OPTIMISM: "eip155:10";
|
|
126
|
+
readonly BNB: "eip155:56";
|
|
127
|
+
readonly POLYGON: "eip155:137";
|
|
128
|
+
readonly ABSTRACT: "eip155:2741";
|
|
129
|
+
readonly ANCIENT8: "eip155:888888888";
|
|
130
|
+
readonly ANIMECHAIN: "eip155:69000";
|
|
131
|
+
readonly APE_CHAIN: "eip155:33139";
|
|
132
|
+
readonly ARBITRUM_NOVA: "eip155:42170";
|
|
133
|
+
readonly AVALANCHE: "eip155:43114";
|
|
134
|
+
readonly B3: "eip155:8333";
|
|
135
|
+
readonly BERACHAIN: "eip155:80094";
|
|
136
|
+
readonly BLAST: "eip155:81457";
|
|
137
|
+
readonly BOB: "eip155:60808";
|
|
138
|
+
readonly BOBA: "eip155:288";
|
|
139
|
+
readonly CELO: "eip155:42220";
|
|
140
|
+
readonly CORN: "eip155:21000000";
|
|
141
|
+
readonly CRONOS: "eip155:25";
|
|
142
|
+
readonly CYBER: "eip155:7560";
|
|
143
|
+
readonly DEGEN: "eip155:666666666";
|
|
144
|
+
readonly FLOW_EVM: "eip155:747";
|
|
145
|
+
readonly GNOSIS: "eip155:100";
|
|
146
|
+
readonly GUNZ: "eip155:49321";
|
|
147
|
+
readonly HEMI: "eip155:43111";
|
|
148
|
+
readonly HYPER_EVM: "eip155:999";
|
|
149
|
+
readonly INK: "eip155:57073";
|
|
150
|
+
readonly LINEA: "eip155:59144";
|
|
151
|
+
readonly LISK: "eip155:1135";
|
|
152
|
+
readonly MANTA_PACIFIC: "eip155:169";
|
|
153
|
+
readonly MANTLE: "eip155:5000";
|
|
154
|
+
readonly MEGA_ETH: "eip155:6342";
|
|
155
|
+
readonly METIS: "eip155:1088";
|
|
156
|
+
readonly MODE: "eip155:34443";
|
|
157
|
+
readonly MONAD: "eip155:10143";
|
|
158
|
+
readonly MORPH: "eip155:2818";
|
|
159
|
+
readonly PLUME: "eip155:98866";
|
|
160
|
+
readonly RARI: "eip155:1380012617";
|
|
161
|
+
readonly REDSTONE: "eip155:690";
|
|
162
|
+
readonly RONIN: "eip155:2020";
|
|
163
|
+
readonly SCROLL: "eip155:534352";
|
|
164
|
+
readonly SEI: "eip155:1329";
|
|
165
|
+
readonly SHAPE: "eip155:360";
|
|
166
|
+
readonly SOMNIA: "eip155:50312";
|
|
167
|
+
readonly SONEIUM: "eip155:1868";
|
|
168
|
+
readonly SONIC: "eip155:146";
|
|
169
|
+
readonly STORY: "eip155:1514";
|
|
170
|
+
readonly SUPERPOSITION: "eip155:55244";
|
|
171
|
+
readonly SUPERSEED: "eip155:5330";
|
|
172
|
+
readonly SWELL_CHAIN: "eip155:1923";
|
|
173
|
+
readonly TAIKO: "eip155:167000";
|
|
174
|
+
readonly UNICHAIN: "eip155:130";
|
|
175
|
+
readonly WORLD_CHAIN: "eip155:480";
|
|
176
|
+
readonly ZERO: "eip155:543210";
|
|
177
|
+
readonly ZIRCUIT: "eip155:48900";
|
|
178
|
+
readonly ZKSYNC_ERA: "eip155:324";
|
|
179
|
+
readonly ZORA: "eip155:7777777";
|
|
180
|
+
readonly LOCALHOST: "eip155:31337";
|
|
181
|
+
readonly SOLANA: "solana:mainnet";
|
|
182
|
+
readonly SOLANA_DEVNET: "solana:devnet";
|
|
183
|
+
};
|
|
184
|
+
type ChainId = typeof CHAINS[keyof typeof CHAINS];
|
|
185
|
+
|
|
186
|
+
interface WalletSelectorProps {
|
|
187
|
+
provider: DecaneProvider;
|
|
188
|
+
open: boolean;
|
|
189
|
+
onClose: () => void;
|
|
190
|
+
onConnect: (wallet: UnifiedWalletAccount, preference?: ChainType) => void;
|
|
191
|
+
theme?: "light" | "dark" | "auto";
|
|
192
|
+
networks?: "evm" | "solana" | "all";
|
|
193
|
+
}
|
|
194
|
+
declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, }: WalletSelectorProps): React.ReactPortal | null;
|
|
195
|
+
|
|
196
|
+
type Theme = "light" | "dark" | "auto";
|
|
197
|
+
interface DecaneKitProps {
|
|
198
|
+
config?: DecaneConfig;
|
|
199
|
+
children: ReactNode;
|
|
200
|
+
}
|
|
201
|
+
declare function DecaneKit({ config, children }: DecaneKitProps): React.JSX.Element;
|
|
202
|
+
|
|
203
|
+
declare function useDecane(): {
|
|
204
|
+
provider: DecaneProvider;
|
|
205
|
+
wallets: UnifiedWalletAccount[];
|
|
206
|
+
evmWallets: UnifiedWalletAccount[];
|
|
207
|
+
solanaWallets: UnifiedWalletAccount[];
|
|
208
|
+
multiChainWallets: UnifiedWalletAccount[];
|
|
209
|
+
chains: ChainDescriptor[];
|
|
210
|
+
connectedWallet: UnifiedWalletAccount | null;
|
|
211
|
+
activeSession: ActiveSession | null;
|
|
212
|
+
activeChain: string | null;
|
|
213
|
+
isConnected: boolean;
|
|
214
|
+
theme: Theme;
|
|
215
|
+
setTheme: (t: Theme) => void;
|
|
216
|
+
connect: (wallet: UnifiedWalletAccount, preference?: ChainType) => Promise<void>;
|
|
217
|
+
disconnect: () => Promise<void>;
|
|
218
|
+
addChain: (chain: ChainDescriptor) => void;
|
|
219
|
+
removeChain: (chainId: string) => void;
|
|
220
|
+
};
|
|
221
|
+
declare function useWalletSelector(): {
|
|
222
|
+
isOpen: boolean;
|
|
223
|
+
open: () => void;
|
|
224
|
+
close: () => void;
|
|
225
|
+
};
|
|
226
|
+
declare function useChainSwitch(): {
|
|
227
|
+
switchChain: (chainId: string) => Promise<void>;
|
|
228
|
+
loading: boolean;
|
|
229
|
+
error: DecaneError | null;
|
|
230
|
+
activeChain: string | null;
|
|
231
|
+
grantedChains: string[];
|
|
232
|
+
};
|
|
233
|
+
declare function useSignMessage(): {
|
|
234
|
+
signMessage: (message: string, options?: {
|
|
235
|
+
chainId?: string;
|
|
236
|
+
account?: string;
|
|
237
|
+
}) => Promise<string>;
|
|
238
|
+
signature: string | null;
|
|
239
|
+
loading: boolean;
|
|
240
|
+
error: DecaneError | null;
|
|
241
|
+
reset: () => void;
|
|
242
|
+
};
|
|
243
|
+
interface TxParams {
|
|
244
|
+
to: string;
|
|
245
|
+
value?: string;
|
|
246
|
+
data?: string;
|
|
247
|
+
gas?: string;
|
|
248
|
+
gasPrice?: string;
|
|
249
|
+
}
|
|
250
|
+
declare function useSendTransaction(): {
|
|
251
|
+
sendTransaction: (tx: TxParams, options?: {
|
|
252
|
+
chainId?: string;
|
|
253
|
+
from?: string;
|
|
254
|
+
}) => Promise<string>;
|
|
255
|
+
txHash: string | null;
|
|
256
|
+
loading: boolean;
|
|
257
|
+
error: DecaneError | null;
|
|
258
|
+
reset: () => void;
|
|
259
|
+
};
|
|
260
|
+
declare function useSignTypedData(): {
|
|
261
|
+
signTypedData: (typedData: {
|
|
262
|
+
domain: unknown;
|
|
263
|
+
types: unknown;
|
|
264
|
+
message: unknown;
|
|
265
|
+
}, options?: {
|
|
266
|
+
chainId?: string;
|
|
267
|
+
account?: string;
|
|
268
|
+
}) => Promise<string>;
|
|
269
|
+
signature: string | null;
|
|
270
|
+
loading: boolean;
|
|
271
|
+
error: DecaneError | null;
|
|
272
|
+
reset: () => void;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export { type ActiveSession, BUILT_IN_CHAINS, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type DecaneConfig, DecaneError, DecaneErrorCode, DecaneKit, type DecaneProvider, type Theme, type TxParams, type UnifiedWalletAccount, WalletSelector, createDecane, useChainSwitch, useDecane, useSendTransaction, useSignMessage, useSignTypedData, useWalletSelector };
|