@wagmi/core 1.0.0-next.4 → 1.0.0-next.6

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.
@@ -374,7 +374,7 @@ var Config = class {
374
374
  this.webSocketPublicClients = /* @__PURE__ */ new Map();
375
375
  __privateAdd(this, _isAutoConnecting, void 0);
376
376
  __privateAdd(this, _lastUsedConnector, void 0);
377
- this.constructorArgs = {
377
+ this.args = {
378
378
  autoConnect,
379
379
  connectors,
380
380
  logger,
@@ -516,6 +516,18 @@ var Config = class {
516
516
  __privateSet(this, _isAutoConnecting, false);
517
517
  return this.data;
518
518
  }
519
+ setConnectors(connectors) {
520
+ this.args = {
521
+ ...this.args,
522
+ connectors
523
+ };
524
+ const connectors_ = typeof connectors === "function" ? connectors() : connectors;
525
+ connectors_.forEach((connector) => connector.setStorage(this.args.storage));
526
+ this.setState((x) => ({
527
+ ...x,
528
+ connectors: connectors_
529
+ }));
530
+ }
519
531
  getPublicClient({ chainId } = {}) {
520
532
  let publicClient_ = this.publicClients.get(-1);
521
533
  if (publicClient_ && publicClient_?.chain.id === chainId)
@@ -523,11 +535,23 @@ var Config = class {
523
535
  publicClient_ = this.publicClients.get(chainId ?? -1);
524
536
  if (publicClient_)
525
537
  return publicClient_;
526
- const { publicClient } = this.constructorArgs;
538
+ const { publicClient } = this.args;
527
539
  publicClient_ = typeof publicClient === "function" ? publicClient({ chainId }) : publicClient;
528
540
  this.publicClients.set(chainId ?? -1, publicClient_);
529
541
  return publicClient_;
530
542
  }
543
+ setPublicClient(publicClient) {
544
+ const chainId = this.data?.chain?.id;
545
+ this.args = {
546
+ ...this.args,
547
+ publicClient
548
+ };
549
+ this.publicClients.clear();
550
+ this.setState((x) => ({
551
+ ...x,
552
+ publicClient: this.getPublicClient({ chainId })
553
+ }));
554
+ }
531
555
  getWebSocketPublicClient({ chainId } = {}) {
532
556
  let webSocketPublicClient_ = this.webSocketPublicClients.get(-1);
533
557
  if (webSocketPublicClient_ && webSocketPublicClient_?.chain.id === chainId)
@@ -535,12 +559,26 @@ var Config = class {
535
559
  webSocketPublicClient_ = this.webSocketPublicClients.get(chainId ?? -1);
536
560
  if (webSocketPublicClient_)
537
561
  return webSocketPublicClient_;
538
- const { webSocketPublicClient } = this.constructorArgs;
562
+ const { webSocketPublicClient } = this.args;
539
563
  webSocketPublicClient_ = typeof webSocketPublicClient === "function" ? webSocketPublicClient({ chainId }) : webSocketPublicClient;
540
564
  if (webSocketPublicClient_)
541
565
  this.webSocketPublicClients.set(chainId ?? -1, webSocketPublicClient_);
542
566
  return webSocketPublicClient_;
543
567
  }
568
+ setWebSocketPublicClient(webSocketPublicClient) {
569
+ const chainId = this.data?.chain?.id;
570
+ this.args = {
571
+ ...this.args,
572
+ webSocketPublicClient
573
+ };
574
+ this.webSocketPublicClients.clear();
575
+ this.setState((x) => ({
576
+ ...x,
577
+ webSocketPublicClient: this.getWebSocketPublicClient({
578
+ chainId
579
+ })
580
+ }));
581
+ }
544
582
  setLastUsedConnector(lastUsedConnector = null) {
545
583
  this.storage?.setItem("wallet", lastUsedConnector);
546
584
  }
@@ -574,7 +612,7 @@ addEffects_fn = function() {
574
612
  connector.on?.("error", onError);
575
613
  }
576
614
  );
577
- const { publicClient, webSocketPublicClient } = this.constructorArgs;
615
+ const { publicClient, webSocketPublicClient } = this.args;
578
616
  const subscribePublicClient = typeof publicClient === "function";
579
617
  const subscribeWebSocketPublicClient = typeof webSocketPublicClient === "function";
580
618
  if (subscribePublicClient || subscribeWebSocketPublicClient)
package/dist/index.d.ts CHANGED
@@ -64,7 +64,7 @@ type State<TPublicClient extends PublicClient = PublicClient, TWebSocketPublicCl
64
64
  };
65
65
  declare class Config<TPublicClient extends PublicClient = PublicClient, TWebSocketPublicClient extends WebSocketPublicClient = WebSocketPublicClient> {
66
66
  #private;
67
- constructorArgs: CreateConfigParameters<TPublicClient, TWebSocketPublicClient>;
67
+ args: CreateConfigParameters<TPublicClient, TWebSocketPublicClient>;
68
68
  publicClients: Map<number, TPublicClient | undefined>;
69
69
  storage: ClientStorage;
70
70
  store: Mutate<StoreApi<State<TPublicClient, TWebSocketPublicClient>>, [
@@ -99,13 +99,15 @@ declare class Config<TPublicClient extends PublicClient = PublicClient, TWebSock
99
99
  clearState(): void;
100
100
  destroy(): Promise<void>;
101
101
  autoConnect(): Promise<ConnectorData | undefined>;
102
+ setConnectors(connectors: NonNullable<CreateConfigParameters['connectors']>): void;
102
103
  getPublicClient({ chainId }?: {
103
- bust?: boolean;
104
104
  chainId?: number;
105
105
  }): TPublicClient;
106
+ setPublicClient(publicClient: CreateConfigParameters<TPublicClient>['publicClient']): void;
106
107
  getWebSocketPublicClient({ chainId }?: {
107
108
  chainId?: number;
108
109
  }): TWebSocketPublicClient | undefined;
110
+ setWebSocketPublicClient(webSocketPublicClient: NonNullable<CreateConfigParameters<TPublicClient>['webSocketPublicClient']>): void;
109
111
  setLastUsedConnector(lastUsedConnector?: string | null): void;
110
112
  }
111
113
  declare function createConfig<TPublicClient extends PublicClient = PublicClient, TWebSocketPublicClient extends WebSocketPublicClient = WebSocketPublicClient>(args: CreateConfigParameters<TPublicClient, TWebSocketPublicClient>): Config<TPublicClient, TWebSocketPublicClient>;
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  watchWalletClient,
59
59
  watchWebSocketPublicClient,
60
60
  writeContract
61
- } from "./chunk-YPGOLRBI.js";
61
+ } from "./chunk-4FHLBJG5.js";
62
62
  import {
63
63
  mainnet,
64
64
  sepolia
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getCallParameters,
3
3
  getSendTransactionParameters
4
- } from "../chunk-YPGOLRBI.js";
4
+ } from "../chunk-4FHLBJG5.js";
5
5
  import "../chunk-BVC4KGLQ.js";
6
6
  import "../chunk-MQXBDTVK.js";
7
7
  export {
@@ -1,5 +1,5 @@
1
1
  import "../chunk-KX4UEHS5.js";
2
- import "../chunk-YPGOLRBI.js";
2
+ import "../chunk-4FHLBJG5.js";
3
3
  import {
4
4
  foundry,
5
5
  goerli,
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": "1.0.0-next.4",
5
+ "version": "1.0.0-next.6",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -123,8 +123,8 @@
123
123
  "abitype": "^0.7.1",
124
124
  "eventemitter3": "^4.0.7",
125
125
  "zustand": "^4.3.1",
126
- "@wagmi/chains": "0.2.20",
127
- "@wagmi/connectors": "1.0.0-next.5"
126
+ "@wagmi/connectors": "1.0.0-next.6",
127
+ "@wagmi/chains": "0.2.20"
128
128
  },
129
129
  "devDependencies": {
130
130
  "viem": "~0.3.17"