@hinkal/common 0.2.2 → 0.2.3

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Hinkal SDK
2
2
 
3
- Hinkal is a middleware and a set of smart contracts on EVM chains that use ZK-proofs and stealth addresses to enable compliant and private transactions on major dApps. Users can privately store assets and transact on major dApps such as Uniswap, Pendle, Lido, Curve, and others.
3
+ Hinkal is middleware and a set of smart contracts on EVM chains that use ZK-proofs and stealth addresses to enable compliant and private transactions on major dApps. Users can privately store assets and transact on platforms such as Uniswap, Pendle, Lido, Curve, and others.
4
4
 
5
- This SDK allows users to perform arbitrary smart contract interactions privately.
5
+ This SDK enables users to perform arbitrary smart contract interactions privately.
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,35 +20,38 @@ yarn add @hinkal/common
20
20
 
21
21
  ### Usage
22
22
 
23
- 1. Import hinkal from @hinkal/common package and initiate a Hinkal instance:
23
+ #### Initialization
24
24
 
25
- ```typescript
26
- import { Hinkal } from '@hinkal/common';
27
-
28
- const hinkal = new Hinkal<Connector>();
29
- ```
25
+ To get started with Hinkal, initialize it based on the Web3 connection library you’re using:
30
26
 
31
- 2. Initialize a ProviderAdapter object, where the connector should be an instance of the wagmi Connector.
27
+ **ethers.js:**
32
28
 
33
29
  ```typescript
34
- const providerAdapter = new ProviderAdapter(connector);
35
- await hinkal.initProviderAdapter(connector, providerAdapter);
30
+ import { prepareEthersHinkal } from '@hinkal/common/providers/prepareEthersHinkal';
31
+ // signer: ethers.Signer
32
+ const hinkal = await prepareEthersHinkal(signer);
36
33
  ```
37
34
 
38
- 3. Prompt a user to generate their shielded address and fetch the state from the smart contract.
35
+ **wagmi:**
39
36
 
40
37
  ```typescript
41
- await hinkal.initUserKeys();
42
- await hinkal.resetMerkle();
38
+ import { prepareWagmiHinkal } from '@hinkal/common/providers/prepareWagmiHinkal';
39
+ // connector: wagmi.Connector
40
+ // config: wagmi.Config
41
+ const hinkal = await prepareWagmiHinkal(connector, config);
43
42
  ```
44
43
 
45
- 4. Once a user has generated a shielded address, the shielded balances become available and can be displayed on the front end:
44
+ #### Shielded balance
45
+
46
+ Once the Hinkal object is initialized, shielded balances become accessible and can be calculated as needed:
46
47
 
47
48
  ```typescript
48
49
  const balances = await hinkal.getBalances();
49
50
  ```
50
51
 
51
- 5. A user can deposit to their shielded account using:
52
+ #### Depositing funds to the shielded balance
53
+
54
+ A user can deposit funds to their shielded address using:
52
55
 
53
56
  ```typescript
54
57
  function deposit(erc20addresses: string[], amountChanges: bigint[]): Promise<TransactionObject>;
@@ -56,7 +59,9 @@ function deposit(erc20addresses: string[], amountChanges: bigint[]): Promise<Tra
56
59
 
57
60
  where erc20Addresses is an array of token addresses, and amountChanges represents the token amounts for the deposit.
58
61
 
59
- 6. Once a user’s balance is updated, they can perform any smart contract interaction:
62
+ #### Interacting with smart contracts privately
63
+
64
+ After a user’s shielded balance is updated, they can perform any smart contract interaction privately using:
60
65
 
61
66
  ```typescript
62
67
  function actionPrivateWallet(
@@ -67,27 +72,32 @@ function actionPrivateWallet(
67
72
  ): Promise<TransactionObject>;
68
73
  ```
69
74
 
70
- where onChainCreation indicates the amounts of tokens that are uncertain before the transaction is executed on-chain. The ops array is an encoded array of user operations.
75
+ where onChainCreation indicates the amounts of tokens that are uncertain before the transaction is executed on-chain. The ops array contains encoded user operations.
71
76
 
72
77
  ### Access Tokens
73
78
 
74
- Before interacting with Hinkal smart contracts, a user needs to mint an access token after passing compliance checks.
79
+ Before interacting with Hinkal smart contracts, users need to mint an access token after passing compliance checks.
75
80
 
76
- To check whether the user already has an access token, one can use the checkAccessToken function:
81
+ To check whether a user already has an access token, use the checkAccessToken function:
77
82
 
78
83
  ```typescript
79
84
  function checkAccessToken(): Promise<boolean>;
80
85
  ```
81
86
 
82
- If the user does not have an access token, one of the compliance providers should be used to pass the check. To view the available providers:
87
+ If the user does not have an access token, they must use one of the compliance providers to pass the check. To view the available providers:
83
88
 
84
89
  ```typescript
85
90
  function getSupportedPassportLinks(): string[];
86
91
  ```
87
92
 
88
- Once the user has passed the check, they can mint an access token using:
93
+ After passing the compliance check, the user can mint an access token using:
89
94
 
90
95
  ```typescript
91
96
  const { signatureData } = await hinkal.getAPI().getAccessTokenSignature(chainId, ethereumAddress, accessKey);
92
97
  await mintAccessToken(this, signatureData);
93
98
  ```
99
+
100
+ ### References
101
+
102
+ Application: [Hinkal](https://app.hinkal.pro)
103
+ Docs: [Hinkal Documentation](https://hinkal-team.gitbook.io/hinkal)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -60,7 +60,7 @@
60
60
  "uuid": "^9.0.1"
61
61
  },
62
62
  "peerDependencies": {
63
- "wagmi": "2.12.24",
63
+ "wagmi": "2.13.3",
64
64
  "ethers": "5.x"
65
65
  },
66
66
  "peerDependenciesMeta": {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../constants/chains.constants.cjs"),h=require("../constants/contracts.constants.cjs"),c=require("../error-handling/error-codes.constants.cjs"),s=require("ethers"),d=require("wagmi"),g=require("../node_modules/@wagmi/core/dist/esm/actions/disconnect.cjs"),w=require("../node_modules/@wagmi/core/dist/esm/actions/connect.cjs"),u=require("../node_modules/@wagmi/core/dist/esm/actions/signMessage.cjs"),f=require("../node_modules/@wagmi/core/dist/esm/actions/switchChain.cjs"),l=require("../node_modules/@wagmi/core/dist/esm/actions/getAccount.cjs"),v=require("../node_modules/@wagmi/core/dist/esm/actions/watchAccount.cjs"),C=require("../node_modules/@wagmi/core/dist/esm/actions/watchChainId.cjs");class a{connector;chainId;originalProvider;fetchProvider;signer;chainEventListener;config;unsubscribeFns=[];initConnector(r){this.connector=r}requireConnector(){if(!this.connector)throw Error("No Connector In Provider Adapter")}initConfig(r){this.config=r}async init(r){this.requireConnector(),r&&(this.chainId=r),this.originalProvider=await this.connector.getProvider(),this.fetchProvider=this.createFetchProvider()??this.originalProvider,this.fetchProvider===this.originalProvider&&console.warn("fetchProvider not available");const t=await this.connector.getProvider(),e=await this.connector.getAccounts();this.signer=await this.walletClientToSigner({transport:t,account:e[0]},this.chainId)}async disconnectFromConnector(){if(!this.config)throw new Error("No Config In Provider Adapter");this.release(),await g.disconnect(this.config)}async connectToConnector(r){if(!this.config)throw new Error("No Config In Provider Adapter");try{return(await w.connect(this.config,{connector:r})).chainId}catch(t){if(t instanceof d.ConnectorAlreadyConnectedError)return r.getChainId();throw console.log(t),new Error(c.transactionErrorCodes.CONNECTION_FAILED)}}async waitForTransaction(r,t){if((await this.fetchProvider?.waitForTransaction(r,t))?.status)return!0;throw Error(c.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(r){if(!this.config)throw new Error("No Config In Provider Adapter");const t=await u.signMessage(this.config,{message:r});if(!t)throw new Error(c.transactionErrorCodes.SIGNING_FAILED);if(t.includes("error"))throw new Error(c.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return t}async signTypedData(r,t,e){return this.signer._signTypedData(r,t,e)}getSelectedNetwork=()=>{if(!this.chainId)throw new Error("Illegal state: no chaindId");return i.networkRegistry[this.chainId]};async switchNetwork(r){if(!this.config)throw new Error("No Config In Provider Adapter");return f.switchChain(this.config,{chainId:r.chainId})}createFetchProvider(){try{const t=i.networkRegistry[this.chainId]?.fetchRpcUrl;return t?t.includes("wss")?new s.providers.WebSocketProvider(t):new s.providers.StaticJsonRpcProvider(t):void 0}catch(r){console.log("create Fetch Provider error",r);return}}async getAddress(){if(!this.config)throw new Error("No Config In Provider Adapter");const{address:r}=l.getAccount(this.config);if(!r)throw new Error("IllegalState");return s.utils.getAddress(r)}setChainEventListener(r){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=r,this.chainEventListener&&(this.unsubscribeFns.push(v.watchAccount(this.config,{onChange:({address:t},{address:e})=>{if(!this.chainEventListener){console.warn("chainEventListener is not set");return}console.log("Account changed"),t!==e&&(console.log("Account changed"),this.chainEventListener.onAccountChanged())}})),this.unsubscribeFns.push(C.watchChainId(this.config,{onChange:t=>{if(!this.chainEventListener){console.warn("chainEventListener is not set");return}console.log("Chain ID changed!",t),this.chainEventListener.onChainChanged(t)}})))}onAccountChanged(){return this.init()}onChainChanged(r){return this.init(r)}release(){this.removeListeners()}removeListeners(){this.unsubscribeFns.forEach(r=>r()),this.unsubscribeFns=[]}getContractMetadata(r,t){const e=t??this.chainId;if(!e)throw new Error("No chainId provided in context");const n=i.networkRegistry[e];if(!n)throw new Error(c.transactionErrorCodes.UNSUPPORTED_NETWORK);const o=h.contractMetadataMapping[r];if(!o)throw new Error(`Unsupported contractType: ${r}`);return o(n.contractData)}getContract(r,t=void 0,e){const n=this.getContractMetadata(r,e);if(!n.abi)throw new Error(`No ABI configured for contractType: ${r}`);if(n.address&&t)throw new Error(`Overriding address is not supported for contractType: ${r}`);const o=n.address??t;if(!o)throw new Error(`No contractAddress configured for contractType: ${r}`);return new s.ethers.Contract(o,n.abi)}getContractWithSigner(r,t=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(r,t).connect(this.signer)}getContractWithFetcher(r,t=void 0){if(!this.fetchProvider)throw new Error("fetchProvider not initialized");return this.getContract(r,t).connect(this.fetchProvider)}getContractWithFetcherForEthereum(r,t=void 0){const e=this.chainId===i.chainIds.localhost&&i.localhostNetwork===i.chainIds.ethMainnet?i.chainIds.localhost:i.chainIds.ethMainnet;return this.getContract(r,t).connect(new s.ethers.providers.StaticJsonRpcProvider(i.networkRegistry[e].fetchRpcUrl))}async sendTransaction(r){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(r)}async patchExternalProvider(r){const t=await r.getProvider();let e;if(t instanceof s.ethers.providers.Web3Provider?e=t.provider:e=t,"isWalletConnect"in e){const n=await r.getChainId();e.http=e.setHttpProvider?.(n)}}async connectAndPatchProvider(r){const t=await this.connectToConnector(r);return await this.patchExternalProvider(r),t}isPermitterAvailable(){return!!this.getSelectedNetwork()?.contractData?.permitterAddress}async getGasPrice(){const r=await this.fetchProvider?.getGasPrice();if(!r)throw Error("Could not fetch gas price in getGasPrice");return r.toBigInt()}async walletClientToSigner(r,t){const{account:e,transport:n}=r,o={chainId:t,name:""};return new s.providers.Web3Provider(n,o).getSigner(e)}}const p=new a,E=()=>new a;exports.WagmiProviderAdapter=a;exports.default=E;exports.wagmiProviderAdapter=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../constants/chains.constants.cjs"),d=require("../constants/contracts.constants.cjs"),c=require("../error-handling/error-codes.constants.cjs"),s=require("ethers"),g=require("wagmi"),h=require("../node_modules/@wagmi/core/dist/esm/actions/disconnect.cjs"),w=require("../node_modules/@wagmi/core/dist/esm/actions/reconnect.cjs"),u=require("../node_modules/@wagmi/core/dist/esm/actions/connect.cjs"),f=require("../node_modules/@wagmi/core/dist/esm/actions/signMessage.cjs"),l=require("../node_modules/@wagmi/core/dist/esm/actions/switchChain.cjs"),v=require("../node_modules/@wagmi/core/dist/esm/actions/getAccount.cjs"),C=require("../node_modules/@wagmi/core/dist/esm/actions/watchAccount.cjs"),E=require("../node_modules/@wagmi/core/dist/esm/actions/watchChainId.cjs");class a{connector;chainId;originalProvider;fetchProvider;signer;chainEventListener;config;unsubscribeFns=[];initConnector(t){this.connector=t}requireConnector(){if(!this.connector)throw Error("No Connector In Provider Adapter")}initConfig(t){this.config=t}async init(t){this.requireConnector(),t&&(this.chainId=t),this.originalProvider=await this.connector.getProvider(),this.fetchProvider=this.createFetchProvider()??this.originalProvider,this.fetchProvider===this.originalProvider&&console.warn("fetchProvider not available");const r=await this.connector.getProvider(),e=await this.connector.getAccounts();this.signer=await this.walletClientToSigner({transport:r,account:e[0]},this.chainId)}async disconnectFromConnector(){if(!this.config)throw new Error("No Config In Provider Adapter");this.release(),await h.disconnect(this.config)}async connectToConnector(t){if(!this.config)throw new Error("No Config In Provider Adapter");if(t.id==="walletConnect")try{await w.reconnect(this.config,{connectors:[t]}),await h.disconnect(this.config)}catch{}try{return(await u.connect(this.config,{connector:t})).chainId}catch(r){if(r instanceof g.ConnectorAlreadyConnectedError)return t.getChainId();throw console.log(r),new Error(c.transactionErrorCodes.CONNECTION_FAILED)}}async waitForTransaction(t,r){if((await this.fetchProvider?.waitForTransaction(t,r))?.status)return!0;throw Error(c.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(t){if(!this.config)throw new Error("No Config In Provider Adapter");const r=await f.signMessage(this.config,{message:t});if(!r)throw new Error(c.transactionErrorCodes.SIGNING_FAILED);if(r.includes("error"))throw new Error(c.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return r}async signTypedData(t,r,e){return this.signer._signTypedData(t,r,e)}getSelectedNetwork=()=>{if(!this.chainId)throw new Error("Illegal state: no chaindId");return i.networkRegistry[this.chainId]};async switchNetwork(t){if(!this.config)throw new Error("No Config In Provider Adapter");return l.switchChain(this.config,{chainId:t.chainId})}createFetchProvider(){try{const r=i.networkRegistry[this.chainId]?.fetchRpcUrl;return r?r.includes("wss")?new s.providers.WebSocketProvider(r):new s.providers.StaticJsonRpcProvider(r):void 0}catch(t){console.log("create Fetch Provider error",t);return}}async getAddress(){if(!this.config)throw new Error("No Config In Provider Adapter");const{address:t}=v.getAccount(this.config);if(!t)throw new Error("IllegalState");return s.utils.getAddress(t)}setChainEventListener(t){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=t,this.chainEventListener&&(this.unsubscribeFns.push(C.watchAccount(this.config,{onChange:({address:r},{address:e})=>{if(!this.chainEventListener){console.warn("chainEventListener is not set");return}console.log("Account changed"),r!==e&&(console.log("Account changed"),this.chainEventListener.onAccountChanged())}})),this.unsubscribeFns.push(E.watchChainId(this.config,{onChange:r=>{if(!this.chainEventListener){console.warn("chainEventListener is not set");return}console.log("Chain ID changed!",r),this.chainEventListener.onChainChanged(r)}})))}onAccountChanged(){return this.init()}onChainChanged(t){return this.init(t)}release(){this.removeListeners()}removeListeners(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}getContractMetadata(t,r){const e=r??this.chainId;if(!e)throw new Error("No chainId provided in context");const n=i.networkRegistry[e];if(!n)throw new Error(c.transactionErrorCodes.UNSUPPORTED_NETWORK);const o=d.contractMetadataMapping[t];if(!o)throw new Error(`Unsupported contractType: ${t}`);return o(n.contractData)}getContract(t,r=void 0,e){const n=this.getContractMetadata(t,e);if(!n.abi)throw new Error(`No ABI configured for contractType: ${t}`);if(n.address&&r)throw new Error(`Overriding address is not supported for contractType: ${t}`);const o=n.address??r;if(!o)throw new Error(`No contractAddress configured for contractType: ${t}`);return new s.ethers.Contract(o,n.abi)}getContractWithSigner(t,r=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(t,r).connect(this.signer)}getContractWithFetcher(t,r=void 0){if(!this.fetchProvider)throw new Error("fetchProvider not initialized");return this.getContract(t,r).connect(this.fetchProvider)}getContractWithFetcherForEthereum(t,r=void 0){const e=this.chainId===i.chainIds.localhost&&i.localhostNetwork===i.chainIds.ethMainnet?i.chainIds.localhost:i.chainIds.ethMainnet;return this.getContract(t,r).connect(new s.ethers.providers.StaticJsonRpcProvider(i.networkRegistry[e].fetchRpcUrl))}async sendTransaction(t){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(t)}async connectAndPatchProvider(t){return await this.connectToConnector(t)}isPermitterAvailable(){return!!this.getSelectedNetwork()?.contractData?.permitterAddress}async getGasPrice(){const t=await this.fetchProvider?.getGasPrice();if(!t)throw Error("Could not fetch gas price in getGasPrice");return t.toBigInt()}async walletClientToSigner(t,r){const{account:e,transport:n}=t,o={chainId:r,name:""};return new s.providers.Web3Provider(n,o).getSigner(e)}}const p=new a,P=()=>new a;exports.WagmiProviderAdapter=a;exports.default=P;exports.wagmiProviderAdapter=p;
@@ -35,7 +35,6 @@ export declare class WagmiProviderAdapter implements IProviderAdapter<Connector>
35
35
  getContractWithFetcher(contract: ContractType, contractAddress?: undefined): ethers.Contract;
36
36
  getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: undefined): ethers.Contract;
37
37
  sendTransaction(tx: ethers.providers.TransactionRequest): Promise<ethers.providers.TransactionResponse>;
38
- patchExternalProvider(connector: Connector): Promise<void>;
39
38
  connectAndPatchProvider(connector: Connector): Promise<number>;
40
39
  isPermitterAvailable(): boolean;
41
40
  getGasPrice(): Promise<bigint>;
@@ -1,16 +1,17 @@
1
- import { networkRegistry as s, chainIds as c, localhostNetwork as g } from "../constants/chains.constants.mjs";
2
- import { contractMetadataMapping as f } from "../constants/contracts.constants.mjs";
1
+ import { networkRegistry as c, chainIds as s, localhostNetwork as f } from "../constants/chains.constants.mjs";
2
+ import { contractMetadataMapping as w } from "../constants/contracts.constants.mjs";
3
3
  import { transactionErrorCodes as o } from "../error-handling/error-codes.constants.mjs";
4
- import { providers as a, utils as w, ethers as h } from "ethers";
5
- import { ConnectorAlreadyConnectedError as l } from "wagmi";
6
- import { disconnect as v } from "../node_modules/@wagmi/core/dist/esm/actions/disconnect.mjs";
7
- import { connect as u } from "../node_modules/@wagmi/core/dist/esm/actions/connect.mjs";
8
- import { signMessage as p } from "../node_modules/@wagmi/core/dist/esm/actions/signMessage.mjs";
9
- import { switchChain as C } from "../node_modules/@wagmi/core/dist/esm/actions/switchChain.mjs";
4
+ import { providers as a, utils as l, ethers as h } from "ethers";
5
+ import { ConnectorAlreadyConnectedError as u } from "wagmi";
6
+ import { disconnect as d } from "../node_modules/@wagmi/core/dist/esm/actions/disconnect.mjs";
7
+ import { reconnect as v } from "../node_modules/@wagmi/core/dist/esm/actions/reconnect.mjs";
8
+ import { connect as p } from "../node_modules/@wagmi/core/dist/esm/actions/connect.mjs";
9
+ import { signMessage as C } from "../node_modules/@wagmi/core/dist/esm/actions/signMessage.mjs";
10
+ import { switchChain as E } from "../node_modules/@wagmi/core/dist/esm/actions/switchChain.mjs";
10
11
  import { getAccount as P } from "../node_modules/@wagmi/core/dist/esm/actions/getAccount.mjs";
11
- import { watchAccount as E } from "../node_modules/@wagmi/core/dist/esm/actions/watchAccount.mjs";
12
- import { watchChainId as I } from "../node_modules/@wagmi/core/dist/esm/actions/watchChainId.mjs";
13
- class d {
12
+ import { watchAccount as I } from "../node_modules/@wagmi/core/dist/esm/actions/watchAccount.mjs";
13
+ import { watchChainId as m } from "../node_modules/@wagmi/core/dist/esm/actions/watchChainId.mjs";
14
+ class g {
14
15
  connector;
15
16
  chainId;
16
17
  originalProvider;
@@ -37,15 +38,20 @@ class d {
37
38
  async disconnectFromConnector() {
38
39
  if (!this.config)
39
40
  throw new Error("No Config In Provider Adapter");
40
- this.release(), await v(this.config);
41
+ this.release(), await d(this.config);
41
42
  }
42
43
  async connectToConnector(t) {
43
44
  if (!this.config)
44
45
  throw new Error("No Config In Provider Adapter");
46
+ if (t.id === "walletConnect")
47
+ try {
48
+ await v(this.config, { connectors: [t] }), await d(this.config);
49
+ } catch {
50
+ }
45
51
  try {
46
- return (await u(this.config, { connector: t })).chainId;
52
+ return (await p(this.config, { connector: t })).chainId;
47
53
  } catch (r) {
48
- if (r instanceof l)
54
+ if (r instanceof u)
49
55
  return t.getChainId();
50
56
  throw console.log(r), new Error(o.CONNECTION_FAILED);
51
57
  }
@@ -58,7 +64,7 @@ class d {
58
64
  async signMessage(t) {
59
65
  if (!this.config)
60
66
  throw new Error("No Config In Provider Adapter");
61
- const r = await p(this.config, { message: t });
67
+ const r = await C(this.config, { message: t });
62
68
  if (!r)
63
69
  throw new Error(o.SIGNING_FAILED);
64
70
  if (r.includes("error"))
@@ -71,16 +77,16 @@ class d {
71
77
  getSelectedNetwork = () => {
72
78
  if (!this.chainId)
73
79
  throw new Error("Illegal state: no chaindId");
74
- return s[this.chainId];
80
+ return c[this.chainId];
75
81
  };
76
82
  async switchNetwork(t) {
77
83
  if (!this.config)
78
84
  throw new Error("No Config In Provider Adapter");
79
- return C(this.config, { chainId: t.chainId });
85
+ return E(this.config, { chainId: t.chainId });
80
86
  }
81
87
  createFetchProvider() {
82
88
  try {
83
- const r = s[this.chainId]?.fetchRpcUrl;
89
+ const r = c[this.chainId]?.fetchRpcUrl;
84
90
  return r ? r.includes("wss") ? new a.WebSocketProvider(r) : new a.StaticJsonRpcProvider(r) : void 0;
85
91
  } catch (t) {
86
92
  console.log("create Fetch Provider error", t);
@@ -93,13 +99,13 @@ class d {
93
99
  const { address: t } = P(this.config);
94
100
  if (!t)
95
101
  throw new Error("IllegalState");
96
- return w.getAddress(t);
102
+ return l.getAddress(t);
97
103
  }
98
104
  setChainEventListener(t) {
99
105
  if (!this.config)
100
106
  throw new Error("No Config In Provider Adapter");
101
107
  this.chainEventListener = t, this.chainEventListener && (this.unsubscribeFns.push(
102
- E(this.config, {
108
+ I(this.config, {
103
109
  onChange: ({ address: r }, { address: e }) => {
104
110
  if (!this.chainEventListener) {
105
111
  console.warn("chainEventListener is not set");
@@ -109,7 +115,7 @@ class d {
109
115
  }
110
116
  })
111
117
  ), this.unsubscribeFns.push(
112
- I(this.config, {
118
+ m(this.config, {
113
119
  onChange: (r) => {
114
120
  if (!this.chainEventListener) {
115
121
  console.warn("chainEventListener is not set");
@@ -136,10 +142,10 @@ class d {
136
142
  const e = r ?? this.chainId;
137
143
  if (!e)
138
144
  throw new Error("No chainId provided in context");
139
- const n = s[e];
145
+ const n = c[e];
140
146
  if (!n)
141
147
  throw new Error(o.UNSUPPORTED_NETWORK);
142
- const i = f[t];
148
+ const i = w[t];
143
149
  if (!i)
144
150
  throw new Error(`Unsupported contractType: ${t}`);
145
151
  return i(n.contractData);
@@ -166,9 +172,9 @@ class d {
166
172
  return this.getContract(t, r).connect(this.fetchProvider);
167
173
  }
168
174
  getContractWithFetcherForEthereum(t, r = void 0) {
169
- const e = this.chainId === c.localhost && g === c.ethMainnet ? c.localhost : c.ethMainnet;
175
+ const e = this.chainId === s.localhost && f === s.ethMainnet ? s.localhost : s.ethMainnet;
170
176
  return this.getContract(t, r).connect(
171
- new h.providers.StaticJsonRpcProvider(s[e].fetchRpcUrl)
177
+ new h.providers.StaticJsonRpcProvider(c[e].fetchRpcUrl)
172
178
  );
173
179
  }
174
180
  async sendTransaction(t) {
@@ -176,17 +182,8 @@ class d {
176
182
  throw new Error("IllegalState: no signer");
177
183
  return await this.signer.sendTransaction(t);
178
184
  }
179
- async patchExternalProvider(t) {
180
- const r = await t.getProvider();
181
- let e;
182
- if (r instanceof h.providers.Web3Provider ? e = r.provider : e = r, "isWalletConnect" in e) {
183
- const n = await t.getChainId();
184
- e.http = e.setHttpProvider?.(n);
185
- }
186
- }
187
185
  async connectAndPatchProvider(t) {
188
- const r = await this.connectToConnector(t);
189
- return await this.patchExternalProvider(t), r;
186
+ return await this.connectToConnector(t);
190
187
  }
191
188
  isPermitterAvailable() {
192
189
  return !!this.getSelectedNetwork()?.contractData?.permitterAddress;
@@ -205,9 +202,9 @@ class d {
205
202
  return new a.Web3Provider(n, i).getSigner(e);
206
203
  }
207
204
  }
208
- const W = new d(), _ = () => new d();
205
+ const G = new g(), $ = () => new g();
209
206
  export {
210
- d as WagmiProviderAdapter,
211
- _ as default,
212
- W as wagmiProviderAdapter
207
+ g as WagmiProviderAdapter,
208
+ $ as default,
209
+ G as wagmiProviderAdapter
213
210
  };
@@ -1,3 +1,3 @@
1
1
  import { IProviderAdapter } from '../data-structures/provider-adapter/IProviderAdapter';
2
- export declare const exportWagmiv1Provider: <T = unknown>() => Promise<IProviderAdapter<T>>;
2
+ export declare const exportWagmiProvider: <T = unknown>() => Promise<IProviderAdapter<T>>;
3
3
  export declare const exportEthersProvider: () => Promise<IProviderAdapter<unknown>>;