@wagmi/core 0.7.9 → 0.8.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.
Files changed (36) hide show
  1. package/dist/{base-a32d0b91.d.ts → base-a82112a9.d.ts} +1 -1
  2. package/dist/chains.d.ts +1 -3
  3. package/dist/chains.js +13 -1
  4. package/dist/chunk-6KG5TOAU.js +42 -0
  5. package/dist/chunk-J6DUE3KA.js +0 -0
  6. package/dist/chunk-SK7UQXOC.js +191 -0
  7. package/dist/{chunk-HEIMP7HQ.js → chunk-TQC2HCNN.js} +1166 -1126
  8. package/dist/connectors/coinbaseWallet.d.ts +2 -2
  9. package/dist/connectors/coinbaseWallet.js +8 -5
  10. package/dist/connectors/metaMask.d.ts +4 -3
  11. package/dist/connectors/metaMask.js +2 -2
  12. package/dist/connectors/mock/index.d.ts +3 -2
  13. package/dist/connectors/mock/index.js +6 -185
  14. package/dist/connectors/walletConnect.d.ts +2 -2
  15. package/dist/connectors/walletConnect.js +8 -4
  16. package/dist/{index-58cffc47.d.ts → index-971cda79.d.ts} +2 -103
  17. package/dist/index.d.ts +51 -46
  18. package/dist/index.js +9 -20
  19. package/dist/{injected-82510902.d.ts → injected-610c34b6.d.ts} +3 -2
  20. package/dist/{internal.d.ts → internal/index.d.ts} +3 -2
  21. package/dist/internal/index.js +8 -0
  22. package/dist/internal/test.d.ts +12 -0
  23. package/dist/internal/test.js +142 -0
  24. package/dist/providers/alchemy.d.ts +2 -1
  25. package/dist/providers/alchemy.js +2 -2
  26. package/dist/providers/infura.d.ts +2 -1
  27. package/dist/providers/infura.js +2 -2
  28. package/dist/providers/jsonRpc.d.ts +2 -1
  29. package/dist/providers/jsonRpc.js +2 -2
  30. package/dist/providers/public.d.ts +2 -1
  31. package/dist/providers/public.js +2 -2
  32. package/internal/package.json +1 -1
  33. package/internal/test/package.json +4 -0
  34. package/package.json +12 -7
  35. package/dist/chunk-4DNFSL2K.js +0 -376
  36. package/dist/internal.js +0 -8
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./chunk-J6DUE3KA.js";
1
2
  import {
2
3
  AddChainError,
3
4
  ChainDoesNotSupportMulticallError,
@@ -40,6 +41,7 @@ import {
40
41
  fetchToken,
41
42
  fetchTransaction,
42
43
  getAccount,
44
+ getClient,
43
45
  getContract,
44
46
  getNetwork,
45
47
  getProvider,
@@ -71,18 +73,11 @@ import {
71
73
  watchSigner,
72
74
  watchWebSocketProvider,
73
75
  writeContract
74
- } from "./chunk-HEIMP7HQ.js";
76
+ } from "./chunk-TQC2HCNN.js";
75
77
  import {
76
- alchemyRpcUrls,
77
- allChains,
78
- chain,
79
- chainId,
80
- defaultChains,
81
- defaultL2Chains,
82
- etherscanBlockExplorers,
83
- infuraRpcUrls,
84
- publicRpcUrls
85
- } from "./chunk-4DNFSL2K.js";
78
+ goerli,
79
+ mainnet
80
+ } from "./chunk-6KG5TOAU.js";
86
81
  import "./chunk-MQXBDTVK.js";
87
82
  export {
88
83
  AddChainError,
@@ -105,23 +100,16 @@ export {
105
100
  SwitchChainError,
106
101
  SwitchChainNotSupportedError,
107
102
  UserRejectedRequestError,
108
- alchemyRpcUrls,
109
- allChains,
110
- chain,
111
- chainId,
112
103
  configureChains,
113
104
  connect,
114
105
  createClient,
115
106
  createStorage,
116
107
  deepEqual,
117
- defaultChains,
118
- defaultL2Chains,
119
108
  deserialize,
120
109
  disconnect,
121
110
  erc20ABI,
122
111
  erc4626ABI,
123
112
  erc721ABI,
124
- etherscanBlockExplorers,
125
113
  fetchBalance,
126
114
  fetchBlockNumber,
127
115
  fetchEnsAddress,
@@ -133,11 +121,13 @@ export {
133
121
  fetchToken,
134
122
  fetchTransaction,
135
123
  getAccount,
124
+ getClient,
136
125
  getContract,
137
126
  getNetwork,
138
127
  getProvider,
139
128
  getWebSocketProvider,
140
- infuraRpcUrls,
129
+ goerli,
130
+ mainnet,
141
131
  minimizeContractInterface,
142
132
  multicall,
143
133
  noopStorage,
@@ -145,7 +135,6 @@ export {
145
135
  parseContractResult,
146
136
  prepareSendTransaction,
147
137
  prepareWriteContract,
148
- publicRpcUrls,
149
138
  readContract,
150
139
  readContracts,
151
140
  sendTransaction,
@@ -1,7 +1,8 @@
1
- import { C as Chain, E as Ethereum } from './index-58cffc47.js';
1
+ import { Chain } from '@wagmi/chains';
2
2
  import { Address } from 'abitype';
3
3
  import { providers } from 'ethers';
4
- import { C as Connector } from './base-a32d0b91.js';
4
+ import { C as Connector } from './base-a82112a9.js';
5
+ import { E as Ethereum } from './index-971cda79.js';
5
6
 
6
7
  type InjectedConnectorOptions = {
7
8
  /** Name of connector */
@@ -1,7 +1,8 @@
1
- import './index-58cffc47.js';
2
- export { g as AbiParameter, h as ContractConfig, b as ContractsConfig, c as ContractsResult, E as Event, i as GetArgs, G as GetConfig, d as GetReturnType, f as IsNever, N as NotEqual, j as Optional, e as Or } from './contracts-3880ee54.js';
1
+ export { g as AbiParameter, h as ContractConfig, b as ContractsConfig, c as ContractsResult, E as Event, i as GetArgs, G as GetConfig, d as GetReturnType, f as IsNever, N as NotEqual, j as Optional, e as Or } from '../contracts-3880ee54.js';
2
+ import '../index-971cda79.js';
3
3
  import 'abitype';
4
4
  import 'ethers';
5
+ import '@wagmi/chains';
5
6
 
6
7
  declare function debounce(fn: (...args: any) => void, waitTime?: number): (...args: any) => void;
7
8
 
@@ -0,0 +1,8 @@
1
+ import {
2
+ debounce
3
+ } from "../chunk-TQC2HCNN.js";
4
+ import "../chunk-6KG5TOAU.js";
5
+ import "../chunk-MQXBDTVK.js";
6
+ export {
7
+ debounce
8
+ };
@@ -0,0 +1,12 @@
1
+ import '../index-971cda79.js';
2
+ import { Wallet, providers } from 'ethers';
3
+ import { Chain } from '@wagmi/chains';
4
+ import 'abitype';
5
+
6
+ declare const testChains: Chain[];
7
+ declare class WalletSigner extends Wallet {
8
+ connectUnchecked(): providers.JsonRpcSigner;
9
+ }
10
+ declare function getSigners(): WalletSigner[];
11
+
12
+ export { getSigners, testChains };
@@ -0,0 +1,142 @@
1
+ import "../chunk-J6DUE3KA.js";
2
+ import "../chunk-SK7UQXOC.js";
3
+ import "../chunk-TQC2HCNN.js";
4
+ import {
5
+ foundry,
6
+ goerli,
7
+ mainnet,
8
+ optimism,
9
+ polygon
10
+ } from "../chunk-6KG5TOAU.js";
11
+ import "../chunk-MQXBDTVK.js";
12
+
13
+ // test/utils.ts
14
+ import { BigNumber, Wallet, providers } from "ethers";
15
+ function getNetwork(chain) {
16
+ return {
17
+ chainId: chain.id,
18
+ ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
19
+ name: chain.name
20
+ };
21
+ }
22
+ var foundryMainnet = {
23
+ ...mainnet,
24
+ rpcUrls: foundry.rpcUrls
25
+ };
26
+ var testChains = [foundryMainnet, mainnet, goerli, optimism, polygon];
27
+ var EthersProviderWrapper = class extends providers.StaticJsonRpcProvider {
28
+ toJSON() {
29
+ return `<Provider network={${this.network.chainId}} />`;
30
+ }
31
+ };
32
+ function getProvider({
33
+ chains = testChains,
34
+ chainId
35
+ } = {}) {
36
+ const chain = testChains.find((x) => x.id === chainId) ?? foundryMainnet;
37
+ const url = foundryMainnet.rpcUrls.default.http[0];
38
+ const provider = new EthersProviderWrapper(url, getNetwork(chain));
39
+ provider.pollingInterval = 1e3;
40
+ return Object.assign(provider, { chains });
41
+ }
42
+ var EthersWebSocketProviderWrapper = class extends providers.WebSocketProvider {
43
+ toJSON() {
44
+ return `<WebSocketProvider network={${this.network.chainId}} />`;
45
+ }
46
+ };
47
+ var accounts = [
48
+ {
49
+ privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
50
+ balance: "10000000000000000000000"
51
+ },
52
+ {
53
+ privateKey: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
54
+ balance: "10000000000000000000000"
55
+ },
56
+ {
57
+ privateKey: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
58
+ balance: "10000000000000000000000"
59
+ },
60
+ {
61
+ privateKey: "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
62
+ balance: "10000000000000000000000"
63
+ },
64
+ {
65
+ privateKey: "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
66
+ balance: "10000000000000000000000"
67
+ },
68
+ {
69
+ privateKey: "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba",
70
+ balance: "10000000000000000000000"
71
+ },
72
+ {
73
+ privateKey: "0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e",
74
+ balance: "10000000000000000000000"
75
+ },
76
+ {
77
+ privateKey: "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
78
+ balance: "10000000000000000000000"
79
+ },
80
+ {
81
+ privateKey: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
82
+ balance: "10000000000000000000000"
83
+ },
84
+ {
85
+ privateKey: "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
86
+ balance: "10000000000000000000000"
87
+ },
88
+ {
89
+ privateKey: "0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897",
90
+ balance: "10000000000000000000000"
91
+ },
92
+ {
93
+ privateKey: "0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82",
94
+ balance: "10000000000000000000000"
95
+ },
96
+ {
97
+ privateKey: "0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1",
98
+ balance: "10000000000000000000000"
99
+ },
100
+ {
101
+ privateKey: "0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd",
102
+ balance: "10000000000000000000000"
103
+ },
104
+ {
105
+ privateKey: "0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa",
106
+ balance: "10000000000000000000000"
107
+ },
108
+ {
109
+ privateKey: "0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61",
110
+ balance: "10000000000000000000000"
111
+ },
112
+ {
113
+ privateKey: "0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0",
114
+ balance: "10000000000000000000000"
115
+ },
116
+ {
117
+ privateKey: "0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd",
118
+ balance: "10000000000000000000000"
119
+ },
120
+ {
121
+ privateKey: "0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0",
122
+ balance: "10000000000000000000000"
123
+ },
124
+ {
125
+ privateKey: "0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e",
126
+ balance: "10000000000000000000000"
127
+ }
128
+ ];
129
+ var WalletSigner = class extends Wallet {
130
+ connectUnchecked() {
131
+ const uncheckedSigner = this.provider.getUncheckedSigner(this.address);
132
+ return uncheckedSigner;
133
+ }
134
+ };
135
+ function getSigners() {
136
+ const provider = getProvider();
137
+ return accounts.map((x) => new WalletSigner(x.privateKey, provider));
138
+ }
139
+ export {
140
+ getSigners,
141
+ testChains
142
+ };
@@ -1,6 +1,7 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, a as ChainProviderFn } from '../index-58cffc47.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
3
3
  import 'abitype';
4
+ import '@wagmi/chains';
4
5
 
5
6
  type AlchemyProviderConfig = FallbackProviderConfig & {
6
7
  /** Your Alchemy API key from the [Alchemy Dashboard](https://dashboard.alchemyapi.io/). */
@@ -9,14 +9,14 @@ function alchemyProvider({
9
9
  weight
10
10
  }) {
11
11
  return function(chain) {
12
- if (!chain.rpcUrls.alchemy)
12
+ if (!chain.rpcUrls.alchemy?.http[0])
13
13
  return null;
14
14
  return {
15
15
  chain: {
16
16
  ...chain,
17
17
  rpcUrls: {
18
18
  ...chain.rpcUrls,
19
- default: `${chain.rpcUrls.alchemy}/${apiKey}`
19
+ default: { http: [`${chain.rpcUrls.alchemy?.http[0]}/${apiKey}`] }
20
20
  }
21
21
  },
22
22
  provider: () => {
@@ -1,6 +1,7 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, a as ChainProviderFn } from '../index-58cffc47.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
3
3
  import 'abitype';
4
+ import '@wagmi/chains';
4
5
 
5
6
  type InfuraProviderConfig = FallbackProviderConfig & {
6
7
  /** Your Infura API key from the [Infura Dashboard](https://infura.io/login). */
@@ -9,14 +9,14 @@ function infuraProvider({
9
9
  weight
10
10
  }) {
11
11
  return function(chain) {
12
- if (!chain.rpcUrls.infura)
12
+ if (!chain.rpcUrls.infura?.http[0])
13
13
  return null;
14
14
  return {
15
15
  chain: {
16
16
  ...chain,
17
17
  rpcUrls: {
18
18
  ...chain.rpcUrls,
19
- default: `${chain.rpcUrls.infura}/${apiKey}`
19
+ default: { http: [`${chain.rpcUrls.infura?.http[0]}/${apiKey}`] }
20
20
  }
21
21
  },
22
22
  provider: () => {
@@ -1,5 +1,6 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as Chain, a as ChainProviderFn } from '../index-58cffc47.js';
2
+ import { Chain } from '@wagmi/chains';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
3
4
  import 'abitype';
4
5
 
5
6
  type JsonRpcProviderConfig = FallbackProviderConfig & {
@@ -18,13 +18,13 @@ function jsonRpcProvider({
18
18
  ...chain,
19
19
  rpcUrls: {
20
20
  ...chain.rpcUrls,
21
- default: rpcConfig.http
21
+ default: { http: [rpcConfig.http] }
22
22
  }
23
23
  },
24
24
  provider: () => {
25
25
  const RpcProvider = static_ ? providers.StaticJsonRpcProvider : providers.JsonRpcProvider;
26
26
  const provider = new RpcProvider(rpcConfig.http, {
27
- ensAddress: chain.ens?.address,
27
+ ensAddress: chain.contracts?.ensRegistry?.address,
28
28
  chainId: chain.id,
29
29
  name: chain.network
30
30
  });
@@ -1,6 +1,7 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, a as ChainProviderFn } from '../index-58cffc47.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
3
3
  import 'abitype';
4
+ import '@wagmi/chains';
4
5
 
5
6
  type PublicProviderConfig = FallbackProviderConfig;
6
7
  declare function publicProvider({ priority, stallTimeout, weight, }?: PublicProviderConfig): ChainProviderFn<providers.StaticJsonRpcProvider>;
@@ -8,13 +8,13 @@ function publicProvider({
8
8
  weight
9
9
  } = {}) {
10
10
  return function(chain) {
11
- if (!chain.rpcUrls.default)
11
+ if (!chain.rpcUrls.default.http[0])
12
12
  return null;
13
13
  return {
14
14
  chain,
15
15
  provider: () => {
16
16
  const provider = new providers.StaticJsonRpcProvider(
17
- chain.rpcUrls.default,
17
+ chain.rpcUrls.default.http[0],
18
18
  {
19
19
  chainId: chain.id,
20
20
  name: chain.network
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "type": "module",
3
- "main": "../dist/internal.js"
3
+ "main": "../dist/internal/index.js"
4
4
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/internal/test.js"
4
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wagmi/core",
3
3
  "description": "Vanilla JS library for Ethereum",
4
4
  "license": "MIT",
5
- "version": "0.7.9",
5
+ "version": "0.8.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -35,10 +35,6 @@
35
35
  "types": "./dist/chains.d.ts",
36
36
  "default": "./dist/chains.js"
37
37
  },
38
- "./internal": {
39
- "types": "./dist/internal.d.ts",
40
- "default": "./dist/internal.js"
41
- },
42
38
  "./connectors/coinbaseWallet": {
43
39
  "types": "./dist/connectors/coinbaseWallet.d.ts",
44
40
  "default": "./dist/connectors/coinbaseWallet.js"
@@ -55,6 +51,14 @@
55
51
  "types": "./dist/connectors/walletConnect.d.ts",
56
52
  "default": "./dist/connectors/walletConnect.js"
57
53
  },
54
+ "./internal": {
55
+ "types": "./dist/internal/index.d.ts",
56
+ "default": "./dist/internal/index.js"
57
+ },
58
+ "./internal/test": {
59
+ "types": "./dist/internal/test.d.ts",
60
+ "default": "./dist/internal/test.js"
61
+ },
58
62
  "./providers/infura": {
59
63
  "types": "./dist/providers/infura.d.ts",
60
64
  "default": "./dist/providers/infura.js"
@@ -82,7 +86,7 @@
82
86
  "/dist"
83
87
  ],
84
88
  "peerDependencies": {
85
- "@coinbase/wallet-sdk": ">=3.3.0",
89
+ "@coinbase/wallet-sdk": ">=3.6.0",
86
90
  "@walletconnect/ethereum-provider": ">=1.7.5",
87
91
  "ethers": ">=5.5.1"
88
92
  },
@@ -95,12 +99,13 @@
95
99
  }
96
100
  },
97
101
  "dependencies": {
102
+ "@wagmi/chains": "^0.1.0",
98
103
  "abitype": "^0.1.8",
99
104
  "eventemitter3": "^4.0.7",
100
105
  "zustand": "^4.1.4"
101
106
  },
102
107
  "devDependencies": {
103
- "@coinbase/wallet-sdk": "^3.4.1",
108
+ "@coinbase/wallet-sdk": "^3.6.0",
104
109
  "@walletconnect/ethereum-provider": "^1.7.8",
105
110
  "typescript": "^4.9.3"
106
111
  },