@wagmi/connectors 0.1.10 → 0.2.0

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.
@@ -2,7 +2,7 @@ import { Address } from '@wagmi/core';
2
2
  import { Chain } from '@wagmi/core/chains';
3
3
  import EventEmitter from 'eventemitter3';
4
4
 
5
- declare type ConnectorData<Provider = any> = {
5
+ type ConnectorData<Provider = any> = {
6
6
  account?: Address;
7
7
  chain?: {
8
8
  id: number;
@@ -2,11 +2,11 @@ import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
2
2
  import { CoinbaseWalletSDKOptions } from '@coinbase/wallet-sdk/dist/CoinbaseWalletSDK';
3
3
  import { Chain } from '@wagmi/core/chains';
4
4
  import { providers } from 'ethers';
5
- import { C as Connector } from './base-542af431.js';
5
+ import { C as Connector } from './base-84a689bb.js';
6
6
  import '@wagmi/core';
7
7
  import 'eventemitter3';
8
8
 
9
- declare type Options = Omit<CoinbaseWalletSDKOptions, 'reloadOnDisconnect'> & {
9
+ type Options = Omit<CoinbaseWalletSDKOptions, 'reloadOnDisconnect'> & {
10
10
  /**
11
11
  * Fallback Ethereum JSON RPC URL
12
12
  * @default ""
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-542af431.js';
1
+ export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-84a689bb.js';
2
+ export { E as Ethereum } from './types-15a470bc.js';
2
3
  import '@wagmi/core';
3
4
  import '@wagmi/core/chains';
4
5
  import 'eventemitter3';
6
+ import 'abitype';
@@ -1,11 +1,12 @@
1
- import * as _wagmi_core_dist_index_1260a84c from '@wagmi/core/dist/index-1260a84c';
2
1
  import { Address } from '@wagmi/core';
3
2
  import { Chain } from '@wagmi/core/chains';
4
3
  import { providers } from 'ethers';
5
- import { C as Connector } from './base-542af431.js';
4
+ import { C as Connector } from './base-84a689bb.js';
5
+ import { E as Ethereum } from './types-15a470bc.js';
6
6
  import 'eventemitter3';
7
+ import 'abitype';
7
8
 
8
- declare type InjectedConnectorOptions = {
9
+ type InjectedConnectorOptions = {
9
10
  /** Name of connector */
10
11
  name?: string | ((detectedName: string | string[]) => string);
11
12
  /**
@@ -14,7 +15,7 @@ declare type InjectedConnectorOptions = {
14
15
  * @default
15
16
  * () => typeof window !== 'undefined' ? window.ethereum : undefined
16
17
  */
17
- getProvider?: () => Window['ethereum'] | undefined;
18
+ getProvider?: () => Ethereum | undefined;
18
19
  /**
19
20
  * MetaMask 10.9.3 emits disconnect event when chain is changed.
20
21
  * This flag prevents the `"disconnect"` event from being emitted upon switching chains. See [GitHub issue](https://github.com/MetaMask/metamask-extension/issues/13375#issuecomment-1027663334) for more info.
@@ -27,8 +28,8 @@ declare type InjectedConnectorOptions = {
27
28
  */
28
29
  shimDisconnect?: boolean;
29
30
  };
30
- declare type ConnectorOptions = InjectedConnectorOptions & Required<Pick<InjectedConnectorOptions, 'getProvider'>>;
31
- declare class InjectedConnector extends Connector<Window['ethereum'], ConnectorOptions, providers.JsonRpcSigner> {
31
+ type ConnectorOptions = InjectedConnectorOptions & Required<Pick<InjectedConnectorOptions, 'getProvider'>>;
32
+ declare class InjectedConnector extends Connector<Ethereum | undefined, ConnectorOptions, providers.JsonRpcSigner> {
32
33
  #private;
33
34
  readonly id: string;
34
35
  readonly name: string;
@@ -46,12 +47,12 @@ declare class InjectedConnector extends Connector<Window['ethereum'], ConnectorO
46
47
  id: number;
47
48
  unsupported: boolean;
48
49
  };
49
- provider: _wagmi_core_dist_index_1260a84c.E;
50
+ provider: Ethereum;
50
51
  }>;
51
52
  disconnect(): Promise<void>;
52
53
  getAccount(): Promise<`0x${string}`>;
53
54
  getChainId(): Promise<number>;
54
- getProvider(): Promise<_wagmi_core_dist_index_1260a84c.E | undefined>;
55
+ getProvider(): Promise<Ethereum | undefined>;
55
56
  getSigner({ chainId }?: {
56
57
  chainId?: number;
57
58
  }): Promise<providers.JsonRpcSigner>;
package/dist/ledger.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { EthereumProvider } from '@ledgerhq/connect-kit-loader';
2
2
  import { Chain } from '@wagmi/core';
3
3
  import { providers } from 'ethers';
4
- import { C as Connector, a as ConnectorData } from './base-542af431.js';
4
+ import { C as Connector, a as ConnectorData } from './base-84a689bb.js';
5
5
  import '@wagmi/core/chains';
6
6
  import 'eventemitter3';
7
7
 
8
- declare type LedgerConnectorOptions = {
8
+ type LedgerConnectorOptions = {
9
9
  bridge?: string;
10
10
  chainId?: number;
11
11
  enableDebugLogs?: boolean;
@@ -13,7 +13,7 @@ declare type LedgerConnectorOptions = {
13
13
  [chainId: number]: string;
14
14
  };
15
15
  };
16
- declare type LedgerSigner = providers.JsonRpcSigner;
16
+ type LedgerSigner = providers.JsonRpcSigner;
17
17
  declare class LedgerConnector extends Connector<EthereumProvider, LedgerConnectorOptions, LedgerSigner> {
18
18
  #private;
19
19
  readonly id = "ledger";
@@ -1,12 +1,13 @@
1
- import { Ethereum } from '@wagmi/core';
2
1
  import { Chain } from '@wagmi/core/chains';
3
2
  import { InjectedConnectorOptions, InjectedConnector } from './injected.js';
4
- import '@wagmi/core/dist/index-1260a84c';
3
+ import { E as Ethereum } from './types-15a470bc.js';
4
+ import '@wagmi/core';
5
5
  import 'ethers';
6
- import './base-542af431.js';
6
+ import './base-84a689bb.js';
7
7
  import 'eventemitter3';
8
+ import 'abitype';
8
9
 
9
- declare type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimChainChangedDisconnect' | 'shimDisconnect'> & {
10
+ type MetaMaskConnectorOptions = Pick<InjectedConnectorOptions, 'shimChainChangedDisconnect' | 'shimDisconnect'> & {
10
11
  /**
11
12
  * While "disconnected" with `shimDisconnect`, allows user to select a different MetaMask account (than the currently connected account) when trying to connect.
12
13
  */
package/dist/metaMask.js CHANGED
@@ -27,29 +27,30 @@ var MetaMaskConnector = class extends InjectedConnector {
27
27
  shimDisconnect: true,
28
28
  shimChainChangedDisconnect: true,
29
29
  getProvider() {
30
- function getReady(ethereum) {
31
- const isMetaMask = !!ethereum?.isMetaMask;
30
+ function getReady(ethereum2) {
31
+ const isMetaMask = !!ethereum2?.isMetaMask;
32
32
  if (!isMetaMask)
33
33
  return;
34
- if (ethereum.isBraveWallet && !ethereum._events && !ethereum._state)
34
+ if (ethereum2.isBraveWallet && !ethereum2._events && !ethereum2._state)
35
35
  return;
36
- if (ethereum.isAvalanche)
36
+ if (ethereum2.isAvalanche)
37
37
  return;
38
- if (ethereum.isKuCoinWallet)
38
+ if (ethereum2.isKuCoinWallet)
39
39
  return;
40
- if (ethereum.isPortal)
40
+ if (ethereum2.isPortal)
41
41
  return;
42
- if (ethereum.isTokenPocket)
42
+ if (ethereum2.isTokenPocket)
43
43
  return;
44
- if (ethereum.isTokenary)
44
+ if (ethereum2.isTokenary)
45
45
  return;
46
- return ethereum;
46
+ return ethereum2;
47
47
  }
48
48
  if (typeof window === "undefined")
49
49
  return;
50
- if (window.ethereum?.providers)
51
- return window.ethereum.providers.find(getReady);
52
- return getReady(window.ethereum);
50
+ const ethereum = window.ethereum;
51
+ if (ethereum?.providers)
52
+ return ethereum.providers.find(getReady);
53
+ return getReady(ethereum);
53
54
  },
54
55
  ...options_
55
56
  };
@@ -1,11 +1,11 @@
1
1
  import * as ethers from 'ethers';
2
2
  import { providers } from 'ethers';
3
3
  import { Chain } from '@wagmi/core/chains';
4
- import { C as Connector, a as ConnectorData } from '../base-542af431.js';
4
+ import { C as Connector, a as ConnectorData } from '../base-84a689bb.js';
5
5
  import { Signer } from '@wagmi/core';
6
6
  import EventEmitter from 'eventemitter3';
7
7
 
8
- declare type MockProviderOptions = {
8
+ type MockProviderOptions = {
9
9
  chainId: number;
10
10
  flags?: {
11
11
  isAuthorized?: boolean;
@@ -15,12 +15,12 @@ declare type MockProviderOptions = {
15
15
  };
16
16
  signer: Signer;
17
17
  };
18
- declare type Events = {
18
+ type Events = {
19
19
  accountsChanged(accounts: string[]): void;
20
20
  chainChanged(chainId: number | string): void;
21
21
  disconnect(): void;
22
22
  };
23
- declare type Event = keyof Events;
23
+ type Event = keyof Events;
24
24
  declare class MockProvider extends providers.BaseProvider {
25
25
  #private;
26
26
  events: EventEmitter<Events, any>;
@@ -44,7 +44,7 @@ declare class MockProvider extends providers.BaseProvider {
44
44
  toJSON(): string;
45
45
  }
46
46
 
47
- declare type MockConnectorOptions = Omit<MockProviderOptions, 'chainId'> & {
47
+ type MockConnectorOptions = Omit<MockProviderOptions, 'chainId'> & {
48
48
  chainId?: number;
49
49
  };
50
50
  declare class MockConnector extends Connector<MockProvider, MockConnectorOptions> {
@@ -0,0 +1,145 @@
1
+ import { Address, ResolvedConfig } from 'abitype';
2
+
3
+ type AddEthereumChainParameter = {
4
+ /** A 0x-prefixed hexadecimal string */
5
+ chainId: string;
6
+ chainName: string;
7
+ nativeCurrency?: {
8
+ name: string;
9
+ /** 2-6 characters long */
10
+ symbol: string;
11
+ decimals: number;
12
+ };
13
+ rpcUrls: string[];
14
+ blockExplorerUrls?: string[];
15
+ /** Currently ignored. */
16
+ iconUrls?: string[];
17
+ };
18
+ type WalletPermissionCaveat = {
19
+ type: string;
20
+ value: any;
21
+ };
22
+ type WalletPermission = {
23
+ caveats: WalletPermissionCaveat[];
24
+ date: number;
25
+ id: string;
26
+ invoker: `http://${string}` | `https://${string}`;
27
+ parentCapability: 'eth_accounts' | string;
28
+ };
29
+ type WatchAssetParams = {
30
+ /** In the future, other standards will be supported */
31
+ type: 'ERC20';
32
+ options: {
33
+ /** Address of token contract */
34
+ address: Address;
35
+ /** Number of token decimals */
36
+ decimals: ResolvedConfig['IntType'];
37
+ /** String url of token logo */
38
+ image?: string;
39
+ /** A ticker symbol or shorthand, up to 5 characters */
40
+ symbol: string;
41
+ };
42
+ };
43
+ type InjectedProviderFlags = {
44
+ isAvalanche?: true;
45
+ isBitKeep?: true;
46
+ isBraveWallet?: true;
47
+ isCoinbaseWallet?: true;
48
+ isExodus?: true;
49
+ isFrame?: true;
50
+ isKuCoinWallet?: true;
51
+ isMathWallet?: true;
52
+ isMetaMask?: true;
53
+ isOneInchAndroidWallet?: true;
54
+ isOneInchIOSWallet?: true;
55
+ isOpera?: true;
56
+ isPhantom?: true;
57
+ isPortal?: true;
58
+ isRainbow?: true;
59
+ isTally?: true;
60
+ isTokenPocket?: true;
61
+ isTokenary?: true;
62
+ isTrust?: true;
63
+ isTrustWallet?: true;
64
+ };
65
+ type InjectedProviders = InjectedProviderFlags & {
66
+ isMetaMask: true;
67
+ /** Only exists in MetaMask as of 2022/04/03 */
68
+ _events: {
69
+ connect?: () => void;
70
+ };
71
+ /** Only exists in MetaMask as of 2022/04/03 */
72
+ _state?: {
73
+ accounts?: string[];
74
+ initialized?: boolean;
75
+ isConnected?: boolean;
76
+ isPermanentlyDisconnected?: boolean;
77
+ isUnlocked?: boolean;
78
+ };
79
+ };
80
+ interface Ethereum extends InjectedProviders {
81
+ on?: (...args: any[]) => void;
82
+ removeListener?: (...args: any[]) => void;
83
+ providers?: Ethereum[];
84
+ /**
85
+ * EIP-747: Add wallet_watchAsset to Provider
86
+ * https://eips.ethereum.org/EIPS/eip-747
87
+ */
88
+ request(args: {
89
+ method: 'wallet_watchAsset';
90
+ params: WatchAssetParams;
91
+ }): Promise<boolean>;
92
+ /**
93
+ * EIP-1193: Ethereum Provider JavaScript API
94
+ * https://eips.ethereum.org/EIPS/eip-1193
95
+ */
96
+ request(args: {
97
+ method: 'eth_accounts';
98
+ }): Promise<Address[]>;
99
+ request(args: {
100
+ method: 'eth_chainId';
101
+ }): Promise<string>;
102
+ request(args: {
103
+ method: 'eth_requestAccounts';
104
+ }): Promise<Address[]>;
105
+ /**
106
+ * EIP-1474: Remote procedure call specification
107
+ * https://eips.ethereum.org/EIPS/eip-1474
108
+ */
109
+ request(args: {
110
+ method: 'web3_clientVersion';
111
+ }): Promise<string>;
112
+ /**
113
+ * EIP-2255: Wallet Permissions System
114
+ * https://eips.ethereum.org/EIPS/eip-2255
115
+ */
116
+ request(args: {
117
+ method: 'wallet_requestPermissions';
118
+ params: [{
119
+ eth_accounts: Record<string, any>;
120
+ }];
121
+ }): Promise<WalletPermission[]>;
122
+ request(args: {
123
+ method: 'wallet_getPermissions';
124
+ }): Promise<WalletPermission[]>;
125
+ /**
126
+ * EIP-3085: Wallet Add Ethereum Chain RPC Method
127
+ * https://eips.ethereum.org/EIPS/eip-3085
128
+ */
129
+ request(args: {
130
+ method: 'wallet_addEthereumChain';
131
+ params: AddEthereumChainParameter[];
132
+ }): Promise<null>;
133
+ /**
134
+ * EIP-3326: Wallet Switch Ethereum Chain RPC Method
135
+ * https://eips.ethereum.org/EIPS/eip-3326
136
+ */
137
+ request(args: {
138
+ method: 'wallet_switchEthereumChain';
139
+ params: [{
140
+ chainId: string;
141
+ }];
142
+ }): Promise<null>;
143
+ }
144
+
145
+ export { Ethereum as E };
@@ -3,12 +3,12 @@ import { UniversalProvider as UniversalProvider$1, UniversalProviderOpts } from
3
3
  import { Chain } from '@wagmi/core';
4
4
  import WalletConnectProvider from '@walletconnect/ethereum-provider';
5
5
  import { providers } from 'ethers';
6
- import { C as Connector } from './base-542af431.js';
6
+ import { C as Connector } from './base-84a689bb.js';
7
7
  import '@wagmi/core/chains';
8
8
  import 'eventemitter3';
9
9
 
10
- declare type UniversalProvider = InstanceType<typeof UniversalProvider$1>;
11
- declare type WalletConnectOptions = {
10
+ type UniversalProvider = InstanceType<typeof UniversalProvider$1>;
11
+ type WalletConnectOptions = {
12
12
  /** When `true`, uses default WalletConnect QR Code modal */
13
13
  qrcode?: boolean;
14
14
  } & (({
@@ -20,7 +20,7 @@ declare type WalletConnectOptions = {
20
20
  projectId: NonNullable<UniversalProviderOpts['projectId']>;
21
21
  version: '2';
22
22
  } & Omit<UniversalProviderOpts, 'projectId'>));
23
- declare type WalletConnectSigner = providers.JsonRpcSigner;
23
+ type WalletConnectSigner = providers.JsonRpcSigner;
24
24
  declare class WalletConnectConnector extends Connector<WalletConnectProvider | UniversalProvider, WalletConnectOptions, WalletConnectSigner> {
25
25
  #private;
26
26
  readonly id = "walletConnect";
package/package.json CHANGED
@@ -2,26 +2,31 @@
2
2
  "name": "@wagmi/connectors",
3
3
  "description": "A collection of connectors for wagmi",
4
4
  "license": "MIT",
5
- "version": "0.1.10",
5
+ "version": "0.2.0",
6
6
  "peerDependencies": {
7
- "@wagmi/core": "0.8.x",
8
- "ethers": "^5.0.0"
7
+ "@wagmi/core": ">=0.9.x",
8
+ "ethers": ">=5.5.1",
9
+ "typescript": ">=4.9.4"
9
10
  },
10
11
  "peerDependenciesMeta": {
11
12
  "@wagmi/core": {
12
13
  "optional": true
14
+ },
15
+ "typescript": {
16
+ "optional": true
13
17
  }
14
18
  },
15
19
  "dependencies": {
16
20
  "@coinbase/wallet-sdk": "^3.5.4",
17
21
  "@ledgerhq/connect-kit-loader": "^1.0.1",
18
22
  "@walletconnect/ethereum-provider": "^1.8.0",
19
- "@web3modal/standalone": "^2.0.0-rc.2",
20
23
  "@walletconnect/universal-provider": "^2.2.1",
24
+ "@web3modal/standalone": "^2.0.0-rc.2",
25
+ "abitype": "^0.3.0",
21
26
  "eventemitter3": "^4.0.7"
22
27
  },
23
28
  "devDependencies": {
24
- "@wagmi/core": "^0.8.12",
29
+ "@wagmi/core": "^0.8.19",
25
30
  "ethers": "^5.7.2"
26
31
  },
27
32
  "type": "module",
@@ -32,13 +37,17 @@
32
37
  "types": "./dist/index.d.ts",
33
38
  "default": "./dist/index.js"
34
39
  },
40
+ "./coinbaseWallet": {
41
+ "types": "./dist/coinbaseWallet.d.ts",
42
+ "default": "./dist/coinbaseWallet.js"
43
+ },
35
44
  "./injected": {
36
45
  "types": "./dist/injected.d.ts",
37
46
  "default": "./dist/injected.js"
38
47
  },
39
- "./coinbaseWallet": {
40
- "types": "./dist/coinbaseWallet.d.ts",
41
- "default": "./dist/coinbaseWallet.js"
48
+ "./ledger": {
49
+ "types": "./dist/ledger.d.ts",
50
+ "default": "./dist/ledger.js"
42
51
  },
43
52
  "./metaMask": {
44
53
  "types": "./dist/metaMask.d.ts",
@@ -52,20 +61,16 @@
52
61
  "types": "./dist/walletConnect.d.ts",
53
62
  "default": "./dist/walletConnect.js"
54
63
  },
55
- "./ledger": {
56
- "types": "./dist/ledger.d.ts",
57
- "default": "./dist/ledger.js"
58
- },
59
64
  "./package.json": "./package.json"
60
65
  },
61
66
  "files": [
62
67
  "/coinbaseWallet",
63
- "/dist",
64
68
  "/injected",
69
+ "/ledger",
65
70
  "/metaMask",
66
71
  "/mock",
67
72
  "/walletConnect",
68
- "/ledger"
73
+ "/dist"
69
74
  ],
70
75
  "sideEffects": false,
71
76
  "contributors": [
@@ -77,7 +82,7 @@
77
82
  "funding": [
78
83
  {
79
84
  "type": "gitcoin",
80
- "url": "https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum"
85
+ "url": "https://wagmi.sh/gitcoin"
81
86
  },
82
87
  {
83
88
  "type": "github",