@hinkal/common 0.1.14 → 0.1.16
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/crypto/preProcessing.cjs +1 -1
- package/crypto/preProcessing.mjs +7 -6
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +3 -2
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +3 -2
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +8 -9
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.mjs +6 -7
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +3 -2
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -10
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +3 -2
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +3 -2
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +3 -2
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +3 -2
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +8 -7
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +1 -1
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +6 -5
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -6
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +7 -6
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +3 -2
- package/package.json +1 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +3 -4
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +3 -4
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
package/crypto/preProcessing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./babyJub.cjs"),i=require("./poseidon.cjs"),o=require("buffer"),s=require("process");let e=!1;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./babyJub.cjs"),i=require("./poseidon.cjs"),o=require("libsodium-wrappers"),n=require("buffer"),s=require("process");let e=!1;const t=async()=>{e||(typeof window<"u"&&(window.global=window,window.Buffer=n.Buffer,window.process=s),await o.ready,await i.poseidonHolder.init(),await r.jubHolder.init(),e=!0)};exports.preProcessing=t;
|
package/crypto/preProcessing.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jubHolder as r } from "./babyJub.mjs";
|
|
2
|
-
import { poseidonHolder as
|
|
3
|
-
import
|
|
4
|
-
import t from "
|
|
2
|
+
import { poseidonHolder as i } from "./poseidon.mjs";
|
|
3
|
+
import e from "libsodium-wrappers";
|
|
4
|
+
import { Buffer as t } from "buffer";
|
|
5
|
+
import d from "process";
|
|
5
6
|
let o = !1;
|
|
6
|
-
const
|
|
7
|
-
o || (typeof window < "u" && (window.Buffer =
|
|
7
|
+
const m = async () => {
|
|
8
|
+
o || (typeof window < "u" && (window.global = window, window.Buffer = t, window.process = d), await e.ready, await i.init(), await r.init(), o = !0);
|
|
8
9
|
};
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
m as preProcessing
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
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");require("buffer");require("process");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
|
+
"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");require("libsodium-wrappers");require("buffer");require("process");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;
|
|
@@ -14,6 +14,7 @@ import { resetMerkleTrees as E } from "./resetMerkleTrees.mjs";
|
|
|
14
14
|
import { MerkleTree as h } from "../merkle-tree/MerkleTree.mjs";
|
|
15
15
|
import { poseidonFunction as d } from "../../crypto/poseidon.mjs";
|
|
16
16
|
import "circomlibjs";
|
|
17
|
+
import "libsodium-wrappers";
|
|
17
18
|
import "buffer";
|
|
18
19
|
import "process";
|
|
19
20
|
import { networkRegistry as H } from "../../constants/chains.constants.mjs";
|
|
@@ -43,7 +44,7 @@ import { getConnextReceiveFee as x } from "../../API/getConnextReceiveFee.mjs";
|
|
|
43
44
|
import { hinkalActionStake as B } from "./hinkalActionStake.mjs";
|
|
44
45
|
import { multiThreadedUtxoUtils as U } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
|
|
45
46
|
import { hinkalPrivateWallet as b } from "./hinkalPrivateWallet.mjs";
|
|
46
|
-
class
|
|
47
|
+
class Ne {
|
|
47
48
|
providerAdapter;
|
|
48
49
|
userKeys;
|
|
49
50
|
signingMessage = "Login to Hinkal Protocol";
|
|
@@ -297,5 +298,5 @@ class We {
|
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
300
|
export {
|
|
300
|
-
|
|
301
|
+
Ne as Hinkal
|
|
301
302
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const g=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const S=require("../../types/hinkal.stake.types.cjs");require("ethers");const j=require("../crypto-keys/keys.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const g=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const S=require("../../types/hinkal.stake.types.cjs");require("ethers");const j=require("../crypto-keys/keys.cjs");require("libsodium-wrappers");const w=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),z=async(t,x,o,s,i)=>{const C=await t.getEthereumAddress(),a=f.getERC20Token(x[0],t.getCurrentChainId());if(!a)throw Error("Deposit Action: No Token Found");const u=s===S.HinkalStakeMode.Stake,n=s===S.HinkalStakeMode.Unstake,{symbol:E}=a;console.log(`${s} token ${E} Start`);const{erc20TokenAddress:H}=a,r=[...await N.addPaddingToUtxos(t,x,o,2,void 0,s!==S.HinkalStakeMode.Deposit)];if(u||n){r[0][0]=y.Utxo.createFrom(r[0][0],{amount:o[0]*(u?1n:-1n),isStakeOrUnstakeInput:!0});for(let e=0;e<r.length;e+=1)for(let c=0;c<r[e].length;c+=1)e===0&&c===0||(r[e][c]=y.Utxo.createFrom(r[e][c],{amount:0n}))}const{outputUtxos:P}=O.outputUtxoProcessing(t.userKeys,r[0],o[0]),d=[P.map(e=>y.Utxo.createFrom(e,{isStake:u,isUnstakeOutput:n}))];n&&(d[0][0]=y.Utxo.createFrom(d[0][0],{amount:0n,isUnstakeOutput:n}));const h=[!1],l=B.randomBigInt(30),K=j.UserKeys.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()),D=p.encryptStake(l,i,T.ownerPublicKey),F=p.encryptStake(l,i,K.publicKey),I=n?0n:p.createStakeCommitment(!0,i,l,H,o[0],BigInt(d[0][0].timeStamp)),v=u?0:1,W=p.encodeHStakeMetadata(v,I,C,D,F),q=t.getContractWithSigner(g.ContractType.HinkalWrapper2),k=t.getContractWithSigner(g.ContractType.HinkalStakeExternalAction);console.log("external action address",k.address);const{zkCallData:A,dimData:U,circomData:m}=await _.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,r,d,t.userKeys,"swapperME1x2x1",M.ExternalActionId.HinkalStake,k.address,W,T.zeroAddress,t.getCurrentChainId(),h,void 0,void 0,{stakedTokenRecipient:i,stakeBlinding:l,mode:s,depositorAddress:C});if(console.log(m),n){const e=f.getHToken(a,t.getCurrentChainId());if(!e)throw new Error("hToken not found");const b=(await t.getContractWithFetcher(g.ContractType.HToken,e.erc20TokenAddress).previewWithdraw(-o[0])).toBigInt();return w.transactCallDirect(t,b,e,A,m,U,k,q)}return w.transactCallDirect(t,o[0],a,A,m,U,k,q)};exports.hinkalActionStake=z;
|
|
@@ -14,7 +14,7 @@ import "../../types/curve.types.mjs";
|
|
|
14
14
|
import { HinkalStakeMode as g } from "../../types/hinkal.stake.types.mjs";
|
|
15
15
|
import "ethers";
|
|
16
16
|
import { UserKeys as J } from "../crypto-keys/keys.mjs";
|
|
17
|
-
import "
|
|
17
|
+
import "libsodium-wrappers";
|
|
18
18
|
import { transactCallDirect as w } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
19
19
|
const ut = async (t, y, e, a, c) => {
|
|
20
20
|
const A = await t.getEthereumAddress(), s = N(y[0], t.getCurrentChainId());
|
|
@@ -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("../../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("buffer");require("process");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,
|
|
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("libsodium-wrappers");require("buffer");require("process");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,m,d=[],p,y=!1)=>{const i=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:i,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],a=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);a.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:q}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,a,e.userKeys,r.length,s[0].length,c,d,n,e.getCurrentChainId(),m,i,p);return y?await U.estimateGasRelayer(e,u,q,l):await I.transactCallRelayer(e.getCurrentChainId(),u,q,l)};exports.hinkalPrivateWallet=T;
|
|
@@ -8,6 +8,7 @@ import { ExternalActionId as w } from "../../types/external-action.types.mjs";
|
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
10
|
import "circomlibjs";
|
|
11
|
+
import "libsodium-wrappers";
|
|
11
12
|
import "buffer";
|
|
12
13
|
import "process";
|
|
13
14
|
import "../../constants/reorg-depths.constants.mjs";
|
|
@@ -17,7 +18,7 @@ import { outputUtxoProcessing as C } from "../../functions/pre-transaction/outpu
|
|
|
17
18
|
import { addPaddingToUtxos as I } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
18
19
|
import { estimateGasRelayer as P } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
19
20
|
import { transactCallRelayer as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
20
|
-
const
|
|
21
|
+
const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
21
22
|
const m = e.map((r) => 0n);
|
|
22
23
|
o = U({
|
|
23
24
|
erc20Addresses: e,
|
|
@@ -56,5 +57,5 @@ const S = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
56
57
|
return E ? await P(t, n, f, c) : await T(t.getCurrentChainId(), n, f, c);
|
|
57
58
|
};
|
|
58
59
|
export {
|
|
59
|
-
|
|
60
|
+
X as hinkalPrivateWallet
|
|
60
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),y=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),u=require("./keys.cjs"),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 y.crypto_box_seal(n,t.ethers.utils.arrayify(e.getEncryptionKey()))},d=(e,s)=>{const{publicKey:i,privateKey:n}=u.UserKeys.getEncryptionKeyPair(s.getShieldedPrivateKey()),c=y.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,a)=>{let f;return[0,2,4,5].includes(a)?f=BigInt(`0x${o}`):[1,3].includes(a)&&(f=`0x${o}`),f});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,8 +1,7 @@
|
|
|
1
1
|
import { ethers as t } from "ethers";
|
|
2
|
-
import
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { UserKeys as
|
|
5
|
-
(async () => await a.ready)();
|
|
2
|
+
import l from "libsodium-wrappers";
|
|
3
|
+
import { Utxo as c } from "../utxo/Utxo.mjs";
|
|
4
|
+
import { UserKeys as d } from "./keys.mjs";
|
|
6
5
|
const B = (e, i) => {
|
|
7
6
|
const o = [
|
|
8
7
|
Buffer.from(t.utils.hexlify(i ? 0n : e.amount)),
|
|
@@ -13,15 +12,15 @@ const B = (e, i) => {
|
|
|
13
12
|
];
|
|
14
13
|
e.tokenId > 0 && o.push(Buffer.from(t.utils.hexlify(e.tokenId)));
|
|
15
14
|
const n = Buffer.concat(o);
|
|
16
|
-
return
|
|
15
|
+
return l.crypto_box_seal(n, t.utils.arrayify(e.getEncryptionKey()));
|
|
17
16
|
}, m = (e, i) => {
|
|
18
|
-
const { publicKey: o, privateKey: n } =
|
|
17
|
+
const { publicKey: o, privateKey: n } = d.getEncryptionKeyPair(i.getShieldedPrivateKey()), a = l.crypto_box_seal_open(
|
|
19
18
|
e,
|
|
20
19
|
t.utils.arrayify(o),
|
|
21
20
|
t.utils.arrayify(n)
|
|
22
|
-
), r = Buffer.from(
|
|
21
|
+
), r = Buffer.from(a).toString("utf-8").split("0x").filter((f) => f.length !== 0).map((f, y) => {
|
|
23
22
|
let s;
|
|
24
|
-
return [0, 2, 4, 5].includes(
|
|
23
|
+
return [0, 2, 4, 5].includes(y) ? s = BigInt(`0x${f}`) : [1, 3].includes(y) && (s = `0x${f}`), s;
|
|
25
24
|
});
|
|
26
25
|
return {
|
|
27
26
|
amount: r[0],
|
|
@@ -33,7 +32,7 @@ const B = (e, i) => {
|
|
|
33
32
|
tokenId: r[5] ? Number(r[5]) : 0
|
|
34
33
|
// tokenId
|
|
35
34
|
};
|
|
36
|
-
}, x = (e, i) => new
|
|
35
|
+
}, x = (e, i) => new c(m(e, i));
|
|
37
36
|
export {
|
|
38
37
|
x as decryptUtxo,
|
|
39
38
|
m as decryptUtxoConstructorArgs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),y=require("libsodium-wrappers"),g=require("../../constants/protocol.constants.cjs"),S=require("../../crypto/babyJub.cjs"),o=require("../../crypto/poseidon.cjs"),h=require("../../functions/utils/memoize.utils.cjs"),c=require("./keyUtils.cjs"),p={privateKey:"",publicKey:""};class K{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),u.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),u.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey()));getAccessKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getWalletSalt=e=>(this.requireSignature(),o.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getBackendToken=()=>(this.requireSignature(),o.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=h.memoizeFunc((e,i)=>{const t=S.babyJubInstance(),s=BigInt(i)%g.CIRCOM_P,n=e*s%g.CIRCOM_P,r=t.mulPointEscalar(t.Base8,e),a=t.mulPointEscalar(t.Base8,n),d=[BigInt(t.F.toString(r[0])),BigInt(t.F.toString(r[1]))],l=[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))];return{H0:d,H1:l}});static getStealthAddressCompressedPoints=(e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),[n,r]=[t,s].map(a=>BigInt(a[1])+2n**255n*c.getCircomSign(a[0]));return{h0:n,h1:r}};static getStealthAddress=h.memoizeFunc((e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),r=[2n*c.getCircomSign(t[0])+c.getCircomSign(s[0]),t[1],s[1]];return o.poseidonHash(...r)});static getStealthAddressWithEKey=(e,i)=>({stealthAddress:this.getStealthAddress(e,i),encryptionKey:this.getEncryptionKeyPair(i).publicKey});static checkSignature=(e,i,t,s)=>{const{h0:n,h1:r}=this.getStealthAddressCompressedPoints(e,s);return i===n&&t===r};static getEncryptionKeyPair=e=>{const i=y.crypto_box_seed_keypair(u.ethers.utils.arrayify(e));return{privateKey:u.ethers.utils.hexlify(i.privateKey),publicKey:u.ethers.utils.hexlify(i.publicKey)}}}exports.EncryptionKeyPairDefaultValue=p;exports.UserKeys=K;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import
|
|
1
|
+
import { utils as y, ethers as o } from "ethers";
|
|
2
|
+
import S from "libsodium-wrappers";
|
|
3
3
|
import { CIRCOM_P as h } from "../../constants/protocol.constants.mjs";
|
|
4
4
|
import { babyJubInstance as m } from "../../crypto/babyJub.mjs";
|
|
5
5
|
import { poseidonHash as u } from "../../crypto/poseidon.mjs";
|
|
6
6
|
import { memoizeFunc as c } from "../../functions/utils/memoize.utils.mjs";
|
|
7
7
|
import { getCircomSign as g } from "./keyUtils.mjs";
|
|
8
|
-
(async () => await d.ready)();
|
|
9
8
|
const q = {
|
|
10
9
|
privateKey: "",
|
|
11
10
|
publicKey: ""
|
|
@@ -26,7 +25,7 @@ class H {
|
|
|
26
25
|
throw Error("No signature provided");
|
|
27
26
|
}
|
|
28
27
|
verifyMessage(t) {
|
|
29
|
-
return this.requireSignature(),
|
|
28
|
+
return this.requireSignature(), y.verifyMessage(t, this.signature);
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
31
|
* get shielded private key from message signature used to login to the application,
|
|
@@ -54,8 +53,8 @@ class H {
|
|
|
54
53
|
getBackendToken = () => (this.requireSignature(), u(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
55
54
|
static getRandomizedStealthPair = c(
|
|
56
55
|
(t, i) => {
|
|
57
|
-
const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n),
|
|
58
|
-
return { H0:
|
|
56
|
+
const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n), d = [BigInt(e.F.toString(s[0])), BigInt(e.F.toString(s[1]))], l = [BigInt(e.F.toString(a[0])), BigInt(e.F.toString(a[1]))];
|
|
57
|
+
return { H0: d, H1: l };
|
|
59
58
|
}
|
|
60
59
|
);
|
|
61
60
|
static getStealthAddressCompressedPoints = (t, i) => {
|
|
@@ -77,7 +76,7 @@ class H {
|
|
|
77
76
|
* and must correspond to 32 bytes
|
|
78
77
|
*/
|
|
79
78
|
static getEncryptionKeyPair = (t) => {
|
|
80
|
-
const i =
|
|
79
|
+
const i = S.crypto_box_seed_keypair(o.utils.arrayify(t));
|
|
81
80
|
return {
|
|
82
81
|
privateKey: o.utils.hexlify(i.privateKey),
|
|
83
82
|
publicKey: o.utils.hexlify(i.publicKey)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("circomlibjs");require("buffer");require("process");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs"),u=require("./AbstractSnapshotService.cjs");class A extends u.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;if(e.latestBlockNumber&&e.merkleTree){const d=new Map(Object.entries(e.merkleTree.tree).map(([t,a])=>[BigInt(t),BigInt(a)]));s=o.MerkleTree.createWithData(d,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),c.poseidonFunction,25n,0n)}else s=o.MerkleTree.create(c.poseidonFunction,25n,0n);return e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===l.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=A;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("circomlibjs");require("libsodium-wrappers");require("buffer");require("process");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs"),u=require("./AbstractSnapshotService.cjs");class A extends u.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;if(e.latestBlockNumber&&e.merkleTree){const d=new Map(Object.entries(e.merkleTree.tree).map(([t,a])=>[BigInt(t),BigInt(a)]));s=o.MerkleTree.createWithData(d,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),c.poseidonFunction,25n,0n)}else s=o.MerkleTree.create(c.poseidonFunction,25n,0n);return e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===l.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=A;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { zeroAddress as o } from "../../constants/protocol.constants.mjs";
|
|
2
2
|
import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
|
|
3
3
|
import "circomlibjs";
|
|
4
|
+
import "libsodium-wrappers";
|
|
4
5
|
import "buffer";
|
|
5
6
|
import "process";
|
|
6
7
|
import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
|
|
7
8
|
import { MerkleTree as c } from "../merkle-tree/MerkleTree.mjs";
|
|
8
9
|
import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
|
|
9
|
-
class
|
|
10
|
+
class I extends l {
|
|
10
11
|
constructor(e, s, r, d) {
|
|
11
12
|
super(
|
|
12
13
|
e,
|
|
@@ -106,5 +107,5 @@ class b extends l {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
export {
|
|
109
|
-
|
|
110
|
+
I as AbstractAccessTokenSnapshotService
|
|
110
111
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("circomlibjs");require("buffer");require("process");const s=require("../merkle-tree/MerkleTree.cjs"),u=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,n,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,n,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([c,o])=>[BigInt(c),BigInt(o)]));t=s.MerkleTree.createWithData(r,u.toBigInt(e.merkleTree.index),u.toBigInt(e.merkleTree.count),i.poseidonFunction,25n,0n)}else t=s.MerkleTree.create(i.poseidonFunction,25n,0n);const n=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:n||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:n,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(n),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(n=>n.value).includes(e.encryptedOutput)){if(this.isServer&&console.log(`Adding commitment to file ${e.commitment} at index ${e.index} for encrypted output ${e.encryptedOutput}. Block Number: ${t}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("circomlibjs");require("libsodium-wrappers");require("buffer");require("process");const s=require("../merkle-tree/MerkleTree.cjs"),u=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,n,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,n,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([c,o])=>[BigInt(c),BigInt(o)]));t=s.MerkleTree.createWithData(r,u.toBigInt(e.merkleTree.index),u.toBigInt(e.merkleTree.count),i.poseidonFunction,25n,0n)}else t=s.MerkleTree.create(i.poseidonFunction,25n,0n);const n=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:n||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:n,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(n),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(n=>n.value).includes(e.encryptedOutput)){if(this.isServer&&console.log(`Adding commitment to file ${e.commitment} at index ${e.index} for encrypted output ${e.encryptedOutput}. Block Number: ${t}
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
`),!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return console.log(`Could not add ${e.commitment} at index ${e.index} `),!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
1
|
+
import { poseidonFunction as n } from "../../crypto/poseidon.mjs";
|
|
2
2
|
import "circomlibjs";
|
|
3
|
+
import "libsodium-wrappers";
|
|
3
4
|
import "buffer";
|
|
4
5
|
import "process";
|
|
5
6
|
import { MerkleTree as i } from "../merkle-tree/MerkleTree.mjs";
|
|
6
|
-
import { toBigInt as
|
|
7
|
+
import { toBigInt as m } from "../../functions/utils/amounts.utils.mjs";
|
|
7
8
|
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
8
|
-
class
|
|
9
|
+
class b extends o {
|
|
9
10
|
constructor(e, t, u, r) {
|
|
10
11
|
super(
|
|
11
12
|
e,
|
|
@@ -48,14 +49,14 @@ class x extends o {
|
|
|
48
49
|
);
|
|
49
50
|
t = i.createWithData(
|
|
50
51
|
r,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
m(e.merkleTree.index),
|
|
53
|
+
m(e.merkleTree.count),
|
|
54
|
+
n,
|
|
54
55
|
25n,
|
|
55
56
|
0n
|
|
56
57
|
);
|
|
57
58
|
} else
|
|
58
|
-
t = i.create(
|
|
59
|
+
t = i.create(n, 25n, 0n);
|
|
59
60
|
const u = e.encryptedOutputs?.map((r) => ({
|
|
60
61
|
value: r.value,
|
|
61
62
|
isPositive: JSON.parse(r.isPositive)
|
|
@@ -83,8 +84,8 @@ class x extends o {
|
|
|
83
84
|
mapEvent(e) {
|
|
84
85
|
const { commitment: t, index: u, encryptedOutput: r } = e;
|
|
85
86
|
return {
|
|
86
|
-
commitment:
|
|
87
|
-
index:
|
|
87
|
+
commitment: m(t),
|
|
88
|
+
index: m(u),
|
|
88
89
|
encryptedOutput: r
|
|
89
90
|
};
|
|
90
91
|
}
|
|
@@ -107,5 +108,5 @@ class x extends o {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
export {
|
|
110
|
-
|
|
111
|
+
b as AbstractCommitmentsSnapshotService
|
|
111
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("circomlibjs");require("ethers");require("buffer");require("process");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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("circomlibjs");require("ethers");require("libsodium-wrappers");require("buffer");require("process");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,12 +1,13 @@
|
|
|
1
1
|
import { AbstractAccessTokenSnapshotService as s } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
|
|
2
2
|
import "circomlibjs";
|
|
3
3
|
import "ethers";
|
|
4
|
+
import "libsodium-wrappers";
|
|
4
5
|
import "buffer";
|
|
5
6
|
import "process";
|
|
6
7
|
import "../../constants/vite.constants.mjs";
|
|
7
8
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
9
|
import { fetchAccessTokenSnapshot as t } from "../../API/fetchCommitmentsCache.mjs";
|
|
9
|
-
class
|
|
10
|
+
class k extends s {
|
|
10
11
|
constructor(r, e) {
|
|
11
12
|
super(r, 0, !1, e);
|
|
12
13
|
}
|
|
@@ -26,5 +27,5 @@ class l extends s {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
k as ClientAccessTokenSnapshotService
|
|
30
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("buffer");require("process");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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("libsodium-wrappers");require("buffer");require("process");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;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import "circomlibjs";
|
|
2
2
|
import "ethers";
|
|
3
|
+
import "libsodium-wrappers";
|
|
3
4
|
import "buffer";
|
|
4
5
|
import "process";
|
|
5
6
|
import "../../constants/vite.constants.mjs";
|
|
6
7
|
import "../../constants/reorg-depths.constants.mjs";
|
|
7
8
|
import { AbstractCommitmentsSnapshotService as e } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
|
|
8
9
|
import { fetchCommitmentsSnapshot as o } from "../../API/fetchCommitmentsCache.mjs";
|
|
9
|
-
class
|
|
10
|
+
class u extends e {
|
|
10
11
|
constructor(r, t) {
|
|
11
12
|
super(r, 0, !1, t);
|
|
12
13
|
}
|
|
@@ -25,5 +26,5 @@ class l extends e {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
+
u as ClientCommitmentsSnapshotService
|
|
29
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("buffer");require("process");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("libsodium-wrappers");require("buffer");require("process");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;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import "circomlibjs";
|
|
2
2
|
import "ethers";
|
|
3
|
+
import "libsodium-wrappers";
|
|
3
4
|
import "buffer";
|
|
4
5
|
import "process";
|
|
5
6
|
import "../../constants/vite.constants.mjs";
|
|
6
7
|
import "../../constants/reorg-depths.constants.mjs";
|
|
7
8
|
import { AbstractNullifierSnapshotService as e } from "../event-service/AbstractNullifierSnapshotService.mjs";
|
|
8
9
|
import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
|
|
9
|
-
class
|
|
10
|
+
class h extends e {
|
|
10
11
|
constructor(t, r) {
|
|
11
12
|
super(t, 0, !1, r);
|
|
12
13
|
}
|
|
@@ -22,5 +23,5 @@ class f extends e {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
export {
|
|
25
|
-
|
|
26
|
+
h as ClientNullifierSnapshotService
|
|
26
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../data-structures/utxo/Utxo.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../data-structures/utxo/Utxo.cjs"),q=require("../../error-handling/error-codes.constants.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");require("libsodium-wrappers");require("buffer");require("process");require("../../constants/reorg-depths.constants.cjs");const c=(o,t,e,u,i)=>{let r=0n;if(t.forEach(s=>{r+=s.amount}),e<0n&&r+e<0n)throw Error(q.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{outputUtxos:[new n.Utxo({amount:r+e,erc20TokenAddress:t[0].erc20TokenAddress,shieldedPrivateKey:o.getShieldedPrivateKey(),timeStamp:u,tokenId:i})]}};exports.outputUtxoProcessing=c;
|
|
@@ -8,10 +8,11 @@ import "../../types/circom-data.types.mjs";
|
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
10
|
import "circomlibjs";
|
|
11
|
+
import "libsodium-wrappers";
|
|
11
12
|
import "buffer";
|
|
12
13
|
import "process";
|
|
13
14
|
import "../../constants/reorg-depths.constants.mjs";
|
|
14
|
-
const
|
|
15
|
+
const P = (i, r, o, e, m) => {
|
|
15
16
|
let t = 0n;
|
|
16
17
|
if (r.forEach((p) => {
|
|
17
18
|
t += p.amount;
|
|
@@ -28,5 +29,5 @@ const I = (i, r, o, e, m) => {
|
|
|
28
29
|
] };
|
|
29
30
|
};
|
|
30
31
|
export {
|
|
31
|
-
|
|
32
|
+
P as outputUtxoProcessing
|
|
32
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),d=require("../../error-handling/customErrors/FeeOverTransactionValueError.cjs"),y=require("../utils/amounts.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");const O=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs"),c=require("../../types/slippage.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("buffer");require("process");require("../../constants/reorg-depths.constants.cjs");const _=require("./interaction-to-action.cjs"),N=(t,A,r)=>{const l=y.absBigInt(t)-A;if(A<0n)throw new d.FeeOverTransactionValueError({totalFeeWEI:l,feeUnit:r});return A},F=({erc20Addresses:t=[],amountChanges:A,flatFees:r,feeUnit:I,externalActionId:l,action:p,gasTokenAddress:b})=>{const i=_.getInteractionFromAction(l,p);if(i===e.INTERACTION.NONE)throw Error("No interaction was choosen");switch(i){case e.INTERACTION.WITHDRAW:{N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break}case e.INTERACTION.SWAP:{A[1]=N(A[1],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[1],r[1],c.SlippageType.Swap),I);break}case e.INTERACTION.CURVE_DEPOSIT:{const E=A.length-1;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.CurveDeposit),I);break}case e.INTERACTION.CURVE_WITHDRAW:r.forEach((E,R)=>{E>0n?A[R]=N(A[R],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[R],E,c.SlippageType.CurveWithdraw),I):E===0n&&A[R]>0n&&R!==r.length-1&&(A[R]=T.getAmountAfterSlippage(A[R],c.SlippageType.CurveWithdraw))});break;case e.INTERACTION.CURVE_WITHDRAW_INBALANCED:break;case e.INTERACTION.STAKING:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.UNSTAKING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.CLAIMING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY:{const E=O.isBeefyDeposit(p)?1:0;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Beefy),I);break}case e.INTERACTION.BEEFY_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY_UNSTAKE:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.BEEFY_GET_REWARDS:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.LIDO_REQUEST:N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_TRANSACT:A[0]<0n&&N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break;case e.INTERACTION.PENDLE_YT_IN_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_YT_OUT_SWAP:break;case e.INTERACTION.PENDLE_PT_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_MINT:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_REDEEM:A[2]=N(A[2],T.getAmountAfterRelayAndFlatFees(A[2],r[2]),I);break;case e.INTERACTION.PENDLE_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_LP:{const E=A.findIndex(R=>R>0n);A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Pendle));break}case e.INTERACTION.PENDLE_LP_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break}return A};exports.processAmountChanges=F;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),d=require("../../error-handling/customErrors/FeeOverTransactionValueError.cjs"),y=require("../utils/amounts.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");const O=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs"),c=require("../../types/slippage.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("libsodium-wrappers");require("buffer");require("process");require("../../constants/reorg-depths.constants.cjs");const _=require("./interaction-to-action.cjs"),N=(t,A,r)=>{const l=y.absBigInt(t)-A;if(A<0n)throw new d.FeeOverTransactionValueError({totalFeeWEI:l,feeUnit:r});return A},F=({erc20Addresses:t=[],amountChanges:A,flatFees:r,feeUnit:I,externalActionId:l,action:p,gasTokenAddress:b})=>{const i=_.getInteractionFromAction(l,p);if(i===e.INTERACTION.NONE)throw Error("No interaction was choosen");switch(i){case e.INTERACTION.WITHDRAW:{N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break}case e.INTERACTION.SWAP:{A[1]=N(A[1],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[1],r[1],c.SlippageType.Swap),I);break}case e.INTERACTION.CURVE_DEPOSIT:{const E=A.length-1;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.CurveDeposit),I);break}case e.INTERACTION.CURVE_WITHDRAW:r.forEach((E,R)=>{E>0n?A[R]=N(A[R],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[R],E,c.SlippageType.CurveWithdraw),I):E===0n&&A[R]>0n&&R!==r.length-1&&(A[R]=T.getAmountAfterSlippage(A[R],c.SlippageType.CurveWithdraw))});break;case e.INTERACTION.CURVE_WITHDRAW_INBALANCED:break;case e.INTERACTION.STAKING:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.UNSTAKING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.CLAIMING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY:{const E=O.isBeefyDeposit(p)?1:0;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Beefy),I);break}case e.INTERACTION.BEEFY_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY_UNSTAKE:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.BEEFY_GET_REWARDS:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.LIDO_REQUEST:N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_TRANSACT:A[0]<0n&&N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break;case e.INTERACTION.PENDLE_YT_IN_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_YT_OUT_SWAP:break;case e.INTERACTION.PENDLE_PT_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_MINT:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_REDEEM:A[2]=N(A[2],T.getAmountAfterRelayAndFlatFees(A[2],r[2]),I);break;case e.INTERACTION.PENDLE_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_LP:{const E=A.findIndex(R=>R>0n);A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Pendle));break}case e.INTERACTION.PENDLE_LP_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break}return A};exports.processAmountChanges=F;
|
|
@@ -12,6 +12,7 @@ import { SlippageType as b } from "../../types/slippage.types.mjs";
|
|
|
12
12
|
import "../../types/transactions.types.mjs";
|
|
13
13
|
import "../../types/curve.types.mjs";
|
|
14
14
|
import "circomlibjs";
|
|
15
|
+
import "libsodium-wrappers";
|
|
15
16
|
import "buffer";
|
|
16
17
|
import "process";
|
|
17
18
|
import "../../constants/reorg-depths.constants.mjs";
|
|
@@ -24,19 +25,19 @@ const p = (D, r, E) => {
|
|
|
24
25
|
feeUnit: E
|
|
25
26
|
});
|
|
26
27
|
return r;
|
|
27
|
-
},
|
|
28
|
+
}, l = ({
|
|
28
29
|
erc20Addresses: D = [],
|
|
29
30
|
amountChanges: r,
|
|
30
31
|
flatFees: E,
|
|
31
32
|
feeUnit: A,
|
|
32
33
|
externalActionId: T,
|
|
33
|
-
action:
|
|
34
|
+
action: i,
|
|
34
35
|
gasTokenAddress: w
|
|
35
36
|
}) => {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
37
|
+
const P = d(T, i);
|
|
38
|
+
if (P === c.NONE)
|
|
38
39
|
throw Error("No interaction was choosen");
|
|
39
|
-
switch (
|
|
40
|
+
switch (P) {
|
|
40
41
|
case c.WITHDRAW: {
|
|
41
42
|
p(
|
|
42
43
|
r[0],
|
|
@@ -95,7 +96,7 @@ const p = (D, r, E) => {
|
|
|
95
96
|
);
|
|
96
97
|
break;
|
|
97
98
|
case c.BEEFY: {
|
|
98
|
-
const k = R(
|
|
99
|
+
const k = R(i) ? 1 : 0;
|
|
99
100
|
r[k] = p(
|
|
100
101
|
r[k],
|
|
101
102
|
N(
|
|
@@ -212,5 +213,5 @@ const p = (D, r, E) => {
|
|
|
212
213
|
return r;
|
|
213
214
|
};
|
|
214
215
|
export {
|
|
215
|
-
|
|
216
|
+
l as processAmountChanges
|
|
216
217
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("libsodium-wrappers");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("buffer");require("process");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r?.symbol.toLowerCase()==="weth"&&console.log("token:",r),r}function w(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const q=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},F=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=q;exports.determinePendleSwapTypeApiRoute=F;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=w;exports.getTokenIndexForPendleFlatFee=k;
|
|
@@ -15,7 +15,7 @@ import { PendleAssetType as d, PendleSwapType as t } from "../../types/pendle.ty
|
|
|
15
15
|
import "../../types/curve.types.mjs";
|
|
16
16
|
import "ethers";
|
|
17
17
|
import "circomlibjs";
|
|
18
|
-
import "
|
|
18
|
+
import "libsodium-wrappers";
|
|
19
19
|
import "idb-keyval";
|
|
20
20
|
import "../utils/external-action.utils.mjs";
|
|
21
21
|
import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
|
|
@@ -2,7 +2,7 @@ import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
|
|
|
2
2
|
import "../../../constants/chains.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "circomlibjs";
|
|
5
|
-
import "
|
|
5
|
+
import "libsodium-wrappers";
|
|
6
6
|
import "../../../constants/vite.constants.mjs";
|
|
7
7
|
import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
|
|
8
8
|
import "../../../types/circom-data.types.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");require("buffer");require("process");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");require("libsodium-wrappers");require("buffer");require("process");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
|
|
@@ -16,16 +16,17 @@ import "../../types/transactions.types.mjs";
|
|
|
16
16
|
import "../../types/curve.types.mjs";
|
|
17
17
|
import "circomlibjs";
|
|
18
18
|
import "ethers";
|
|
19
|
+
import "libsodium-wrappers";
|
|
19
20
|
import "buffer";
|
|
20
21
|
import "process";
|
|
21
|
-
const
|
|
22
|
+
const b = async (r, t, e, i) => {
|
|
22
23
|
try {
|
|
23
24
|
const o = {
|
|
24
25
|
chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
|
|
25
26
|
inputTokens: [
|
|
26
27
|
{
|
|
27
28
|
tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
28
|
-
amount: u(t,
|
|
29
|
+
amount: u(t, i).toString()
|
|
29
30
|
}
|
|
30
31
|
],
|
|
31
32
|
outputTokens: [
|
|
@@ -38,11 +39,11 @@ const _ = async (r, t, e, n) => {
|
|
|
38
39
|
slippageLimitPercent: 10,
|
|
39
40
|
disableRFQs: !0
|
|
40
41
|
// sometimes swap fails because of RFQs
|
|
41
|
-
}, { odosResponse: s, status:
|
|
42
|
+
}, { odosResponse: s, status: n } = await d(
|
|
42
43
|
r.getCurrentChainId(),
|
|
43
44
|
o
|
|
44
45
|
);
|
|
45
|
-
if (
|
|
46
|
+
if (n !== "success")
|
|
46
47
|
throw Error("Odos API Fetch Error");
|
|
47
48
|
return {
|
|
48
49
|
outSwapAmountValue: BigInt(s.outputTokens[0].amount),
|
|
@@ -53,5 +54,5 @@ const _ = async (r, t, e, n) => {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
export {
|
|
56
|
-
|
|
57
|
+
b as getOdosPrice
|
|
57
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");require("buffer");require("process");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");require("libsodium-wrappers");require("buffer");require("process");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
|
|
@@ -3,7 +3,7 @@ import "../../constants/chains.constants.mjs";
|
|
|
3
3
|
import "../../constants/vite.constants.mjs";
|
|
4
4
|
import "../../constants/contracts.constants.mjs";
|
|
5
5
|
import "../../constants/kyc.constants.mjs";
|
|
6
|
-
import { zeroAddress as e, oneInchZeroAddress as
|
|
6
|
+
import { zeroAddress as e, oneInchZeroAddress as m } from "../../constants/protocol.constants.mjs";
|
|
7
7
|
import "../../constants/coingecko.constants.mjs";
|
|
8
8
|
import "../../constants/axelar.constants.mjs";
|
|
9
9
|
import "../../constants/rewards.constants.mjs";
|
|
@@ -17,17 +17,18 @@ import "../../types/transactions.types.mjs";
|
|
|
17
17
|
import "../../types/curve.types.mjs";
|
|
18
18
|
import "circomlibjs";
|
|
19
19
|
import "ethers";
|
|
20
|
+
import "libsodium-wrappers";
|
|
20
21
|
import "buffer";
|
|
21
22
|
import "process";
|
|
22
|
-
const
|
|
23
|
+
const v = async (s, t, i, n) => {
|
|
23
24
|
try {
|
|
24
25
|
const o = {
|
|
25
|
-
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress :
|
|
26
|
-
toTokenAddress:
|
|
26
|
+
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : m,
|
|
27
|
+
toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : m,
|
|
27
28
|
fromAddress: e,
|
|
28
29
|
// we user zero address here because this paramater is not relevant to us, only destReceiver is
|
|
29
30
|
destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
|
|
30
|
-
amount: d(t,
|
|
31
|
+
amount: d(t, n),
|
|
31
32
|
slippage: 10,
|
|
32
33
|
disableEstimate: !0,
|
|
33
34
|
// disable gas estimation, we don't need it
|
|
@@ -49,5 +50,5 @@ const q = async (s, t, n, m) => {
|
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
export {
|
|
52
|
-
|
|
53
|
+
v as getOneInchPrice
|
|
53
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const T=require("../../error-handling/get-error.message.cjs");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");require("buffer");require("process");require("../../constants/reorg-depths.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const T=require("../../error-handling/get-error.message.cjs");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");require("libsodium-wrappers");require("buffer");require("process");require("../../constants/reorg-depths.constants.cjs");const q=5e4,d=1,m=11,w=15,g=async(s,o)=>{try{const r=await s.getFeeData(),n=o===0?m:w,e=r.gasPrice?.mul(n).div(10)??void 0;return console.log("getGasPrice , ",e?.toBigInt(),{gasPremiumType:o}),e}catch(r){console.log("getGasPrice error: ",{err:r});return}},E=(s,o,r)=>new Promise((n,e)=>{const a=setTimeout(()=>{e(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);s.wait(o).then(t=>{clearTimeout(a),n(t)}).catch(t=>{clearTimeout(a),e(t)})}),l=async({contractFunction:s,args:o,gasPrice:r,gasLimit:n,nonce:e,confirmations:a,waitTime:t})=>{const i=await s(...o,{type:0,gasLimit:n,gasPrice:r,nonce:e});return console.log("runTransaction: ",i?.hash),await E(i,a??d,t??q)},P=async({provider:s,contractFunction:o,args:r,gasLimit:n,nonce:e,confirmations:a})=>{try{const t=await g(s,0);return await l({contractFunction:o,args:r,gasPrice:t,gasLimit:n,nonce:e,confirmations:a})}catch(t){const i=T.getErrorMessage(t);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(s,1);return await l({contractFunction:o,args:r,gasPrice:u,gasLimit:n,nonce:e,confirmations:a})}throw t}};exports.runContractFunction=P;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserFriendlyErrorCodes as l, transactionErrorCodes as g } from "../../error-handling/error-codes.constants.mjs";
|
|
2
2
|
import "ethers";
|
|
3
|
-
import { getErrorMessage as
|
|
3
|
+
import { getErrorMessage as p } from "../../error-handling/get-error.message.mjs";
|
|
4
4
|
import "axios";
|
|
5
5
|
import "../../constants/chains.constants.mjs";
|
|
6
6
|
import "../../constants/vite.constants.mjs";
|
|
@@ -8,10 +8,11 @@ import "../../types/circom-data.types.mjs";
|
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
10
|
import "circomlibjs";
|
|
11
|
+
import "libsodium-wrappers";
|
|
11
12
|
import "buffer";
|
|
12
13
|
import "process";
|
|
13
14
|
import "../../constants/reorg-depths.constants.mjs";
|
|
14
|
-
const
|
|
15
|
+
const T = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
15
16
|
try {
|
|
16
17
|
const t = await a.getFeeData(), s = e === 0 ? P : d, r = t.gasPrice?.mul(s).div(10) ?? void 0;
|
|
17
18
|
return console.log("getGasPrice , ", r?.toBigInt(), { gasPremiumType: e }), r;
|
|
@@ -46,9 +47,9 @@ const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
46
47
|
return console.log("runTransaction: ", n?.hash), await E(
|
|
47
48
|
n,
|
|
48
49
|
i ?? w,
|
|
49
|
-
o ??
|
|
50
|
+
o ?? T
|
|
50
51
|
);
|
|
51
|
-
},
|
|
52
|
+
}, U = async ({
|
|
52
53
|
provider: a,
|
|
53
54
|
contractFunction: e,
|
|
54
55
|
args: t,
|
|
@@ -64,7 +65,7 @@ const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
64
65
|
);
|
|
65
66
|
return await u({ contractFunction: e, args: t, gasPrice: o, gasLimit: s, nonce: r, confirmations: i });
|
|
66
67
|
} catch (o) {
|
|
67
|
-
const n =
|
|
68
|
+
const n = p(o);
|
|
68
69
|
if (n === l.MAX_FEE_GAS_ERROR || n === g.TRANSACTION_TIMEOUT) {
|
|
69
70
|
console.log("Timeout Hit: Increase gas");
|
|
70
71
|
const c = await m(
|
|
@@ -78,5 +79,5 @@ const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
export {
|
|
81
|
-
|
|
82
|
+
U as runContractFunction
|
|
82
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("buffer");require("process");const h=require("../../error-handling/logError.cjs"),w=async(t,c,r,o)=>{const n=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await c.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),s=await Promise.all(n.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=s.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return s.find(e=>e.token1Balance===i)},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("libsodium-wrappers");require("buffer");require("process");const h=require("../../error-handling/logError.cjs"),w=async(t,c,r,o)=>{const n=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await c.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),s=await Promise.all(n.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=s.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return s.find(e=>e.token1Balance===i)},q=async(t,c,r,o,n)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(s){throw h.logError(s),s}},g=async(t,c,r)=>{try{const o=t.getCurrentChainId(),n=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),s=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(s,n,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,c,r,o)=>{try{const n=await g(t,r,o),s=A.utils.defaultAbiCoder.encode(["uint24"],[n]),a=y.getAmountInWei(r,c);return{tokenPrice:await q(t,r,o,n,a),poolFee:s}}catch(n){throw console.log({error:n}),Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=g;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
|
|
@@ -16,6 +16,7 @@ import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
|
16
16
|
import "../../types/transactions.types.mjs";
|
|
17
17
|
import "../../types/curve.types.mjs";
|
|
18
18
|
import "circomlibjs";
|
|
19
|
+
import "libsodium-wrappers";
|
|
19
20
|
import "buffer";
|
|
20
21
|
import "process";
|
|
21
22
|
import { logError as C } from "../../error-handling/logError.mjs";
|
|
@@ -70,7 +71,7 @@ const g = async (e, c, t, o) => {
|
|
|
70
71
|
} catch (o) {
|
|
71
72
|
throw console.log("Error in getUniswapFee", o), o;
|
|
72
73
|
}
|
|
73
|
-
},
|
|
74
|
+
}, D = async (e, c, t, o) => {
|
|
74
75
|
try {
|
|
75
76
|
const n = await I(e, t, o), s = l.defaultAbiCoder.encode(["uint24"], [n]), a = A(t, c);
|
|
76
77
|
return { tokenPrice: await f(e, t, o, n, a), poolFee: s };
|
|
@@ -80,7 +81,7 @@ const g = async (e, c, t, o) => {
|
|
|
80
81
|
};
|
|
81
82
|
export {
|
|
82
83
|
I as getUniswapFee,
|
|
83
|
-
|
|
84
|
+
D as getUniswapPrice,
|
|
84
85
|
f as getUniswapPriceHelper,
|
|
85
86
|
g as searchPoolAndFee
|
|
86
87
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("libsodium-wrappers");const t=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");const u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const r=require("./EthersProviderAdapter.cjs"),q=async i=>{await u.preProcessing();const e=new t.Hinkal;return r.ethersProvierAdapter.initSigner?.(i),await e.initProviderAdapter(void 0,r.ethersProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareEthersHinkal=q;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "ethers";
|
|
2
2
|
import "circomlibjs";
|
|
3
|
-
import "
|
|
4
|
-
import "../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
3
|
+
import "libsodium-wrappers";
|
|
5
4
|
import { Hinkal as o } from "../data-structures/Hinkal/Hinkal.mjs";
|
|
6
5
|
import "../constants/chains.constants.mjs";
|
|
7
6
|
import "../types/circom-data.types.mjs";
|
|
@@ -22,11 +21,11 @@ import "../functions/web3/events/getShieldedBalance.mjs";
|
|
|
22
21
|
import "../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
23
22
|
import "idb-keyval";
|
|
24
23
|
import { ethersProvierAdapter as i } from "./EthersProviderAdapter.mjs";
|
|
25
|
-
const
|
|
24
|
+
const S = async (t) => {
|
|
26
25
|
await p();
|
|
27
26
|
const r = new o();
|
|
28
27
|
return i.initSigner?.(t), await r.initProviderAdapter(void 0, i), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
29
28
|
};
|
|
30
29
|
export {
|
|
31
|
-
|
|
30
|
+
S as prepareEthersHinkal
|
|
32
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs");require("libsodium-wrappers");const i=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/axelar.constants.cjs");require("../constants/rewards.constants.cjs");require("../constants/reorg-depths.constants.cjs");const u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const a=require("./Wagmiv1ProviderAdapter.cjs"),q=async r=>{await u.preProcessing();const e=new i.Hinkal;return await e.initProviderAdapter(r,a.wagmiv1ProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareWagmiv1Hinkal=q;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "ethers";
|
|
2
2
|
import "circomlibjs";
|
|
3
|
-
import "
|
|
4
|
-
import "../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
3
|
+
import "libsodium-wrappers";
|
|
5
4
|
import { Hinkal as t } from "../data-structures/Hinkal/Hinkal.mjs";
|
|
6
5
|
import "../constants/chains.constants.mjs";
|
|
7
6
|
import "../types/circom-data.types.mjs";
|
|
@@ -22,11 +21,11 @@ import "../functions/web3/events/getShieldedBalance.mjs";
|
|
|
22
21
|
import "../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
23
22
|
import "idb-keyval";
|
|
24
23
|
import { wagmiv1ProvierAdapter as p } from "./Wagmiv1ProviderAdapter.mjs";
|
|
25
|
-
const
|
|
24
|
+
const W = async (i) => {
|
|
26
25
|
await o();
|
|
27
26
|
const r = new t();
|
|
28
27
|
return await r.initProviderAdapter(i, p), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
29
28
|
};
|
|
30
29
|
export {
|
|
31
|
-
|
|
30
|
+
W as prepareWagmiv1Hinkal
|
|
32
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-CB4QU7Zm.js").href:new URL("../../assets/utxoWorkerLauncher-CB4QU7Zm.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-CqRz9ir5.js").href:new URL("../../assets/zkProofWorkerLauncher-CqRz9ir5.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=r;
|