@hinkal/common 0.2.16 → 0.2.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hinkal/common",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../constants/chains.constants.cjs"),s=require("../error-handling/error-codes.constants.cjs"),a=require("ethers"),w=require("wagmi"),d=require("../functions/web3/getContractMetadata.cjs"),h=require("../types/eip5792.types.cjs"),f=require("../error-handling/logger.cjs"),u=require("../node_modules/@wagmi/core/dist/esm/actions/disconnect.cjs"),v=require("../node_modules/@wagmi/core/dist/esm/actions/reconnect.cjs"),C=require("../node_modules/@wagmi/core/dist/esm/actions/connect.cjs"),P=require("../node_modules/@wagmi/core/dist/esm/actions/signMessage.cjs"),p=require("../node_modules/@wagmi/core/dist/esm/actions/switchChain.cjs"),I=require("../node_modules/@wagmi/core/dist/esm/actions/getAccount.cjs"),E=require("../node_modules/@wagmi/core/dist/esm/actions/watchAccount.cjs"),A=require("../node_modules/@wagmi/core/dist/esm/actions/watchChainId.cjs");class l{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);const r=await this.connector.getProvider();this.originalProvider=new a.providers.Web3Provider(r),this.fetchProvider=this.createFetchProvider()??this.originalProvider,this.fetchProvider===this.originalProvider&&console.warn("fetchProvider not available");const 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 u.disconnect(this.config)}async connectToConnector(t){if(!this.config)throw new Error("No Config In Provider Adapter");if(t.id==="walletConnect")try{await v.reconnect(this.config,{connectors:[t]}),await u.disconnect(this.config)}catch{}try{return(await C.connect(this.config,{connector:t})).chainId}catch(r){if(r instanceof w.ConnectorAlreadyConnectedError)return t.getChainId();let e=s.transactionErrorCodes.CONNECTION_FAILED;throw r?.code===4001&&(e=s.UserFriendlyErrorCodes.YOU_CANCELED_REQUEST),new Error(e)}}async waitForTransaction(t,r){if((await this.fetchProvider?.waitForTransaction(t,r))?.status)return!0;throw Error(s.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(t){if(!this.config)throw new Error("No Config In Provider Adapter");const r=await P.signMessage(this.config,{message:t});if(!r)throw new Error(s.transactionErrorCodes.SIGNING_FAILED);if(r.includes("error"))throw new Error(s.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 o.networkRegistry[this.chainId]};async switchNetwork(t){if(!this.config)throw new Error("No Config In Provider Adapter");return p.switchChain(this.config,{chainId:t.chainId})}createFetchProvider(){try{const r=o.networkRegistry[this.chainId]?.fetchRpcUrl;return r?r.includes("wss")?new a.providers.WebSocketProvider(r):new a.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}=I.getAccount(this.config);if(!t)throw new Error("IllegalState");return a.utils.getAddress(t)}setChainEventListener(t){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=t,this.chainEventListener&&(this.unsubscribeFns.push(E.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(A.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=[]}parseChainIdParam(t){const r=t??this.chainId;if(!r)throw new Error("No chainId provided in context");return r}getContractMetadata(t,r){const e=this.parseChainIdParam(r);return d.getContractMetadata(t,e)}getContract(t,r=void 0,e){const n=this.parseChainIdParam(e);return d.getContract(t,n,r)}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===o.chainIds.localhost&&o.localhostNetwork===o.chainIds.ethMainnet?o.chainIds.localhost:o.chainIds.ethMainnet;return d.getContractWithFetcherByChainId(e,t,r)}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,i={chainId:r,name:""};return new a.providers.Web3Provider(n,i).getSigner(e)}switchAccount(){throw new Error("Method not implemented.")}async supportsBatchCall(){if(!this.originalProvider||!this.chainId)return!1;try{const t=await this.getAddress(),r=`0x${this.chainId.toString(16)}`,e=await this.originalProvider.send("wallet_getCapabilities",[t,[r]]),n=e?.[r]||e?.["0x0"];if(!n?.atomic)return!1;const i=typeof n.atomic=="string"?n.atomic:n.atomic?.status;return i==="supported"||i==="ready"}catch{return!1}}async waitForBatchTransactionStatus(t){if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=1e3,e=60;for(let n=0;n<e;n+=1){await new Promise(i=>{setTimeout(()=>i(),r)});try{const i=await this.originalProvider.send("wallet_getCallsStatus",[t]);if(i.status===h.CallsStatus.Confirmed&&i.receipts?.[0]?.transactionHash)return i.receipts[0].transactionHash;if(i.status===h.CallsStatus.OffchainFailure||i.status===h.CallsStatus.ChainFailure||i.status===h.CallsStatus.PartialFailure)break}catch(i){f.Logger.log("waitForBatchTransactionStatus:",i)}}throw new Error("Batch transaction timed out or failed")}async sendBatchCallsTransaction(t){if(!this.chainId)throw new Error("WagmiProviderAdapter: chainId not initialized");if(!this.fetchProvider)throw new Error("WagmiProviderAdapter: fetchProvider not initialized");if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=await this.getAddress(),n={version:"2.0.0",chainId:`0x${this.chainId.toString(16)}`,from:r,atomicRequired:!0,calls:t},i=await this.originalProvider.send("wallet_sendCalls",[n]),c=i?.id||i;if(!c||typeof c!="string")throw new Error("Invalid batch ID received from wallet_sendCalls");const g=await this.waitForBatchTransactionStatus(c);return this.fetchProvider.getTransaction(g)}}const m=new l,y=()=>new l;exports.WagmiProviderAdapter=l;exports.default=y;exports.wagmiProviderAdapter=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../constants/chains.constants.cjs"),a=require("../error-handling/error-codes.constants.cjs"),c=require("ethers"),w=require("wagmi"),o=require("wagmi/actions"),l=require("../functions/web3/getContractMetadata.cjs"),d=require("../types/eip5792.types.cjs"),f=require("../error-handling/logger.cjs");class g{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);const r=await this.connector.getProvider();this.originalProvider=new c.providers.Web3Provider(r),this.fetchProvider=this.createFetchProvider()??this.originalProvider,this.fetchProvider===this.originalProvider&&console.warn("fetchProvider not available");const 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 o.disconnect(this.config)}async connectToConnector(t){if(!this.config)throw new Error("No Config In Provider Adapter");if(t.id==="walletConnect")try{await o.reconnect(this.config,{connectors:[t]}),await o.disconnect(this.config)}catch{}try{return(await o.connect(this.config,{connector:t})).chainId}catch(r){if(r instanceof w.ConnectorAlreadyConnectedError)return t.getChainId();let e=a.transactionErrorCodes.CONNECTION_FAILED;throw r?.code===4001&&(e=a.UserFriendlyErrorCodes.YOU_CANCELED_REQUEST),new Error(e)}}async waitForTransaction(t,r){if((await this.fetchProvider?.waitForTransaction(t,r))?.status)return!0;throw Error(a.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(t){if(!this.config)throw new Error("No Config In Provider Adapter");const r=await o.signMessage(this.config,{message:t});if(!r)throw new Error(a.transactionErrorCodes.SIGNING_FAILED);if(r.includes("error"))throw new Error(a.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 s.networkRegistry[this.chainId]};async switchNetwork(t){if(!this.config)throw new Error("No Config In Provider Adapter");return o.switchChain(this.config,{chainId:t.chainId})}createFetchProvider(){try{const r=s.networkRegistry[this.chainId]?.fetchRpcUrl;return r?r.includes("wss")?new c.providers.WebSocketProvider(r):new c.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}=o.getAccount(this.config);if(!t)throw new Error("IllegalState");return c.utils.getAddress(t)}setChainEventListener(t){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=t,this.chainEventListener&&(this.unsubscribeFns.push(o.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(o.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=[]}parseChainIdParam(t){const r=t??this.chainId;if(!r)throw new Error("No chainId provided in context");return r}getContractMetadata(t,r){const e=this.parseChainIdParam(r);return l.getContractMetadata(t,e)}getContract(t,r=void 0,e){const n=this.parseChainIdParam(e);return l.getContract(t,n,r)}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===s.chainIds.localhost&&s.localhostNetwork===s.chainIds.ethMainnet?s.chainIds.localhost:s.chainIds.ethMainnet;return l.getContractWithFetcherByChainId(e,t,r)}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,i={chainId:r,name:""};return new c.providers.Web3Provider(n,i).getSigner(e)}switchAccount(){throw new Error("Method not implemented.")}async supportsBatchCall(){if(!this.originalProvider||!this.chainId)return!1;try{const t=await this.getAddress(),r=`0x${this.chainId.toString(16)}`,e=await this.originalProvider.send("wallet_getCapabilities",[t,[r]]),n=e?.[r]||e?.["0x0"];if(!n?.atomic)return!1;const i=typeof n.atomic=="string"?n.atomic:n.atomic?.status;return i==="supported"||i==="ready"}catch{return!1}}async waitForBatchTransactionStatus(t){if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=1e3,e=60;for(let n=0;n<e;n+=1){await new Promise(i=>{setTimeout(()=>i(),r)});try{const i=await this.originalProvider.send("wallet_getCallsStatus",[t]);if(i.status===d.CallsStatus.Confirmed&&i.receipts?.[0]?.transactionHash)return i.receipts[0].transactionHash;if(i.status===d.CallsStatus.OffchainFailure||i.status===d.CallsStatus.ChainFailure||i.status===d.CallsStatus.PartialFailure)break}catch(i){f.Logger.log("waitForBatchTransactionStatus:",i)}}throw new Error("Batch transaction timed out or failed")}async sendBatchCallsTransaction(t){if(!this.chainId)throw new Error("WagmiProviderAdapter: chainId not initialized");if(!this.fetchProvider)throw new Error("WagmiProviderAdapter: fetchProvider not initialized");if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=await this.getAddress(),n={version:"2.0.0",chainId:`0x${this.chainId.toString(16)}`,from:r,atomicRequired:!0,calls:t},i=await this.originalProvider.send("wallet_sendCalls",[n]),h=i?.id||i;if(!h||typeof h!="string")throw new Error("Invalid batch ID received from wallet_sendCalls");const u=await this.waitForBatchTransactionStatus(h);return this.fetchProvider.getTransaction(u)}}const v=new g,C=()=>new g;exports.WagmiProviderAdapter=g;exports.default=C;exports.wagmiProviderAdapter=v;
@@ -1,19 +1,12 @@
1
- import { networkRegistry as l, chainIds as a, localhostNetwork as w } from "../constants/chains.constants.mjs";
1
+ import { networkRegistry as l, chainIds as a, localhostNetwork as f } from "../constants/chains.constants.mjs";
2
2
  import { transactionErrorCodes as s, UserFriendlyErrorCodes as u } from "../error-handling/error-codes.constants.mjs";
3
3
  import { providers as c, utils as v } from "ethers";
4
- import { ConnectorAlreadyConnectedError as p } from "wagmi";
5
- import { getContractMetadata as C, getContract as m, getContractWithFetcherByChainId as P } from "../functions/web3/getContractMetadata.mjs";
4
+ import { ConnectorAlreadyConnectedError as C } from "wagmi";
5
+ import { disconnect as g, reconnect as p, connect as P, signMessage as I, switchChain as E, getAccount as m, watchAccount as A, watchChainId as y } from "wagmi/actions";
6
+ import { getContractMetadata as F, getContract as N, getContractWithFetcherByChainId as S } from "../functions/web3/getContractMetadata.mjs";
6
7
  import { CallsStatus as h } from "../types/eip5792.types.mjs";
7
- import { Logger as I } from "../error-handling/logger.mjs";
8
- import { disconnect as g } from "../node_modules/@wagmi/core/dist/esm/actions/disconnect.mjs";
9
- import { reconnect as E } from "../node_modules/@wagmi/core/dist/esm/actions/reconnect.mjs";
10
- import { connect as A } from "../node_modules/@wagmi/core/dist/esm/actions/connect.mjs";
11
- import { signMessage as y } from "../node_modules/@wagmi/core/dist/esm/actions/signMessage.mjs";
12
- import { switchChain as F } from "../node_modules/@wagmi/core/dist/esm/actions/switchChain.mjs";
13
- import { getAccount as N } from "../node_modules/@wagmi/core/dist/esm/actions/getAccount.mjs";
14
- import { watchAccount as S } from "../node_modules/@wagmi/core/dist/esm/actions/watchAccount.mjs";
15
- import { watchChainId as T } from "../node_modules/@wagmi/core/dist/esm/actions/watchChainId.mjs";
16
- class f {
8
+ import { Logger as T } from "../error-handling/logger.mjs";
9
+ class w {
17
10
  connector;
18
11
  chainId;
19
12
  originalProvider;
@@ -36,8 +29,8 @@ class f {
36
29
  this.requireConnector(), t && (this.chainId = t);
37
30
  const r = await this.connector.getProvider();
38
31
  this.originalProvider = new c.Web3Provider(r), this.fetchProvider = this.createFetchProvider() ?? this.originalProvider, this.fetchProvider === this.originalProvider && console.warn("fetchProvider not available");
39
- const i = await this.connector.getAccounts();
40
- this.signer = await this.walletClientToSigner({ transport: r, account: i[0] }, this.chainId);
32
+ const e = await this.connector.getAccounts();
33
+ this.signer = await this.walletClientToSigner({ transport: r, account: e[0] }, this.chainId);
41
34
  }
42
35
  async disconnectFromConnector() {
43
36
  if (!this.config)
@@ -49,16 +42,16 @@ class f {
49
42
  throw new Error("No Config In Provider Adapter");
50
43
  if (t.id === "walletConnect")
51
44
  try {
52
- await E(this.config, { connectors: [t] }), await g(this.config);
45
+ await p(this.config, { connectors: [t] }), await g(this.config);
53
46
  } catch {
54
47
  }
55
48
  try {
56
- return (await A(this.config, { connector: t })).chainId;
49
+ return (await P(this.config, { connector: t })).chainId;
57
50
  } catch (r) {
58
- if (r instanceof p)
51
+ if (r instanceof C)
59
52
  return t.getChainId();
60
- let i = s.CONNECTION_FAILED;
61
- throw r?.code === 4001 && (i = u.YOU_CANCELED_REQUEST), new Error(i);
53
+ let e = s.CONNECTION_FAILED;
54
+ throw r?.code === 4001 && (e = u.YOU_CANCELED_REQUEST), new Error(e);
62
55
  }
63
56
  }
64
57
  async waitForTransaction(t, r) {
@@ -69,15 +62,15 @@ class f {
69
62
  async signMessage(t) {
70
63
  if (!this.config)
71
64
  throw new Error("No Config In Provider Adapter");
72
- const r = await y(this.config, { message: t });
65
+ const r = await I(this.config, { message: t });
73
66
  if (!r)
74
67
  throw new Error(s.SIGNING_FAILED);
75
68
  if (r.includes("error"))
76
69
  throw new Error(s.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);
77
70
  return r;
78
71
  }
79
- async signTypedData(t, r, i) {
80
- return this.signer._signTypedData(t, r, i);
72
+ async signTypedData(t, r, e) {
73
+ return this.signer._signTypedData(t, r, e);
81
74
  }
82
75
  getSelectedNetwork = () => {
83
76
  if (!this.chainId)
@@ -87,7 +80,7 @@ class f {
87
80
  async switchNetwork(t) {
88
81
  if (!this.config)
89
82
  throw new Error("No Config In Provider Adapter");
90
- return F(this.config, {
83
+ return E(this.config, {
91
84
  chainId: t.chainId
92
85
  });
93
86
  }
@@ -103,7 +96,7 @@ class f {
103
96
  async getAddress() {
104
97
  if (!this.config)
105
98
  throw new Error("No Config In Provider Adapter");
106
- const { address: t } = N(this.config);
99
+ const { address: t } = m(this.config);
107
100
  if (!t)
108
101
  throw new Error("IllegalState");
109
102
  return v.getAddress(t);
@@ -112,17 +105,17 @@ class f {
112
105
  if (!this.config)
113
106
  throw new Error("No Config In Provider Adapter");
114
107
  this.chainEventListener = t, this.chainEventListener && (this.unsubscribeFns.push(
115
- S(this.config, {
116
- onChange: ({ address: r }, { address: i }) => {
108
+ A(this.config, {
109
+ onChange: ({ address: r }, { address: e }) => {
117
110
  if (!this.chainEventListener) {
118
111
  console.warn("chainEventListener is not set");
119
112
  return;
120
113
  }
121
- console.log("Account changed"), r !== i && (console.log("Account changed"), this.chainEventListener.onAccountChanged());
114
+ console.log("Account changed"), r !== e && (console.log("Account changed"), this.chainEventListener.onAccountChanged());
122
115
  }
123
116
  })
124
117
  ), this.unsubscribeFns.push(
125
- T(this.config, {
118
+ y(this.config, {
126
119
  onChange: (r) => {
127
120
  if (!this.chainEventListener) {
128
121
  console.warn("chainEventListener is not set");
@@ -152,12 +145,12 @@ class f {
152
145
  return r;
153
146
  }
154
147
  getContractMetadata(t, r) {
155
- const i = this.parseChainIdParam(r);
156
- return C(t, i);
148
+ const e = this.parseChainIdParam(r);
149
+ return F(t, e);
157
150
  }
158
- getContract(t, r = void 0, i) {
159
- const n = this.parseChainIdParam(i);
160
- return m(t, n, r);
151
+ getContract(t, r = void 0, e) {
152
+ const n = this.parseChainIdParam(e);
153
+ return N(t, n, r);
161
154
  }
162
155
  getContractWithSigner(t, r = void 0) {
163
156
  if (!this.signer)
@@ -170,8 +163,8 @@ class f {
170
163
  return this.getContract(t, r).connect(this.fetchProvider);
171
164
  }
172
165
  getContractWithFetcherForEthereum(t, r = void 0) {
173
- const i = this.chainId === a.localhost && w === a.ethMainnet ? a.localhost : a.ethMainnet;
174
- return P(i, t, r);
166
+ const e = this.chainId === a.localhost && f === a.ethMainnet ? a.localhost : a.ethMainnet;
167
+ return S(e, t, r);
175
168
  }
176
169
  async sendTransaction(t) {
177
170
  if (!this.signer)
@@ -191,11 +184,11 @@ class f {
191
184
  return t.toBigInt();
192
185
  }
193
186
  async walletClientToSigner(t, r) {
194
- const { account: i, transport: n } = t, e = {
187
+ const { account: e, transport: n } = t, i = {
195
188
  chainId: r,
196
189
  name: ""
197
190
  };
198
- return new c.Web3Provider(n, e).getSigner(i);
191
+ return new c.Web3Provider(n, i).getSigner(e);
199
192
  }
200
193
  switchAccount() {
201
194
  throw new Error("Method not implemented.");
@@ -204,11 +197,11 @@ class f {
204
197
  if (!this.originalProvider || !this.chainId)
205
198
  return !1;
206
199
  try {
207
- const t = await this.getAddress(), r = `0x${this.chainId.toString(16)}`, i = await this.originalProvider.send("wallet_getCapabilities", [t, [r]]), n = i?.[r] || i?.["0x0"];
200
+ const t = await this.getAddress(), r = `0x${this.chainId.toString(16)}`, e = await this.originalProvider.send("wallet_getCapabilities", [t, [r]]), n = e?.[r] || e?.["0x0"];
208
201
  if (!n?.atomic)
209
202
  return !1;
210
- const e = typeof n.atomic == "string" ? n.atomic : n.atomic?.status;
211
- return e === "supported" || e === "ready";
203
+ const i = typeof n.atomic == "string" ? n.atomic : n.atomic?.status;
204
+ return i === "supported" || i === "ready";
212
205
  } catch {
213
206
  return !1;
214
207
  }
@@ -216,19 +209,19 @@ class f {
216
209
  async waitForBatchTransactionStatus(t) {
217
210
  if (!this.originalProvider)
218
211
  throw new Error("WagmiProviderAdapter: Provider not initialized");
219
- const r = 1e3, i = 60;
220
- for (let n = 0; n < i; n += 1) {
221
- await new Promise((e) => {
222
- setTimeout(() => e(), r);
212
+ const r = 1e3, e = 60;
213
+ for (let n = 0; n < e; n += 1) {
214
+ await new Promise((i) => {
215
+ setTimeout(() => i(), r);
223
216
  });
224
217
  try {
225
- const e = await this.originalProvider.send("wallet_getCallsStatus", [t]);
226
- if (e.status === h.Confirmed && e.receipts?.[0]?.transactionHash)
227
- return e.receipts[0].transactionHash;
228
- if (e.status === h.OffchainFailure || e.status === h.ChainFailure || e.status === h.PartialFailure)
218
+ const i = await this.originalProvider.send("wallet_getCallsStatus", [t]);
219
+ if (i.status === h.Confirmed && i.receipts?.[0]?.transactionHash)
220
+ return i.receipts[0].transactionHash;
221
+ if (i.status === h.OffchainFailure || i.status === h.ChainFailure || i.status === h.PartialFailure)
229
222
  break;
230
- } catch (e) {
231
- I.log("waitForBatchTransactionStatus:", e);
223
+ } catch (i) {
224
+ T.log("waitForBatchTransactionStatus:", i);
232
225
  }
233
226
  }
234
227
  throw new Error("Batch transaction timed out or failed");
@@ -246,16 +239,16 @@ class f {
246
239
  from: r,
247
240
  atomicRequired: !0,
248
241
  calls: t
249
- }, e = await this.originalProvider.send("wallet_sendCalls", [n]), o = e?.id || e;
242
+ }, i = await this.originalProvider.send("wallet_sendCalls", [n]), o = i?.id || i;
250
243
  if (!o || typeof o != "string")
251
244
  throw new Error("Invalid batch ID received from wallet_sendCalls");
252
245
  const d = await this.waitForBatchTransactionStatus(o);
253
246
  return this.fetchProvider.getTransaction(d);
254
247
  }
255
248
  }
256
- const $ = new f(), J = () => new f();
249
+ const O = new w(), U = () => new w();
257
250
  export {
258
- f as WagmiProviderAdapter,
259
- J as default,
260
- $ as wagmiProviderAdapter
251
+ w as WagmiProviderAdapter,
252
+ U as default,
253
+ O as wagmiProviderAdapter
261
254
  };
@@ -14,8 +14,8 @@
14
14
  var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
15
15
 
16
16
  const n = async () => ({
17
- [e.ZKProof]: await getWorkerURL(domain + '/0.2.16/' + 'zkProofWorkerLauncher.js'),
18
- [e.SnarkJS]: await getWorkerURL(domain + '/0.2.16/' + 'snarkjsWorkerLauncher.js'),
19
- [e.UTXO]: await getWorkerURL(domain + '/0.2.16/' + 'utxoWorkerLauncher.js'),
17
+ [e.ZKProof]: await getWorkerURL(domain + '/0.2.17/' + 'zkProofWorkerLauncher.js'),
18
+ [e.SnarkJS]: await getWorkerURL(domain + '/0.2.17/' + 'snarkjsWorkerLauncher.js'),
19
+ [e.UTXO]: await getWorkerURL(domain + '/0.2.17/' + 'utxoWorkerLauncher.js'),
20
20
  });
21
21
  exports.getWorkerViteURL = n;
@@ -14,8 +14,8 @@
14
14
  var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
15
15
 
16
16
  const n = async () => ({
17
- [e.ZKProof]: await getWorkerURL(domain + '/0.2.16/' + 'zkProofWorkerLauncher.js'),
18
- [e.SnarkJS]: await getWorkerURL(domain + '/0.2.16/' + 'snarkjsWorkerLauncher.js'),
19
- [e.UTXO]: await getWorkerURL(domain + '/0.2.16/' + 'utxoWorkerLauncher.js'),
17
+ [e.ZKProof]: await getWorkerURL(domain + '/0.2.17/' + 'zkProofWorkerLauncher.js'),
18
+ [e.SnarkJS]: await getWorkerURL(domain + '/0.2.17/' + 'snarkjsWorkerLauncher.js'),
19
+ [e.UTXO]: await getWorkerURL(domain + '/0.2.17/' + 'utxoWorkerLauncher.js'),
20
20
  });
21
21
  export { n as getWorkerViteURL };