@dynamic-labs/wagmi-connector 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.
- package/CHANGELOG.md +39 -0
- package/package.json +8 -7
- package/src/lib/Connector.d.ts +321 -72
- package/src/lib/Connector.js +77 -95
- package/src/lib/DynamicWagmiConnector.d.ts +2 -4
- package/src/lib/DynamicWagmiConnector.js +18 -48
- package/src/lib/SyncDynamicWagmi.d.ts +1 -1
- package/src/lib/SyncDynamicWagmi.js +4 -9
- package/src/lib/utils/index.d.ts +0 -1
- package/src/lib/getConnector.d.ts +0 -3
- package/src/lib/getConnector.js +0 -9
- package/src/lib/getWagmiChainsFromDynamicChains.d.ts +0 -3
- package/src/lib/getWagmiChainsFromDynamicChains.js +0 -9
- package/src/lib/getWagmiProvidersFromDynamicChains.d.ts +0 -3
- package/src/lib/getWagmiProvidersFromDynamicChains.js +0 -37
- package/src/lib/mappers/chain.d.ts +0 -4
- package/src/lib/mappers/chain.js +0 -50
- package/src/lib/utils/resolveRpcUrlFromEvmNetworks/index.d.ts +0 -1
- package/src/lib/utils/resolveRpcUrlFromEvmNetworks/resolveRpcUrlFromEvmNetworks.d.ts +0 -2
- package/src/lib/utils/resolveRpcUrlFromEvmNetworks/resolveRpcUrlFromEvmNetworks.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.4...v2.0.0-alpha.5) (2024-02-22)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* wagmi v2 (#4660)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* wagmi v2 ([#4660](https://github.com/dynamic-labs/DynamicAuth/issues/4660)) ([d8894e6](https://github.com/dynamic-labs/DynamicAuth/commit/d8894e61393b90ccf44904c33394b54286f0f9e9))
|
|
12
|
+
|
|
13
|
+
## [2.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-02-22)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### ⚠ BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* remove wallet connector from callback types (#4730)
|
|
19
|
+
* drop support for walletconnect v1 (#4666)
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add coin98 evm ([1d64f5f](https://github.com/dynamic-labs/DynamicAuth/commit/1d64f5f00885ff671358651fd0251b77a2e05739))
|
|
24
|
+
* add support for solana versioned transactions ([#4721](https://github.com/dynamic-labs/DynamicAuth/issues/4721)) ([25b1643](https://github.com/dynamic-labs/DynamicAuth/commit/25b1643f8addbada09fff5d22e988bdf22038170))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* allow rpc-providers package to use exports based on usage ([#4539](https://github.com/dynamic-labs/DynamicAuth/issues/4539)) ([abdc196](https://github.com/dynamic-labs/DynamicAuth/commit/abdc19641580cbcfe8f9e357c645f8291bc9ed66))
|
|
30
|
+
* coinbasesocial should display coinbase in profile linking section ([#4680](https://github.com/dynamic-labs/DynamicAuth/issues/4680)) ([21cbe2e](https://github.com/dynamic-labs/DynamicAuth/commit/21cbe2e24345a33bc927428c01cc7b5c724e40e5))
|
|
31
|
+
* improve on transaction confirmation step ([#4704](https://github.com/dynamic-labs/DynamicAuth/issues/4704)) ([f2b27cf](https://github.com/dynamic-labs/DynamicAuth/commit/f2b27cfd94452be2eb7e88a298f61ef56985931f))
|
|
32
|
+
* prevent the DynamicMultiWalletPromptsWidget from opening if useris not logged in ([#4701](https://github.com/dynamic-labs/DynamicAuth/issues/4701)) ([2bb35fd](https://github.com/dynamic-labs/DynamicAuth/commit/2bb35fd29b60677e893390f7d47857cd76c73adc))
|
|
33
|
+
* reduce isPreauthorized calls when starknet wallet is connected ([#4710](https://github.com/dynamic-labs/DynamicAuth/issues/4710)) ([ca6a630](https://github.com/dynamic-labs/DynamicAuth/commit/ca6a630dd47a1c116afcd63fe7256ffc745532ab))
|
|
34
|
+
* update sepolia currency symbol ([#4728](https://github.com/dynamic-labs/DynamicAuth/issues/4728)) ([3c228a0](https://github.com/dynamic-labs/DynamicAuth/commit/3c228a03ccc962374ad1dac3ab45af92732ba61a))
|
|
35
|
+
* use overflow clip when available, use hidden by default ([#4696](https://github.com/dynamic-labs/DynamicAuth/issues/4696)) ([29fb2a1](https://github.com/dynamic-labs/DynamicAuth/commit/29fb2a1e48b010c6c1d525403fbdcf7ded068466))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
* drop support for walletconnect v1 ([#4666](https://github.com/dynamic-labs/DynamicAuth/issues/4666)) ([4af93e4](https://github.com/dynamic-labs/DynamicAuth/commit/4af93e4f9b95fa4c49bbfda0c1144da1a4a43991))
|
|
39
|
+
* remove wallet connector from callback types ([#4730](https://github.com/dynamic-labs/DynamicAuth/issues/4730)) ([08cb200](https://github.com/dynamic-labs/DynamicAuth/commit/08cb200a09c0fd78d2093d1a60b17089b3b2c2b1))
|
|
40
|
+
|
|
2
41
|
## [2.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2024-02-13)
|
|
3
42
|
|
|
4
43
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/wagmi-connector",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
7
7
|
"directory": "packages/wagmi-connector"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
+
"@wagmi/core": "2.6.4",
|
|
10
11
|
"react": "^18.0.0",
|
|
11
|
-
"viem": "
|
|
12
|
-
"wagmi": "
|
|
13
|
-
"@dynamic-labs/rpc-providers": "2.0.0-alpha.
|
|
14
|
-
"@dynamic-labs/sdk-react-core": "2.0.0-alpha.
|
|
15
|
-
"@dynamic-labs/types": "2.0.0-alpha.
|
|
16
|
-
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.
|
|
12
|
+
"viem": "2.7.6",
|
|
13
|
+
"wagmi": "2.5.7",
|
|
14
|
+
"@dynamic-labs/rpc-providers": "2.0.0-alpha.5",
|
|
15
|
+
"@dynamic-labs/sdk-react-core": "2.0.0-alpha.5",
|
|
16
|
+
"@dynamic-labs/types": "2.0.0-alpha.5",
|
|
17
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.5",
|
|
17
18
|
"eventemitter3": "5.0.1"
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
package/src/lib/Connector.d.ts
CHANGED
|
@@ -1,41 +1,23 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Account, Transport,
|
|
4
|
-
import { WalletConnector } from '@dynamic-labs/sdk-react-core';
|
|
5
|
-
export
|
|
2
|
+
import { Connector } from 'wagmi';
|
|
3
|
+
import { Account, Transport, Chain } from 'viem';
|
|
4
|
+
import { Wallet, WalletConnector } from '@dynamic-labs/sdk-react-core';
|
|
5
|
+
export type ConnectorParameters = {
|
|
6
6
|
handleLogOut: () => Promise<void>;
|
|
7
7
|
walletConnector: WalletConnector;
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
ready: boolean;
|
|
11
|
-
/** See this variable's reason in it's definition in DynamicContext */
|
|
12
8
|
preventWagmiSyncFromCallingLogout: MutableRefObject<boolean>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
chain: number | string;
|
|
24
|
-
}): void;
|
|
25
|
-
_onDisconnect(): void;
|
|
26
|
-
setupEventListeners(): void;
|
|
27
|
-
connect(config?: {
|
|
28
|
-
chainId?: number;
|
|
29
|
-
}): Promise<Required<ConnectorData>>;
|
|
30
|
-
disconnect(): Promise<void>;
|
|
31
|
-
getAccount(): Promise<Address>;
|
|
32
|
-
getChainId(): Promise<number>;
|
|
33
|
-
getProvider(config?: {
|
|
34
|
-
chainId?: number;
|
|
35
|
-
} | undefined): Promise<WalletClient<Transport, Chain, Account>>;
|
|
36
|
-
getWalletClient(config?: {
|
|
9
|
+
};
|
|
10
|
+
export declare const getCreateConnectorFn: (parameters: ConnectorParameters) => import("@wagmi/core").CreateConnectorFn<unknown, {
|
|
11
|
+
connect: () => Promise<{
|
|
12
|
+
accounts: readonly `0x${string}`[];
|
|
13
|
+
chainId: number;
|
|
14
|
+
}>;
|
|
15
|
+
disconnect: () => Promise<void>;
|
|
16
|
+
getAccounts: () => Promise<`0x${string}`[]>;
|
|
17
|
+
getChainId: () => Promise<number>;
|
|
18
|
+
getClient: (args?: {
|
|
37
19
|
chainId?: number;
|
|
38
|
-
} | undefined)
|
|
20
|
+
} | undefined) => Promise<{
|
|
39
21
|
account: Account;
|
|
40
22
|
batch?: {
|
|
41
23
|
multicall?: boolean | {
|
|
@@ -53,29 +35,31 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
53
35
|
type: string;
|
|
54
36
|
uid: string;
|
|
55
37
|
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
56
|
-
deployContract: <const
|
|
38
|
+
deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends Chain | undefined>(args: import("viem").DeployContractParameters<abi, Chain, Account, chainOverride>) => Promise<`0x${string}`>;
|
|
57
39
|
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
58
40
|
getChainId: () => Promise<number>;
|
|
59
41
|
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
60
|
-
prepareTransactionRequest: <
|
|
42
|
+
prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends Chain | undefined = undefined, TAccountOverride extends `0x${string}` | Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<Chain, Account, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<Chain, Account, TChainOverride, TAccountOverride, TParameterType>>;
|
|
61
43
|
requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
|
|
62
44
|
requestPermissions: (args: {
|
|
63
45
|
[x: string]: Record<string, any>;
|
|
64
46
|
eth_accounts: Record<string, any>;
|
|
65
47
|
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
66
|
-
sendRawTransaction: (args: import("
|
|
67
|
-
sendTransaction: <
|
|
48
|
+
sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
49
|
+
sendTransaction: <TChainOverride_1 extends Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<Chain, Account, TChainOverride_1>) => Promise<`0x${string}`>;
|
|
68
50
|
signMessage: (args: import("viem").SignMessageParameters<Account>) => Promise<`0x${string}`>;
|
|
69
|
-
signTransaction: <
|
|
51
|
+
signTransaction: <TChainOverride_2 extends Chain | undefined>(args: import("viem").SignTransactionParameters<Chain, Account, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
70
52
|
signTypedData: <const TTypedData extends {
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
} | {
|
|
71
55
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
72
56
|
[x: `string[${string}]`]: undefined;
|
|
73
57
|
[x: `function[${string}]`]: undefined;
|
|
74
58
|
[x: `address[${string}]`]: undefined;
|
|
75
59
|
[x: `bool[${string}]`]: undefined;
|
|
76
60
|
[x: `bytes[${string}]`]: undefined;
|
|
77
|
-
[x: `bytes16[${string}]`]: undefined;
|
|
78
61
|
[x: `bytes1[${string}]`]: undefined;
|
|
62
|
+
[x: `bytes16[${string}]`]: undefined;
|
|
79
63
|
[x: `bytes2[${string}]`]: undefined;
|
|
80
64
|
[x: `bytes3[${string}]`]: undefined;
|
|
81
65
|
[x: `bytes4[${string}]`]: undefined;
|
|
@@ -176,8 +160,8 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
176
160
|
address?: undefined;
|
|
177
161
|
bool?: undefined;
|
|
178
162
|
bytes?: undefined;
|
|
179
|
-
bytes16?: undefined;
|
|
180
163
|
bytes1?: undefined;
|
|
164
|
+
bytes16?: undefined;
|
|
181
165
|
bytes2?: undefined;
|
|
182
166
|
bytes3?: undefined;
|
|
183
167
|
bytes4?: undefined;
|
|
@@ -272,12 +256,10 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
272
256
|
uint240?: undefined;
|
|
273
257
|
uint248?: undefined;
|
|
274
258
|
uint256?: undefined;
|
|
275
|
-
} | {
|
|
276
|
-
[key: string]: unknown;
|
|
277
259
|
}, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, Account>) => Promise<`0x${string}`>;
|
|
278
260
|
switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
|
|
279
261
|
watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
|
|
280
|
-
writeContract: <const
|
|
262
|
+
writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "payable" | "nonpayable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, Chain, Account, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
281
263
|
extend: <const client extends {
|
|
282
264
|
[x: string]: unknown;
|
|
283
265
|
account?: undefined;
|
|
@@ -291,7 +273,7 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
291
273
|
transport?: undefined;
|
|
292
274
|
type?: undefined;
|
|
293
275
|
uid?: undefined;
|
|
294
|
-
} & 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<Transport, Chain, Account, import("viem").WalletRpcSchema, import("viem").WalletActions<Chain, Account>>) => client) => import("viem").Client<Transport, Chain, Account, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<Chain, Account>>;
|
|
276
|
+
} & Partial<Pick<import("viem").PublicActions<Transport, Chain, Account>, "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<Chain, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<Transport, Chain, Account, import("viem").WalletRpcSchema, import("viem").WalletActions<Chain, Account>>) => client) => import("viem").Client<Transport, Chain, Account, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<Chain, Account>>;
|
|
295
277
|
} | {
|
|
296
278
|
account: {
|
|
297
279
|
address: `0x${string}`;
|
|
@@ -313,44 +295,49 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
313
295
|
type: string;
|
|
314
296
|
uid: string;
|
|
315
297
|
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
316
|
-
deployContract: <const
|
|
298
|
+
deployContract: <const abi_2 extends import("viem").Abi | readonly unknown[], chainOverride_1 extends Chain | undefined>(args: import("viem").DeployContractParameters<abi_2, Chain, {
|
|
317
299
|
address: `0x${string}`;
|
|
318
300
|
type: "json-rpc";
|
|
319
|
-
},
|
|
301
|
+
}, chainOverride_1>) => Promise<`0x${string}`>;
|
|
320
302
|
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
321
303
|
getChainId: () => Promise<number>;
|
|
322
304
|
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
323
|
-
prepareTransactionRequest: <
|
|
305
|
+
prepareTransactionRequest: <TParameterType_1 extends import("viem").PrepareTransactionRequestParameterType, TChainOverride_4 extends Chain | undefined = undefined, TAccountOverride_1 extends `0x${string}` | Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<Chain, {
|
|
306
|
+
address: `0x${string}`;
|
|
307
|
+
type: "json-rpc";
|
|
308
|
+
}, TChainOverride_4, TAccountOverride_1, TParameterType_1>) => Promise<import("viem").PrepareTransactionRequestReturnType<Chain, {
|
|
324
309
|
address: `0x${string}`;
|
|
325
310
|
type: "json-rpc";
|
|
326
|
-
},
|
|
311
|
+
}, TChainOverride_4, TAccountOverride_1, TParameterType_1>>;
|
|
327
312
|
requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
|
|
328
313
|
requestPermissions: (args: {
|
|
329
314
|
[x: string]: Record<string, any>;
|
|
330
315
|
eth_accounts: Record<string, any>;
|
|
331
316
|
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
332
|
-
sendRawTransaction: (args: import("
|
|
333
|
-
sendTransaction: <
|
|
317
|
+
sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
318
|
+
sendTransaction: <TChainOverride_5 extends Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<Chain, {
|
|
334
319
|
address: `0x${string}`;
|
|
335
320
|
type: "json-rpc";
|
|
336
|
-
},
|
|
321
|
+
}, TChainOverride_5>) => Promise<`0x${string}`>;
|
|
337
322
|
signMessage: (args: import("viem").SignMessageParameters<{
|
|
338
323
|
address: `0x${string}`;
|
|
339
324
|
type: "json-rpc";
|
|
340
325
|
}>) => Promise<`0x${string}`>;
|
|
341
|
-
signTransaction: <
|
|
326
|
+
signTransaction: <TChainOverride_6 extends Chain | undefined>(args: import("viem").SignTransactionParameters<Chain, {
|
|
342
327
|
address: `0x${string}`;
|
|
343
328
|
type: "json-rpc";
|
|
344
|
-
},
|
|
329
|
+
}, TChainOverride_6>) => Promise<`0x${string}`>;
|
|
345
330
|
signTypedData: <const TTypedData_1 extends {
|
|
331
|
+
[key: string]: unknown;
|
|
332
|
+
} | {
|
|
346
333
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
347
334
|
[x: `string[${string}]`]: undefined;
|
|
348
335
|
[x: `function[${string}]`]: undefined;
|
|
349
336
|
[x: `address[${string}]`]: undefined;
|
|
350
337
|
[x: `bool[${string}]`]: undefined;
|
|
351
338
|
[x: `bytes[${string}]`]: undefined;
|
|
352
|
-
[x: `bytes16[${string}]`]: undefined;
|
|
353
339
|
[x: `bytes1[${string}]`]: undefined;
|
|
340
|
+
[x: `bytes16[${string}]`]: undefined;
|
|
354
341
|
[x: `bytes2[${string}]`]: undefined;
|
|
355
342
|
[x: `bytes3[${string}]`]: undefined;
|
|
356
343
|
[x: `bytes4[${string}]`]: undefined;
|
|
@@ -451,8 +438,8 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
451
438
|
address?: undefined;
|
|
452
439
|
bool?: undefined;
|
|
453
440
|
bytes?: undefined;
|
|
454
|
-
bytes16?: undefined;
|
|
455
441
|
bytes1?: undefined;
|
|
442
|
+
bytes16?: undefined;
|
|
456
443
|
bytes2?: undefined;
|
|
457
444
|
bytes3?: undefined;
|
|
458
445
|
bytes4?: undefined;
|
|
@@ -547,18 +534,16 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
547
534
|
uint240?: undefined;
|
|
548
535
|
uint248?: undefined;
|
|
549
536
|
uint256?: undefined;
|
|
550
|
-
} | {
|
|
551
|
-
[key: string]: unknown;
|
|
552
537
|
}, TPrimaryType_1 extends string>(args: import("viem").SignTypedDataParameters<TTypedData_1, TPrimaryType_1, {
|
|
553
538
|
address: `0x${string}`;
|
|
554
539
|
type: "json-rpc";
|
|
555
540
|
}>) => Promise<`0x${string}`>;
|
|
556
541
|
switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
|
|
557
542
|
watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
|
|
558
|
-
writeContract: <const
|
|
543
|
+
writeContract: <const abi_3 extends import("viem").Abi | readonly unknown[], functionName_1 extends import("viem").ContractFunctionName<abi_3, "payable" | "nonpayable">, args_1 extends import("viem").ContractFunctionArgs<abi_3, "pure" | "view", functionName_1>, TChainOverride_7 extends Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_3, functionName_1, args_1, Chain, {
|
|
559
544
|
address: `0x${string}`;
|
|
560
545
|
type: "json-rpc";
|
|
561
|
-
},
|
|
546
|
+
}, TChainOverride_7>) => Promise<`0x${string}`>;
|
|
562
547
|
extend: <const client_1 extends {
|
|
563
548
|
[x: string]: unknown;
|
|
564
549
|
account?: undefined;
|
|
@@ -572,7 +557,13 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
572
557
|
transport?: undefined;
|
|
573
558
|
type?: undefined;
|
|
574
559
|
uid?: undefined;
|
|
575
|
-
} & Partial<Pick<import("viem").PublicActions
|
|
560
|
+
} & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, Chain, {
|
|
561
|
+
address: `0x${string}`;
|
|
562
|
+
type: "json-rpc";
|
|
563
|
+
}>, "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<Chain, {
|
|
564
|
+
address: `0x${string}`;
|
|
565
|
+
type: "json-rpc";
|
|
566
|
+
}>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, Chain, {
|
|
576
567
|
address: `0x${string}`;
|
|
577
568
|
type: "json-rpc";
|
|
578
569
|
}, import("viem").WalletRpcSchema, import("viem").WalletActions<Chain, {
|
|
@@ -586,15 +577,273 @@ export declare class Connector extends BaseWagmiConnector<WalletClient<Transport
|
|
|
586
577
|
type: "json-rpc";
|
|
587
578
|
}>>;
|
|
588
579
|
}>;
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
580
|
+
getProvider: () => Promise<{
|
|
581
|
+
account: Account;
|
|
582
|
+
batch?: {
|
|
583
|
+
multicall?: boolean | {
|
|
584
|
+
batchSize?: number | undefined;
|
|
585
|
+
wait?: number | undefined;
|
|
586
|
+
} | undefined;
|
|
587
|
+
} | undefined;
|
|
588
|
+
cacheTime: number;
|
|
589
|
+
chain: Chain;
|
|
590
|
+
key: string;
|
|
591
|
+
name: string;
|
|
592
|
+
pollingInterval: number;
|
|
593
|
+
request: import("viem").EIP1193RequestFn<import("viem").WalletRpcSchema>;
|
|
594
|
+
transport: import("viem").TransportConfig<string, import("viem").EIP1193RequestFn> & Record<string, any>;
|
|
595
|
+
type: string;
|
|
596
|
+
uid: string;
|
|
597
|
+
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
598
|
+
deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends Chain | undefined>(args: import("viem").DeployContractParameters<abi, Chain, Account, chainOverride>) => Promise<`0x${string}`>;
|
|
599
|
+
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
600
|
+
getChainId: () => Promise<number>;
|
|
601
|
+
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
602
|
+
prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends Chain | undefined = undefined, TAccountOverride extends `0x${string}` | Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<Chain, Account, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<Chain, Account, TChainOverride, TAccountOverride, TParameterType>>;
|
|
603
|
+
requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
|
|
604
|
+
requestPermissions: (args: {
|
|
605
|
+
[x: string]: Record<string, any>;
|
|
606
|
+
eth_accounts: Record<string, any>;
|
|
607
|
+
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
608
|
+
sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
609
|
+
sendTransaction: <TChainOverride_1 extends Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<Chain, Account, TChainOverride_1>) => Promise<`0x${string}`>;
|
|
610
|
+
signMessage: (args: import("viem").SignMessageParameters<Account>) => Promise<`0x${string}`>;
|
|
611
|
+
signTransaction: <TChainOverride_2 extends Chain | undefined>(args: import("viem").SignTransactionParameters<Chain, Account, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
612
|
+
signTypedData: <const TTypedData extends {
|
|
613
|
+
[key: string]: unknown;
|
|
614
|
+
} | {
|
|
615
|
+
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
616
|
+
[x: `string[${string}]`]: undefined;
|
|
617
|
+
[x: `function[${string}]`]: undefined;
|
|
618
|
+
[x: `address[${string}]`]: undefined;
|
|
619
|
+
[x: `bool[${string}]`]: undefined;
|
|
620
|
+
[x: `bytes[${string}]`]: undefined;
|
|
621
|
+
[x: `bytes1[${string}]`]: undefined;
|
|
622
|
+
[x: `bytes16[${string}]`]: undefined;
|
|
623
|
+
[x: `bytes2[${string}]`]: undefined;
|
|
624
|
+
[x: `bytes3[${string}]`]: undefined;
|
|
625
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
626
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
627
|
+
[x: `bytes6[${string}]`]: undefined;
|
|
628
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
629
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
630
|
+
[x: `bytes9[${string}]`]: undefined;
|
|
631
|
+
[x: `bytes10[${string}]`]: undefined;
|
|
632
|
+
[x: `bytes11[${string}]`]: undefined;
|
|
633
|
+
[x: `bytes12[${string}]`]: undefined;
|
|
634
|
+
[x: `bytes13[${string}]`]: undefined;
|
|
635
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
636
|
+
[x: `bytes15[${string}]`]: undefined;
|
|
637
|
+
[x: `bytes17[${string}]`]: undefined;
|
|
638
|
+
[x: `bytes18[${string}]`]: undefined;
|
|
639
|
+
[x: `bytes19[${string}]`]: undefined;
|
|
640
|
+
[x: `bytes20[${string}]`]: undefined;
|
|
641
|
+
[x: `bytes21[${string}]`]: undefined;
|
|
642
|
+
[x: `bytes22[${string}]`]: undefined;
|
|
643
|
+
[x: `bytes23[${string}]`]: undefined;
|
|
644
|
+
[x: `bytes24[${string}]`]: undefined;
|
|
645
|
+
[x: `bytes25[${string}]`]: undefined;
|
|
646
|
+
[x: `bytes26[${string}]`]: undefined;
|
|
647
|
+
[x: `bytes27[${string}]`]: undefined;
|
|
648
|
+
[x: `bytes28[${string}]`]: undefined;
|
|
649
|
+
[x: `bytes29[${string}]`]: undefined;
|
|
650
|
+
[x: `bytes30[${string}]`]: undefined;
|
|
651
|
+
[x: `bytes31[${string}]`]: undefined;
|
|
652
|
+
[x: `bytes32[${string}]`]: undefined;
|
|
653
|
+
[x: `int[${string}]`]: undefined;
|
|
654
|
+
[x: `int16[${string}]`]: undefined;
|
|
655
|
+
[x: `int8[${string}]`]: undefined;
|
|
656
|
+
[x: `int24[${string}]`]: undefined;
|
|
657
|
+
[x: `int32[${string}]`]: undefined;
|
|
658
|
+
[x: `int40[${string}]`]: undefined;
|
|
659
|
+
[x: `int48[${string}]`]: undefined;
|
|
660
|
+
[x: `int56[${string}]`]: undefined;
|
|
661
|
+
[x: `int64[${string}]`]: undefined;
|
|
662
|
+
[x: `int72[${string}]`]: undefined;
|
|
663
|
+
[x: `int80[${string}]`]: undefined;
|
|
664
|
+
[x: `int88[${string}]`]: undefined;
|
|
665
|
+
[x: `int96[${string}]`]: undefined;
|
|
666
|
+
[x: `int104[${string}]`]: undefined;
|
|
667
|
+
[x: `int112[${string}]`]: undefined;
|
|
668
|
+
[x: `int120[${string}]`]: undefined;
|
|
669
|
+
[x: `int128[${string}]`]: undefined;
|
|
670
|
+
[x: `int136[${string}]`]: undefined;
|
|
671
|
+
[x: `int144[${string}]`]: undefined;
|
|
672
|
+
[x: `int152[${string}]`]: undefined;
|
|
673
|
+
[x: `int160[${string}]`]: undefined;
|
|
674
|
+
[x: `int168[${string}]`]: undefined;
|
|
675
|
+
[x: `int176[${string}]`]: undefined;
|
|
676
|
+
[x: `int184[${string}]`]: undefined;
|
|
677
|
+
[x: `int192[${string}]`]: undefined;
|
|
678
|
+
[x: `int200[${string}]`]: undefined;
|
|
679
|
+
[x: `int208[${string}]`]: undefined;
|
|
680
|
+
[x: `int216[${string}]`]: undefined;
|
|
681
|
+
[x: `int224[${string}]`]: undefined;
|
|
682
|
+
[x: `int232[${string}]`]: undefined;
|
|
683
|
+
[x: `int240[${string}]`]: undefined;
|
|
684
|
+
[x: `int248[${string}]`]: undefined;
|
|
685
|
+
[x: `int256[${string}]`]: undefined;
|
|
686
|
+
[x: `uint[${string}]`]: undefined;
|
|
687
|
+
[x: `uint16[${string}]`]: undefined;
|
|
688
|
+
[x: `uint8[${string}]`]: undefined;
|
|
689
|
+
[x: `uint24[${string}]`]: undefined;
|
|
690
|
+
[x: `uint32[${string}]`]: undefined;
|
|
691
|
+
[x: `uint40[${string}]`]: undefined;
|
|
692
|
+
[x: `uint48[${string}]`]: undefined;
|
|
693
|
+
[x: `uint56[${string}]`]: undefined;
|
|
694
|
+
[x: `uint64[${string}]`]: undefined;
|
|
695
|
+
[x: `uint72[${string}]`]: undefined;
|
|
696
|
+
[x: `uint80[${string}]`]: undefined;
|
|
697
|
+
[x: `uint88[${string}]`]: undefined;
|
|
698
|
+
[x: `uint96[${string}]`]: undefined;
|
|
699
|
+
[x: `uint104[${string}]`]: undefined;
|
|
700
|
+
[x: `uint112[${string}]`]: undefined;
|
|
701
|
+
[x: `uint120[${string}]`]: undefined;
|
|
702
|
+
[x: `uint128[${string}]`]: undefined;
|
|
703
|
+
[x: `uint136[${string}]`]: undefined;
|
|
704
|
+
[x: `uint144[${string}]`]: undefined;
|
|
705
|
+
[x: `uint152[${string}]`]: undefined;
|
|
706
|
+
[x: `uint160[${string}]`]: undefined;
|
|
707
|
+
[x: `uint168[${string}]`]: undefined;
|
|
708
|
+
[x: `uint176[${string}]`]: undefined;
|
|
709
|
+
[x: `uint184[${string}]`]: undefined;
|
|
710
|
+
[x: `uint192[${string}]`]: undefined;
|
|
711
|
+
[x: `uint200[${string}]`]: undefined;
|
|
712
|
+
[x: `uint208[${string}]`]: undefined;
|
|
713
|
+
[x: `uint216[${string}]`]: undefined;
|
|
714
|
+
[x: `uint224[${string}]`]: undefined;
|
|
715
|
+
[x: `uint232[${string}]`]: undefined;
|
|
716
|
+
[x: `uint240[${string}]`]: undefined;
|
|
717
|
+
[x: `uint248[${string}]`]: undefined;
|
|
718
|
+
[x: `uint256[${string}]`]: undefined;
|
|
719
|
+
string?: undefined;
|
|
720
|
+
address?: undefined;
|
|
721
|
+
bool?: undefined;
|
|
722
|
+
bytes?: undefined;
|
|
723
|
+
bytes1?: undefined;
|
|
724
|
+
bytes16?: undefined;
|
|
725
|
+
bytes2?: undefined;
|
|
726
|
+
bytes3?: undefined;
|
|
727
|
+
bytes4?: undefined;
|
|
728
|
+
bytes5?: undefined;
|
|
729
|
+
bytes6?: undefined;
|
|
730
|
+
bytes7?: undefined;
|
|
731
|
+
bytes8?: undefined;
|
|
732
|
+
bytes9?: undefined;
|
|
733
|
+
bytes10?: undefined;
|
|
734
|
+
bytes11?: undefined;
|
|
735
|
+
bytes12?: undefined;
|
|
736
|
+
bytes13?: undefined;
|
|
737
|
+
bytes14?: undefined;
|
|
738
|
+
bytes15?: undefined;
|
|
739
|
+
bytes17?: undefined;
|
|
740
|
+
bytes18?: undefined;
|
|
741
|
+
bytes19?: undefined;
|
|
742
|
+
bytes20?: undefined;
|
|
743
|
+
bytes21?: undefined;
|
|
744
|
+
bytes22?: undefined;
|
|
745
|
+
bytes23?: undefined;
|
|
746
|
+
bytes24?: undefined;
|
|
747
|
+
bytes25?: undefined;
|
|
748
|
+
bytes26?: undefined;
|
|
749
|
+
bytes27?: undefined;
|
|
750
|
+
bytes28?: undefined;
|
|
751
|
+
bytes29?: undefined;
|
|
752
|
+
bytes30?: undefined;
|
|
753
|
+
bytes31?: undefined;
|
|
754
|
+
bytes32?: undefined;
|
|
755
|
+
int16?: undefined;
|
|
756
|
+
int8?: undefined;
|
|
757
|
+
int24?: undefined;
|
|
758
|
+
int32?: undefined;
|
|
759
|
+
int40?: undefined;
|
|
760
|
+
int48?: undefined;
|
|
761
|
+
int56?: undefined;
|
|
762
|
+
int64?: undefined;
|
|
763
|
+
int72?: undefined;
|
|
764
|
+
int80?: undefined;
|
|
765
|
+
int88?: undefined;
|
|
766
|
+
int96?: undefined;
|
|
767
|
+
int104?: undefined;
|
|
768
|
+
int112?: undefined;
|
|
769
|
+
int120?: undefined;
|
|
770
|
+
int128?: undefined;
|
|
771
|
+
int136?: undefined;
|
|
772
|
+
int144?: undefined;
|
|
773
|
+
int152?: undefined;
|
|
774
|
+
int160?: undefined;
|
|
775
|
+
int168?: undefined;
|
|
776
|
+
int176?: undefined;
|
|
777
|
+
int184?: undefined;
|
|
778
|
+
int192?: undefined;
|
|
779
|
+
int200?: undefined;
|
|
780
|
+
int208?: undefined;
|
|
781
|
+
int216?: undefined;
|
|
782
|
+
int224?: undefined;
|
|
783
|
+
int232?: undefined;
|
|
784
|
+
int240?: undefined;
|
|
785
|
+
int248?: undefined;
|
|
786
|
+
int256?: undefined;
|
|
787
|
+
uint16?: undefined;
|
|
788
|
+
uint8?: undefined;
|
|
789
|
+
uint24?: undefined;
|
|
790
|
+
uint32?: undefined;
|
|
791
|
+
uint40?: undefined;
|
|
792
|
+
uint48?: undefined;
|
|
793
|
+
uint56?: undefined;
|
|
794
|
+
uint64?: undefined;
|
|
795
|
+
uint72?: undefined;
|
|
796
|
+
uint80?: undefined;
|
|
797
|
+
uint88?: undefined;
|
|
798
|
+
uint96?: undefined;
|
|
799
|
+
uint104?: undefined;
|
|
800
|
+
uint112?: undefined;
|
|
801
|
+
uint120?: undefined;
|
|
802
|
+
uint128?: undefined;
|
|
803
|
+
uint136?: undefined;
|
|
804
|
+
uint144?: undefined;
|
|
805
|
+
uint152?: undefined;
|
|
806
|
+
uint160?: undefined;
|
|
807
|
+
uint168?: undefined;
|
|
808
|
+
uint176?: undefined;
|
|
809
|
+
uint184?: undefined;
|
|
810
|
+
uint192?: undefined;
|
|
811
|
+
uint200?: undefined;
|
|
812
|
+
uint208?: undefined;
|
|
813
|
+
uint216?: undefined;
|
|
814
|
+
uint224?: undefined;
|
|
815
|
+
uint232?: undefined;
|
|
816
|
+
uint240?: undefined;
|
|
817
|
+
uint248?: undefined;
|
|
818
|
+
uint256?: undefined;
|
|
819
|
+
}, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, Account>) => Promise<`0x${string}`>;
|
|
820
|
+
switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
|
|
821
|
+
watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
|
|
822
|
+
writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "payable" | "nonpayable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, Chain, Account, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
823
|
+
extend: <const client extends {
|
|
824
|
+
[x: string]: unknown;
|
|
825
|
+
account?: undefined;
|
|
826
|
+
batch?: undefined;
|
|
827
|
+
cacheTime?: undefined;
|
|
828
|
+
chain?: undefined;
|
|
829
|
+
key?: undefined;
|
|
830
|
+
name?: undefined;
|
|
831
|
+
pollingInterval?: undefined;
|
|
832
|
+
request?: undefined;
|
|
833
|
+
transport?: undefined;
|
|
834
|
+
type?: undefined;
|
|
835
|
+
uid?: undefined;
|
|
836
|
+
} & Partial<Pick<import("viem").PublicActions<Transport, Chain, Account>, "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<Chain, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<Transport, Chain, Account, import("viem").WalletRpcSchema, import("viem").WalletActions<Chain, Account>>) => client) => import("viem").Client<Transport, Chain, Account, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<Chain, Account>>;
|
|
837
|
+
}>;
|
|
838
|
+
id: `dynamic-${string}`;
|
|
839
|
+
isAuthorized: () => Promise<boolean>;
|
|
840
|
+
name: "Dynamic";
|
|
841
|
+
onAccountsChanged: (accounts: string[]) => void;
|
|
842
|
+
onChainChanged: (chainId: number | string) => void;
|
|
843
|
+
onDisconnect: () => void;
|
|
844
|
+
switchChain: ({ chainId }: {
|
|
845
|
+
chainId: number;
|
|
846
|
+
}) => Promise<Chain>;
|
|
847
|
+
type: "dynamic";
|
|
848
|
+
}, {}>;
|
|
849
|
+
export declare const createConnectorForFirstConnectedEvmWallet: (wallets: Wallet[], createConnector: (wallet: Wallet) => Connector) => Connector | undefined;
|
package/src/lib/Connector.js
CHANGED
|
@@ -1,146 +1,128 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
-
import {
|
|
3
|
-
import { getAddress, createWalletClient, custom
|
|
2
|
+
import { createConnector } from '@wagmi/core';
|
|
3
|
+
import { getAddress, createWalletClient, custom } from 'viem';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
super({ chains, options: undefined });
|
|
8
|
-
// wagmi properties
|
|
9
|
-
this.id = 'dynamic';
|
|
10
|
-
this.name = 'Dynamic';
|
|
11
|
-
// also a wagmi prop, but is only used for auto-connect
|
|
12
|
-
// which we have implemented ourselves, so this value
|
|
13
|
-
// doesn't matter
|
|
14
|
-
this.ready = false;
|
|
15
|
-
this.onAccountsChanged = (accounts) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
this.emit('change', {
|
|
17
|
-
account: getAddress(accounts[0]),
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
this.onChainChanged = (chain) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
this.emit('change', {
|
|
22
|
-
chain: { id: Number(chain), unsupported: false },
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
this.onDisconnect = () => __awaiter(this, void 0, void 0, function* () { });
|
|
26
|
-
this.handleLogOut = handleLogOut;
|
|
27
|
-
this.walletConnector = walletConnector;
|
|
28
|
-
this.id = `dynamic-${walletConnector.key}`;
|
|
29
|
-
this.preventWagmiSyncFromCallingLogout = preventWagmiSyncFromCallingLogout;
|
|
30
|
-
}
|
|
31
|
-
_onAccountsChanged({ accounts }) {
|
|
32
|
-
this.onAccountsChanged(accounts);
|
|
33
|
-
}
|
|
34
|
-
_onChainChanged({ chain }) {
|
|
35
|
-
this.onChainChanged(chain);
|
|
36
|
-
}
|
|
37
|
-
_onDisconnect() {
|
|
38
|
-
this.onDisconnect();
|
|
39
|
-
}
|
|
40
|
-
setupEventListeners() {
|
|
41
|
-
this.walletConnector.on('accountChange', this._onAccountsChanged, this);
|
|
42
|
-
this.walletConnector.on('chainChange', this._onChainChanged, this);
|
|
43
|
-
this.walletConnector.on('disconnect', this._onDisconnect, this);
|
|
44
|
-
}
|
|
45
|
-
connect(config) {
|
|
5
|
+
const getCreateConnectorFn = (parameters) => createConnector((config) => ({
|
|
6
|
+
connect() {
|
|
46
7
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (!
|
|
8
|
+
if (!parameters.walletConnector) {
|
|
48
9
|
throw new Error('WalletConnector is not defined');
|
|
49
10
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
11
|
+
parameters.walletConnector.on('accountChange', ({ accounts }) => {
|
|
12
|
+
const handler = this.onAccountsChanged.bind(this);
|
|
13
|
+
handler(accounts);
|
|
14
|
+
});
|
|
15
|
+
parameters.walletConnector.on('chainChange', ({ chain }) => this.onChainChanged(chain));
|
|
16
|
+
parameters.walletConnector.on('disconnect', this.onDisconnect.bind(this));
|
|
17
|
+
const accounts = yield this.getAccounts();
|
|
53
18
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
19
|
+
accounts,
|
|
20
|
+
chainId: yield this.getChainId(),
|
|
56
21
|
};
|
|
57
22
|
});
|
|
58
|
-
}
|
|
23
|
+
},
|
|
59
24
|
disconnect() {
|
|
60
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!this.preventWagmiSyncFromCallingLogout.current) {
|
|
65
|
-
yield this.walletConnector.endSession();
|
|
66
|
-
yield this.handleLogOut();
|
|
26
|
+
if (!parameters.preventWagmiSyncFromCallingLogout.current) {
|
|
27
|
+
yield parameters.walletConnector.endSession();
|
|
28
|
+
yield parameters.handleLogOut();
|
|
67
29
|
}
|
|
30
|
+
parameters.walletConnector.off('accountChange');
|
|
31
|
+
parameters.walletConnector.off('chainChange');
|
|
32
|
+
parameters.walletConnector.off('disconnect');
|
|
68
33
|
/**
|
|
69
34
|
* In our own Dynamic Wagmi sync component, we will flip the flag to true before calling disconnect,
|
|
70
35
|
* and here it automatically flips back to false afterwards. This will prevent the Connector from
|
|
71
36
|
* calling handleLogOut when we are the ones calling disconnect, but will preserve the existing behavior
|
|
72
37
|
* for customers who use useDisconnect directly.
|
|
73
38
|
*/
|
|
74
|
-
|
|
39
|
+
parameters.preventWagmiSyncFromCallingLogout.current = false;
|
|
75
40
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
41
|
+
},
|
|
42
|
+
getAccounts() {
|
|
78
43
|
var _a;
|
|
79
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const address = yield ((_a =
|
|
45
|
+
const address = yield ((_a = parameters.walletConnector) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress());
|
|
81
46
|
if (!address) {
|
|
82
47
|
throw new Error('Not connected');
|
|
83
48
|
}
|
|
84
|
-
return getAddress(address);
|
|
49
|
+
return [getAddress(address)];
|
|
85
50
|
});
|
|
86
|
-
}
|
|
51
|
+
},
|
|
87
52
|
getChainId() {
|
|
88
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
if (!
|
|
54
|
+
if (!parameters.walletConnector) {
|
|
90
55
|
throw new Error('WalletConnector is not defined');
|
|
91
56
|
}
|
|
92
|
-
const network = yield
|
|
57
|
+
const network = yield parameters.walletConnector.getNetwork();
|
|
93
58
|
if (!network) {
|
|
94
59
|
throw new Error('Network is not defined');
|
|
95
60
|
}
|
|
96
61
|
return Number(network);
|
|
97
62
|
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var _a;
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
return (_a = this.walletConnector) === null || _a === void 0 ? void 0 : _a.getWalletClient();
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
getWalletClient(config) {
|
|
106
|
-
var _a;
|
|
63
|
+
},
|
|
64
|
+
getClient(args) {
|
|
65
|
+
var _a, _b;
|
|
107
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const signer = yield
|
|
67
|
+
const signer = yield parameters.walletConnector.getSigner();
|
|
109
68
|
if (signer.account && signer.chain) {
|
|
110
69
|
return signer;
|
|
111
70
|
}
|
|
112
71
|
const walletClient = createWalletClient({
|
|
113
|
-
account: yield this.
|
|
114
|
-
chain: (
|
|
72
|
+
account: (_a = (yield this.getAccounts())) === null || _a === void 0 ? void 0 : _a[0],
|
|
73
|
+
chain: (_b = config.chains.find((chain) => chain.id === (args === null || args === void 0 ? void 0 : args.chainId))) !== null && _b !== void 0 ? _b : config.chains[0],
|
|
115
74
|
transport: custom(signer),
|
|
116
75
|
});
|
|
117
76
|
return walletClient;
|
|
118
77
|
});
|
|
119
|
-
}
|
|
78
|
+
},
|
|
79
|
+
getProvider() {
|
|
80
|
+
var _a;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return (_a = parameters.walletConnector) === null || _a === void 0 ? void 0 : _a.getWalletClient();
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
id: `dynamic-${parameters.walletConnector.key}`,
|
|
120
86
|
isAuthorized() {
|
|
121
87
|
var _a, _b;
|
|
122
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const accounts = (_b = (yield ((_a =
|
|
89
|
+
const accounts = (_b = (yield ((_a = parameters.walletConnector) === null || _a === void 0 ? void 0 : _a.getConnectedAccounts()))) !== null && _b !== void 0 ? _b : [];
|
|
124
90
|
return accounts.length > 0;
|
|
125
91
|
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
92
|
+
},
|
|
93
|
+
name: 'Dynamic',
|
|
94
|
+
onAccountsChanged(accounts) {
|
|
95
|
+
config.emitter.emit('change', {
|
|
96
|
+
accounts: [getAddress(accounts[0])],
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
onChainChanged(chainId) {
|
|
100
|
+
config.emitter.emit('change', {
|
|
101
|
+
chainId: Number(chainId),
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
onDisconnect() { },
|
|
105
|
+
switchChain({ chainId }) {
|
|
106
|
+
var _a;
|
|
129
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
108
|
+
const chain = config.chains.find((x) => x.id === chainId);
|
|
109
|
+
if (!chain) {
|
|
110
|
+
throw new Error(`Chain ${chainId} is not supported`);
|
|
111
|
+
}
|
|
112
|
+
yield ((_a = parameters.walletConnector) === null || _a === void 0 ? void 0 : _a.switchNetwork({
|
|
113
|
+
networkChainId: chainId,
|
|
114
|
+
}));
|
|
115
|
+
return chain;
|
|
139
116
|
});
|
|
117
|
+
},
|
|
118
|
+
type: 'dynamic',
|
|
119
|
+
}));
|
|
120
|
+
const createConnectorForFirstConnectedEvmWallet = (wallets, createConnector) => {
|
|
121
|
+
for (const wallet of wallets) {
|
|
122
|
+
if (wallet.connected && wallet.connector.connectedChain === 'EVM') {
|
|
123
|
+
return createConnector(wallet);
|
|
124
|
+
}
|
|
140
125
|
}
|
|
141
|
-
|
|
142
|
-
throw new Error('Method not implemented.');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
126
|
+
};
|
|
145
127
|
|
|
146
|
-
export {
|
|
128
|
+
export { createConnectorForFirstConnectedEvmWallet, getCreateConnectorFn };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { WagmiEvmNetworks } from './types';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
3
2
|
type DynamicWagmiConnectorProps = {
|
|
4
3
|
children: ReactNode;
|
|
5
|
-
evmNetworks?: WagmiEvmNetworks[];
|
|
6
4
|
};
|
|
7
|
-
export declare const DynamicWagmiConnector:
|
|
5
|
+
export declare const DynamicWagmiConnector: React.FC<DynamicWagmiConnectorProps>;
|
|
8
6
|
export {};
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { publicProvider } from 'wagmi/providers/public';
|
|
2
|
+
import { useRef, useMemo, useEffect } from 'react';
|
|
3
|
+
import { useConfig } from 'wagmi';
|
|
5
4
|
import { useDynamicContext, useUserWallets } from '@dynamic-labs/sdk-react-core';
|
|
6
|
-
import { Connector } from './Connector.js';
|
|
7
|
-
import { getConnector } from './getConnector.js';
|
|
8
|
-
import { getWagmiChainsFromDynamicChains } from './getWagmiChainsFromDynamicChains.js';
|
|
9
|
-
import { getWagmiProvidersFromDynamicChains } from './getWagmiProvidersFromDynamicChains.js';
|
|
10
|
-
import { SyncDynamicWagmi } from './SyncDynamicWagmi.js';
|
|
11
5
|
import { findAndOrderEvmWallets } from './utils/findAndOrderEvmWallets/findAndOrderEvmWallets.js';
|
|
6
|
+
import { createConnectorForFirstConnectedEvmWallet, getCreateConnectorFn } from './Connector.js';
|
|
7
|
+
import { SyncDynamicWagmi } from './SyncDynamicWagmi.js';
|
|
12
8
|
|
|
13
|
-
const
|
|
14
|
-
const config =
|
|
15
|
-
|
|
16
|
-
publicClient,
|
|
17
|
-
});
|
|
18
|
-
const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, children, }) => {
|
|
19
|
-
const { networkConfigurations, handleLogOut, sendWagmiSettings, primaryWallet, } = useDynamicContext();
|
|
9
|
+
const DynamicWagmiConnector = ({ children, }) => {
|
|
10
|
+
const config = useConfig();
|
|
11
|
+
const { handleLogOut, primaryWallet } = useDynamicContext();
|
|
20
12
|
/**
|
|
21
13
|
* This will prevent the wagmi Connector from calling handleLogOut when we are the ones calling disconnect
|
|
22
14
|
* as a result of a handleLogOut call (see SyncDynamicWagmi), but will preserve the existing behavior for customers.
|
|
@@ -25,29 +17,14 @@ const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, child
|
|
|
25
17
|
// Sort places the primary wallet as the first wallet to attempt to connect with
|
|
26
18
|
const wallets = useUserWallets().sort((wallet) => wallet.address === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address) ? -1 : 1);
|
|
27
19
|
const evmWallets = useMemo(() => findAndOrderEvmWallets(primaryWallet, wallets), [primaryWallet, wallets]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _a;
|
|
37
|
-
const evmNetworks = ((_a = customerSuppliedEvmNetworks !== null && customerSuppliedEvmNetworks !== void 0 ? customerSuppliedEvmNetworks : networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) !== null && _a !== void 0 ? _a : []).map((network) => {
|
|
38
|
-
network.chainId = parseInt(network.chainId.toString());
|
|
39
|
-
return network;
|
|
40
|
-
});
|
|
41
|
-
const mappedChains = getWagmiChainsFromDynamicChains(evmNetworks);
|
|
42
|
-
const mappedProviders = getWagmiProvidersFromDynamicChains(evmNetworks);
|
|
43
|
-
return configureChains(mappedChains, mappedProviders);
|
|
44
|
-
}, [customerSuppliedEvmNetworks, networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm]);
|
|
45
|
-
const connector = useMemo(() => getConnector(evmWallets, (wallet) => new Connector({
|
|
46
|
-
chains,
|
|
47
|
-
handleLogOut,
|
|
48
|
-
preventWagmiSyncFromCallingLogout,
|
|
49
|
-
walletConnector: wallet.connector,
|
|
50
|
-
})), [evmWallets, chains, handleLogOut, preventWagmiSyncFromCallingLogout]);
|
|
20
|
+
const connector = useMemo(() => createConnectorForFirstConnectedEvmWallet(evmWallets, (wallet) => {
|
|
21
|
+
const connector = config._internal.connectors.setup(getCreateConnectorFn({
|
|
22
|
+
handleLogOut,
|
|
23
|
+
preventWagmiSyncFromCallingLogout,
|
|
24
|
+
walletConnector: wallet.connector,
|
|
25
|
+
}));
|
|
26
|
+
return connector;
|
|
27
|
+
}), [config._internal.connectors, evmWallets, handleLogOut]);
|
|
51
28
|
/**
|
|
52
29
|
* Updating the wagmi config must be done in a useEffect because
|
|
53
30
|
* when setting the public client and connectors, wagmi will fire
|
|
@@ -56,16 +33,9 @@ const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, child
|
|
|
56
33
|
* while react is in the middle of rendering.
|
|
57
34
|
*/
|
|
58
35
|
useEffect(() => {
|
|
59
|
-
config.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, [connector, publicClient, webSocketPublicClient]);
|
|
63
|
-
if (React.version.startsWith('18')) {
|
|
64
|
-
return (jsx(WagmiConfig, { config: config, children: jsx(SyncDynamicWagmi, { connector: connector, preventWagmiSyncFromCallingLogout: preventWagmiSyncFromCallingLogout, wallets: wallets, children: children }) }));
|
|
65
|
-
}
|
|
66
|
-
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
67
|
-
// which is not compatible when bundling apps using React 17
|
|
68
|
-
return React.createElement(WagmiConfig, { config: config }, React.createElement(SyncDynamicWagmi, { connector, preventWagmiSyncFromCallingLogout, wallets }, children));
|
|
36
|
+
config._internal.connectors.setState(connector ? [connector] : []);
|
|
37
|
+
}, [config._internal.connectors, connector]);
|
|
38
|
+
return (jsx(SyncDynamicWagmi, { connector: connector, preventWagmiSyncFromCallingLogout: preventWagmiSyncFromCallingLogout, wallets: wallets, children: children }));
|
|
69
39
|
};
|
|
70
40
|
|
|
71
41
|
export { DynamicWagmiConnector };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { MutableRefObject } from 'react';
|
|
2
|
+
import { Connector } from 'wagmi';
|
|
2
3
|
import { Wallet } from '@dynamic-labs/sdk-react-core';
|
|
3
|
-
import { Connector } from './Connector';
|
|
4
4
|
export type SyncDynamicWagmiProps = React.PropsWithChildren<{
|
|
5
5
|
connector: Connector | undefined;
|
|
6
6
|
wallets: Wallet[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
3
|
import { useConfig, useConnect, useDisconnect } from 'wagmi';
|
|
4
4
|
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
|
|
5
5
|
|
|
6
6
|
const SyncDynamicWagmi = ({ children, connector, wallets, preventWagmiSyncFromCallingLogout, }) => {
|
|
7
|
-
const { status: clientStatus } = useConfig();
|
|
7
|
+
const { state: { status: clientStatus }, } = useConfig();
|
|
8
8
|
const { connect } = useConnect();
|
|
9
9
|
const { disconnect } = useDisconnect();
|
|
10
10
|
const { walletConnector } = useDynamicContext();
|
|
@@ -52,13 +52,8 @@ const SyncDynamicWagmi = ({ children, connector, wallets, preventWagmiSyncFromCa
|
|
|
52
52
|
walletConnector,
|
|
53
53
|
wallets,
|
|
54
54
|
]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return jsx(Fragment, { children: children });
|
|
58
|
-
}
|
|
59
|
-
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
60
|
-
// which is not compatible when bundling apps using React 17
|
|
61
|
-
return React.createElement(React.Fragment, null, children);
|
|
55
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
56
|
+
return jsx(Fragment, { children: children });
|
|
62
57
|
};
|
|
63
58
|
|
|
64
59
|
export { SyncDynamicWagmi };
|
package/src/lib/utils/index.d.ts
CHANGED
package/src/lib/getConnector.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { mainnet } from 'viem/chains';
|
|
2
|
-
import { mapDynamicChainToWagmi } from './mappers/chain.js';
|
|
3
|
-
|
|
4
|
-
const getWagmiChainsFromDynamicChains = (dynamicChains) => {
|
|
5
|
-
const mappedChains = dynamicChains.map(mapDynamicChainToWagmi);
|
|
6
|
-
return mappedChains.length > 0 ? mappedChains : [mainnet];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { getWagmiChainsFromDynamicChains };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { publicProvider } from 'wagmi/providers/public';
|
|
2
|
-
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
|
|
3
|
-
|
|
4
|
-
/* eslint-disable prefer-destructuring */
|
|
5
|
-
const getProvider = (dynamicChain, rpcUrl) => {
|
|
6
|
-
let http;
|
|
7
|
-
let webSocket;
|
|
8
|
-
if (typeof rpcUrl !== 'string') {
|
|
9
|
-
http = rpcUrl.http;
|
|
10
|
-
webSocket = rpcUrl.webSocket;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
http = rpcUrl;
|
|
14
|
-
}
|
|
15
|
-
return (chain) => {
|
|
16
|
-
if (chain.id !== dynamicChain.chainId)
|
|
17
|
-
return null;
|
|
18
|
-
return jsonRpcProvider({
|
|
19
|
-
rpc: () => ({
|
|
20
|
-
http,
|
|
21
|
-
webSocket,
|
|
22
|
-
}),
|
|
23
|
-
})(chain);
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const getWagmiProvidersFromDynamicChains = (dynamicChains) => {
|
|
27
|
-
const wagmiProviders = [];
|
|
28
|
-
dynamicChains.forEach((dynamicChain) => {
|
|
29
|
-
var _a;
|
|
30
|
-
((_a = dynamicChain.privateCustomerRpcUrls) !== null && _a !== void 0 ? _a : []).forEach((rpcUrl) => {
|
|
31
|
-
wagmiProviders.push(getProvider(dynamicChain, rpcUrl));
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
return [...wagmiProviders, publicProvider()];
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { getWagmiProvidersFromDynamicChains };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Chain } from 'wagmi';
|
|
2
|
-
import { WagmiEvmNetworks } from '../types';
|
|
3
|
-
export declare const mapDynamicChainToWagmi: (dynamicChain: WagmiEvmNetworks) => Chain;
|
|
4
|
-
export declare const overrideWagmiChainWithDynamicSettings: (wagmiChain: Chain | undefined, dynamicChain: WagmiEvmNetworks) => Chain;
|
package/src/lib/mappers/chain.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as allChains from 'wagmi/chains';
|
|
2
|
-
import { resolveRpcUrlFromEvmNetworks } from '../utils/resolveRpcUrlFromEvmNetworks/resolveRpcUrlFromEvmNetworks.js';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line import/no-namespace
|
|
5
|
-
const updateRpcProvider = (rpcUrls, privateCustomerRpcUrls, name) => {
|
|
6
|
-
const findRpcUrl = privateCustomerRpcUrls === null || privateCustomerRpcUrls === void 0 ? void 0 : privateCustomerRpcUrls.find((rpcUrl) => {
|
|
7
|
-
if (typeof rpcUrl === 'string') {
|
|
8
|
-
return rpcUrl.includes(name);
|
|
9
|
-
}
|
|
10
|
-
else if (typeof rpcUrl.http === 'string') {
|
|
11
|
-
return rpcUrl.http.includes(name);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (typeof findRpcUrl === 'string') {
|
|
18
|
-
rpcUrls[name] = { http: [findRpcUrl] };
|
|
19
|
-
}
|
|
20
|
-
else if (typeof (findRpcUrl === null || findRpcUrl === void 0 ? void 0 : findRpcUrl.http) === 'string') {
|
|
21
|
-
rpcUrls[name] = { http: [findRpcUrl.http] };
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const mapDynamicChainToWagmi = (dynamicChain) => {
|
|
25
|
-
/**
|
|
26
|
-
* Find the chain in Wagmi that matches the chainId of the dynamic chain.
|
|
27
|
-
*/
|
|
28
|
-
const wagmiChain = Object.values(allChains).find((chain) => chain.id === dynamicChain.chainId);
|
|
29
|
-
return overrideWagmiChainWithDynamicSettings(wagmiChain, dynamicChain);
|
|
30
|
-
};
|
|
31
|
-
const generateRpcUrls = (dynamicChain) => {
|
|
32
|
-
const rpcUrlResolved = resolveRpcUrlFromEvmNetworks(dynamicChain);
|
|
33
|
-
const rpcUrls = {
|
|
34
|
-
default: {
|
|
35
|
-
http: rpcUrlResolved,
|
|
36
|
-
},
|
|
37
|
-
public: {
|
|
38
|
-
http: rpcUrlResolved,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const rpcUrlProviders = ['alchemy', 'infura'];
|
|
42
|
-
rpcUrlProviders.forEach((name) => updateRpcProvider(rpcUrls, dynamicChain.privateCustomerRpcUrls, name));
|
|
43
|
-
return rpcUrls;
|
|
44
|
-
};
|
|
45
|
-
const overrideWagmiChainWithDynamicSettings = (wagmiChain, dynamicChain) => {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
47
|
-
return (Object.assign(Object.assign({}, wagmiChain), { blockExplorers: Object.assign(Object.assign({}, wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.blockExplorers), { default: Object.assign(Object.assign({}, (_a = wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.blockExplorers) === null || _a === void 0 ? void 0 : _a.default), { name: '', url: (_c = (_b = dynamicChain.blockExplorerUrls) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '' }) }), contracts: (_d = dynamicChain.contracts) !== null && _d !== void 0 ? _d : wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.contracts, id: (_e = wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.id) !== null && _e !== void 0 ? _e : dynamicChain.chainId, name: (_g = (_f = dynamicChain.vanityName) !== null && _f !== void 0 ? _f : dynamicChain.name) !== null && _g !== void 0 ? _g : wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.name, nativeCurrency: (_h = dynamicChain.nativeCurrency) !== null && _h !== void 0 ? _h : wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.nativeCurrency, network: (_k = (_j = wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.network) !== null && _j !== void 0 ? _j : dynamicChain.chainName) !== null && _k !== void 0 ? _k : '', rpcUrls: generateRpcUrls(dynamicChain) }));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { mapDynamicChainToWagmi, overrideWagmiChainWithDynamicSettings };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { resolveRpcUrlFromEvmNetworks } from './resolveRpcUrlFromEvmNetworks';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const mapCustomProviderOptionsToString = (rpcUrl) => (typeof rpcUrl === 'string' ? rpcUrl : rpcUrl.http);
|
|
2
|
-
const resolveRpcUrlFromEvmNetworks = (dynamicChain) => {
|
|
3
|
-
var _a;
|
|
4
|
-
const privateCustomerRpcUrls = (_a = dynamicChain.privateCustomerRpcUrls) !== null && _a !== void 0 ? _a : [];
|
|
5
|
-
const customerRpcUrls = privateCustomerRpcUrls.map(mapCustomProviderOptionsToString);
|
|
6
|
-
return customerRpcUrls.length ? customerRpcUrls : dynamicChain.rpcUrls;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { resolveRpcUrlFromEvmNetworks };
|