@hinkal/common 0.1.29 → 0.1.31
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/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +4 -4
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.mjs +30 -30
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +44 -18
- package/crypto/babyJub.cjs +1 -1
- package/crypto/babyJub.d.ts +1 -1
- package/crypto/babyJub.mjs +3 -2
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.d.ts +1 -1
- package/crypto/poseidon.mjs +14 -13
- package/crypto/preProcessing.cjs +1 -1
- package/crypto/preProcessing.mjs +6 -11
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +3 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +3 -2
- 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/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.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 +11 -10
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +14 -13
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +7 -6
- 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 +2 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +3 -2
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +3 -2
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const f=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const A=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 k=require("../../functions/snarkjs/generateZkProof.cjs");require("../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const f=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const A=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 k=require("../../functions/snarkjs/generateZkProof.cjs");require("../../types/circom-data.types.cjs");const q=require("../../types/transactions.types.cjs"),I=require("../../types/time.types.cjs"),x=require("./history/getTxDetails.cjs");require("circomlibjs-hinkal-fork");const P=require("../../error-handling/error-codes.constants.cjs"),C=require("../crypto-keys/keys.cjs"),w=require("../crypto-keys/encryptDecryptUtxo.cjs"),p=require("../../functions/utils/getDataFromTransaction.cjs"),S=require("../../functions/utils/cacheFunctions.cjs");class v{circuitSize=50;hinkalContract;init(e){this.hinkalContract=e}requireInit(){if(!this.hinkalContract)throw Error("TransactionsManager not initialized")}filterOwnTransactions=async(e,r,t,a)=>{const{transactMethodId:s,transactWithExternalActionMethodId:n,hinkalInterface:i}=A.getHinkalParameters(T.getNonLocalhostChainId(e)),c=o=>"decodedInput"in o,l=r.filter(o=>o.methodId===s||o.methodId===n).map(o=>c(o)?o:{...o,decodedInput:p.decodeTxInput(i,o.input),status:o.isError==="0"?"SUCCESS":"FAILURE"}),h=t.getShieldedPrivateKey();return l.filter(o=>{try{if(c(o)){if(w.decryptUtxo(Buffer.from(o.decodedInput.encryptedOutputs[0].slice(2),"hex"),t),!a&&o.methodId===s){const{extraRandomization:g,H0:y,H1:m}=o.decodedInput.stealthAddressStructure;return C.UserKeys.checkSignature(g,y,m,h)}return!0}return!1}catch{return!1}})};saveTxsInStorage=(e,r,t,a)=>{const s=t.getShieldedPublicKey();return S.saveTxsCache(e,r,s,this.hinkalContract.address,a)};loadTxsFromStorage=async(e,r)=>{const t=r.getShieldedPublicKey();return await S.loadTxsCache(e,t,this.hinkalContract.address)};getAllTransactions=async(e,r,t)=>{if(t){const{transactions:i}=await f.API.userGetTransactions(e,t);return i}const{decodedTxs:a,lastHash:s}=await this.loadTxsFromStorage(e,r),{transactions:n}=await f.API.userGetTransactions(e,t,s);return[...n,...a]};getHinkalHistoryBase=async(e,r,t,a=!1)=>{this.requireInit();const s=await this.getAllTransactions(e,r,t)??[];s.sort((i,c)=>c.timeStamp-i.timeStamp);const n=await this.filterOwnTransactions(e,s,r,a);return!t&&s.length>0&&await this.saveTxsInStorage(n,e,r,s[0].hash),n};getHinkalHistory=async(e,r)=>{const t=await this.getHinkalHistoryBase(e,r,void 0,!0),a=p.decodeTxLogs(e,t);return await Promise.all(a.map(async n=>({...n,status:n.status,details:await x.getTxDetails(e,n.decodedInput,n.utxosArray)})))};sortInBatches=e=>{const r=[];let t=0,a=0;e.forEach(i=>{t===0&&r.push([]),r[a].push(i),t+=1,t===this.circuitSize&&(t=0,a+=1)});const s=r[r.length-1],n=s.length;if(n<this.circuitSize){const i=this.circuitSize-n,c=new Array(i).fill(q.emptyDecodedTx);r[r.length-1]=s.concat(c)}return r};generateTransactionsProof=async(e,r,t)=>{const a=this.sortInBatches(r),s=new Array(a.length).fill([]);for(let n=0;n<a.length;n+=1){const i=a[n].map(d=>d.decodedInput.stealthAddressStructure),c=i.map(d=>d.extraRandomization),u=i.map(d=>d.stealthAddress);console.log({extraRandomizations:c,stealthAddresses:u});const l={shieldedPrivateKey:t,extraRandomizations:c,stealthAddresses:u};console.log({chainId:e,input:l});const{zkCallData:h}=await k.generateZkProof(e,"transactionsProver",l);console.log({zkCallData:h}),s[n]=h}return{zkCallDataArray:s}};userVerifyTransactions=async(e,r,t,a,s,n)=>await f.API.userVerifyTransactions(e,r,t,a,s,n);processAndSendTransactionsForVerification=async(e,r,t,a)=>{this.requireInit();const s=I.getCurrentWeek(),n=a?s-1:s;console.log("retrieving transactions in processAndSendTransactionsForVerification",{week:n});const i=await this.getHinkalHistoryBase(e,r,n);console.log("retrieved transactions",i);let c=[],u=[];i.length>0&&({zkCallDataArray:u}=await this.generateTransactionsProof(e,i,r.getShieldedPrivateKey()),c=i.map(y=>y.hash));const l=r.getBackendToken(),{trade:h,transactions:d,lockedDeposit:o,verification:g}=await this.userVerifyTransactions(e,c,u,l,t,n);return{trade:h,transactions:d,lockedDeposit:o,verification:g}};multiProcessAndSendTransactionsForVerification=async(e,r)=>{console.log("Multi Certify Starts");const t=T.chainIdsByType[T.EthereumNetworkType.Mainnet];let a=!0;for(let s=0;s<t.length;s+=1)try{const{hasCertified:n}=await f.API.verificationStartDate(t[s],r);if(console.log(`certification status for chain ${t[s]} is ${n}`),n)continue;const{trade:i,transactions:c,lockedDeposit:u,verification:l}=await this.processAndSendTransactionsForVerification(t[s],e,r,!0);if(console.log({chainId:t[s],trade:i,totalTransactions:c,lockedDeposit:u,verification:l}),a=a&&l,!a)break}catch(n){console.log(`current chain ${t[s]} certification error`,{err:n}),a=!1;break}if(!a)throw Error(P.transactionErrorCodes.MULTI_VERIFICATION_FAILED);return!0}}exports.TransactionsManager=v;
|
|
@@ -15,12 +15,13 @@ import "../../types/circom-data.types.mjs";
|
|
|
15
15
|
import { emptyDecodedTx as I } from "../../types/transactions.types.mjs";
|
|
16
16
|
import { getCurrentWeek as x } from "../../types/time.types.mjs";
|
|
17
17
|
import { getTxDetails as w } from "./history/getTxDetails.mjs";
|
|
18
|
+
import "circomlibjs-hinkal-fork";
|
|
18
19
|
import { transactionErrorCodes as C } from "../../error-handling/error-codes.constants.mjs";
|
|
19
20
|
import { UserKeys as P } from "../crypto-keys/keys.mjs";
|
|
20
21
|
import { decryptUtxo as v } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
21
22
|
import { decodeTxInput as H, decodeTxLogs as z } from "../../functions/utils/getDataFromTransaction.mjs";
|
|
22
23
|
import { saveTxsCache as E, loadTxsCache as b } from "../../functions/utils/cacheFunctions.mjs";
|
|
23
|
-
class
|
|
24
|
+
class et {
|
|
24
25
|
circuitSize = 50;
|
|
25
26
|
hinkalContract;
|
|
26
27
|
init(r) {
|
|
@@ -181,5 +182,5 @@ class rt {
|
|
|
181
182
|
};
|
|
182
183
|
}
|
|
183
184
|
export {
|
|
184
|
-
|
|
185
|
+
et as TransactionsManager
|
|
185
186
|
};
|
|
@@ -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-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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;
|
|
@@ -7,11 +7,12 @@ import "../../constants/vite.constants.mjs";
|
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
+
import "circomlibjs-hinkal-fork";
|
|
10
11
|
import "libsodium-wrappers";
|
|
11
12
|
import "process";
|
|
12
13
|
import "buffer";
|
|
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("libsodium-wrappers");require("process");require("buffer");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-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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;
|
|
@@ -11,6 +11,7 @@ import { INTERACTION as c } from "../../types/hinkal.types.mjs";
|
|
|
11
11
|
import { SlippageType as b } from "../../types/slippage.types.mjs";
|
|
12
12
|
import "../../types/transactions.types.mjs";
|
|
13
13
|
import "../../types/curve.types.mjs";
|
|
14
|
+
import "circomlibjs-hinkal-fork";
|
|
14
15
|
import "libsodium-wrappers";
|
|
15
16
|
import "process";
|
|
16
17
|
import "buffer";
|
|
@@ -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("libsodium-wrappers");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("process");require("buffer");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
|
|
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-hinkal-fork");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("process");require("buffer");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;
|
|
@@ -14,6 +14,7 @@ import "../../types/transactions.types.mjs";
|
|
|
14
14
|
import { PendleAssetType as d, PendleSwapType as t } from "../../types/pendle.types.mjs";
|
|
15
15
|
import "../../types/curve.types.mjs";
|
|
16
16
|
import "ethers";
|
|
17
|
+
import "circomlibjs-hinkal-fork";
|
|
17
18
|
import "libsodium-wrappers";
|
|
18
19
|
import "idb-keyval";
|
|
19
20
|
import "../utils/external-action.utils.mjs";
|
|
@@ -26,14 +27,14 @@ import "../utils/userAgent.mjs";
|
|
|
26
27
|
import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
27
28
|
import "../../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
28
29
|
import { isInEnum as w } from "../utils/enum.utils.mjs";
|
|
29
|
-
function
|
|
30
|
+
function z(e) {
|
|
30
31
|
if (!e)
|
|
31
32
|
return;
|
|
32
33
|
const r = T(e.address, e.chainId);
|
|
33
34
|
if (!r?.isVolatile)
|
|
34
35
|
return r?.symbol.toLowerCase() === "weth" && console.log("token:", r), r;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function H(e, r) {
|
|
37
38
|
if (!e || !r)
|
|
38
39
|
return;
|
|
39
40
|
let o;
|
|
@@ -56,7 +57,7 @@ function z(e, r) {
|
|
|
56
57
|
}
|
|
57
58
|
return o;
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
+
const J = (e, r, o) => {
|
|
60
61
|
if (i(e.yt.address, o.erc20TokenAddress))
|
|
61
62
|
return t.SwapExactTokenForYt;
|
|
62
63
|
if (i(e.pt.address, o.erc20TokenAddress))
|
|
@@ -65,7 +66,7 @@ const H = (e, r, o) => {
|
|
|
65
66
|
return t.SwapExactYtForToken;
|
|
66
67
|
if (i(e.pt.address, r.erc20TokenAddress))
|
|
67
68
|
return t.SwapExactPtForToken;
|
|
68
|
-
},
|
|
69
|
+
}, K = (e) => {
|
|
69
70
|
let r;
|
|
70
71
|
switch (e) {
|
|
71
72
|
case t.SwapExactTokenForYt:
|
|
@@ -84,7 +85,7 @@ const H = (e, r, o) => {
|
|
|
84
85
|
throw new Error("Cant determine Pendle Swap Type Api Route");
|
|
85
86
|
}
|
|
86
87
|
return r;
|
|
87
|
-
},
|
|
88
|
+
}, Q = (e, r, o, s) => {
|
|
88
89
|
if (!w(p, e))
|
|
89
90
|
throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
|
|
90
91
|
if (s)
|
|
@@ -98,9 +99,9 @@ const H = (e, r, o) => {
|
|
|
98
99
|
return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (c = l), c;
|
|
99
100
|
};
|
|
100
101
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
J as determinePendleSwapType,
|
|
103
|
+
K as determinePendleSwapTypeApiRoute,
|
|
104
|
+
z as erc20TokenFromPendleAsset,
|
|
105
|
+
H as getAssetTypeFromPendleMarket,
|
|
106
|
+
Q as getTokenIndexForPendleFlatFee
|
|
106
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers"),y=require("../../data-structures/crypto-keys/keys.cjs"),s=require("libsodium-wrappers"),c=require("../../crypto/poseidon.cjs");require("process");require("buffer");const f=(e,t,r)=>{const n=i.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=s.crypto_box_seal(n,i.ethers.utils.arrayify(r));return`0x${Buffer.from(a).toString("hex")}`},p=(e,t)=>{const r=Buffer.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=y.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const o=s.crypto_box_seal_open(r,i.ethers.utils.arrayify(n),i.ethers.utils.arrayify(a)),d=Buffer.from(o).toString("utf-8"),[u,l]=i.ethers.utils.defaultAbiCoder.decode(["uint256","address"],d);return{stakeBlinding:u.toBigInt(),stakedTokenRecipient:l}}catch{console.log("failed to decrypt");return}},S=(e,t,r,n,a,o)=>BigInt(c.poseidonHash(...[e,t,r,n,a,o].map(BigInt))),k=(e,t)=>c.poseidonHash(e,t),g=(e,t,r,n,a)=>i.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=k;exports.createStakeCommitment=S;exports.decryptStake=p;exports.encodeHStakeMetadata=g;exports.encryptStake=f;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers"),y=require("../../data-structures/crypto-keys/keys.cjs"),s=require("libsodium-wrappers"),c=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("process");require("buffer");const f=(e,t,r)=>{const n=i.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=s.crypto_box_seal(n,i.ethers.utils.arrayify(r));return`0x${Buffer.from(a).toString("hex")}`},p=(e,t)=>{const r=Buffer.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=y.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const o=s.crypto_box_seal_open(r,i.ethers.utils.arrayify(n),i.ethers.utils.arrayify(a)),d=Buffer.from(o).toString("utf-8"),[u,l]=i.ethers.utils.defaultAbiCoder.decode(["uint256","address"],d);return{stakeBlinding:u.toBigInt(),stakedTokenRecipient:l}}catch{console.log("failed to decrypt");return}},S=(e,t,r,n,a,o)=>BigInt(c.poseidonHash(...[e,t,r,n,a,o].map(BigInt))),k=(e,t)=>c.poseidonHash(e,t),g=(e,t,r,n,a)=>i.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=k;exports.createStakeCommitment=S;exports.decryptStake=p;exports.encodeHStakeMetadata=g;exports.encryptStake=f;
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { ethers as n } from "ethers";
|
|
2
|
-
import { UserKeys as
|
|
2
|
+
import { UserKeys as y } from "../../data-structures/crypto-keys/keys.mjs";
|
|
3
3
|
import s from "libsodium-wrappers";
|
|
4
4
|
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
5
|
+
import "circomlibjs-hinkal-fork";
|
|
5
6
|
import "process";
|
|
6
7
|
import "buffer";
|
|
7
|
-
const
|
|
8
|
+
const B = (t, e, r) => {
|
|
8
9
|
const o = n.utils.defaultAbiCoder.encode(
|
|
9
10
|
["uint256", "address"],
|
|
10
11
|
[t, e]
|
|
11
12
|
), i = s.crypto_box_seal(o, n.utils.arrayify(r));
|
|
12
13
|
return `0x${Buffer.from(i).toString("hex")}`;
|
|
13
|
-
},
|
|
14
|
-
const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } =
|
|
14
|
+
}, h = (t, e) => {
|
|
15
|
+
const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } = y.getEncryptionKeyPair(e.getShieldedPrivateKey());
|
|
15
16
|
try {
|
|
16
17
|
const a = s.crypto_box_seal_open(
|
|
17
18
|
r,
|
|
18
19
|
n.utils.arrayify(o),
|
|
19
20
|
n.utils.arrayify(i)
|
|
20
|
-
), d = Buffer.from(a).toString("utf-8"), [u,
|
|
21
|
+
), d = Buffer.from(a).toString("utf-8"), [u, p] = n.utils.defaultAbiCoder.decode(
|
|
21
22
|
["uint256", "address"],
|
|
22
23
|
d
|
|
23
24
|
);
|
|
24
|
-
return { stakeBlinding: u.toBigInt(), stakedTokenRecipient:
|
|
25
|
+
return { stakeBlinding: u.toBigInt(), stakedTokenRecipient: p };
|
|
25
26
|
} catch {
|
|
26
27
|
console.log("failed to decrypt");
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
},
|
|
30
|
+
}, x = (t, e, r, o, i, a) => BigInt(
|
|
30
31
|
c(...[t, e, r, o, i, a].map(BigInt))
|
|
31
|
-
),
|
|
32
|
+
), K = (t, e) => c(t, e), _ = (t, e, r, o, i) => n.utils.defaultAbiCoder.encode(
|
|
32
33
|
["uint8", "uint256", "address", "bytes", "bytes"],
|
|
33
34
|
[t, e, r, o, i]
|
|
34
35
|
);
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
K as calculateStakeNullifier,
|
|
38
|
+
x as createStakeCommitment,
|
|
39
|
+
h as decryptStake,
|
|
40
|
+
_ as encodeHStakeMetadata,
|
|
41
|
+
B as encryptStake
|
|
41
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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-hinkal-fork");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;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { callRelayerTransactAPI as
|
|
1
|
+
import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
|
|
2
2
|
import "../../../constants/chains.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
|
+
import "circomlibjs-hinkal-fork";
|
|
4
5
|
import "libsodium-wrappers";
|
|
5
6
|
import "../../../constants/vite.constants.mjs";
|
|
6
7
|
import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
|
|
7
8
|
import "../../../types/circom-data.types.mjs";
|
|
8
9
|
import "../../utils/external-action.utils.mjs";
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const h = async (t, r, s, a, i) => {
|
|
11
|
+
const c = m(a), o = await e(t, {
|
|
11
12
|
a: r[0],
|
|
12
13
|
b: r[1],
|
|
13
14
|
c: r[2],
|
|
14
15
|
dimData: s,
|
|
15
|
-
circomData:
|
|
16
|
-
withPrivateMempool:
|
|
16
|
+
circomData: c,
|
|
17
|
+
withPrivateMempool: i
|
|
17
18
|
});
|
|
18
19
|
if (o.status === "success")
|
|
19
20
|
return o.message;
|
|
20
21
|
throw new Error(o.error);
|
|
21
22
|
};
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
h as transactCallRelayer
|
|
24
25
|
};
|
|
@@ -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("ethers");require("libsodium-wrappers");require("process");require("buffer");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("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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;
|
|
@@ -15,17 +15,18 @@ import "../../types/circom-data.types.mjs";
|
|
|
15
15
|
import "../../types/transactions.types.mjs";
|
|
16
16
|
import "../../types/curve.types.mjs";
|
|
17
17
|
import "ethers";
|
|
18
|
+
import "circomlibjs-hinkal-fork";
|
|
18
19
|
import "libsodium-wrappers";
|
|
19
20
|
import "process";
|
|
20
21
|
import "buffer";
|
|
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("ethers");require("libsodium-wrappers");require("process");require("buffer");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("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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";
|
|
@@ -16,18 +16,19 @@ 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 "ethers";
|
|
19
|
+
import "circomlibjs-hinkal-fork";
|
|
19
20
|
import "libsodium-wrappers";
|
|
20
21
|
import "process";
|
|
21
22
|
import "buffer";
|
|
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("libsodium-wrappers");require("process");require("buffer");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-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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,17 +1,18 @@
|
|
|
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";
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
+
import "circomlibjs-hinkal-fork";
|
|
10
11
|
import "libsodium-wrappers";
|
|
11
12
|
import "process";
|
|
12
13
|
import "buffer";
|
|
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("libsodium-wrappers");require("process");require("buffer");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-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");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;
|
|
@@ -15,6 +15,7 @@ import "../../types/circom-data.types.mjs";
|
|
|
15
15
|
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
|
+
import "circomlibjs-hinkal-fork";
|
|
18
19
|
import "libsodium-wrappers";
|
|
19
20
|
import "process";
|
|
20
21
|
import "buffer";
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hinkal/common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"homepage": "hinkal.pro",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hinkal Protocol"
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"async-mutex": "^0.4.0",
|
|
53
53
|
"buffer": "6.0.3",
|
|
54
54
|
"circomlibjs": "^0.1.7",
|
|
55
|
+
"circomlibjs-hinkal-fork": "^0.0.3",
|
|
55
56
|
"dotenv": "^16.4.5",
|
|
56
57
|
"ethers": "5.5.1",
|
|
57
58
|
"idb-keyval": "6.2.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");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,4 +1,5 @@
|
|
|
1
1
|
import "ethers";
|
|
2
|
+
import "circomlibjs-hinkal-fork";
|
|
2
3
|
import "libsodium-wrappers";
|
|
3
4
|
import { Hinkal as o } from "../data-structures/Hinkal/Hinkal.mjs";
|
|
4
5
|
import "../constants/chains.constants.mjs";
|
|
@@ -20,11 +21,11 @@ import "../functions/web3/events/getShieldedBalance.mjs";
|
|
|
20
21
|
import "../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
21
22
|
import "idb-keyval";
|
|
22
23
|
import { ethersProvierAdapter as i } from "./EthersProviderAdapter.mjs";
|
|
23
|
-
const
|
|
24
|
+
const S = async (t) => {
|
|
24
25
|
await p();
|
|
25
26
|
const r = new o();
|
|
26
27
|
return i.initSigner?.(t), await r.initProviderAdapter(void 0, i), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
27
28
|
};
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
S as prepareEthersHinkal
|
|
30
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("circomlibjs-hinkal-fork");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;
|