@hinkal/common 0.2.1 → 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)
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const v=require("../../error-handling/logError.cjs");class g{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,r,t,s,n){this.contract=e,this.eventConfig=r,this._latestBlockNumber=t,this.maxPageSize=n,this.isServer=s,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-u.blockReorgDepth[r]+1)};async retrieveEvents(e,r=!1){try{if(this.requireReady(),this.inProgress&&!r)return!1;this.inProgress=!0;const t=await this.getLastBlockNumberForEventRequest();if(t<e)return this.inProgress=!1,!1;const s=o.getSequence(e,t,this.maxPageSize);return await o.resolveSync(s.map(({from:n,to:i})=>async()=>{const c=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),n,i);let a=[];c.length>0&&(a=await this.processEventsPage(c)),this._latestBlockNumber=i,await this.afterEventsAccepted(),a.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch(t){return v.logError("retrieveEvents error:",{err:t}),this.inProgress=!1,!1}}async processEventsPage(e){const r=[];return await o.resolveSync(e.map(t=>async()=>{const{args:s,blockNumber:n}=t;if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(s);await this.acceptEvent(i,n)&&r.push(i)})),r}handleEvent=async(...e)=>{const{args:r}=this.eventConfig,{blockNumber:t}=e[e.length-1],s=e.slice(0,r.length),n=r.reduce((a,l,h)=>(a[l]=s[h],a),{});if(!t)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,t))throw new Error("Failed to retrieve events");this._latestBlockNumber=t,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");class u{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,t,s,r,n){this.contract=e,this.eventConfig=t,this._latestBlockNumber=s,this.maxPageSize=n,this.isServer=r,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:t}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-v.blockReorgDepth[t]+1)};async retrieveEvents(e,t=!1){try{if(this.requireReady(),this.inProgress&&!t)return!1;this.inProgress=!0;const s=await this.getLastBlockNumberForEventRequest();if(s<e)return this.inProgress=!1,!1;const r=o.getSequence(e,s,this.maxPageSize);return await o.resolveSync(r.map(({from:n,to:i})=>async()=>{const c=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),n,i);let a=[];c.length>0&&(a=await this.processEventsPage(c)),this._latestBlockNumber=i,await this.afterEventsAccepted(),a.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch{return this.inProgress=!1,!1}}async processEventsPage(e){const t=[];return await o.resolveSync(e.map(s=>async()=>{const{args:r,blockNumber:n}=s;if(!r)throw new Error("Wrong event structure");const i=this.mapEvent(r);await this.acceptEvent(i,n)&&t.push(i)})),t}handleEvent=async(...e)=>{const{args:t}=this.eventConfig,{blockNumber:s}=e[e.length-1],r=e.slice(0,t.length),n=t.reduce((a,l,h)=>(a[l]=r[h],a),{});if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,s))throw new Error("Failed to retrieve events");this._latestBlockNumber=s,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=u;
@@ -1,18 +1,6 @@
1
1
  import { blockReorgDepth as v } from "../../constants/reorg-depths.constants.mjs";
2
- import { getSequence as m, resolveSync as c } from "../../functions/utils/resolve-sync.utils.mjs";
3
- import "ethers";
4
- import "axios";
5
- import "../../constants/chains.constants.mjs";
6
- import "../../constants/vite.constants.mjs";
7
- import "../../types/circom-data.types.mjs";
8
- import "../../types/transactions.types.mjs";
9
- import "../../types/curve.types.mjs";
10
- import "circomlibjs-hinkal-fork";
11
- import "libsodium-wrappers";
12
- import "process";
13
- import "buffer";
14
- import { logError as u } from "../../error-handling/logError.mjs";
15
- class q {
2
+ import { getSequence as u, resolveSync as o } from "../../functions/utils/resolve-sync.utils.mjs";
3
+ class g {
16
4
  contract;
17
5
  eventConfig;
18
6
  _latestBlockNumber;
@@ -23,8 +11,8 @@ class q {
23
11
  intervalId;
24
12
  inProgress;
25
13
  // to remove race conditions
26
- constructor(e, r, t, s, n) {
27
- this.contract = e, this.eventConfig = r, this._latestBlockNumber = t, this.maxPageSize = n, this.isServer = s, this.inProgress = !1;
14
+ constructor(e, t, s, r, n) {
15
+ this.contract = e, this.eventConfig = t, this._latestBlockNumber = s, this.maxPageSize = n, this.isServer = r, this.inProgress = !1;
28
16
  }
29
17
  get latestBlockNumber() {
30
18
  return this._latestBlockNumber;
@@ -53,55 +41,55 @@ class q {
53
41
  const e = await this.contract.provider.getBlockNumber();
54
42
  if (!this.isServer)
55
43
  return e;
56
- const { chainId: r } = await this.contract.provider.getNetwork();
57
- return Math.max(this.latestBlockNumber, e - v[r] + 1);
44
+ const { chainId: t } = await this.contract.provider.getNetwork();
45
+ return Math.max(this.latestBlockNumber, e - v[t] + 1);
58
46
  };
59
- async retrieveEvents(e, r = !1) {
47
+ async retrieveEvents(e, t = !1) {
60
48
  try {
61
- if (this.requireReady(), this.inProgress && !r)
49
+ if (this.requireReady(), this.inProgress && !t)
62
50
  return !1;
63
51
  this.inProgress = !0;
64
- const t = await this.getLastBlockNumberForEventRequest();
65
- if (t < e)
52
+ const s = await this.getLastBlockNumberForEventRequest();
53
+ if (s < e)
66
54
  return this.inProgress = !1, !1;
67
- const s = m(e, t, this.maxPageSize);
68
- return await c(
69
- s.map(({ from: n, to: i }) => async () => {
70
- const o = await this.contract.queryFilter(
55
+ const r = u(e, s, this.maxPageSize);
56
+ return await o(
57
+ r.map(({ from: n, to: i }) => async () => {
58
+ const c = await this.contract.queryFilter(
71
59
  this.contract.filters[this.eventConfig.name](),
72
60
  n,
73
61
  i
74
62
  );
75
63
  let a = [];
76
- o.length > 0 && (a = await this.processEventsPage(o)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
64
+ c.length > 0 && (a = await this.processEventsPage(c)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
77
65
  })
78
66
  ), this.inProgress = !1, !0;
79
- } catch (t) {
80
- return u("retrieveEvents error:", { err: t }), this.inProgress = !1, !1;
67
+ } catch {
68
+ return this.inProgress = !1, !1;
81
69
  }
82
70
  }
83
71
  async processEventsPage(e) {
84
- const r = [];
85
- return await c(
86
- e.map((t) => async () => {
87
- const { args: s, blockNumber: n } = t;
88
- if (!s)
72
+ const t = [];
73
+ return await o(
74
+ e.map((s) => async () => {
75
+ const { args: r, blockNumber: n } = s;
76
+ if (!r)
89
77
  throw new Error("Wrong event structure");
90
- const i = this.mapEvent(s);
91
- await this.acceptEvent(i, n) && r.push(i);
78
+ const i = this.mapEvent(r);
79
+ await this.acceptEvent(i, n) && t.push(i);
92
80
  })
93
- ), r;
81
+ ), t;
94
82
  }
95
83
  handleEvent = async (...e) => {
96
- const { args: r } = this.eventConfig, { blockNumber: t } = e[e.length - 1], s = e.slice(0, r.length), n = r.reduce((a, h, l) => (a[h] = s[l], a), {});
97
- if (!t)
84
+ const { args: t } = this.eventConfig, { blockNumber: s } = e[e.length - 1], r = e.slice(0, t.length), n = t.reduce((a, h, l) => (a[h] = r[l], a), {});
85
+ if (!s)
98
86
  throw new Error("Wrong event structure");
99
87
  const i = this.mapEvent(n);
100
- if (!await this.acceptEvent(i, t))
88
+ if (!await this.acceptEvent(i, s))
101
89
  throw new Error("Failed to retrieve events");
102
- this._latestBlockNumber = t, await this.afterEventsAccepted(), this.emitNewEvent(i);
90
+ this._latestBlockNumber = s, await this.afterEventsAccepted(), this.emitNewEvent(i);
103
91
  };
104
92
  }
105
93
  export {
106
- q as AbstractEventService
94
+ g as AbstractEventService
107
95
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
@@ -1,4 +1,4 @@
1
- import { AbstractAccessTokenSnapshotService as t } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
1
+ import { AbstractAccessTokenSnapshotService as s } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
2
2
  import "ethers";
3
3
  import "circomlibjs-hinkal-fork";
4
4
  import "libsodium-wrappers";
@@ -6,18 +6,13 @@ import "process";
6
6
  import "buffer";
7
7
  import "../../constants/vite.constants.mjs";
8
8
  import "../../constants/reorg-depths.constants.mjs";
9
- import "axios";
10
- import "../../constants/chains.constants.mjs";
11
- import "../../types/circom-data.types.mjs";
12
- import "../../types/transactions.types.mjs";
13
- import "../../types/curve.types.mjs";
14
- import { fetchAccessTokenSnapshot as s } from "../../API/fetchCommitmentsCache.mjs";
15
- class u extends t {
9
+ import { fetchAccessTokenSnapshot as t } from "../../API/fetchCommitmentsCache.mjs";
10
+ class k extends s {
16
11
  constructor(r, e) {
17
12
  super(r, 0, !1, e);
18
13
  }
19
14
  async fetchSnapshot() {
20
- const { chainId: r } = await this.contract.provider.getNetwork(), e = await s(r);
15
+ const { chainId: r } = await this.contract.provider.getNetwork(), e = await t(r);
21
16
  if (e.accessTokenContractAddress !== this.contract.address || e.chainId !== r)
22
17
  throw Error("Commitment Snapshot: incorrect contract or chain id");
23
18
  return {
@@ -32,5 +27,5 @@ class u extends t {
32
27
  }
33
28
  }
34
29
  export {
35
- u as ClientAccessTokenSnapshotService
30
+ k as ClientAccessTokenSnapshotService
36
31
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const r=require("../../API/fetchCommitmentsCache.cjs"),i=require("../event-service/AbstractCommitmentsSnapshotService.cjs");class s extends i.AbstractCommitmentsSnapshotService{constructor(t,e){super(t,0,!1,e)}async fetchSnapshot(){const{chainId:t}=await this.contract.provider.getNetwork(),e=await r.fetchCommitmentsSnapshot(t);if(e.hinkalAddress!==this.contract.address||e.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,encryptedOutputs:e.encryptedOutputs}}persistSnapshot(t){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const r=require("../event-service/AbstractCommitmentsSnapshotService.cjs"),s=require("../../API/fetchCommitmentsCache.cjs");class i extends r.AbstractCommitmentsSnapshotService{constructor(t,e){super(t,0,!1,e)}async fetchSnapshot(){const{chainId:t}=await this.contract.provider.getNetwork(),e=await s.fetchCommitmentsSnapshot(t);if(e.hinkalAddress!==this.contract.address||e.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,encryptedOutputs:e.encryptedOutputs}}persistSnapshot(t){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=i;
@@ -5,19 +5,14 @@ import "process";
5
5
  import "buffer";
6
6
  import "../../constants/vite.constants.mjs";
7
7
  import "../../constants/reorg-depths.constants.mjs";
8
- import "axios";
9
- import "../../constants/chains.constants.mjs";
10
- import "../../types/circom-data.types.mjs";
11
- import "../../types/transactions.types.mjs";
12
- import "../../types/curve.types.mjs";
13
- import { fetchCommitmentsSnapshot as e } from "../../API/fetchCommitmentsCache.mjs";
14
- import { AbstractCommitmentsSnapshotService as o } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
15
- class v extends o {
8
+ import { AbstractCommitmentsSnapshotService as e } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
9
+ import { fetchCommitmentsSnapshot as o } from "../../API/fetchCommitmentsCache.mjs";
10
+ class u extends e {
16
11
  constructor(r, t) {
17
12
  super(r, 0, !1, t);
18
13
  }
19
14
  async fetchSnapshot() {
20
- const { chainId: r } = await this.contract.provider.getNetwork(), t = await e(r);
15
+ const { chainId: r } = await this.contract.provider.getNetwork(), t = await o(r);
21
16
  if (t.hinkalAddress !== this.contract.address || t.chainId !== r)
22
17
  throw Error("Commitment Snapshot: incorrect contract or chain id");
23
18
  return {
@@ -31,5 +26,5 @@ class v extends o {
31
26
  }
32
27
  }
33
28
  export {
34
- v as ClientCommitmentsSnapshotService
29
+ u as ClientCommitmentsSnapshotService
35
30
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const i=require("../../API/fetchNullifiers.cjs"),t=require("../event-service/AbstractNullifierSnapshotService.cjs");class s extends t.AbstractNullifierSnapshotService{constructor(e,r){super(e,0,!1,r)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),r=await i.fetchNullifiers(e);return{latestBlockNumber:r.latestBlockNumber,nullifiers:r.nullifiers}}persistSnapshot(e){return Promise.resolve()}}exports.ClientNullifierSnapshotService=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../event-service/AbstractNullifierSnapshotService.cjs"),t=require("../../API/fetchNullifiers.cjs");class s extends i.AbstractNullifierSnapshotService{constructor(e,r){super(e,0,!1,r)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),r=await t.fetchNullifiers(e);return{latestBlockNumber:r.latestBlockNumber,nullifiers:r.nullifiers}}persistSnapshot(e){return Promise.resolve()}}exports.ClientNullifierSnapshotService=s;
@@ -5,14 +5,9 @@ import "process";
5
5
  import "buffer";
6
6
  import "../../constants/vite.constants.mjs";
7
7
  import "../../constants/reorg-depths.constants.mjs";
8
- import "axios";
9
- import "../../constants/chains.constants.mjs";
10
- import "../../types/circom-data.types.mjs";
11
- import "../../types/transactions.types.mjs";
12
- import "../../types/curve.types.mjs";
8
+ import { AbstractNullifierSnapshotService as e } from "../event-service/AbstractNullifierSnapshotService.mjs";
13
9
  import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
14
- import { AbstractNullifierSnapshotService as o } from "../event-service/AbstractNullifierSnapshotService.mjs";
15
- class b extends o {
10
+ class h extends e {
16
11
  constructor(t, r) {
17
12
  super(t, 0, !1, r);
18
13
  }
@@ -28,5 +23,5 @@ class b extends o {
28
23
  }
29
24
  }
30
25
  export {
31
- b as ClientNullifierSnapshotService
26
+ h as ClientNullifierSnapshotService
32
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.2.1",
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>>;