@wagmi/core 0.8.1 → 0.8.2

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.
@@ -340,6 +340,8 @@ function getInjectedName(ethereum) {
340
340
  return "1inch Wallet";
341
341
  if (provider.isOpera)
342
342
  return "Opera";
343
+ if (provider.isPhantom)
344
+ return "Phantom";
343
345
  if (provider.isPortal)
344
346
  return "Ripio Portal";
345
347
  if (provider.isTally)
@@ -3308,7 +3310,12 @@ function watchNetwork(callback, { selector = (x) => x } = {}) {
3308
3310
  import shallow5 from "zustand/shallow";
3309
3311
  function watchSigner({ chainId }, callback) {
3310
3312
  const client2 = getClient();
3311
- const handleChange = async () => callback(await fetchSigner({ chainId }));
3313
+ const handleChange = async () => {
3314
+ const signer = await fetchSigner({ chainId });
3315
+ if (!getClient().connector)
3316
+ return callback(null);
3317
+ return callback(signer);
3318
+ };
3312
3319
  const unsubscribe = client2.subscribe(
3313
3320
  ({ data, connector }) => ({
3314
3321
  account: data?.account,
@@ -2,7 +2,7 @@ import {
2
2
  Connector,
3
3
  UserRejectedRequestError,
4
4
  normalizeChainId
5
- } from "./chunk-TQC2HCNN.js";
5
+ } from "./chunk-63RNYADG.js";
6
6
  import {
7
7
  __privateAdd,
8
8
  __privateGet,
@@ -20,7 +20,7 @@ import { default as EventEmitter } from "eventemitter3";
20
20
  var _options, _signer;
21
21
  var MockProvider = class extends providers.BaseProvider {
22
22
  constructor(options) {
23
- super({ name: "Network", chainId: options.chainId ?? 1 });
23
+ super({ name: "Network", chainId: options.chainId });
24
24
  this.events = new EventEmitter();
25
25
  __privateAdd(this, _options, void 0);
26
26
  __privateAdd(this, _signer, void 0);
@@ -87,8 +87,17 @@ _signer = new WeakMap();
87
87
  // src/connectors/mock/connector.ts
88
88
  var _provider, _switchChain, switchChain_fn;
89
89
  var MockConnector = class extends Connector {
90
- constructor(config) {
91
- super(config);
90
+ constructor({
91
+ chains,
92
+ options
93
+ }) {
94
+ super({
95
+ chains,
96
+ options: {
97
+ ...options,
98
+ chainId: options.chainId ?? chains?.[0]?.id
99
+ }
100
+ });
92
101
  __privateAdd(this, _switchChain);
93
102
  this.id = "mock";
94
103
  this.name = "Mock";
@@ -147,7 +156,10 @@ var MockConnector = class extends Connector {
147
156
  }
148
157
  async getProvider({ chainId } = {}) {
149
158
  if (!__privateGet(this, _provider) || chainId)
150
- __privateSet(this, _provider, new MockProvider({ ...this.options, chainId }));
159
+ __privateSet(this, _provider, new MockProvider({
160
+ ...this.options,
161
+ chainId: chainId ?? this.options.chainId ?? this.chains[0].id
162
+ }));
151
163
  return __privateGet(this, _provider);
152
164
  }
153
165
  async getSigner() {
@@ -5,7 +5,7 @@ import {
5
5
  SwitchChainError,
6
6
  UserRejectedRequestError,
7
7
  normalizeChainId
8
- } from "../chunk-TQC2HCNN.js";
8
+ } from "../chunk-63RNYADG.js";
9
9
  import "../chunk-6KG5TOAU.js";
10
10
  import {
11
11
  __privateAdd,
@@ -1,6 +1,6 @@
1
1
  import { Chain } from '@wagmi/chains';
2
- import { E as Ethereum } from '../index-971cda79.js';
3
- import { a as InjectedConnectorOptions, I as InjectedConnector } from '../injected-610c34b6.js';
2
+ import { E as Ethereum } from '../index-37d6352e.js';
3
+ import { a as InjectedConnectorOptions, I as InjectedConnector } from '../injected-27788d9f.js';
4
4
  import 'abitype';
5
5
  import 'ethers';
6
6
  import '../base-a82112a9.js';
@@ -4,7 +4,7 @@ import {
4
4
  ResourceUnavailableError,
5
5
  UserRejectedRequestError,
6
6
  getClient
7
- } from "../chunk-TQC2HCNN.js";
7
+ } from "../chunk-63RNYADG.js";
8
8
  import "../chunk-6KG5TOAU.js";
9
9
  import {
10
10
  __privateAdd,
@@ -35,6 +35,8 @@ var MetaMaskConnector = class extends InjectedConnector {
35
35
  return;
36
36
  if (ethereum.isKuCoinWallet)
37
37
  return;
38
+ if (ethereum.isPhantom)
39
+ return;
38
40
  if (ethereum.isPortal)
39
41
  return;
40
42
  if (ethereum.isTokenPocket)
@@ -3,11 +3,11 @@ import { providers } from 'ethers';
3
3
  import { Chain } from '@wagmi/chains';
4
4
  import { C as Connector, a as ConnectorData } from '../../base-a82112a9.js';
5
5
  import EventEmitter from 'eventemitter3';
6
- import { S as Signer } from '../../index-971cda79.js';
6
+ import { S as Signer } from '../../index-37d6352e.js';
7
7
  import 'abitype';
8
8
 
9
9
  type MockProviderOptions = {
10
- chainId?: number;
10
+ chainId: number;
11
11
  flags?: {
12
12
  isAuthorized?: boolean;
13
13
  failConnect?: boolean;
@@ -44,14 +44,17 @@ declare class MockProvider extends providers.BaseProvider {
44
44
  toJSON(): string;
45
45
  }
46
46
 
47
- declare class MockConnector extends Connector<MockProvider, MockProviderOptions> {
47
+ type MockConnectorOptions = Omit<MockProviderOptions, 'chainId'> & {
48
+ chainId?: number;
49
+ };
50
+ declare class MockConnector extends Connector<MockProvider, MockConnectorOptions> {
48
51
  #private;
49
52
  readonly id = "mock";
50
53
  readonly name = "Mock";
51
54
  readonly ready = true;
52
- constructor(config: {
55
+ constructor({ chains, options, }: {
53
56
  chains?: Chain[];
54
- options: MockProviderOptions;
57
+ options: MockConnectorOptions;
55
58
  });
56
59
  connect({ chainId }?: {
57
60
  chainId?: number;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MockConnector,
3
3
  MockProvider
4
- } from "../../chunk-SK7UQXOC.js";
5
- import "../../chunk-TQC2HCNN.js";
4
+ } from "../../chunk-6E4ZWCDO.js";
5
+ import "../../chunk-63RNYADG.js";
6
6
  import "../../chunk-6KG5TOAU.js";
7
7
  import "../../chunk-MQXBDTVK.js";
8
8
  export {
@@ -4,7 +4,7 @@ import {
4
4
  UserRejectedRequestError,
5
5
  getClient,
6
6
  normalizeChainId
7
- } from "../chunk-TQC2HCNN.js";
7
+ } from "../chunk-63RNYADG.js";
8
8
  import "../chunk-6KG5TOAU.js";
9
9
  import {
10
10
  __privateAdd,
@@ -92,6 +92,7 @@ type InjectedProviderFlags = {
92
92
  isOneInchAndroidWallet?: true;
93
93
  isOneInchIOSWallet?: true;
94
94
  isOpera?: true;
95
+ isPhantom?: true;
95
96
  isPortal?: true;
96
97
  isTally?: true;
97
98
  isTokenPocket?: true;
package/dist/index.d.ts CHANGED
@@ -2,17 +2,17 @@ import * as _wagmi_chains from '@wagmi/chains';
2
2
  import { Chain } from '@wagmi/chains';
3
3
  export { Chain, goerli, mainnet } from '@wagmi/chains';
4
4
  import { Mutate, StoreApi } from 'zustand/vanilla';
5
- import { P as Provider, W as WebSocketProvider, U as Unit, S as Signer, H as Hash, C as ChainProviderFn, a as ProviderWithFallbackConfig } from './index-971cda79.js';
6
- export { C as ChainProviderFn, E as Ethereum, F as FallbackProviderConfig, H as Hash, P as Provider, a as ProviderWithFallbackConfig, S as Signer, U as Unit, W as WebSocketProvider, u as units } from './index-971cda79.js';
5
+ import { P as Provider, W as WebSocketProvider, U as Unit, S as Signer, H as Hash, C as ChainProviderFn, a as ProviderWithFallbackConfig } from './index-37d6352e.js';
6
+ export { C as ChainProviderFn, E as Ethereum, F as FallbackProviderConfig, H as Hash, P as Provider, a as ProviderWithFallbackConfig, S as Signer, U as Unit, W as WebSocketProvider, u as units } from './index-37d6352e.js';
7
7
  import { C as Connector, a as ConnectorData } from './base-a82112a9.js';
8
8
  export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-a82112a9.js';
9
- import * as abitype from 'abitype';
10
9
  import { Address, ResolvedConfig, TypedDataDomain, Narrow, TypedData, TypedDataToPrimitiveTypes, Abi, ExtractAbiFunction, ExtractAbiEventNames, AbiParametersToPrimitiveTypes, ExtractAbiEvent, AbiFunction, AbiParameter, AbiParameterToPrimitiveType, AbiEvent, ExtractAbiFunctionNames } from 'abitype';
11
10
  export { Address } from 'abitype';
12
11
  import { PopulatedTransaction, Signer as Signer$1, providers, Contract as Contract$1, ethers, ContractInterface } from 'ethers';
13
12
  import { O as Options$2, D as DefaultOptions, G as GetConfig$1, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as ContractsConfig, c as ContractsResult, d as GetReturnType, e as Or, f as IsNever, N as NotEqual } from './contracts-3880ee54.js';
14
13
  import { TransactionResponse } from '@ethersproject/providers';
15
- export { I as InjectedConnector, a as InjectedConnectorOptions } from './injected-610c34b6.js';
14
+ export { I as InjectedConnector, a as InjectedConnectorOptions } from './injected-27788d9f.js';
15
+ import * as abitype_dist_abi_b1bae27f from 'abitype/dist/abi-b1bae27f';
16
16
  import 'eventemitter3';
17
17
 
18
18
  type BaseStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
@@ -1736,7 +1736,7 @@ declare function deserialize(cachedString: string): any;
1736
1736
  declare function minimizeContractInterface<TAbi extends Abi | readonly unknown[]>(config: {
1737
1737
  abi: TAbi;
1738
1738
  functionName: TAbi extends Abi ? ExtractAbiFunctionNames<TAbi> : string;
1739
- }): string[] | (abitype.AbiFunction | abitype.AbiEvent | abitype.AbiError)[];
1739
+ }): string[] | (abitype_dist_abi_b1bae27f.q | abitype_dist_abi_b1bae27f.p | abitype_dist_abi_b1bae27f.o)[];
1740
1740
 
1741
1741
  declare function normalizeChainId(chainId: string | number | bigint): number;
1742
1742
 
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ import {
73
73
  watchSigner,
74
74
  watchWebSocketProvider,
75
75
  writeContract
76
- } from "./chunk-TQC2HCNN.js";
76
+ } from "./chunk-63RNYADG.js";
77
77
  import {
78
78
  goerli,
79
79
  mainnet
@@ -2,7 +2,7 @@ import { Chain } from '@wagmi/chains';
2
2
  import { Address } from 'abitype';
3
3
  import { providers } from 'ethers';
4
4
  import { C as Connector } from './base-a82112a9.js';
5
- import { E as Ethereum } from './index-971cda79.js';
5
+ import { E as Ethereum } from './index-37d6352e.js';
6
6
 
7
7
  type InjectedConnectorOptions = {
8
8
  /** Name of connector */
@@ -1,5 +1,5 @@
1
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';
2
+ import '../index-37d6352e.js';
3
3
  import 'abitype';
4
4
  import 'ethers';
5
5
  import '@wagmi/chains';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debounce
3
- } from "../chunk-TQC2HCNN.js";
3
+ } from "../chunk-63RNYADG.js";
4
4
  import "../chunk-6KG5TOAU.js";
5
5
  import "../chunk-MQXBDTVK.js";
6
6
  export {
@@ -1,4 +1,4 @@
1
- import '../index-971cda79.js';
1
+ import '../index-37d6352e.js';
2
2
  import { Wallet, providers } from 'ethers';
3
3
  import { Chain } from '@wagmi/chains';
4
4
  import 'abitype';
@@ -1,6 +1,6 @@
1
1
  import "../chunk-J6DUE3KA.js";
2
- import "../chunk-SK7UQXOC.js";
3
- import "../chunk-TQC2HCNN.js";
2
+ import "../chunk-6E4ZWCDO.js";
3
+ import "../chunk-63RNYADG.js";
4
4
  import {
5
5
  foundry,
6
6
  goerli,
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-37d6352e.js';
3
3
  import 'abitype';
4
4
  import '@wagmi/chains';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-37d6352e.js';
3
3
  import 'abitype';
4
4
  import '@wagmi/chains';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { providers } from 'ethers';
2
2
  import { Chain } from '@wagmi/chains';
3
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-37d6352e.js';
4
4
  import 'abitype';
5
5
 
6
6
  type JsonRpcProviderConfig = FallbackProviderConfig & {
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-971cda79.js';
2
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-37d6352e.js';
3
3
  import 'abitype';
4
4
  import '@wagmi/chains';
5
5
 
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.8.1",
5
+ "version": "0.8.2",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -100,7 +100,7 @@
100
100
  },
101
101
  "dependencies": {
102
102
  "@wagmi/chains": "^0.1.0",
103
- "abitype": "^0.1.8",
103
+ "abitype": "^0.2.5",
104
104
  "eventemitter3": "^4.0.7",
105
105
  "zustand": "^4.1.4"
106
106
  },