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