@hinkal/common 0.1.7 → 0.1.9

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.
Files changed (53) hide show
  1. package/constants/coingecko.constants.cjs +1 -1
  2. package/constants/coingecko.constants.mjs +13 -14
  3. package/constants/vite.constants.cjs +1 -1
  4. package/constants/vite.constants.mjs +21 -22
  5. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  6. package/data-structures/Hinkal/Hinkal.mjs +70 -71
  7. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  8. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +7 -8
  9. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  10. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +34 -35
  11. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  12. package/data-structures/transactions-manager/TransactionsManager.mjs +27 -28
  13. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  14. package/functions/pre-transaction/outputUtxoProcessing.mjs +2 -3
  15. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  16. package/functions/pre-transaction/processAmountChanges.mjs +2 -3
  17. package/functions/protocols/pendle.helpers.cjs +1 -1
  18. package/functions/protocols/pendle.helpers.mjs +10 -11
  19. package/functions/snarkjs/common.snarkjs.cjs +1 -1
  20. package/functions/snarkjs/common.snarkjs.mjs +27 -28
  21. package/functions/staking/index.cjs +1 -1
  22. package/functions/staking/index.mjs +24 -25
  23. package/functions/utils/process.utils.cjs +1 -1
  24. package/functions/utils/process.utils.mjs +2 -3
  25. package/functions/utils/requireEnv.cjs +1 -1
  26. package/functions/utils/requireEnv.mjs +4 -5
  27. package/functions/web3/events/balanceChangedHandler.cjs +1 -1
  28. package/functions/web3/events/balanceChangedHandler.mjs +3 -4
  29. package/functions/web3/odosAPI.cjs +1 -1
  30. package/functions/web3/odosAPI.mjs +8 -9
  31. package/functions/web3/oneInchAPI.cjs +1 -1
  32. package/functions/web3/oneInchAPI.mjs +2 -3
  33. package/functions/web3/runContractFunction.cjs +1 -1
  34. package/functions/web3/runContractFunction.mjs +2 -3
  35. package/functions/web3/uniswapAPI.cjs +1 -1
  36. package/functions/web3/uniswapAPI.mjs +2 -3
  37. package/package.json +3 -1
  38. package/providers/prepareEthersHinkal.cjs +1 -1
  39. package/providers/prepareEthersHinkal.mjs +2 -4
  40. package/providers/prepareWagmiv1Hinkal.cjs +1 -1
  41. package/providers/prepareWagmiv1Hinkal.mjs +2 -4
  42. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  43. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  44. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  45. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +10 -11
  46. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  47. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +2 -2
  48. package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
  49. package/webworker/utxoWorker/utxoWorkerLogic.mjs +28 -29
  50. package/webworker/workerProxy.cjs +1 -1
  51. package/webworker/workerProxy.mjs +3 -4
  52. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  53. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),e=require("./chains.constants.cjs"),s="https://api.coingecko.com/api/v3",c="https://pro-api.coingecko.com/api/v3",i=t.default.env.COINGECKO_API_KEY,r="x-cg-pro-api-key",o=i?c:s,h=n=>`${o}/simple/price?ids=${n}&vs_currencies=USD,ETH`,l=(n,a)=>`${o}/simple/token_price/${a}?contract_addresses=${n}&vs_currencies=USD`,d=`${c}/coins/list`,I={[e.chainIds.arbMainnet]:"ethereum",[e.chainIds.localhost]:"ethereum",[e.chainIds.ethMainnet]:"ethereum",[e.chainIds.optimism]:"ethereum",[e.chainIds.avalanche]:"avalanche-2",[e.chainIds.polygon]:"matic-network",[e.chainIds.bnbMainnet]:"binancecoin",[e.chainIds.base]:"ethereum"},u=n=>{switch(e.getNonLocalhostChainId(n)){case e.chainIds.ethMainnet:return"ethereum";case e.chainIds.polygon:return"polygon-pos";case e.chainIds.bnbMainnet:return"binance-smart-chain";case e.chainIds.optimism:return"optimistic-ethereum";case e.chainIds.arbMainnet:return"arbitrum-one";case e.chainIds.avalanche:return"avalanche";case e.chainIds.base:return"base";default:return"ethereum"}},m={[e.chainIds.polygon]:"polygon-pos",[e.chainIds.arbMainnet]:"arbitrum-one",[e.chainIds.ethMainnet]:"ethereum",[e.chainIds.avalanche]:"avalanche",[e.chainIds.bnbMainnet]:"binance-smart-chain",[e.chainIds.optimism]:"optimistic-ethereum",[e.chainIds.base]:"base"};exports.COINGECKO_API_KEY=i;exports.CoinGeckoChainLabels=m;exports.coingeckoPriceUrl=h;exports.coingeckoPriceUrl2=l;exports.coingeckoTokenListUrl=d;exports.getCoingeckoIdForNativeTokens=I;exports.getCoingeckoPlatform=u;exports.proCoingeckoUrl=c;exports.proHeader=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chains.constants.cjs"),t="https://api.coingecko.com/api/v3",c="https://pro-api.coingecko.com/api/v3",o=process.env.COINGECKO_API_KEY,s="x-cg-pro-api-key",i=o?c:t,r=n=>`${i}/simple/price?ids=${n}&vs_currencies=USD,ETH`,h=(n,a)=>`${i}/simple/token_price/${a}?contract_addresses=${n}&vs_currencies=USD`,l=`${c}/coins/list`,d={[e.chainIds.arbMainnet]:"ethereum",[e.chainIds.localhost]:"ethereum",[e.chainIds.ethMainnet]:"ethereum",[e.chainIds.optimism]:"ethereum",[e.chainIds.avalanche]:"avalanche-2",[e.chainIds.polygon]:"matic-network",[e.chainIds.bnbMainnet]:"binancecoin",[e.chainIds.base]:"ethereum"},I=n=>{switch(e.getNonLocalhostChainId(n)){case e.chainIds.ethMainnet:return"ethereum";case e.chainIds.polygon:return"polygon-pos";case e.chainIds.bnbMainnet:return"binance-smart-chain";case e.chainIds.optimism:return"optimistic-ethereum";case e.chainIds.arbMainnet:return"arbitrum-one";case e.chainIds.avalanche:return"avalanche";case e.chainIds.base:return"base";default:return"ethereum"}},p={[e.chainIds.polygon]:"polygon-pos",[e.chainIds.arbMainnet]:"arbitrum-one",[e.chainIds.ethMainnet]:"ethereum",[e.chainIds.avalanche]:"avalanche",[e.chainIds.bnbMainnet]:"binance-smart-chain",[e.chainIds.optimism]:"optimistic-ethereum",[e.chainIds.base]:"base"};exports.COINGECKO_API_KEY=o;exports.CoinGeckoChainLabels=p;exports.coingeckoPriceUrl=r;exports.coingeckoPriceUrl2=h;exports.coingeckoTokenListUrl=l;exports.getCoingeckoIdForNativeTokens=d;exports.getCoingeckoPlatform=I;exports.proCoingeckoUrl=c;exports.proHeader=s;
@@ -1,6 +1,5 @@
1
- import c from "../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
2
- import { chainIds as e, getNonLocalhostChainId as r } from "./chains.constants.mjs";
3
- const i = "https://api.coingecko.com/api/v3", t = "https://pro-api.coingecko.com/api/v3", s = c.env.COINGECKO_API_KEY, p = "x-cg-pro-api-key", a = s ? t : i, l = (n) => `${a}/simple/price?ids=${n}&vs_currencies=USD,ETH`, u = (n, o) => `${a}/simple/token_price/${o}?contract_addresses=${n}&vs_currencies=USD`, b = `${t}/coins/list`, g = {
1
+ import { chainIds as e, getNonLocalhostChainId as c } from "./chains.constants.mjs";
2
+ const i = "https://api.coingecko.com/api/v3", t = "https://pro-api.coingecko.com/api/v3", r = process.env.COINGECKO_API_KEY, h = "x-cg-pro-api-key", a = r ? t : i, m = (n) => `${a}/simple/price?ids=${n}&vs_currencies=USD,ETH`, p = (n, o) => `${a}/simple/token_price/${o}?contract_addresses=${n}&vs_currencies=USD`, l = `${t}/coins/list`, u = {
4
3
  [e.arbMainnet]: "ethereum",
5
4
  [e.localhost]: "ethereum",
6
5
  [e.ethMainnet]: "ethereum",
@@ -9,8 +8,8 @@ const i = "https://api.coingecko.com/api/v3", t = "https://pro-api.coingecko.com
9
8
  [e.polygon]: "matic-network",
10
9
  [e.bnbMainnet]: "binancecoin",
11
10
  [e.base]: "ethereum"
12
- }, k = (n) => {
13
- switch (r(n)) {
11
+ }, b = (n) => {
12
+ switch (c(n)) {
14
13
  case e.ethMainnet:
15
14
  return "ethereum";
16
15
  case e.polygon:
@@ -28,7 +27,7 @@ const i = "https://api.coingecko.com/api/v3", t = "https://pro-api.coingecko.com
28
27
  default:
29
28
  return "ethereum";
30
29
  }
31
- }, C = {
30
+ }, g = {
32
31
  [e.polygon]: "polygon-pos",
33
32
  [e.arbMainnet]: "arbitrum-one",
34
33
  [e.ethMainnet]: "ethereum",
@@ -38,13 +37,13 @@ const i = "https://api.coingecko.com/api/v3", t = "https://pro-api.coingecko.com
38
37
  [e.base]: "base"
39
38
  };
40
39
  export {
41
- s as COINGECKO_API_KEY,
42
- C as CoinGeckoChainLabels,
43
- l as coingeckoPriceUrl,
44
- u as coingeckoPriceUrl2,
45
- b as coingeckoTokenListUrl,
46
- g as getCoingeckoIdForNativeTokens,
47
- k as getCoingeckoPlatform,
40
+ r as COINGECKO_API_KEY,
41
+ g as CoinGeckoChainLabels,
42
+ m as coingeckoPriceUrl,
43
+ p as coingeckoPriceUrl2,
44
+ l as coingeckoTokenListUrl,
45
+ u as getCoingeckoIdForNativeTokens,
46
+ b as getCoingeckoPlatform,
48
47
  t as proCoingeckoUrl,
49
- p as proHeader
48
+ h as proHeader
50
49
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),p=require("../functions/utils/enum.utils.cjs"),d=require("../functions/utils/process.utils.cjs");var r=(e=>(e.DEVELOPMENT="development",e.STAGING="staging",e.PLAYGROUND="playground",e.PRODUCTION="production",e))(r||{});const t={development:["localhost","192.","127."],playground:["playground"],staging:["working-branch"]};function i(e,a){return a.some(c=>e.includes(c))}const g=()=>(require("dotenv").config({path:"DOTENV_OVERRIDE"in n.default.env?n.default.env.DOTENV_OVERRIDE:void 0}),p.toEnumValue(r,n.default.env.DEPLOYMENT_MODE)||"development"),f=()=>{if(!d.isOnServer()&&typeof window>"u")return;if(d.isOnServer())return g();const e=window?.location?.host;return i(e,t.development)?"development":i(e,t.playground)?"playground":i(e,t.staging)?"staging":"production"},v=typeof n.default<"u"&&n.default.versions!=null&&n.default.versions.node!=null,y=typeof __webpack_require__<"u",o=f(),s=o==="staging",u=o==="playground",l=o==="development",m=s||l||u;exports.DEPLOYMENT_MODE=r;exports.deploymentMode=o;exports.isDevelopment=l;exports.isNode=v;exports.isNotProduction=m;exports.isPlayground=u;exports.isStaging=s;exports.isWebpack=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../functions/utils/enum.utils.cjs"),s=require("../functions/utils/process.utils.cjs");var r=(e=>(e.DEVELOPMENT="development",e.STAGING="staging",e.PLAYGROUND="playground",e.PRODUCTION="production",e))(r||{});const o={development:["localhost","192.","127."],playground:["playground"],staging:["working-branch"]};function t(e,l){return l.some(c=>e.includes(c))}const g=()=>(require("dotenv").config({path:"DOTENV_OVERRIDE"in process.env?process.env.DOTENV_OVERRIDE:void 0}),p.toEnumValue(r,process.env.DEPLOYMENT_MODE)||"development"),a=()=>{if(!s.isOnServer()&&typeof window>"u")return;if(s.isOnServer())return g();const e=window?.location?.host;return t(e,o.development)?"development":t(e,o.playground)?"playground":t(e,o.staging)?"staging":"production"},v=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,y=typeof __webpack_require__<"u",n=a(),i=n==="staging",d=n==="playground",u=n==="development",m=i||u||d;exports.DEPLOYMENT_MODE=r;exports.deploymentMode=n;exports.isDevelopment=u;exports.isNode=v;exports.isNotProduction=m;exports.isPlayground=d;exports.isStaging=i;exports.isWebpack=y;
@@ -1,35 +1,34 @@
1
- import n from "../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
2
1
  import { toEnumValue as p } from "../functions/utils/enum.utils.mjs";
3
- import { isOnServer as i } from "../functions/utils/process.utils.mjs";
4
- var d = /* @__PURE__ */ ((e) => (e.DEVELOPMENT = "development", e.STAGING = "staging", e.PLAYGROUND = "playground", e.PRODUCTION = "production", e))(d || {});
5
- const o = {
2
+ import { isOnServer as r } from "../functions/utils/process.utils.mjs";
3
+ var s = /* @__PURE__ */ ((e) => (e.DEVELOPMENT = "development", e.STAGING = "staging", e.PLAYGROUND = "playground", e.PRODUCTION = "production", e))(s || {});
4
+ const n = {
6
5
  development: ["localhost", "192.", "127."],
7
6
  playground: ["playground"],
8
7
  // The code deployed to the 'playground' branch is hosted by Netlify at 'hinkal-playground.netlify.app'
9
8
  staging: ["working-branch"]
10
9
  // The code deployed to the 'new' branch is hosted by Netlify at 'working-branch.netlify.app'
11
10
  };
12
- function t(e, s) {
13
- return s.some((u) => e.includes(u));
11
+ function o(e, i) {
12
+ return i.some((d) => e.includes(d));
14
13
  }
15
- const l = () => (require("dotenv").config({
14
+ const u = () => (require("dotenv").config({
16
15
  // allow overriding .env file path, see startServer.sh script for explenation on why it is needed
17
- path: "DOTENV_OVERRIDE" in n.env ? n.env.DOTENV_OVERRIDE : void 0
18
- }), p(d, n.env.DEPLOYMENT_MODE) || "development"), c = () => {
19
- if (!i() && typeof window > "u")
16
+ path: "DOTENV_OVERRIDE" in process.env ? process.env.DOTENV_OVERRIDE : void 0
17
+ }), p(s, process.env.DEPLOYMENT_MODE) || "development"), c = () => {
18
+ if (!r() && typeof window > "u")
20
19
  return;
21
- if (i())
22
- return l();
20
+ if (r())
21
+ return u();
23
22
  const e = window?.location?.host;
24
- return t(e, o.development) ? "development" : t(e, o.playground) ? "playground" : t(e, o.staging) ? "staging" : "production";
25
- }, R = typeof n < "u" && n.versions != null && n.versions.node != null, w = typeof __webpack_require__ < "u", r = c(), g = r === "staging", a = r === "playground", m = r === "development", D = g || m || a;
23
+ return o(e, n.development) ? "development" : o(e, n.playground) ? "playground" : o(e, n.staging) ? "staging" : "production";
24
+ }, y = typeof process < "u" && process.versions != null && process.versions.node != null, f = typeof __webpack_require__ < "u", t = c(), l = t === "staging", g = t === "playground", a = t === "development", R = l || a || g;
26
25
  export {
27
- d as DEPLOYMENT_MODE,
28
- r as deploymentMode,
29
- m as isDevelopment,
30
- R as isNode,
31
- D as isNotProduction,
32
- a as isPlayground,
33
- g as isStaging,
34
- w as isWebpack
26
+ s as DEPLOYMENT_MODE,
27
+ t as deploymentMode,
28
+ a as isDevelopment,
29
+ y as isNode,
30
+ R as isNotProduction,
31
+ g as isPlayground,
32
+ l as isStaging,
33
+ f as isWebpack
35
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),h=require("../../types/hinkal.types.cjs"),d=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),v=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),C=require("./hinkalActionBeefy.cjs"),P=require("./hinkalActionConvex.cjs"),w=require("./hinkalActionCurve.cjs"),T=require("./hinkalActionPendle.cjs"),l=require("./hinkalDeposit.cjs"),m=require("./hinkalSwap.cjs"),q=require("./hinkalWithdraw.cjs"),f=require("./resetMerkleTrees.cjs"),u=require("../merkle-tree/MerkleTree.cjs"),g=require("../../crypto/poseidon.cjs");require("circomlibjs");const S=require("../../constants/chains.constants.cjs"),p=require("../../error-handling/error-codes.constants.cjs"),E=require("../../API/callMonitor.cjs"),F=require("./hinkalActionLidoEth.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const H=require("../../API/getAxelarGasEstimate.cjs"),k=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");require("../../constants/contracts.constants.cjs");const I=require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const M=require("../transactions-manager/TransactionsManager.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");const R=require("../../functions/utils/reloadPage.cjs"),L=require("./hinkalActionVolatile.cjs"),A=require("./hinkalActionPendleLP.cjs"),W=require("../../API/getConnextReceiveFee.cjs"),x=require("./hinkalActionStake.cjs"),K=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),N=require("./hinkalPrivateWallet.cjs");class U{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;transactionsManager;utxoUtils=K.multiThreadedUtxoUtils;constructor(){this.userKeys=new o.UserKeys(void 0),this.merkleTreeHinkal=u.MerkleTree.create(g.poseidonFunction,25n,0n),this.merkleTreeAccessToken=u.MerkleTree.create(g.poseidonFunction,25n,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.transactionsManager=new M.TransactionsManager}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(){this.userKeys=new o.UserKeys(await this.getProviderAdapter().signMessage(this.signingMessage))}async initUserKeysWithPassword(e){this.userKeys=new o.UserKeys(e)}async resetMerkle(){this.isSelectedNetworkSupported()&&await f.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!S.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(p.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=h.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):c.default?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=h.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):c.default?.emit("message",t,void 0)}else await this.disconnectFromConnector(),R.reloadPage()}async monitorConnectedAddress(){E.monitor(await this.getEthereumAddress(),this.getCurrentChainId())}async getBalances(){return v.getShieldedBalance(this)}getSupportedPassportLinks(){return I.supportedPassportLinks}checkAccessToken(){return a.checkHinkalAccessToken(this)}async getAxelarEstimate(e,t,r,n){return H.getAxelarGasEstimate(e,t,r,n,this.userKeys.getAccessKey())}async getConnextReceiveFee(e,t){return W.getConnextReceiveFee(this.getCurrentChainId(),e,t)}async mintHinkalAccessToken(e){return a.mintAccessToken(this,e)}async mintHinkalAccessTokenCrossChain(e,t){return a.mintTokenCrossChain(this,e,t)}async getHinkalTreeRootHash(){return this.getContractWithFetcher(d.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){return this.getContractWithFetcher(d.ContractType.CrossChainAccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(p.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&await this.resetMerkle()}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(){return(await k.API.getIdleRelay(this.getCurrentChainId())).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return k.API}async deposit(e,t){return l.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return l.hinkalDepositForOther(this,e,t,r)}async withdraw(e,t,r,n,i=!1){return q.hinkalWithdraw(this,e,t,r,n,i)}async swap(e,t,r,n,i=!1,s=!1){return m.hinkalSwap(this,e,t,r,n,i,s)}async actionCurve(e,t,r,n,i,s=!1){return w.hinkalActionCurve(this,e,t,r,n,i,s)}async actionConvex(e,t,r,n,i=!1){return P.hinkalActionConvex(this,e,t,r,n,i)}async actionBeefy(e,t,r,n,i,s,y=!1){return C.hinkalActionBeefy(this,e,t,r,n,i,s,y)}async actionLido(e,t,r,n,i,s=!1){return F.hinkalActionLido(this,e,t,r,n,i,s)}async actionPendle(e,t,r,n,i=!1){return T.hinkalActionPendle(this,e,t,r,n,i)}async actionPendleLP(e,t,r,n,i=!1){return A.hinkalActionPendleLP(this,e,t,r,n,i)}async actionVolatile(e,t,r,n=!1){return L.hinkalActionVolatile(this,e,t,r,n)}async actionStake(e,t,r,n){return x.hinkalActionStake(this,e,t,r,n)}async actionPrivateWallet(e,t,r,n=[],i,s=!1){return N.hinkalPrivateWallet(this,e,t,r,n,i,s)}async getPendleLPClaimableParams(e,t){return A.hinkalGetPendleLPClaimableParams(this,e,t)}}exports.Hinkal=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),y=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),v=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),T=require("./hinkalSwap.cjs"),m=require("./hinkalWithdraw.cjs"),q=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("circomlibjs");const S=require("../../constants/chains.constants.cjs"),g=require("../../error-handling/error-codes.constants.cjs"),f=require("../../API/callMonitor.cjs"),E=require("./hinkalActionLidoEth.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const F=require("../../API/getAxelarGasEstimate.cjs"),p=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");require("../../constants/contracts.constants.cjs");const H=require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const I=require("../transactions-manager/TransactionsManager.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");const M=require("../../functions/utils/reloadPage.cjs"),R=require("./hinkalActionVolatile.cjs"),k=require("./hinkalActionPendleLP.cjs"),L=require("../../API/getConnextReceiveFee.cjs"),W=require("./hinkalActionStake.cjs"),K=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),N=require("./hinkalPrivateWallet.cjs");class x{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;transactionsManager;utxoUtils=K.multiThreadedUtxoUtils;constructor(){this.userKeys=new o.UserKeys(void 0),this.merkleTreeHinkal=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.merkleTreeAccessToken=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.transactionsManager=new I.TransactionsManager}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(){this.userKeys=new o.UserKeys(await this.getProviderAdapter().signMessage(this.signingMessage))}async initUserKeysWithPassword(e){this.userKeys=new o.UserKeys(e)}async resetMerkle(){this.isSelectedNetworkSupported()&&await q.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!S.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(g.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=c.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=c.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),M.reloadPage()}async monitorConnectedAddress(){f.monitor(await this.getEthereumAddress(),this.getCurrentChainId())}async getBalances(){return y.getShieldedBalance(this)}getSupportedPassportLinks(){return H.supportedPassportLinks}checkAccessToken(){return a.checkHinkalAccessToken(this)}async getAxelarEstimate(e,t,r,n){return F.getAxelarGasEstimate(e,t,r,n,this.userKeys.getAccessKey())}async getConnextReceiveFee(e,t){return L.getConnextReceiveFee(this.getCurrentChainId(),e,t)}async mintHinkalAccessToken(e){return a.mintAccessToken(this,e)}async mintHinkalAccessTokenCrossChain(e,t){return a.mintTokenCrossChain(this,e,t)}async getHinkalTreeRootHash(){return this.getContractWithFetcher(h.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){return this.getContractWithFetcher(h.ContractType.CrossChainAccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(g.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&await this.resetMerkle()}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(){return(await p.API.getIdleRelay(this.getCurrentChainId())).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return p.API}async deposit(e,t){return d.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return d.hinkalDepositForOther(this,e,t,r)}async withdraw(e,t,r,n,i=!1){return m.hinkalWithdraw(this,e,t,r,n,i)}async swap(e,t,r,n,i=!1,s=!1){return T.hinkalSwap(this,e,t,r,n,i,s)}async actionCurve(e,t,r,n,i,s=!1){return P.hinkalActionCurve(this,e,t,r,n,i,s)}async actionConvex(e,t,r,n,i=!1){return C.hinkalActionConvex(this,e,t,r,n,i)}async actionBeefy(e,t,r,n,i,s,A=!1){return v.hinkalActionBeefy(this,e,t,r,n,i,s,A)}async actionLido(e,t,r,n,i,s=!1){return E.hinkalActionLido(this,e,t,r,n,i,s)}async actionPendle(e,t,r,n,i=!1){return w.hinkalActionPendle(this,e,t,r,n,i)}async actionPendleLP(e,t,r,n,i=!1){return k.hinkalActionPendleLP(this,e,t,r,n,i)}async actionVolatile(e,t,r,n=!1){return R.hinkalActionVolatile(this,e,t,r,n)}async actionStake(e,t,r,n){return W.hinkalActionStake(this,e,t,r,n)}async actionPrivateWallet(e,t,r,n=[],i,s=!1){return N.hinkalPrivateWallet(this,e,t,r,n,i,s)}async getPendleLPClaimableParams(e,t){return k.hinkalGetPendleLPClaimableParams(this,e,t)}}exports.Hinkal=x;
@@ -1,48 +1,47 @@
1
- import o from "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
2
- import { EventType as c } from "../../types/hinkal.types.mjs";
3
- import { ContractType as h } from "../../types/ethereum-network.types.mjs";
4
- import { checkHinkalAccessToken as u, mintAccessToken as k, mintTokenCrossChain as A } from "../../functions/web3/functionCalls/accessTokenCalls.mjs";
5
- import { getShieldedBalance as v } from "../../functions/web3/events/getShieldedBalance.mjs";
1
+ import { EventType as o } from "../../types/hinkal.types.mjs";
2
+ import { ContractType as c } from "../../types/ethereum-network.types.mjs";
3
+ import { checkHinkalAccessToken as g, mintAccessToken as u, mintTokenCrossChain as k } from "../../functions/web3/functionCalls/accessTokenCalls.mjs";
4
+ import { getShieldedBalance as A } from "../../functions/web3/events/getShieldedBalance.mjs";
6
5
  import { UserKeys as s } from "../crypto-keys/keys.mjs";
7
- import { hinkalActionBeefy as y } from "./hinkalActionBeefy.mjs";
8
- import { hinkalActionConvex as f } from "./hinkalActionConvex.mjs";
9
- import { hinkalActionCurve as C } from "./hinkalActionCurve.mjs";
10
- import { hinkalActionPendle as w } from "./hinkalActionPendle.mjs";
11
- import { hinkalDeposit as P, hinkalDepositForOther as T } from "./hinkalDeposit.mjs";
12
- import { hinkalSwap as S } from "./hinkalSwap.mjs";
13
- import { hinkalWithdraw as E } from "./hinkalWithdraw.mjs";
14
- import { resetMerkleTrees as H } from "./resetMerkleTrees.mjs";
15
- import { MerkleTree as d } from "../merkle-tree/MerkleTree.mjs";
16
- import { poseidonFunction as p } from "../../crypto/poseidon.mjs";
6
+ import { hinkalActionBeefy as v } from "./hinkalActionBeefy.mjs";
7
+ import { hinkalActionConvex as y } from "./hinkalActionConvex.mjs";
8
+ import { hinkalActionCurve as f } from "./hinkalActionCurve.mjs";
9
+ import { hinkalActionPendle as C } from "./hinkalActionPendle.mjs";
10
+ import { hinkalDeposit as w, hinkalDepositForOther as P } from "./hinkalDeposit.mjs";
11
+ import { hinkalSwap as T } from "./hinkalSwap.mjs";
12
+ import { hinkalWithdraw as S } from "./hinkalWithdraw.mjs";
13
+ import { resetMerkleTrees as E } from "./resetMerkleTrees.mjs";
14
+ import { MerkleTree as h } from "../merkle-tree/MerkleTree.mjs";
15
+ import { poseidonFunction as d } from "../../crypto/poseidon.mjs";
17
16
  import "circomlibjs";
18
- import { networkRegistry as F } from "../../constants/chains.constants.mjs";
19
- import { transactionErrorCodes as l } from "../../error-handling/error-codes.constants.mjs";
20
- import { monitor as I } from "../../API/callMonitor.mjs";
21
- import { hinkalActionLido as R } from "./hinkalActionLidoEth.mjs";
17
+ import { networkRegistry as H } from "../../constants/chains.constants.mjs";
18
+ import { transactionErrorCodes as p } from "../../error-handling/error-codes.constants.mjs";
19
+ import { monitor as F } from "../../API/callMonitor.mjs";
20
+ import { hinkalActionLido as I } from "./hinkalActionLidoEth.mjs";
22
21
  import "../../constants/vite.constants.mjs";
23
22
  import "axios";
24
23
  import "../../constants/coingecko.constants.mjs";
25
- import { getAxelarGasEstimate as L } from "../../API/getAxelarGasEstimate.mjs";
26
- import { API as m } from "../../API/API.mjs";
24
+ import { getAxelarGasEstimate as R } from "../../API/getAxelarGasEstimate.mjs";
25
+ import { API as l } from "../../API/API.mjs";
27
26
  import "ethers";
28
27
  import "../../types/curve.types.mjs";
29
28
  import "../../constants/contracts.constants.mjs";
30
- import { supportedPassportLinks as M } from "../../constants/kyc.constants.mjs";
29
+ import { supportedPassportLinks as L } from "../../constants/kyc.constants.mjs";
31
30
  import "../../constants/axelar.constants.mjs";
32
31
  import "../../constants/rewards.constants.mjs";
33
32
  import "../../constants/reorg-depths.constants.mjs";
34
- import { TransactionsManager as W } from "../transactions-manager/TransactionsManager.mjs";
33
+ import { TransactionsManager as M } from "../transactions-manager/TransactionsManager.mjs";
35
34
  import "../../functions/utils/external-action.utils.mjs";
36
35
  import "../../types/circom-data.types.mjs";
37
36
  import "../../types/transactions.types.mjs";
38
- import { reloadPage as N } from "../../functions/utils/reloadPage.mjs";
39
- import { hinkalActionVolatile as K } from "./hinkalActionVolatile.mjs";
40
- import { hinkalActionPendleLP as O, hinkalGetPendleLPClaimableParams as x } from "./hinkalActionPendleLP.mjs";
41
- import { getConnextReceiveFee as B } from "../../API/getConnextReceiveFee.mjs";
42
- import { hinkalActionStake as U } from "./hinkalActionStake.mjs";
43
- import { multiThreadedUtxoUtils as b } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
44
- import { hinkalPrivateWallet as D } from "./hinkalPrivateWallet.mjs";
45
- class We {
37
+ import { reloadPage as W } from "../../functions/utils/reloadPage.mjs";
38
+ import { hinkalActionVolatile as N } from "./hinkalActionVolatile.mjs";
39
+ import { hinkalActionPendleLP as K, hinkalGetPendleLPClaimableParams as O } from "./hinkalActionPendleLP.mjs";
40
+ import { getConnextReceiveFee as x } from "../../API/getConnextReceiveFee.mjs";
41
+ import { hinkalActionStake as B } from "./hinkalActionStake.mjs";
42
+ import { multiThreadedUtxoUtils as U } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
43
+ import { hinkalPrivateWallet as b } from "./hinkalPrivateWallet.mjs";
44
+ class Le {
46
45
  providerAdapter;
47
46
  userKeys;
48
47
  signingMessage = "Login to Hinkal Protocol";
@@ -54,9 +53,9 @@ class We {
54
53
  nullifierSnapshotService;
55
54
  accessTokenSnapshotService;
56
55
  transactionsManager;
57
- utxoUtils = b;
56
+ utxoUtils = U;
58
57
  constructor() {
59
- this.userKeys = new s(void 0), this.merkleTreeHinkal = d.create(p, 25n, 0n), this.merkleTreeAccessToken = d.create(p, 25n, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.transactionsManager = new W();
58
+ this.userKeys = new s(void 0), this.merkleTreeHinkal = h.create(d, 25n, 0n), this.merkleTreeAccessToken = h.create(d, 25n, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.transactionsManager = new M();
60
59
  }
61
60
  async initProviderAdapter(e, t) {
62
61
  await this.updateProviderAdapter(t), this.providerAdapter?.initConnector(e);
@@ -70,7 +69,7 @@ class We {
70
69
  this.userKeys = new s(e);
71
70
  }
72
71
  async resetMerkle() {
73
- this.isSelectedNetworkSupported() && await H(this);
72
+ this.isSelectedNetworkSupported() && await E(this);
74
73
  }
75
74
  getProviderAdapter() {
76
75
  if (!this.providerAdapter)
@@ -102,13 +101,13 @@ class We {
102
101
  return this.getProviderAdapter().getContractWithFetcherForEthereum(e, t);
103
102
  }
104
103
  isSelectedNetworkSupported() {
105
- return !!F[this.getCurrentChainId()];
104
+ return !!H[this.getCurrentChainId()];
106
105
  }
107
106
  async switchNetwork(e) {
108
107
  try {
109
108
  await this.getProviderAdapter().switchNetwork(e);
110
109
  } catch {
111
- throw new Error(l.FAILED_TO_SWITCH_NETWORKS);
110
+ throw new Error(p.FAILED_TO_SWITCH_NETWORKS);
112
111
  }
113
112
  }
114
113
  getCurrentChainId() {
@@ -148,31 +147,31 @@ class We {
148
147
  }
149
148
  async onAccountChanged() {
150
149
  await this.getProviderAdapter().onAccountChanged();
151
- const e = c.AccountChanged;
152
- typeof document < "u" ? document?.dispatchEvent(new Event(e)) : o?.emit("message", e, void 0);
150
+ const e = o.AccountChanged;
151
+ typeof document < "u" ? document?.dispatchEvent(new Event(e)) : process?.emit("message", e, void 0);
153
152
  }
154
153
  async onChainChanged(e) {
155
154
  if (e) {
156
155
  await this.getProviderAdapter().onChainChanged(e);
157
- const t = c.NetworkChange;
158
- typeof document < "u" ? document.dispatchEvent(new Event(t)) : o?.emit("message", t, void 0);
156
+ const t = o.NetworkChange;
157
+ typeof document < "u" ? document.dispatchEvent(new Event(t)) : process?.emit("message", t, void 0);
159
158
  } else
160
- await this.disconnectFromConnector(), N();
159
+ await this.disconnectFromConnector(), W();
161
160
  }
162
161
  async monitorConnectedAddress() {
163
- I(await this.getEthereumAddress(), this.getCurrentChainId());
162
+ F(await this.getEthereumAddress(), this.getCurrentChainId());
164
163
  }
165
164
  async getBalances() {
166
- return v(this);
165
+ return A(this);
167
166
  }
168
167
  getSupportedPassportLinks() {
169
- return M;
168
+ return L;
170
169
  }
171
170
  checkAccessToken() {
172
- return u(this);
171
+ return g(this);
173
172
  }
174
173
  async getAxelarEstimate(e, t, r, i) {
175
- return L(
174
+ return R(
176
175
  e,
177
176
  t,
178
177
  r,
@@ -181,23 +180,23 @@ class We {
181
180
  );
182
181
  }
183
182
  async getConnextReceiveFee(e, t) {
184
- return B(this.getCurrentChainId(), e, t);
183
+ return x(this.getCurrentChainId(), e, t);
185
184
  }
186
185
  async mintHinkalAccessToken(e) {
187
- return k(this, e);
186
+ return u(this, e);
188
187
  }
189
188
  async mintHinkalAccessTokenCrossChain(e, t) {
190
- return A(this, e, t);
189
+ return k(this, e, t);
191
190
  }
192
191
  async getHinkalTreeRootHash() {
193
- return this.getContractWithFetcher(h.HinkalContract).getRootHash();
192
+ return this.getContractWithFetcher(c.HinkalContract).getRootHash();
194
193
  }
195
194
  async getAccessTokenTreeRootHash() {
196
- return this.getContractWithFetcher(h.CrossChainAccessTokenContract).getRootHash();
195
+ return this.getContractWithFetcher(c.CrossChainAccessTokenContract).getRootHash();
197
196
  }
198
197
  async resetMerkleTreesIfNecessary() {
199
198
  if (!this.isSelectedNetworkSupported())
200
- throw new Error(l.UNSUPPORTED_NETWORK);
199
+ throw new Error(p.UNSUPPORTED_NETWORK);
201
200
  const [e, t] = await Promise.all([
202
201
  this.getHinkalTreeRootHash(),
203
202
  this.getAccessTokenTreeRootHash()
@@ -215,7 +214,7 @@ class We {
215
214
  return this.getProviderAdapter().getAddress();
216
215
  }
217
216
  async getRandomRelay() {
218
- return (await m.getIdleRelay(this.getCurrentChainId())).relay;
217
+ return (await l.getIdleRelay(this.getCurrentChainId())).relay;
219
218
  }
220
219
  getGasPrice() {
221
220
  if (!this.providerAdapter?.chainId)
@@ -223,22 +222,22 @@ class We {
223
222
  return this.providerAdapter.getGasPrice();
224
223
  }
225
224
  getAPI() {
226
- return m;
225
+ return l;
227
226
  }
228
227
  async deposit(e, t) {
229
- return P(this, e, t);
228
+ return w(this, e, t);
230
229
  }
231
230
  async depositForOther(e, t, r) {
232
- return T(this, e, t, r);
231
+ return P(this, e, t, r);
233
232
  }
234
233
  // async transfer(token: ERC20Token, amount: bigint, recipientAddress: string): Promise<ethers.ContractTransaction> {
235
234
  // return hinkalTransfer(this, token, amount, recipientAddress);
236
235
  // }
237
236
  async withdraw(e, t, r, i, n = !1) {
238
- return E(this, e, t, r, i, n);
237
+ return S(this, e, t, r, i, n);
239
238
  }
240
239
  async swap(e, t, r, i, n = !1, a = !1) {
241
- return S(
240
+ return T(
242
241
  this,
243
242
  e,
244
243
  t,
@@ -249,13 +248,13 @@ class We {
249
248
  );
250
249
  }
251
250
  async actionCurve(e, t, r, i, n, a = !1) {
252
- return C(this, e, t, r, i, n, a);
251
+ return f(this, e, t, r, i, n, a);
253
252
  }
254
253
  async actionConvex(e, t, r, i, n = !1) {
255
- return f(this, e, t, r, i, n);
254
+ return y(this, e, t, r, i, n);
256
255
  }
257
- async actionBeefy(e, t, r, i, n, a, g = !1) {
258
- return y(
256
+ async actionBeefy(e, t, r, i, n, a, m = !1) {
257
+ return v(
259
258
  this,
260
259
  e,
261
260
  t,
@@ -263,17 +262,17 @@ class We {
263
262
  i,
264
263
  n,
265
264
  a,
266
- g
265
+ m
267
266
  );
268
267
  }
269
268
  async actionLido(e, t, r, i, n, a = !1) {
270
- return R(this, e, t, r, i, n, a);
269
+ return I(this, e, t, r, i, n, a);
271
270
  }
272
271
  async actionPendle(e, t, r, i, n = !1) {
273
- return w(this, e, t, r, i, n);
272
+ return C(this, e, t, r, i, n);
274
273
  }
275
274
  async actionPendleLP(e, t, r, i, n = !1) {
276
- return O(
275
+ return K(
277
276
  this,
278
277
  e,
279
278
  t,
@@ -283,18 +282,18 @@ class We {
283
282
  );
284
283
  }
285
284
  async actionVolatile(e, t, r, i = !1) {
286
- return K(this, e, t, r, i);
285
+ return N(this, e, t, r, i);
287
286
  }
288
287
  async actionStake(e, t, r, i) {
289
- return U(this, e, t, r, i);
288
+ return B(this, e, t, r, i);
290
289
  }
291
290
  async actionPrivateWallet(e, t, r, i = [], n, a = !1) {
292
- return D(this, e, t, r, i, n, a);
291
+ return b(this, e, t, r, i, n, a);
293
292
  }
294
293
  async getPendleLPClaimableParams(e, t) {
295
- return x(this, e, t);
294
+ return O(this, e, t);
296
295
  }
297
296
  }
298
297
  export {
299
- We as Hinkal
298
+ Le as Hinkal
300
299
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const C=require("../../functions/snarkjs/constructEmporiumProof.cjs"),P=require("../../functions/pre-transaction/processAmountChanges.cjs"),R=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),I=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),T=async(e,o,r,d,q=[],p,y=!1)=>{const a=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:a,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],i=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);i.push(E)}const n=await e.getRandomRelay();if(!n)throw Error(x.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{contractData:g}=f.networkRegistry[e.getCurrentChainId()],{emporiumAddress:c}=g;if(!c)throw Error("No Emporium Address Provided");const{zkCallData:u,circomData:l,dimData:m}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,i,e.userKeys,r.length,s[0].length,c,q,n,e.getCurrentChainId(),d,a,p);return y?await U.estimateGasRelayer(e,u,m,l):await I.transactCallRelayer(e.getCurrentChainId(),u,m,l)};exports.hinkalPrivateWallet=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const C=require("../../functions/snarkjs/constructEmporiumProof.cjs"),P=require("../../functions/pre-transaction/processAmountChanges.cjs"),R=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),I=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),T=async(e,o,r,d,q=[],p,y=!1)=>{const a=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:a,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],i=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);i.push(E)}const n=await e.getRandomRelay();if(!n)throw Error(x.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{contractData:g}=f.networkRegistry[e.getCurrentChainId()],{emporiumAddress:c}=g;if(!c)throw Error("No Emporium Address Provided");const{zkCallData:u,circomData:l,dimData:m}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,i,e.userKeys,r.length,s[0].length,c,q,n,e.getCurrentChainId(),d,a,p);return y?await U.estimateGasRelayer(e,u,m,l):await I.transactCallRelayer(e.getCurrentChainId(),u,m,l)};exports.hinkalPrivateWallet=T;
@@ -3,7 +3,6 @@ import { transactionErrorCodes as A } from "../../error-handling/error-codes.con
3
3
  import "ethers";
4
4
  import "axios";
5
5
  import "../../constants/vite.constants.mjs";
6
- import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
7
6
  import "../../types/circom-data.types.mjs";
8
7
  import { ExternalActionId as w } from "../../types/external-action.types.mjs";
9
8
  import "../../types/transactions.types.mjs";
@@ -16,7 +15,7 @@ import { outputUtxoProcessing as C } from "../../functions/pre-transaction/outpu
16
15
  import { addPaddingToUtxos as I } from "../../functions/web3/events/getShieldedBalance.mjs";
17
16
  import { estimateGasRelayer as P } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
18
17
  import { transactCallRelayer as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
19
- const Q = async (t, e, o, u, d = [], l, E = !1) => {
18
+ const M = async (t, e, o, u, d = [], l, E = !1) => {
20
19
  const m = e.map((r) => 0n);
21
20
  o = U({
22
21
  erc20Addresses: e,
@@ -33,10 +32,10 @@ const Q = async (t, e, o, u, d = [], l, E = !1) => {
33
32
  const s = await t.getRandomRelay();
34
33
  if (!s)
35
34
  throw Error(A.RELAYER_NOT_AVAILABLE);
36
- const { contractData: x } = g[t.getCurrentChainId()], { emporiumAddress: p } = x;
37
- if (!p)
35
+ const { contractData: x } = g[t.getCurrentChainId()], { emporiumAddress: n } = x;
36
+ if (!n)
38
37
  throw Error("No Emporium Address Provided");
39
- const { zkCallData: n, circomData: c, dimData: f } = await R(
38
+ const { zkCallData: p, circomData: c, dimData: f } = await R(
40
39
  t.merkleTreeHinkal,
41
40
  t.merkleTreeAccessToken,
42
41
  i,
@@ -44,7 +43,7 @@ const Q = async (t, e, o, u, d = [], l, E = !1) => {
44
43
  t.userKeys,
45
44
  o.length,
46
45
  i[0].length,
47
- p,
46
+ n,
48
47
  d,
49
48
  s,
50
49
  t.getCurrentChainId(),
@@ -52,8 +51,8 @@ const Q = async (t, e, o, u, d = [], l, E = !1) => {
52
51
  m,
53
52
  l
54
53
  );
55
- return E ? await P(t, n, f, c) : await T(t.getCurrentChainId(), n, f, c);
54
+ return E ? await P(t, p, f, c) : await T(t.getCurrentChainId(), p, f, c);
56
55
  };
57
56
  export {
58
- Q as hinkalPrivateWallet
57
+ M as hinkalPrivateWallet
59
58
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs"),r=require("ethers"),y=require("libsodium-wrappers"),p=require("../utxo/Utxo.cjs"),u=require("./keys.cjs");(async()=>await y.ready)();const h=(e,i)=>{const n=[t.from(r.ethers.utils.hexlify(i?0n:e.amount)),t.from(r.ethers.utils.hexlify(e.erc20TokenAddress)),t.from(r.ethers.utils.hexlify(e.randomization)),t.from(e.getStealthAddress()),t.from(r.ethers.utils.hexlify(BigInt(e.timeStamp)))];e.tokenId>0&&n.push(t.from(r.ethers.utils.hexlify(e.tokenId)));const a=t.concat(n);return y.crypto_box_seal(a,r.ethers.utils.arrayify(e.getEncryptionKey()))},f=(e,i)=>{const{publicKey:n,privateKey:a}=u.UserKeys.getEncryptionKeyPair(i.getShieldedPrivateKey()),d=y.crypto_box_seal_open(e,r.ethers.utils.arrayify(n),r.ethers.utils.arrayify(a)),s=t.from(d).toString("utf-8").split("0x").filter(o=>o.length!==0).map((o,l)=>{let c;return[0,2,4,5].includes(l)?c=BigInt(`0x${o}`):[1,3].includes(l)&&(c=`0x${o}`),c});return{amount:s[0],erc20TokenAddress:s[1],randomization:s[2],stealthAddress:s[3],shieldedPrivateKey:i.getShieldedPrivateKey(),timeStamp:s[4].toString(),tokenId:s[5]?Number(s[5]):0}},m=(e,i)=>new p.Utxo(f(e,i));exports.decryptUtxo=m;exports.decryptUtxoConstructorArgs=f;exports.encryptUtxo=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),f=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),u=require("./keys.cjs");(async()=>await f.ready)();const p=(e,s)=>{const i=[Buffer.from(t.ethers.utils.hexlify(s?0n:e.amount)),Buffer.from(t.ethers.utils.hexlify(e.erc20TokenAddress)),Buffer.from(t.ethers.utils.hexlify(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(t.ethers.utils.hexlify(BigInt(e.timeStamp)))];e.tokenId>0&&i.push(Buffer.from(t.ethers.utils.hexlify(e.tokenId)));const n=Buffer.concat(i);return f.crypto_box_seal(n,t.ethers.utils.arrayify(e.getEncryptionKey()))},d=(e,s)=>{const{publicKey:i,privateKey:n}=u.UserKeys.getEncryptionKeyPair(s.getShieldedPrivateKey()),c=f.crypto_box_seal_open(e,t.ethers.utils.arrayify(i),t.ethers.utils.arrayify(n)),r=Buffer.from(c).toString("utf-8").split("0x").filter(o=>o.length!==0).map((o,y)=>{let a;return[0,2,4,5].includes(y)?a=BigInt(`0x${o}`):[1,3].includes(y)&&(a=`0x${o}`),a});return{amount:r[0],erc20TokenAddress:r[1],randomization:r[2],stealthAddress:r[3],shieldedPrivateKey:s.getShieldedPrivateKey(),timeStamp:r[4].toString(),tokenId:r[5]?Number(r[5]):0}},h=(e,s)=>new l.Utxo(d(e,s));exports.decryptUtxo=h;exports.decryptUtxoConstructorArgs=d;exports.encryptUtxo=p;
@@ -1,42 +1,41 @@
1
- import e from "../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
2
- import { ethers as r } from "ethers";
3
- import f from "libsodium-wrappers";
4
- import { Utxo as l } from "../utxo/Utxo.mjs";
5
- import { UserKeys as m } from "./keys.mjs";
6
- (async () => await f.ready)();
7
- const S = (t, o) => {
8
- const n = [
9
- e.from(r.utils.hexlify(o ? 0n : t.amount)),
10
- e.from(r.utils.hexlify(t.erc20TokenAddress)),
11
- e.from(r.utils.hexlify(t.randomization)),
12
- e.from(t.getStealthAddress()),
13
- e.from(r.utils.hexlify(BigInt(t.timeStamp)))
1
+ import { ethers as t } from "ethers";
2
+ import a from "libsodium-wrappers";
3
+ import { Utxo as d } from "../utxo/Utxo.mjs";
4
+ import { UserKeys as l } from "./keys.mjs";
5
+ (async () => await a.ready)();
6
+ const B = (e, i) => {
7
+ const o = [
8
+ Buffer.from(t.utils.hexlify(i ? 0n : e.amount)),
9
+ Buffer.from(t.utils.hexlify(e.erc20TokenAddress)),
10
+ Buffer.from(t.utils.hexlify(e.randomization)),
11
+ Buffer.from(e.getStealthAddress()),
12
+ Buffer.from(t.utils.hexlify(BigInt(e.timeStamp)))
14
13
  ];
15
- t.tokenId > 0 && n.push(e.from(r.utils.hexlify(t.tokenId)));
16
- const a = e.concat(n);
17
- return f.crypto_box_seal(a, r.utils.arrayify(t.getEncryptionKey()));
18
- }, p = (t, o) => {
19
- const { publicKey: n, privateKey: a } = m.getEncryptionKeyPair(o.getShieldedPrivateKey()), c = f.crypto_box_seal_open(
20
- t,
21
- r.utils.arrayify(n),
22
- r.utils.arrayify(a)
23
- ), i = e.from(c).toString("utf-8").split("0x").filter((s) => s.length !== 0).map((s, d) => {
24
- let y;
25
- return [0, 2, 4, 5].includes(d) ? y = BigInt(`0x${s}`) : [1, 3].includes(d) && (y = `0x${s}`), y;
14
+ e.tokenId > 0 && o.push(Buffer.from(t.utils.hexlify(e.tokenId)));
15
+ const n = Buffer.concat(o);
16
+ return a.crypto_box_seal(n, t.utils.arrayify(e.getEncryptionKey()));
17
+ }, m = (e, i) => {
18
+ const { publicKey: o, privateKey: n } = l.getEncryptionKeyPair(i.getShieldedPrivateKey()), y = a.crypto_box_seal_open(
19
+ e,
20
+ t.utils.arrayify(o),
21
+ t.utils.arrayify(n)
22
+ ), r = Buffer.from(y).toString("utf-8").split("0x").filter((f) => f.length !== 0).map((f, c) => {
23
+ let s;
24
+ return [0, 2, 4, 5].includes(c) ? s = BigInt(`0x${f}`) : [1, 3].includes(c) && (s = `0x${f}`), s;
26
25
  });
27
26
  return {
28
- amount: i[0],
29
- erc20TokenAddress: i[1],
30
- randomization: i[2],
31
- stealthAddress: i[3],
32
- shieldedPrivateKey: o.getShieldedPrivateKey(),
33
- timeStamp: i[4].toString(),
34
- tokenId: i[5] ? Number(i[5]) : 0
27
+ amount: r[0],
28
+ erc20TokenAddress: r[1],
29
+ randomization: r[2],
30
+ stealthAddress: r[3],
31
+ shieldedPrivateKey: i.getShieldedPrivateKey(),
32
+ timeStamp: r[4].toString(),
33
+ tokenId: r[5] ? Number(r[5]) : 0
35
34
  // tokenId
36
35
  };
37
- }, b = (t, o) => new l(p(t, o));
36
+ }, x = (e, i) => new d(m(e, i));
38
37
  export {
39
- b as decryptUtxo,
40
- p as decryptUtxoConstructorArgs,
41
- S as encryptUtxo
38
+ x as decryptUtxo,
39
+ m as decryptUtxoConstructorArgs,
40
+ B as encryptUtxo
42
41
  };