@dynamic-labs/ethereum 2.0.0-alpha.3 → 2.0.0-alpha.5

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.
@@ -1,52 +1,333 @@
1
- import Client from '@walletconnect/client';
1
+ import type { SessionTypes } from '@walletconnect/types';
2
2
  import { Hex, WalletClient } from 'viem';
3
3
  import { Chain, FetchPublicAddressOpts, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
4
4
  import { EvmNetwork } from '@dynamic-labs/types';
5
5
  import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
6
- type ConnectorSession = {
7
- connected: boolean;
8
- accounts: string[];
9
- chainId: number;
10
- bridge: string;
11
- key: string;
12
- clientId: string;
13
- clientMeta: any;
14
- peerId: string;
15
- peerMeta: any;
16
- handshakeId: number;
17
- handshakeTopic: string;
18
- };
19
6
  export type WalletConnectOpts = EthWalletConnectorOpts & {
20
- walletConnectV1Bridge: string;
7
+ projectId?: string;
21
8
  walletName: string;
22
9
  deepLinkPreference?: DeepLinkVariant;
10
+ walletConnectPreferredChains?: `eip155:${number}`[];
23
11
  };
24
12
  export declare class WalletConnect extends EthWalletConnector {
25
13
  supportedChains: Chain[];
26
14
  connectedChain: Chain;
27
15
  name: string;
28
- bridge: string;
16
+ session: SessionTypes.Struct | undefined;
17
+ activeAccount: Hex | undefined;
18
+ isInitialized: boolean;
19
+ initializePromise: Promise<void> | undefined;
29
20
  canConnectViaQrCode: boolean;
30
21
  isWalletConnect: boolean;
31
- switchNetworkOnlyFromWallet: boolean;
22
+ private static provider;
23
+ private projectId?;
32
24
  private deepLinkPreference;
33
- client?: Client;
34
- clientOptions?: any;
35
- constructor({ walletConnectV1Bridge, walletName, ...props }: WalletConnectOpts);
36
- getClient(): Client;
25
+ private preferredChains;
26
+ private _currentChainId;
27
+ private _hasSwitchedNetwork;
28
+ constructor(opts: WalletConnectOpts);
29
+ private getMappedChains;
30
+ private getMappedChainsByPreferredOrder;
31
+ private initConnection;
32
+ private createInitProviderPromise;
33
+ private initProvider;
34
+ private refreshSession;
35
+ init(): Promise<void>;
36
+ get sessionTopicKey(): string;
37
+ get activeAccountKey(): string;
38
+ get swicthedNetworkKey(): string;
39
+ get currentChainKey(): string;
40
+ private set currentChainId(value);
41
+ private get currentChainId();
42
+ private set hasSwitchedNetwork(value);
43
+ private get hasSwitchedNetwork();
37
44
  supportsNetworkSwitching(): boolean;
38
45
  setupEventListeners(): void;
39
46
  teardownEventListeners(): void;
40
- getWalletClient(): WalletClient | undefined;
47
+ getWalletClient(): {
48
+ account: undefined;
49
+ batch?: {
50
+ multicall?: boolean | {
51
+ batchSize?: number | undefined;
52
+ wait?: number | undefined;
53
+ } | undefined;
54
+ } | undefined;
55
+ cacheTime: number;
56
+ chain: undefined;
57
+ key: string;
58
+ name: string;
59
+ pollingInterval: number;
60
+ request: import("viem").EIP1193RequestFn<import("viem").WalletRpcSchema>;
61
+ transport: import("viem").TransportConfig<"custom", import("viem").EIP1193RequestFn>;
62
+ type: string;
63
+ uid: string;
64
+ addChain: (args: import("viem").AddChainParameters) => Promise<void>;
65
+ deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, undefined, undefined, TChainOverride>) => Promise<`0x${string}`>;
66
+ getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
67
+ getChainId: () => Promise<number>;
68
+ getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
69
+ prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
70
+ requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
71
+ requestPermissions: (args: {
72
+ [x: string]: Record<string, any>;
73
+ eth_accounts: Record<string, any>;
74
+ }) => Promise<import("viem").RequestPermissionsReturnType>;
75
+ sendRawTransaction: (args: import("node_modules/viem/_types/actions/wallet/sendRawTransaction").SendRawTransactionParameters) => Promise<`0x${string}`>;
76
+ sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
77
+ signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
78
+ signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("node_modules/viem/_types/actions/wallet/signTransaction").SignTransactionParameters<undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
79
+ signTypedData: <const TTypedData extends {
80
+ [x: string]: readonly import("viem").TypedDataParameter[];
81
+ [x: `string[${string}]`]: undefined;
82
+ [x: `function[${string}]`]: undefined;
83
+ [x: `address[${string}]`]: undefined;
84
+ [x: `bool[${string}]`]: undefined;
85
+ [x: `bytes[${string}]`]: undefined;
86
+ [x: `bytes16[${string}]`]: undefined;
87
+ [x: `bytes1[${string}]`]: undefined;
88
+ [x: `bytes2[${string}]`]: undefined;
89
+ [x: `bytes3[${string}]`]: undefined;
90
+ [x: `bytes4[${string}]`]: undefined;
91
+ [x: `bytes5[${string}]`]: undefined;
92
+ [x: `bytes6[${string}]`]: undefined;
93
+ [x: `bytes7[${string}]`]: undefined;
94
+ [x: `bytes8[${string}]`]: undefined;
95
+ [x: `bytes9[${string}]`]: undefined;
96
+ [x: `bytes10[${string}]`]: undefined;
97
+ [x: `bytes11[${string}]`]: undefined;
98
+ [x: `bytes12[${string}]`]: undefined;
99
+ [x: `bytes13[${string}]`]: undefined;
100
+ [x: `bytes14[${string}]`]: undefined;
101
+ [x: `bytes15[${string}]`]: undefined;
102
+ [x: `bytes17[${string}]`]: undefined;
103
+ [x: `bytes18[${string}]`]: undefined;
104
+ [x: `bytes19[${string}]`]: undefined;
105
+ [x: `bytes20[${string}]`]: undefined;
106
+ [x: `bytes21[${string}]`]: undefined;
107
+ [x: `bytes22[${string}]`]: undefined;
108
+ [x: `bytes23[${string}]`]: undefined;
109
+ [x: `bytes24[${string}]`]: undefined;
110
+ [x: `bytes25[${string}]`]: undefined;
111
+ [x: `bytes26[${string}]`]: undefined;
112
+ [x: `bytes27[${string}]`]: undefined;
113
+ [x: `bytes28[${string}]`]: undefined;
114
+ [x: `bytes29[${string}]`]: undefined;
115
+ [x: `bytes30[${string}]`]: undefined;
116
+ [x: `bytes31[${string}]`]: undefined;
117
+ [x: `bytes32[${string}]`]: undefined;
118
+ [x: `int[${string}]`]: undefined;
119
+ [x: `int16[${string}]`]: undefined;
120
+ [x: `int8[${string}]`]: undefined;
121
+ [x: `int24[${string}]`]: undefined;
122
+ [x: `int32[${string}]`]: undefined;
123
+ [x: `int40[${string}]`]: undefined;
124
+ [x: `int48[${string}]`]: undefined;
125
+ [x: `int56[${string}]`]: undefined;
126
+ [x: `int64[${string}]`]: undefined;
127
+ [x: `int72[${string}]`]: undefined;
128
+ [x: `int80[${string}]`]: undefined;
129
+ [x: `int88[${string}]`]: undefined;
130
+ [x: `int96[${string}]`]: undefined;
131
+ [x: `int104[${string}]`]: undefined;
132
+ [x: `int112[${string}]`]: undefined;
133
+ [x: `int120[${string}]`]: undefined;
134
+ [x: `int128[${string}]`]: undefined;
135
+ [x: `int136[${string}]`]: undefined;
136
+ [x: `int144[${string}]`]: undefined;
137
+ [x: `int152[${string}]`]: undefined;
138
+ [x: `int160[${string}]`]: undefined;
139
+ [x: `int168[${string}]`]: undefined;
140
+ [x: `int176[${string}]`]: undefined;
141
+ [x: `int184[${string}]`]: undefined;
142
+ [x: `int192[${string}]`]: undefined;
143
+ [x: `int200[${string}]`]: undefined;
144
+ [x: `int208[${string}]`]: undefined;
145
+ [x: `int216[${string}]`]: undefined;
146
+ [x: `int224[${string}]`]: undefined;
147
+ [x: `int232[${string}]`]: undefined;
148
+ [x: `int240[${string}]`]: undefined;
149
+ [x: `int248[${string}]`]: undefined;
150
+ [x: `int256[${string}]`]: undefined;
151
+ [x: `uint[${string}]`]: undefined;
152
+ [x: `uint16[${string}]`]: undefined;
153
+ [x: `uint8[${string}]`]: undefined;
154
+ [x: `uint24[${string}]`]: undefined;
155
+ [x: `uint32[${string}]`]: undefined;
156
+ [x: `uint40[${string}]`]: undefined;
157
+ [x: `uint48[${string}]`]: undefined;
158
+ [x: `uint56[${string}]`]: undefined;
159
+ [x: `uint64[${string}]`]: undefined;
160
+ [x: `uint72[${string}]`]: undefined;
161
+ [x: `uint80[${string}]`]: undefined;
162
+ [x: `uint88[${string}]`]: undefined;
163
+ [x: `uint96[${string}]`]: undefined;
164
+ [x: `uint104[${string}]`]: undefined;
165
+ [x: `uint112[${string}]`]: undefined;
166
+ [x: `uint120[${string}]`]: undefined;
167
+ [x: `uint128[${string}]`]: undefined;
168
+ [x: `uint136[${string}]`]: undefined;
169
+ [x: `uint144[${string}]`]: undefined;
170
+ [x: `uint152[${string}]`]: undefined;
171
+ [x: `uint160[${string}]`]: undefined;
172
+ [x: `uint168[${string}]`]: undefined;
173
+ [x: `uint176[${string}]`]: undefined;
174
+ [x: `uint184[${string}]`]: undefined;
175
+ [x: `uint192[${string}]`]: undefined;
176
+ [x: `uint200[${string}]`]: undefined;
177
+ [x: `uint208[${string}]`]: undefined;
178
+ [x: `uint216[${string}]`]: undefined;
179
+ [x: `uint224[${string}]`]: undefined;
180
+ [x: `uint232[${string}]`]: undefined;
181
+ [x: `uint240[${string}]`]: undefined;
182
+ [x: `uint248[${string}]`]: undefined;
183
+ [x: `uint256[${string}]`]: undefined;
184
+ string?: undefined;
185
+ address?: undefined;
186
+ bool?: undefined;
187
+ bytes?: undefined;
188
+ bytes16?: undefined;
189
+ bytes1?: undefined;
190
+ bytes2?: undefined;
191
+ bytes3?: undefined;
192
+ bytes4?: undefined;
193
+ bytes5?: undefined;
194
+ bytes6?: undefined;
195
+ bytes7?: undefined;
196
+ bytes8?: undefined;
197
+ bytes9?: undefined;
198
+ bytes10?: undefined;
199
+ bytes11?: undefined;
200
+ bytes12?: undefined;
201
+ bytes13?: undefined;
202
+ bytes14?: undefined;
203
+ bytes15?: undefined;
204
+ bytes17?: undefined;
205
+ bytes18?: undefined;
206
+ bytes19?: undefined;
207
+ bytes20?: undefined;
208
+ bytes21?: undefined;
209
+ bytes22?: undefined;
210
+ bytes23?: undefined;
211
+ bytes24?: undefined;
212
+ bytes25?: undefined;
213
+ bytes26?: undefined;
214
+ bytes27?: undefined;
215
+ bytes28?: undefined;
216
+ bytes29?: undefined;
217
+ bytes30?: undefined;
218
+ bytes31?: undefined;
219
+ bytes32?: undefined;
220
+ int16?: undefined;
221
+ int8?: undefined;
222
+ int24?: undefined;
223
+ int32?: undefined;
224
+ int40?: undefined;
225
+ int48?: undefined;
226
+ int56?: undefined;
227
+ int64?: undefined;
228
+ int72?: undefined;
229
+ int80?: undefined;
230
+ int88?: undefined;
231
+ int96?: undefined;
232
+ int104?: undefined;
233
+ int112?: undefined;
234
+ int120?: undefined;
235
+ int128?: undefined;
236
+ int136?: undefined;
237
+ int144?: undefined;
238
+ int152?: undefined;
239
+ int160?: undefined;
240
+ int168?: undefined;
241
+ int176?: undefined;
242
+ int184?: undefined;
243
+ int192?: undefined;
244
+ int200?: undefined;
245
+ int208?: undefined;
246
+ int216?: undefined;
247
+ int224?: undefined;
248
+ int232?: undefined;
249
+ int240?: undefined;
250
+ int248?: undefined;
251
+ int256?: undefined;
252
+ uint16?: undefined;
253
+ uint8?: undefined;
254
+ uint24?: undefined;
255
+ uint32?: undefined;
256
+ uint40?: undefined;
257
+ uint48?: undefined;
258
+ uint56?: undefined;
259
+ uint64?: undefined;
260
+ uint72?: undefined;
261
+ uint80?: undefined;
262
+ uint88?: undefined;
263
+ uint96?: undefined;
264
+ uint104?: undefined;
265
+ uint112?: undefined;
266
+ uint120?: undefined;
267
+ uint128?: undefined;
268
+ uint136?: undefined;
269
+ uint144?: undefined;
270
+ uint152?: undefined;
271
+ uint160?: undefined;
272
+ uint168?: undefined;
273
+ uint176?: undefined;
274
+ uint184?: undefined;
275
+ uint192?: undefined;
276
+ uint200?: undefined;
277
+ uint208?: undefined;
278
+ uint216?: undefined;
279
+ uint224?: undefined;
280
+ uint232?: undefined;
281
+ uint240?: undefined;
282
+ uint248?: undefined;
283
+ uint256?: undefined;
284
+ } | {
285
+ [key: string]: unknown;
286
+ }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, undefined>) => Promise<`0x${string}`>;
287
+ switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
288
+ watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
289
+ writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, undefined, undefined, TChainOverride_4>) => Promise<`0x${string}`>;
290
+ extend: <const client extends {
291
+ [x: string]: unknown;
292
+ account?: undefined;
293
+ batch?: undefined;
294
+ cacheTime?: undefined;
295
+ chain?: undefined;
296
+ key?: undefined;
297
+ name?: undefined;
298
+ pollingInterval?: undefined;
299
+ request?: undefined;
300
+ transport?: undefined;
301
+ type?: undefined;
302
+ uid?: undefined;
303
+ } & Partial<Pick<import("viem").PublicActions, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<undefined, undefined>>;
304
+ } | undefined;
41
305
  fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
306
+ /**
307
+ * WalletConnect V2 will fail to send the sign message request if the chainId
308
+ * is not the same as the one in the session. This method will wait for the
309
+ * chainId to change and then retry the sign message request.
310
+ *
311
+ * Otherwise it will just return the result of the sign message request.
312
+ *
313
+ * @param signMessageFn - Function to sign message with provider
314
+ * @param messageToSign - Message to sign
315
+ * @returns
316
+ */
317
+ protected waitForSignMessage(signMessageFn: (messageToSign: string) => Promise<string | undefined>, messageToSign: string): Promise<string | undefined>;
42
318
  getDeepLink(): string | undefined;
43
319
  signMessage(messageToSign: string): Promise<string | undefined>;
320
+ private clearActiveAccount;
321
+ private clearSession;
322
+ private setActiveAccount;
323
+ private setSession;
44
324
  endSession(): Promise<void>;
325
+ getNetwork(): Promise<number | undefined>;
45
326
  providerSwitchNetwork({ network, provider, }: {
46
327
  network: EvmNetwork;
47
328
  provider: WalletClient;
48
329
  }): Promise<void>;
49
- getConnectedAccounts(): Promise<Hex[]>;
50
- getSession(): Promise<ConnectorSession | undefined>;
330
+ getConnectedAccounts(): Promise<string[]>;
331
+ private isMetaMask;
332
+ getSupportedNetworks(): Promise<string[] | undefined>;
51
333
  }
52
- export {};