@gurge/sdk 0.3.26 → 0.3.27
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/common/src/crypto/rnUtxoCrypto.cjs +1 -1
- package/common/src/crypto/rnUtxoCrypto.d.ts +11 -0
- package/common/src/crypto/rnUtxoCrypto.mjs +46 -12
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +9 -9
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalClaimUtxo.mjs +6 -6
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +18 -18
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +17 -17
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +13 -13
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +11 -11
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +14 -14
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +51 -51
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +51 -51
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +20 -20
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +19 -19
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +9 -9
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +12 -12
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +33 -33
- package/common/src/data-structures/crypto-keys/decodeUTXO.cjs +1 -1
- package/common/src/data-structures/crypto-keys/decodeUTXO.mjs +7 -7
- package/common/src/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/common/src/data-structures/crypto-keys/encryptDecryptUtxo.mjs +1 -1
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +3 -3
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.cjs +1 -1
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.mjs +13 -13
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +14 -14
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.mjs +7 -7
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +77 -76
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +60 -60
- package/common/src/functions/snarkjs/verifyCommitmentValidationData.cjs +1 -1
- package/common/src/functions/snarkjs/verifyCommitmentValidationData.mjs +1 -1
- package/common/src/functions/utils/buildClaimableDepositPlan.cjs +1 -1
- package/common/src/functions/utils/buildClaimableDepositPlan.mjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceiptSolana.mjs +4 -4
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.mjs +2 -2
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +81 -80
- package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +42 -42
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.mjs +1 -1
- package/common/src/webworker/cryptoWorker/cryptoWorker.types.cjs +1 -1
- package/common/src/webworker/cryptoWorker/cryptoWorker.types.d.ts +3 -1
- package/common/src/webworker/cryptoWorker/cryptoWorker.types.mjs +1 -1
- package/common/src/webworker/logError-Dy_GXEF5.js +2 -0
- package/common/src/webworker/package.json +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +4 -4
- package/common/src/webworker/viteWorkerURL.constant.mjs +4 -4
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/package.json +1 -1
- package/sdk/package.json.cjs +1 -1
- package/sdk/package.json.mjs +1 -1
- package/common/src/webworker/logError-DFS-H2t0.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../constants/chains.constants.cjs`);const e=require(`./caseInsensitive.utils.cjs`),t=require(`./amounts.utils.cjs`);require(`../../data-structures/crypto-keys/keys.cjs`);const n=require(`../../types/ethereum-network.types.cjs`);require(`../../types/index.cjs`)
|
|
1
|
+
require(`../../constants/chains.constants.cjs`);const e=require(`./caseInsensitive.utils.cjs`),t=require(`./amounts.utils.cjs`);require(`../../data-structures/crypto-keys/keys.cjs`),require(`../../data-structures/crypto-keys/encryptDecryptUtxo.cjs`);const n=require(`../../types/ethereum-network.types.cjs`);require(`../../types/index.cjs`);const r=require(`../../data-structures/crypto-keys/decodeUTXO.cjs`),i=require(`./getContractAddress.cjs`);require(`ethers`);var a=(a,o,s,c)=>{let l=o.getContractWithFetcher(s,n.ContractType.HinkalContract),u=l.interface,d=o.userKeys.getShieldedPrivateKey(),f=i.getContractAddress(l);return a.logs.filter(t=>e.caseInsensitiveEqual(t.address,f)).map(n=>{try{let i=u.parseLog(n);if(i?.name===`NewCommitment`){let{encryptedOutput:n,index:a}=i.args;if(t.toBigInt(a)<0n){let t=r.decodeUtxo(n,d,s);if(e.caseInsensitiveEqual(t.erc20TokenAddress,c))return t}}}catch{return null}return null}).filter(e=>e!==null)};exports.getOnChainUtxosFromReceipt=a;
|
|
@@ -2,9 +2,9 @@ import "../../constants/chains.constants.mjs";
|
|
|
2
2
|
import { caseInsensitiveEqual as e } from "./caseInsensitive.utils.mjs";
|
|
3
3
|
import { toBigInt as t } from "./amounts.utils.mjs";
|
|
4
4
|
import "../../data-structures/crypto-keys/keys.mjs";
|
|
5
|
+
import "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
5
6
|
import { ContractType as n } from "../../types/ethereum-network.types.mjs";
|
|
6
7
|
import "../../types/index.mjs";
|
|
7
|
-
import "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
8
8
|
import { decodeUtxo as r } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
|
|
9
9
|
import { getContractAddress as i } from "./getContractAddress.mjs";
|
|
10
10
|
import "ethers";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`),require(`../../constants/chains.constants.cjs`);const e=require(`./caseInsensitive.utils.cjs`),t=require(`../../crypto/poseidon.cjs`)
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`),require(`../../constants/chains.constants.cjs`);const e=require(`./caseInsensitive.utils.cjs`),t=require(`../../crypto/poseidon.cjs`);require(`../../data-structures/crypto-keys/encryptDecryptUtxo.cjs`);const n=require(`./bit.operations.cjs`),r=require(`../../data-structures/utxo/Utxo.cjs`),i=require(`./bytes32.utils.cjs`);let a=require(`ethers`),o=require(`@solana/web3.js`),s=require(`@coral-xyz/anchor`);var c=(c,l,u,d)=>[...new s.EventParser(l.programId,new s.BorshCoder(l.idl)).parseLogs(c.meta?.logMessages??[])].filter(({name:t})=>e.caseInsensitiveEqual(t,`newCommitment`)).filter(({data:e})=>e.encryptedOutput.length===0).map(e=>{let{onChainData:s}=e.data,[c,l,d,f,p,m,,h]=s.map(i.convertBytes32ToBigInt),[,g,_]=s,v=new o.PublicKey([...g.slice(16),..._.slice(16)]),y=t.poseidonHash(l,d),b=n.extractHighestBit(f)===1n,x=new r.Utxo({amount:c,timeStamp:h.toString(),nullifyingKey:u.getShieldedPrivateKey(),mintAddress:v.toBase58(),erc20TokenAddress:y,stealthAddress:a.ethers.toBeHex(p),isNewStyle:b,...b?{H0:[n.takeOffHighestBit(f),m]}:{randomization:f}});return x.getStealthAddress(),x}).filter(t=>e.caseInsensitiveEqual(t.erc20TokenAddress,d));exports.getOnChainUtxosFromReceiptSolana=c;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../../constants/chains.constants.mjs";
|
|
2
2
|
import { caseInsensitiveEqual as e } from "./caseInsensitive.utils.mjs";
|
|
3
3
|
import { poseidonHash as t } from "../../crypto/poseidon.mjs";
|
|
4
|
-
import { Utxo as n } from "../../data-structures/utxo/Utxo.mjs";
|
|
5
4
|
import "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
6
|
-
import { extractHighestBit as
|
|
5
|
+
import { extractHighestBit as n, takeOffHighestBit as r } from "./bit.operations.mjs";
|
|
6
|
+
import { Utxo as i } from "../../data-structures/utxo/Utxo.mjs";
|
|
7
7
|
import { convertBytes32ToBigInt as a } from "./bytes32.utils.mjs";
|
|
8
8
|
import { ethers as o } from "ethers";
|
|
9
9
|
import { PublicKey as s } from "@solana/web3.js";
|
|
10
10
|
import { BorshCoder as c, EventParser as l } from "@coral-xyz/anchor";
|
|
11
11
|
//#region libs/shared/common/src/functions/utils/getUtxosFromReceiptSolana.ts
|
|
12
12
|
var u = (u, d, f, p) => [...new l(d.programId, new c(d.idl)).parseLogs(u.meta?.logMessages ?? [])].filter(({ name: t }) => e(t, "newCommitment")).filter(({ data: e }) => e.encryptedOutput.length === 0).map((e) => {
|
|
13
|
-
let { onChainData: c } = e.data, [l, u, d, p, m, h, , g] = c.map(a), [, _, v] = c, y = new s([..._.slice(16), ...v.slice(16)]), b = t(u, d), x =
|
|
13
|
+
let { onChainData: c } = e.data, [l, u, d, p, m, h, , g] = c.map(a), [, _, v] = c, y = new s([..._.slice(16), ...v.slice(16)]), b = t(u, d), x = n(p) === 1n, S = new i({
|
|
14
14
|
amount: l,
|
|
15
15
|
timeStamp: g.toString(),
|
|
16
16
|
nullifyingKey: f.getShieldedPrivateKey(),
|
|
@@ -18,7 +18,7 @@ var u = (u, d, f, p) => [...new l(d.programId, new c(d.idl)).parseLogs(u.meta?.l
|
|
|
18
18
|
erc20TokenAddress: b,
|
|
19
19
|
stealthAddress: o.toBeHex(m),
|
|
20
20
|
isNewStyle: x,
|
|
21
|
-
...x ? { H0: [
|
|
21
|
+
...x ? { H0: [r(p), h] } : { randomization: p }
|
|
22
22
|
});
|
|
23
23
|
return S.getStealthAddress(), S;
|
|
24
24
|
}).filter((t) => e(t.erc20TokenAddress, p));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./abi.utils.cjs`),require(`./serialize.utils.cjs`),require(`./caseInsensitive.utils.cjs`),require(`./amounts.utils.cjs`),require(`./time.utils.cjs`),require(`./upToDateState.cjs`),require(`./cacheFunctions.cjs`),require(`./enclaveHandshakeService.cjs`),require(`./encryptInputForEnclave.cjs`),require(`./solanaMint.utils.cjs`),require(`./customEnclaveFunctionsRegister.cjs`),require(`./addresses.cjs`),require(`./tron.utils.cjs`),require(`./get-signature-header.cjs`),require(`./auth.utils.cjs`),require(`./string.utils.cjs`),require(`./token-check.utils.cjs`),require(`./map.utils.cjs`),require(`./mutexes.utils.cjs`),require(`./erc20tokenFunctions.cjs`),require(`../pre-transaction/outputUtxoProcessing.cjs`),require(
|
|
1
|
+
require(`./abi.utils.cjs`),require(`./serialize.utils.cjs`),require(`./caseInsensitive.utils.cjs`),require(`./amounts.utils.cjs`),require(`./external-action.utils.cjs`),require(`./bit.operations.cjs`),require(`./time.utils.cjs`),require(`./upToDateState.cjs`),require(`./cacheFunctions.cjs`),require(`./enclaveHandshakeService.cjs`),require(`./encryptInputForEnclave.cjs`),require(`./solanaMint.utils.cjs`),require(`./customEnclaveFunctionsRegister.cjs`),require(`./addresses.cjs`),require(`./tron.utils.cjs`),require(`./get-signature-header.cjs`),require(`./auth.utils.cjs`),require(`./string.utils.cjs`),require(`./token-check.utils.cjs`),require(`./map.utils.cjs`),require(`./mutexes.utils.cjs`),require(`./erc20tokenFunctions.cjs`),require(`../pre-transaction/outputUtxoProcessing.cjs`),require(`../pre-transaction/solana.cjs`),require(`../pre-transaction/process-gas-estimates.cjs`),require(`../pre-transaction/getVolatileTransferAmount.cjs`),require(`../pre-transaction/constructAdminData.cjs`),require(`./create-provider.cjs`),require(`../pre-transaction/convert-okx-instructions.cjs`),require(`./process.utils.cjs`),require(`../pre-transaction/sendV0Transaction.cjs`),require(`./bytes32.utils.cjs`),require(`../pre-transaction/recipientUtxoProcessing.cjs`),require(`../pre-transaction/ensureAmountChanges.cjs`),require(`../pre-transaction/getFeeStructure.cjs`),require(`../pre-transaction/waitForDepositedUtxosInMerkleTree.cjs`),require(`../pre-transaction/buildCommitmentValidationData.cjs`),require(`../pre-transaction/index.cjs`),require(`./serialize-utxos.utils.cjs`),require(`./bigint-math.utils.cjs`),require(`./resolve-sync.utils.cjs`),require(`./convertIntegrationProviderToExternalActionId.cjs`),require(`./evmNetworkFunctions.cjs`),require(`./userAgent.cjs`),require(`./reloadPage.cjs`),require(`./cacheDevice.utils.cjs`),require(`./getBlockExplorerUrl.cjs`),require(`./involves-permit2-op.cjs`),require(`./convertEmporiumOpToCallInfo.cjs`),require(`./getRecipientInfoFromUserKeys.cjs`),require(`./publicBalance.utils.cjs`),require(`./rpc-int-encode.cjs`),require(`./walletBalances.utils.cjs`),require(`./nftTokenFunctions.cjs`),require(`./inLogicMetadata.cjs`),require(`./networks.utils.cjs`),require(`./postToOffscreen.cjs`),require(`./solanaSendPreflight.utils.cjs`),require(`./prepareHinkal.cjs`),require(`./getContractAddress.cjs`),require(`./getUtxosFromReceipt.utils.cjs`),require(`./getUtxosFromReceiptSolana.cjs`),require(`./fees.utils.cjs`),require(`./enclave-utxo-storage.cjs`),require(`./enclave-signature-storage.cjs`),require(`./tx-confirmation.utils.cjs`),require(`./buildClaimableDepositPlan.cjs`),require(`./formatter.cjs`),require(`./tronSimulation.utils.cjs`),require(`./getSignerFromContract.cjs`),require(`./deposit-claimable.utils.cjs`),require(`./transfer-claimable.utils.cjs`),require(`./dispatchBalanceRefreshes.cjs`),require(`./lifi.utils.cjs`),require(`./enclave-recipient-info-storage.cjs`),require(`./solana-memo.cjs`),require(`./mnemonics.cjs`),require(`./nearIntents.utils.cjs`);
|
|
@@ -2,6 +2,8 @@ import "./abi.utils.mjs";
|
|
|
2
2
|
import "./serialize.utils.mjs";
|
|
3
3
|
import "./caseInsensitive.utils.mjs";
|
|
4
4
|
import "./amounts.utils.mjs";
|
|
5
|
+
import "./external-action.utils.mjs";
|
|
6
|
+
import "./bit.operations.mjs";
|
|
5
7
|
import "./time.utils.mjs";
|
|
6
8
|
import "./upToDateState.mjs";
|
|
7
9
|
import "./cacheFunctions.mjs";
|
|
@@ -19,8 +21,6 @@ import "./map.utils.mjs";
|
|
|
19
21
|
import "./mutexes.utils.mjs";
|
|
20
22
|
import "./erc20tokenFunctions.mjs";
|
|
21
23
|
import "../pre-transaction/outputUtxoProcessing.mjs";
|
|
22
|
-
import "./external-action.utils.mjs";
|
|
23
|
-
import "./bit.operations.mjs";
|
|
24
24
|
import "../pre-transaction/solana.mjs";
|
|
25
25
|
import "../pre-transaction/process-gas-estimates.mjs";
|
|
26
26
|
import "../pre-transaction/getVolatileTransferAmount.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../utils/utxoPadding.utils.cjs`),
|
|
1
|
+
require(`../../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../../crypto/rnUtxoCrypto.cjs`),r=require(`../../utils/utxoPadding.utils.cjs`),i=require(`../../utils/upToDateState.cjs`),a=require(`../../utils/cacheFunctions.cjs`),o=require(`../../utils/encodeTokenWithId.cjs`),s=require(`../../utils/solanaMint.utils.cjs`),c=require(`./getInputUtxosEnclave.cjs`),l=require(`../../utils/addresses.cjs`),u=require(`../../../API/scheduled-transactions-calls.cjs`),d=require(`../../utils/tron.utils.cjs`),f=require(`../../utils/hinkalTiming.utils.cjs`);var p=new(require(`async-mutex`)).Mutex,m=async(e,t)=>{if(e.allowParallelBalanceLocalDecryption)return t();let n=f.createRnDeltaTiming(`utxoPrep.mutex`);return p.isLocked()&&n.log(`waiting-for-lock`),p.runExclusive(async()=>{n.log(`lock-acquired`);try{return await t()}finally{n.log(`lock-released`)}})},h=async(e,t,n,r,o,s,c,l,u)=>m(e,async()=>{let d=f.createRnDeltaTiming(`utxoPrep.decrypt`);u+=1;let p=s.slice(u);d.log(`batchProcess-start`,{outputsSlice:p.length,cached:c.length});let{lastOutput:m,additionalEncryptedOutputs:h}=await e.utxoUtils.batchProcess(p,l,t,n);d.log(`batchProcess-done`,{additionalEncryptedOutputs:h.length});let g=[...c,...h],_=f.createRnDeltaTiming(`wallet.checkAddress`);await i.checkAddressNotUpdated(e,r),_.log(`during-decrypt`),a.setHinkalCache({lastOutput:m,encryptedOutputs:g},e,n,o),d.log(`cache-write`,{encryptedOutputs:g.length});let v=await e.utxoUtils.buildBatchProcess(g,t,n);return d.log(`buildBatchProcess-done`,{utxoCount:v.length}),v}),g=async(e,t,n,r)=>{let{utxos:i,encryptedOutputs:o,lastOutput:s}=await c.getInputUtxosEnclave(e,n,t);return a.setHinkalCache({encryptedOutputs:o,lastOutput:s},e,n,r),i},_=async(e,t,n,r,i,a,o,s,c)=>{try{return await g(e,t,n,i)}catch{return h(e,t,n,r,i,a,o,s,c)}},v=e=>{if(Array.isArray(e))return e;if(e!==void 0)return[e]},y=async(e,t,n)=>await e.utxoUtils.batchFilterUtxosWithNullifier(t,n),b=async(e,t,n,i,a,o,s,c)=>{for(e.sort((e,t)=>e.amount<=t.amount?1:-1);e.length<t||e.length>t&&e.length<6;){let[t]=await r.createPaddingUtxos(1,{amount:0n,erc20TokenAddress:o,mintAddress:c,nullifyingKey:i,spendingPublicKey:a,isNewStyle:!0});if(e.push(t),n)for(;e.length>6;)e.splice(e.length-1)}},x=async({hinkal:e,chainId:t,passedShieldedPublicKey:n=void 0,ethAddress:r=void 0,resetCacheBefore:o=!1,allowRemoteDecryption:s=!1,useBlockedUtxos:c=!1})=>{let l=f.createRnDeltaTiming(`utxoPrep`);l.log(`start`);let u=r;u?l.log(`wallet.getEthereumAddress-skipped`,{ethAddressPassed:!0}):(u=await e.getEthereumAddress(),l.log(`wallet.getEthereumAddress`));let d=n??e.userKeys.getShieldedPublicKey(),{userKeys:p}=e,m=e.encryptedOutputsByChain[t],g=e.nullifiersByChain[t],v=Array.from(m);o&&a.resetCache(e,t,d);let{encryptedOutputs:b,lastOutput:x}=a.getHinkalCache(e,t,d);l.log(`cache.read`,{cachedEncryptedOutputs:b.length});let S=f.createRnDeltaTiming(`wallet.checkAddress`);await i.checkAddressNotUpdated(e,u),S.log(`before-decrypt`);let C=x!==``,w=v.findIndex(e=>e.value===x);l.log(`findLastOutputIndex`,{hinkalOutputs:v.length,lastOutputIndex:w});let T=w>-1,E=!C&&w===-1,D=e.areMerkleTreeUpdatesDisabled(),O=!D&&(T||!s&&E),k=!D&&s&&E,A=!O&&!k;l.log(`branch`,{decryptLocally:O,decryptRemotely:k,useCache:A,outputsSlice:w>-1?v.length-(w+1):0});let j=[];O?(j=await h(e,p,t,u,d,v,b,x,w),l.log(`decryptLocally-done`,{utxoCount:j.length})):k?(j=await _(e,p,t,u,d,v,b,x,w),l.log(`decryptRemotely-done`,{utxoCount:j.length})):A&&(j=await e.utxoUtils.buildBatchProcess(b,p,t),l.log(`useCache-buildBatchProcess-done`,{utxoCount:j.length}));let M=f.createRnDeltaTiming(`wallet.checkAddress`);await i.checkAddressNotUpdated(e,u),M.log(`after-decrypt`);let N=await y(e,j,g);l.log(`filterSpentUtxos`,{allUtxos:j.length,inputUtxos:N.length});let P=c?N.filter(e=>e.isBlocked):N.filter(e=>!e.isBlocked);return l.log(`done`,{inputUtxos:P.length}),{inputUtxos:P}},S=async({hinkal:t,chainId:n,passedShieldedPublicKey:r=void 0,ethAddress:i=void 0,resetCacheBefore:a=!1,allowRemoteDecryption:o=!1})=>{let s=i??await t.getEthereumAddressByChain(n),c=l.hashEthereumAddress(e.isTronLike(n)?d.addressToHexFormat(s):s),{inputUtxos:f}=await x({hinkal:t,chainId:n,passedShieldedPublicKey:r,ethAddress:s,resetCacheBefore:a,allowRemoteDecryption:o,useBlockedUtxos:!0});if(!f.length)return{inputUtxos:[]};let{indexes:p}=await u.getScheduledTransactionsNullifierIndexes({hashedEthereumAddress:c,nullifiers:f.map(e=>e.getNullifier())});return{inputUtxos:p.map(e=>f[e]).filter(e=>!!e)}},C=async({hinkal:r,tokenWithId:i,minInput:a=2,sliceIfMore6:c=!0,chainId:l,passedShieldedPrivateKey:u=void 0,passedShieldedPublicKey:d=void 0,ethAddress:f=void 0,resetCacheBefore:p=!1,ensuredTokensWithId:m,allowRemoteDecryption:h=!1,useBlockedUtxos:g=!1})=>{let _=u??r.userKeys.getShieldedPrivateKey(),y=await n.getSpendingPublicKeyForRn(r.userKeys),{inputUtxos:C}=g?await S({hinkal:r,chainId:l,ethAddress:f,passedShieldedPrivateKey:u,resetCacheBefore:p,allowRemoteDecryption:h}):await x({hinkal:r,tokenWithId:i,minInput:a,sliceIfMore6:c,chainId:l,passedShieldedPrivateKey:u,passedShieldedPublicKey:d,ethAddress:f,resetCacheBefore:p,allowRemoteDecryption:h}),w=v(i),T=new Map;C.forEach(e=>{let n=e.getTokenAddress(l);if(w&&!w.some(e=>t.caseInsensitiveEqual(e.erc20TokenAddress,n)))return;let r=o.encodeTokenWithId(l,{erc20TokenAddress:n,tokenId:0}),i=T.get(r)??[];T.set(r,[...i,e])}),m?.forEach(e=>{let t=o.encodeTokenWithId(l,{erc20TokenAddress:e.erc20TokenAddress,tokenId:0});T.set(t,T.get(t)??[])});for(let[t,n]of T){let r=t.split(`-`)[0],i=Number(t.split(`-`)[1]),o=e.isSolanaLike(l),u=o?r:void 0;await b(n,a,c,_,y,o?s.formatMintAddress(r).compressedAddress.toLowerCase():r.toLowerCase(),i,u)}return T};exports.attemptGetInputUtxosRemotely=_,exports.getInputUtxoAndBalance=x,exports.getInputUtxoAndBalanceOfStuckUtxos=S,exports.getInputUtxoAndBalancePerToken=C,exports.getInputUtxosRemotely=g;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { isSolanaLike as e, isTronLike as t } from "../../../constants/chains.constants.mjs";
|
|
2
2
|
import { caseInsensitiveEqual as n } from "../../utils/caseInsensitive.utils.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
3
|
+
import { getSpendingPublicKeyForRn as r } from "../../../crypto/rnUtxoCrypto.mjs";
|
|
4
|
+
import { createPaddingUtxos as i } from "../../utils/utxoPadding.utils.mjs";
|
|
5
|
+
import { checkAddressNotUpdated as a } from "../../utils/upToDateState.mjs";
|
|
6
|
+
import { getHinkalCache as o, resetCache as s, setHinkalCache as c } from "../../utils/cacheFunctions.mjs";
|
|
7
|
+
import { encodeTokenWithId as l } from "../../utils/encodeTokenWithId.mjs";
|
|
8
|
+
import { formatMintAddress as u } from "../../utils/solanaMint.utils.mjs";
|
|
9
|
+
import { getInputUtxosEnclave as d } from "./getInputUtxosEnclave.mjs";
|
|
10
|
+
import { hashEthereumAddress as f } from "../../utils/addresses.mjs";
|
|
11
|
+
import { getScheduledTransactionsNullifierIndexes as p } from "../../../API/scheduled-transactions-calls.mjs";
|
|
12
|
+
import { addressToHexFormat as m } from "../../utils/tron.utils.mjs";
|
|
13
|
+
import { createRnDeltaTiming as h } from "../../utils/hinkalTiming.utils.mjs";
|
|
14
|
+
import { Mutex as g } from "async-mutex";
|
|
14
15
|
//#region libs/shared/common/src/functions/web3/events/getInputUtxoAndBalance.ts
|
|
15
|
-
var
|
|
16
|
+
var _ = new g(), v = async (e, t) => {
|
|
16
17
|
if (e.allowParallelBalanceLocalDecryption) return t();
|
|
17
|
-
let n =
|
|
18
|
-
return
|
|
18
|
+
let n = h("utxoPrep.mutex");
|
|
19
|
+
return _.isLocked() && n.log("waiting-for-lock"), _.runExclusive(async () => {
|
|
19
20
|
n.log("lock-acquired");
|
|
20
21
|
try {
|
|
21
22
|
return await t();
|
|
@@ -23,62 +24,62 @@ var g = new h(), _ = async (e, t) => {
|
|
|
23
24
|
n.log("lock-released");
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
|
-
},
|
|
27
|
-
let d =
|
|
27
|
+
}, y = async (e, t, n, r, i, o, s, l, u) => v(e, async () => {
|
|
28
|
+
let d = h("utxoPrep.decrypt");
|
|
28
29
|
u += 1;
|
|
29
30
|
let f = o.slice(u);
|
|
30
31
|
d.log("batchProcess-start", {
|
|
31
32
|
outputsSlice: f.length,
|
|
32
|
-
cached:
|
|
33
|
+
cached: s.length
|
|
33
34
|
});
|
|
34
|
-
let { lastOutput: p, additionalEncryptedOutputs:
|
|
35
|
-
d.log("batchProcess-done", { additionalEncryptedOutputs:
|
|
36
|
-
let g = [...
|
|
37
|
-
await
|
|
35
|
+
let { lastOutput: p, additionalEncryptedOutputs: m } = await e.utxoUtils.batchProcess(f, l, t, n);
|
|
36
|
+
d.log("batchProcess-done", { additionalEncryptedOutputs: m.length });
|
|
37
|
+
let g = [...s, ...m], _ = h("wallet.checkAddress");
|
|
38
|
+
await a(e, r), _.log("during-decrypt"), c({
|
|
38
39
|
lastOutput: p,
|
|
39
40
|
encryptedOutputs: g
|
|
40
|
-
}, e, n,
|
|
41
|
+
}, e, n, i), d.log("cache-write", { encryptedOutputs: g.length });
|
|
41
42
|
let v = await e.utxoUtils.buildBatchProcess(g, t, n);
|
|
42
43
|
return d.log("buildBatchProcess-done", { utxoCount: v.length }), v;
|
|
43
|
-
}),
|
|
44
|
-
let { utxos: i, encryptedOutputs: a, lastOutput: o } = await
|
|
45
|
-
return
|
|
44
|
+
}), b = async (e, t, n, r) => {
|
|
45
|
+
let { utxos: i, encryptedOutputs: a, lastOutput: o } = await d(e, n, t);
|
|
46
|
+
return c({
|
|
46
47
|
encryptedOutputs: a,
|
|
47
48
|
lastOutput: o
|
|
48
49
|
}, e, n, r), i;
|
|
49
|
-
},
|
|
50
|
+
}, x = async (e, t, n, r, i, a, o, s, c) => {
|
|
50
51
|
try {
|
|
51
|
-
return await
|
|
52
|
+
return await b(e, t, n, i);
|
|
52
53
|
} catch {
|
|
53
|
-
return
|
|
54
|
+
return y(e, t, n, r, i, a, o, s, c);
|
|
54
55
|
}
|
|
55
|
-
},
|
|
56
|
+
}, S = (e) => {
|
|
56
57
|
if (Array.isArray(e)) return e;
|
|
57
58
|
if (e !== void 0) return [e];
|
|
58
|
-
},
|
|
59
|
+
}, C = async (e, t, n) => await e.utxoUtils.batchFilterUtxosWithNullifier(t, n), w = async (e, t, n, r, a, o, s, c) => {
|
|
59
60
|
for (e.sort((e, t) => e.amount <= t.amount ? 1 : -1); e.length < t || e.length > t && e.length < 6;) {
|
|
60
|
-
let [t] = await
|
|
61
|
+
let [t] = await i(1, {
|
|
61
62
|
amount: 0n,
|
|
62
63
|
erc20TokenAddress: o,
|
|
63
64
|
mintAddress: c,
|
|
64
|
-
nullifyingKey:
|
|
65
|
+
nullifyingKey: r,
|
|
65
66
|
spendingPublicKey: a,
|
|
66
67
|
isNewStyle: !0
|
|
67
68
|
});
|
|
68
69
|
if (e.push(t), n) for (; e.length > 6;) e.splice(e.length - 1);
|
|
69
70
|
}
|
|
70
|
-
},
|
|
71
|
-
let u =
|
|
71
|
+
}, T = async ({ hinkal: e, chainId: t, passedShieldedPublicKey: n = void 0, ethAddress: r = void 0, resetCacheBefore: i = !1, allowRemoteDecryption: c = !1, useBlockedUtxos: l = !1 }) => {
|
|
72
|
+
let u = h("utxoPrep");
|
|
72
73
|
u.log("start");
|
|
73
74
|
let d = r;
|
|
74
75
|
d ? u.log("wallet.getEthereumAddress-skipped", { ethAddressPassed: !0 }) : (d = await e.getEthereumAddress(), u.log("wallet.getEthereumAddress"));
|
|
75
|
-
let f = n ?? e.userKeys.getShieldedPublicKey(), { userKeys: p } = e,
|
|
76
|
-
|
|
77
|
-
let { encryptedOutputs:
|
|
78
|
-
u.log("cache.read", { cachedEncryptedOutputs:
|
|
79
|
-
let
|
|
80
|
-
await
|
|
81
|
-
let w =
|
|
76
|
+
let f = n ?? e.userKeys.getShieldedPublicKey(), { userKeys: p } = e, m = e.encryptedOutputsByChain[t], g = e.nullifiersByChain[t], _ = Array.from(m);
|
|
77
|
+
i && s(e, t, f);
|
|
78
|
+
let { encryptedOutputs: v, lastOutput: b } = o(e, t, f);
|
|
79
|
+
u.log("cache.read", { cachedEncryptedOutputs: v.length });
|
|
80
|
+
let S = h("wallet.checkAddress");
|
|
81
|
+
await a(e, d), S.log("before-decrypt");
|
|
82
|
+
let w = b !== "", T = _.findIndex((e) => e.value === b);
|
|
82
83
|
u.log("findLastOutputIndex", {
|
|
83
84
|
hinkalOutputs: _.length,
|
|
84
85
|
lastOutputIndex: T
|
|
@@ -91,18 +92,18 @@ var g = new h(), _ = async (e, t) => {
|
|
|
91
92
|
outputsSlice: T > -1 ? _.length - (T + 1) : 0
|
|
92
93
|
});
|
|
93
94
|
let M = [];
|
|
94
|
-
k ? (M = await
|
|
95
|
-
let N =
|
|
96
|
-
await
|
|
97
|
-
let P = await
|
|
95
|
+
k ? (M = await y(e, p, t, d, f, _, v, b, T), u.log("decryptLocally-done", { utxoCount: M.length })) : A ? (M = await x(e, p, t, d, f, _, v, b, T), u.log("decryptRemotely-done", { utxoCount: M.length })) : j && (M = await e.utxoUtils.buildBatchProcess(v, p, t), u.log("useCache-buildBatchProcess-done", { utxoCount: M.length }));
|
|
96
|
+
let N = h("wallet.checkAddress");
|
|
97
|
+
await a(e, d), N.log("after-decrypt");
|
|
98
|
+
let P = await C(e, M, g);
|
|
98
99
|
u.log("filterSpentUtxos", {
|
|
99
100
|
allUtxos: M.length,
|
|
100
101
|
inputUtxos: P.length
|
|
101
102
|
});
|
|
102
103
|
let F = l ? P.filter((e) => e.isBlocked) : P.filter((e) => !e.isBlocked);
|
|
103
104
|
return u.log("done", { inputUtxos: F.length }), { inputUtxos: F };
|
|
104
|
-
},
|
|
105
|
-
let s = i ?? await e.getEthereumAddressByChain(n), c =
|
|
105
|
+
}, E = async ({ hinkal: e, chainId: n, passedShieldedPublicKey: r = void 0, ethAddress: i = void 0, resetCacheBefore: a = !1, allowRemoteDecryption: o = !1 }) => {
|
|
106
|
+
let s = i ?? await e.getEthereumAddressByChain(n), c = f(t(n) ? m(s) : s), { inputUtxos: l } = await T({
|
|
106
107
|
hinkal: e,
|
|
107
108
|
chainId: n,
|
|
108
109
|
passedShieldedPublicKey: r,
|
|
@@ -112,51 +113,51 @@ var g = new h(), _ = async (e, t) => {
|
|
|
112
113
|
useBlockedUtxos: !0
|
|
113
114
|
});
|
|
114
115
|
if (!l.length) return { inputUtxos: [] };
|
|
115
|
-
let { indexes: u } = await
|
|
116
|
+
let { indexes: u } = await p({
|
|
116
117
|
hashedEthereumAddress: c,
|
|
117
118
|
nullifiers: l.map((e) => e.getNullifier())
|
|
118
119
|
});
|
|
119
120
|
return { inputUtxos: u.map((e) => l[e]).filter((e) => !!e) };
|
|
120
|
-
},
|
|
121
|
-
let
|
|
121
|
+
}, D = async ({ hinkal: t, tokenWithId: i, minInput: a = 2, sliceIfMore6: o = !0, chainId: s, passedShieldedPrivateKey: c = void 0, passedShieldedPublicKey: d = void 0, ethAddress: f = void 0, resetCacheBefore: p = !1, ensuredTokensWithId: m, allowRemoteDecryption: h = !1, useBlockedUtxos: g = !1 }) => {
|
|
122
|
+
let _ = c ?? t.userKeys.getShieldedPrivateKey(), v = await r(t.userKeys), { inputUtxos: y } = g ? await E({
|
|
122
123
|
hinkal: t,
|
|
123
|
-
chainId:
|
|
124
|
-
ethAddress:
|
|
125
|
-
passedShieldedPrivateKey:
|
|
126
|
-
resetCacheBefore:
|
|
127
|
-
allowRemoteDecryption:
|
|
128
|
-
}) : await
|
|
124
|
+
chainId: s,
|
|
125
|
+
ethAddress: f,
|
|
126
|
+
passedShieldedPrivateKey: c,
|
|
127
|
+
resetCacheBefore: p,
|
|
128
|
+
allowRemoteDecryption: h
|
|
129
|
+
}) : await T({
|
|
129
130
|
hinkal: t,
|
|
130
|
-
tokenWithId:
|
|
131
|
-
minInput:
|
|
132
|
-
sliceIfMore6:
|
|
133
|
-
chainId:
|
|
134
|
-
passedShieldedPrivateKey:
|
|
135
|
-
passedShieldedPublicKey:
|
|
136
|
-
ethAddress:
|
|
137
|
-
resetCacheBefore:
|
|
138
|
-
allowRemoteDecryption:
|
|
139
|
-
}),
|
|
140
|
-
|
|
141
|
-
let t = e.getTokenAddress(
|
|
142
|
-
if (
|
|
143
|
-
let r =
|
|
131
|
+
tokenWithId: i,
|
|
132
|
+
minInput: a,
|
|
133
|
+
sliceIfMore6: o,
|
|
134
|
+
chainId: s,
|
|
135
|
+
passedShieldedPrivateKey: c,
|
|
136
|
+
passedShieldedPublicKey: d,
|
|
137
|
+
ethAddress: f,
|
|
138
|
+
resetCacheBefore: p,
|
|
139
|
+
allowRemoteDecryption: h
|
|
140
|
+
}), b = S(i), x = /* @__PURE__ */ new Map();
|
|
141
|
+
y.forEach((e) => {
|
|
142
|
+
let t = e.getTokenAddress(s);
|
|
143
|
+
if (b && !b.some((e) => n(e.erc20TokenAddress, t))) return;
|
|
144
|
+
let r = l(s, {
|
|
144
145
|
erc20TokenAddress: t,
|
|
145
146
|
tokenId: 0
|
|
146
|
-
}), i =
|
|
147
|
-
|
|
148
|
-
}),
|
|
149
|
-
let t =
|
|
147
|
+
}), i = x.get(r) ?? [];
|
|
148
|
+
x.set(r, [...i, e]);
|
|
149
|
+
}), m?.forEach((e) => {
|
|
150
|
+
let t = l(s, {
|
|
150
151
|
erc20TokenAddress: e.erc20TokenAddress,
|
|
151
152
|
tokenId: 0
|
|
152
153
|
});
|
|
153
|
-
|
|
154
|
+
x.set(t, x.get(t) ?? []);
|
|
154
155
|
});
|
|
155
|
-
for (let [t, n] of
|
|
156
|
-
let r = t.split("-")[0],
|
|
157
|
-
await
|
|
156
|
+
for (let [t, n] of x) {
|
|
157
|
+
let r = t.split("-")[0], i = Number(t.split("-")[1]), c = e(s), l = c ? r : void 0;
|
|
158
|
+
await w(n, a, o, _, v, c ? u(r).compressedAddress.toLowerCase() : r.toLowerCase(), i, l);
|
|
158
159
|
}
|
|
159
|
-
return
|
|
160
|
+
return x;
|
|
160
161
|
};
|
|
161
162
|
//#endregion
|
|
162
|
-
export {
|
|
163
|
+
export { x as attemptGetInputUtxosRemotely, T as getInputUtxoAndBalance, E as getInputUtxoAndBalanceOfStuckUtxos, D as getInputUtxoAndBalancePerToken, b as getInputUtxosRemotely };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../../error-handling/customErrors/ErrorWithTx.cjs`),
|
|
1
|
+
const e=require(`../../snarkjs/common.snarkjs.cjs`),t=require(`../../../error-handling/customErrors/ErrorWithTx.cjs`),n=require(`../../../constants/server.constants.cjs`),r=require(`../../../API/getServerURL.cjs`),i=require(`../../../data-structures/http/HttpClient.cjs`),a=require(`../../../API/callRelayer.cjs`);require(`../../../error-handling/index.cjs`),require(`../../snarkjs/index.cjs`);var o=e=>{if(e.status===`success`)return e.message;throw e.message&&e.error?new t.ErrorWithRelayerTransaction(e.error,e.message):Error(e.error)},s=async(t,n,r,i,s,c,l,u,d)=>{let f=e.serializeCircomData(i);return o(await a.callRelayerTransactAPI({chainId:t,a:n[0],b:n[1],c:n[2],dimData:r,circomData:f,withUniswapWorkAround:c,authorizationData:l,adminData:u,tronProofSignature:d,commitmentValidationData:s}))},c=async e=>o(await i.httpClient.post(`${r.RELAYER_URL}${n.RELAYER_CONFIG.SOLANA_TRANSACT}`,e)),l=e=>{if(e.status===`success`)return e.message.scheduleId;throw Error(e.error||`Batch transaction failed`)},u=async(t,n,r,i,o,s)=>{let c=n.map(t=>e.serializeCircomData(t.circomData));return l(await a.callRelayerTransactBatchAPI({chainId:t,transactions:n.map((e,n)=>({chainId:t,a:e.zkCallData[0],b:e.zkCallData[1],c:e.zkCallData[2],dimData:e.dimData,circomData:c[n],commitmentValidationData:e.commitmentValidationData,withUniswapWorkAround:e.withUniswapWorkAround,authorizationData:e.authorizationData,adminData:e.adminData,recipientAddress:e.recipientAddress,tronProofSignature:e.tronProofSignature})),txCompletionTime:i,hashedEthereumAddress:r,ref:o,hashedDashboardAccountId:s}))},d=async(e,t,n,r,i,o)=>l(await a.callRelayerSolanaTransactBatchAPI({chainId:e,transactions:t,hashedEthereumAddress:n,txCompletionTime:r,ref:i,hashedDashboardAccountId:o}));exports.solanaTransactCallRelayer=c,exports.solanaTransactCallRelayerBatch=d,exports.transactCallRelayer=s,exports.transactCallRelayerBatch=u;
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { serializeCircomData as e } from "../../snarkjs/common.snarkjs.mjs";
|
|
2
|
+
import { ErrorWithRelayerTransaction as t } from "../../../error-handling/customErrors/ErrorWithTx.mjs";
|
|
3
|
+
import { RELAYER_CONFIG as n } from "../../../constants/server.constants.mjs";
|
|
4
|
+
import { RELAYER_URL as r } from "../../../API/getServerURL.mjs";
|
|
5
|
+
import { httpClient as i } from "../../../data-structures/http/HttpClient.mjs";
|
|
6
|
+
import { callRelayerSolanaTransactBatchAPI as a, callRelayerTransactAPI as o, callRelayerTransactBatchAPI as s } from "../../../API/callRelayer.mjs";
|
|
7
7
|
import "../../../error-handling/index.mjs";
|
|
8
8
|
import "../../snarkjs/index.mjs";
|
|
9
9
|
//#region libs/shared/common/src/functions/web3/functionCalls/transactCallRelayer.ts
|
|
10
|
-
var c = (
|
|
11
|
-
if (
|
|
12
|
-
throw
|
|
13
|
-
}, l = async (
|
|
14
|
-
let f =
|
|
15
|
-
return c(await
|
|
16
|
-
chainId:
|
|
17
|
-
a:
|
|
18
|
-
b:
|
|
19
|
-
c:
|
|
20
|
-
dimData:
|
|
10
|
+
var c = (e) => {
|
|
11
|
+
if (e.status === "success") return e.message;
|
|
12
|
+
throw e.message && e.error ? new t(e.error, e.message) : Error(e.error);
|
|
13
|
+
}, l = async (t, n, r, i, a, s, l, u, d) => {
|
|
14
|
+
let f = e(i);
|
|
15
|
+
return c(await o({
|
|
16
|
+
chainId: t,
|
|
17
|
+
a: n[0],
|
|
18
|
+
b: n[1],
|
|
19
|
+
c: n[2],
|
|
20
|
+
dimData: r,
|
|
21
21
|
circomData: f,
|
|
22
|
-
withUniswapWorkAround:
|
|
22
|
+
withUniswapWorkAround: s,
|
|
23
23
|
authorizationData: l,
|
|
24
24
|
adminData: u,
|
|
25
25
|
tronProofSignature: d,
|
|
26
|
-
commitmentValidationData:
|
|
26
|
+
commitmentValidationData: a
|
|
27
27
|
}));
|
|
28
|
-
}, u = async (e) => c(await
|
|
28
|
+
}, u = async (e) => c(await i.post(`${r}${n.SOLANA_TRANSACT}`, e)), d = (e) => {
|
|
29
29
|
if (e.status === "success") return e.message.scheduleId;
|
|
30
30
|
throw Error(e.error || "Batch transaction failed");
|
|
31
|
-
}, f = async (
|
|
32
|
-
let c =
|
|
33
|
-
return d(await
|
|
34
|
-
chainId:
|
|
35
|
-
transactions:
|
|
36
|
-
chainId:
|
|
37
|
-
a:
|
|
38
|
-
b:
|
|
39
|
-
c:
|
|
40
|
-
dimData:
|
|
31
|
+
}, f = async (t, n, r, i, a, o) => {
|
|
32
|
+
let c = n.map((t) => e(t.circomData));
|
|
33
|
+
return d(await s({
|
|
34
|
+
chainId: t,
|
|
35
|
+
transactions: n.map((e, n) => ({
|
|
36
|
+
chainId: t,
|
|
37
|
+
a: e.zkCallData[0],
|
|
38
|
+
b: e.zkCallData[1],
|
|
39
|
+
c: e.zkCallData[2],
|
|
40
|
+
dimData: e.dimData,
|
|
41
41
|
circomData: c[n],
|
|
42
|
-
commitmentValidationData:
|
|
43
|
-
withUniswapWorkAround:
|
|
44
|
-
authorizationData:
|
|
45
|
-
adminData:
|
|
46
|
-
recipientAddress:
|
|
47
|
-
tronProofSignature:
|
|
42
|
+
commitmentValidationData: e.commitmentValidationData,
|
|
43
|
+
withUniswapWorkAround: e.withUniswapWorkAround,
|
|
44
|
+
authorizationData: e.authorizationData,
|
|
45
|
+
adminData: e.adminData,
|
|
46
|
+
recipientAddress: e.recipientAddress,
|
|
47
|
+
tronProofSignature: e.tronProofSignature
|
|
48
48
|
})),
|
|
49
|
-
txCompletionTime:
|
|
50
|
-
hashedEthereumAddress:
|
|
51
|
-
ref:
|
|
52
|
-
hashedDashboardAccountId:
|
|
49
|
+
txCompletionTime: i,
|
|
50
|
+
hashedEthereumAddress: r,
|
|
51
|
+
ref: a,
|
|
52
|
+
hashedDashboardAccountId: o
|
|
53
53
|
}));
|
|
54
|
-
}, p = async (e, t, n, r,
|
|
54
|
+
}, p = async (e, t, n, r, i, o) => d(await a({
|
|
55
55
|
chainId: e,
|
|
56
56
|
transactions: t,
|
|
57
57
|
hashedEthereumAddress: n,
|
|
58
58
|
txCompletionTime: r,
|
|
59
|
-
ref:
|
|
59
|
+
ref: i,
|
|
60
60
|
hashedDashboardAccountId: o
|
|
61
61
|
}));
|
|
62
62
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chains.types.cjs`),require(`./hinkal.types.cjs`),require(`./circom-data.types.cjs`),require(`./
|
|
1
|
+
require(`./chains.types.cjs`),require(`./hinkal.types.cjs`),require(`./circom-data.types.cjs`),require(`./external-action.types.cjs`),require(`./ethereum-network.types.cjs`),require(`./token.types.cjs`),require(`./transactions.types.cjs`),require(`./admin.types.cjs`),require(`./activities.types.cjs`),require(`./transaction.types.cjs`),require(`./balances.types.cjs`),require(`./cache.types.cjs`),require(`./new-rewards.type.cjs`),require(`./eip5792.types.cjs`),require(`./offscreen.types.cjs`),require(`./scheduled-transactions.types.cjs`),require(`./events.types.cjs`),require(`./schedule.types.cjs`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./chains.types.mjs";
|
|
2
2
|
import "./hinkal.types.mjs";
|
|
3
3
|
import "./circom-data.types.mjs";
|
|
4
|
-
import "./ethereum-network.types.mjs";
|
|
5
4
|
import "./external-action.types.mjs";
|
|
5
|
+
import "./ethereum-network.types.mjs";
|
|
6
6
|
import "./token.types.mjs";
|
|
7
7
|
import "./transactions.types.mjs";
|
|
8
8
|
import "./admin.types.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=function(e){return e.INIT=`init`,e.PREPARE_NEW_STYLE_UTXO_FIELDS=`prepareNewStyleUtxoFields`,e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH=`prepareNewStyleUtxoFieldsBatch`,e.BATCH_STEALTH_VALIDATION=`batchStealthValidation`,e.POSEIDON_HASH=`poseidonHash`,e.GET_SPENDING_KEY_PAIR=`getSpendingKeyPair`,e}({});exports.CryptoWorkerOp=e;
|
|
1
|
+
var e=function(e){return e.INIT=`init`,e.PREPARE_NEW_STYLE_UTXO_FIELDS=`prepareNewStyleUtxoFields`,e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH=`prepareNewStyleUtxoFieldsBatch`,e.BATCH_STEALTH_VALIDATION=`batchStealthValidation`,e.POSEIDON_HASH=`poseidonHash`,e.GET_SPENDING_KEY_PAIR=`getSpendingKeyPair`,e.SIGN_EDDSA=`signEddsa`,e.CALC_STEALTH_ADDRESS_STRUCTURE=`calcStealthAddressStructure`,e}({});exports.CryptoWorkerOp=e;
|
|
@@ -29,7 +29,9 @@ export declare enum CryptoWorkerOp {
|
|
|
29
29
|
PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH = "prepareNewStyleUtxoFieldsBatch",
|
|
30
30
|
BATCH_STEALTH_VALIDATION = "batchStealthValidation",
|
|
31
31
|
POSEIDON_HASH = "poseidonHash",
|
|
32
|
-
GET_SPENDING_KEY_PAIR = "getSpendingKeyPair"
|
|
32
|
+
GET_SPENDING_KEY_PAIR = "getSpendingKeyPair",
|
|
33
|
+
SIGN_EDDSA = "signEddsa",
|
|
34
|
+
CALC_STEALTH_ADDRESS_STRUCTURE = "calcStealthAddressStructure"
|
|
33
35
|
}
|
|
34
36
|
export type CryptoWorkerRequest = {
|
|
35
37
|
requestId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region libs/shared/common/src/webworker/cryptoWorker/cryptoWorker.types.ts
|
|
2
2
|
var e = /* @__PURE__ */ function(e) {
|
|
3
|
-
return e.INIT = "init", e.PREPARE_NEW_STYLE_UTXO_FIELDS = "prepareNewStyleUtxoFields", e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH = "prepareNewStyleUtxoFieldsBatch", e.BATCH_STEALTH_VALIDATION = "batchStealthValidation", e.POSEIDON_HASH = "poseidonHash", e.GET_SPENDING_KEY_PAIR = "getSpendingKeyPair", e;
|
|
3
|
+
return e.INIT = "init", e.PREPARE_NEW_STYLE_UTXO_FIELDS = "prepareNewStyleUtxoFields", e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH = "prepareNewStyleUtxoFieldsBatch", e.BATCH_STEALTH_VALIDATION = "batchStealthValidation", e.POSEIDON_HASH = "poseidonHash", e.GET_SPENDING_KEY_PAIR = "getSpendingKeyPair", e.SIGN_EDDSA = "signEddsa", e.CALC_STEALTH_ADDRESS_STRUCTURE = "calcStealthAddressStructure", e;
|
|
4
4
|
}({});
|
|
5
5
|
//#endregion
|
|
6
6
|
export { e as CryptoWorkerOp };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./workerProxy-DPeuP2Mg.js`);let t=require(`buffer`),n=require(`process`);n=e.u(n);let r=require(`ethers`),i=require(`poseidon-lite`);i=e.u(i);let a=require(`libsodium-wrappers`);a=e.u(a);let o=require(`@solana/web3.js`),s=require(`bs58`);s=e.u(s);let c=require(`tweetnacl`);c=e.u(c);let l=require(`tronweb`);var u=class{static bridge=null},d=()=>{let e=u.bridge;if(!e)throw Error(`RN crypto bridge is not registered. Mount HinkalWebViewWorker in your app.`);return e},f=new class{babyjub=void 0;async init(){if(this.babyjub)return;if(e.o){await d().init();return}let{buildBabyjub:t}=await import(`circomlibjs-hinkal-fork`);this.babyjub=await t()}getJub(){if(e.o)throw Error(`babyJubInstance is unavailable on React Native main thread. Use WebView crypto bridge.`);return this.babyjub}},p=()=>f.getJub(),m=new class{eddsa=void 0;async init(){if(this.eddsa)return;if(e.o){await d().init();return}let{buildEddsa:t}=await import(`circomlibjs-hinkal-fork`);this.eddsa=await t()}getEddsa(){if(e.o)throw Error(`eddsaInstance is unavailable on React Native main thread. Use WebView crypto bridge.`);return this.eddsa}},h=()=>m.getEddsa();function g(e){return typeof e==`object`&&`toBigInt`in e?e.toBigInt():BigInt(e)}var _=()=>{let e=e=>{let t=i[`poseidon${e.length}`];if(!t)throw Error(`Poseidon: arity ${e.length} not supported (1..16)`);return t(e.map(e=>BigInt(e)))};return e.F={toString:e=>BigInt(e).toString()},e},v=new class{poseidon=void 0;async init(){if(this.poseidon)return;if(e.o){await d().init(),this.poseidon=_();return}let{buildPoseidon:t}=await import(`circomlibjs-hinkal-fork`);this.poseidon=await t()}getPoseidon(){return this.poseidon}};function y(...e){let t=v.getPoseidon();return g(t.F.toString(t(e)))}var b=(...e)=>{let t=v.getPoseidon();return r.ethers.toBeHex(t.F.toString(t([...e])))},ee=async(r=!1)=>{if((typeof window<`u`||typeof self<`u`)&&(typeof window<`u`&&(window.global=window),globalThis.Buffer=t.Buffer,globalThis.process=n.default),e.o&&!r){await Promise.all([a.default.ready,d().init(),v.init()]);return}await Promise.all([a.default.ready,v.init(),f.init(),...r?[]:[m.init()]])};`${`00`.repeat(20)}`;var x=21888242871839275222246405745257275088548364400416034343698204186575808495617n,S=x/2n,C=200n;`${`00`.repeat(32)}`;var w=class{inMemoryCache=new Map;constructor(e){e&&this.mergeWithSerialized(e)}getInMemory(e){return this.inMemoryCache.get(e)??void 0}setInMemory(e,t){this.inMemoryCache.set(e,t)}mergeWithSerialized(t){Object.entries(t).forEach(([t,n])=>{this.set(t,e.c(n))})}},T=class extends w{isAttached=!1;get(e){return this.getInMemory(e)}set(e,t){this.setInMemory(e,t)}serialize(){return Object.fromEntries([...this.inMemoryCache].map(([t,n])=>[t,e.l(n)]))}attach(t){if(this.isAttached)throw Error(`can't reattach cache device`);return this.isAttached=!0,(...n)=>{let r=e.l(n),i=this.get(r);if(i!==void 0)return i;let a=t(...n);return this.set(r,a),a}}},E=e=>{if(e<0n||e>=21888242871839275222246405745257275088548364400416034343698204186575808495617n)throw RangeError();return e>S},D=e=>E(e)?1n:0n,O=new T,k=new T,A=new T,j=class{signature;nullifyingKey;PREFIX_FOR_SPENDING_PAIR=`1`;PREFIX_FOR_NULLIFYING_PAIR=`2`;constructor(e,t){this.signature=e,this.nullifyingKey=t}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error(`No signature provided`)}requireKeyMaterial(){if(!this.signature&&!this.nullifyingKey)throw Error(`No signature or private key provided`)}verifyTronMessage(e,t){return this.requireSignature(),t===l.Trx.verifyMessageV2(e,this.signature)}getShieldedPrivateKey=()=>(this.requireKeyMaterial(),this.nullifyingKey||=r.ethers.keccak256(this.signature),this.nullifyingKey);getShieldedPublicKey=()=>(this.requireKeyMaterial(),b(this.getShieldedPrivateKey()));getSpendingKeyPair=()=>{this.requireSignature();let e=h(),t=p(),n=b(this.PREFIX_FOR_SPENDING_PAIR,this.getSignature()),i=Buffer.from(r.ethers.getBytes(n)),a=e.prv2pub(i);return{privSpendingKey:n,pubSpendingBJJPoint:[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))]}};signEddsa=e=>{this.requireSignature();let t=p(),n=h(),i=Buffer.from(r.ethers.getBytes(this.getSpendingKeyPair().privSpendingKey)),a=t.F.e(e),o=n.signPoseidon(i,a);return{R8:[BigInt(t.F.toString(o.R8[0])),BigInt(t.F.toString(o.R8[1]))],S:BigInt(o.S)}};getShieldedPrivateKeyFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(`hinkal-offchain-shielded-key:${t}`))};getClaimableSignatureFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(`hinkal-claimable-utxo-signature:${t}`))};getDerivedEthereumAddress=()=>(this.requireKeyMaterial(),new r.ethers.Wallet(this.getShieldedPrivateKey()).address);getDerivedSolanaPublicKey=()=>(this.requireKeyMaterial(),o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey())).publicKey.toBase58());getNearIntentsAccountId=()=>{this.requireKeyMaterial();let e=o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey()));return r.ethers.hexlify(e.publicKey.toBytes()).slice(2)};getNearIntentsKeyPairString=()=>{this.requireKeyMaterial();let e=o.Keypair.fromSeed(r.ethers.getBytes(this.getShieldedPrivateKey()));return`ed25519:${s.default.encode(e.secretKey)}`};getSignerPrivateKeyFromNonce=e=>{this.requireKeyMaterial();let t=b(e,this.getShieldedPrivateKey(),this.getShieldedPublicKey());return r.ethers.keccak256(r.ethers.toUtf8Bytes(t))};getSignerSolanaPrivateKeyFromNonce=e=>{let t=this.getSignerPrivateKeyFromNonce(e),n=r.ethers.getBytes(t),i=o.Keypair.fromSeed(n);return s.default.encode(i.secretKey)};verifyMessage(e){return this.requireSignature(),r.ethers.verifyMessage(e,this.signature)}verifySolanaMessage(e,t){this.requireSignature();let n=new TextEncoder().encode(e),i=r.ethers.getBytes(this.signature),a=new o.PublicKey(t).toBytes();return c.default.sign.detached.verify(n,i,a)}static getRandomizedStealthPairOld=k.attach((e,t)=>{let n=p(),r=e*(BigInt(t)%x)%x,i=n.mulPointEscalar(n.Base8,e),a=n.mulPointEscalar(n.Base8,r);return{H0:[BigInt(n.F.toString(i[0])),BigInt(n.F.toString(i[1]))],H1:[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]}});static getRandomizedStealthPair=O.attach((e,t)=>{let n=p(),r=BigInt(t)%x,i=n.mulPointEscalar(n.Base8,e),a=n.mulPointEscalar(i,r);return{H0:[BigInt(n.F.toString(i[0])),BigInt(n.F.toString(i[1]))],H1:[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]}});static getStealthAddressCompressedPoints=(e,t)=>{let{H0:n,H1:r}=this.getRandomizedStealthPairOld(e,t),[i,a]=[n,r].map(e=>BigInt(e[1])+2n**255n*D(e[0]));return{h0:i,h1:a}};static checkSignature=(e,t,n,r)=>{let{h0:i,h1:a}=this.getStealthAddressCompressedPoints(e,r);return t===i&&n===a};static getStealthAddress=A.attach((e,t)=>{let{H0:n,H1:r}=this.getRandomizedStealthPairOld(e,t);return b(2n*D(n[0])+D(r[0]),n[1],r[1])});static getH1FromH0=(e,t)=>{let n=p(),r=BigInt(t)%x,i=[n.F.e(e[0]),n.F.e(e[1])],a=n.mulPointEscalar(i,r);return[BigInt(n.F.toString(a[0])),BigInt(n.F.toString(a[1]))]};static verifyStealthPair=(e,t,n,r=!0)=>{let i=this.getH1FromH0(e,n);return r?i[1]===t[1]:i===t};static getStealthAddressNewStyle=(e,t,n)=>{if(n?.length!==2)throw Error(`Spending public key must be an array of 2 elements`);let r=this.getH1FromH0(e,t);return b(2n*D(e[0])+D(r[0]),e[1],r[1],n[0],n[1],t)};static findCorrectRandomization(e,t){if(!t)throw Error(`No Private Shielded Key Provided`);let n=BigInt(t)%x,r,i,a=0n;do r=e*10n**a%x,i=r*n%x,a+=1n;while(i>=2n**253n||r>=2n**253n);return r}static getH0FromRandomization=e=>{let t=p(),n=t.mulPointEscalar(t.Base8,e);return[BigInt(t.F.toString(n[0])),BigInt(t.F.toString(n[1]))]};static findH0(e,t){if(!t)return;let{H0:n}=this.getRandomizedStealthPair(e,t);return n}static getEncryptionKeyPair=e=>{let t=a.default.crypto_box_seed_keypair(r.ethers.getBytes(e));return{privateKey:r.ethers.hexlify(t.privateKey),publicKey:r.ethers.hexlify(t.publicKey)}};getAccessKey=()=>(this.requireKeyMaterial(),b(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getBackendToken=()=>(this.requireKeyMaterial(),b(this.getAccessKey(),this.getShieldedPublicKey()))},M={CANNOT_CERTIFY_FOR_PAST_WEEK:`Certification for the past week is not available`,CYCLICAL_REFERRALS_FORBIDDEN:`Cyclical referrals are forbidden`,USER_IS_UNRANKED:`Please certify transactions to see rank`},N={WC_NO_MATCHING_KEY:`creating the transaction failed
|
|
2
|
+
version`,CONNECTION_PROBLEM:`Failed to connect wallet. Please try again.`,REQUEST_PENDING:`request of type 'wallet_requestpermissions' already pending for origin`},P={INSUFFICIENT_FUNDS:`Insufficient funds`,INSUFFICIENT_FUNDS_WITHDRAW:`Not enough funds to withdraw`,INSUFFICIENT_FUNDS_TRANSFER:`Not enough funds to transfer`,INSUFFICIENT_FUNDS_TO_TRANSACT:`Not enough funds to transact`,INSUFFICIENT_FUNDS_GAS:`Insufficient funds for gas * price`,INSUFFICIENT_TRON_BALANCE_FOR_FEE:`Insufficient TRX balance to cover transfer amount and transaction fee reserve`,INSUFFICIENT_SOL_BALANCE:`Insufficient SOL balance`},F={GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT:`Skipped shielding due to gas fee exceeding your limit.`,AUTO_SHIELD_INSUFFICIENT_GAS:`Auto-Shield skipped due to insufficient gas.`};({...M,...N,...P,...F});var I=e=>BigInt(r.ethers.hexlify(r.ethers.randomBytes(e))),L=function(e){return e.INIT=`init`,e.PREPARE_NEW_STYLE_UTXO_FIELDS=`prepareNewStyleUtxoFields`,e.PREPARE_NEW_STYLE_UTXO_FIELDS_BATCH=`prepareNewStyleUtxoFieldsBatch`,e.BATCH_STEALTH_VALIDATION=`batchStealthValidation`,e.POSEIDON_HASH=`poseidonHash`,e.GET_SPENDING_KEY_PAIR=`getSpendingKeyPair`,e.SIGN_EDDSA=`signEddsa`,e.CALC_STEALTH_ADDRESS_STRUCTURE=`calcStealthAddressStructure`,e}({}),R=()=>a.default.crypto_box_SEALBYTES+a.default.crypto_secretbox_KEYBYTES,z=e=>{let t=a.default.crypto_secretbox_NONCEBYTES,n=R(),r=0,i=e[r];r+=1;let o=e.slice(r,r+t);r+=t;let s=[];for(let t=0;t<i;t+=1)s.push(e.slice(r,r+n)),r+=n;return{nonce:o,sealedKeys:s,ciphertext:e.slice(r)}},B=(e,t,n,i)=>{let{nonce:o,sealedKeys:s,ciphertext:c}=z(e),l=a.default.crypto_box_seal_open(s[i],r.ethers.getBytes(n),r.ethers.getBytes(t)),u=a.default.crypto_secretbox_open_easy(c,o,l);return Buffer.from(u)},V=(e,t,n)=>{let i=a.default.crypto_box_seal_open(e,r.ethers.getBytes(n),r.ethers.getBytes(t));return Buffer.from(i)},H=54912,U=2,W=e=>e[0]*256+e[1],G=(e,t)=>{let{privateKey:n,publicKey:r}=j.getEncryptionKeyPair(t.getShieldedPrivateKey()),i=W(e)===H?B(e.slice(U),n,r,0):V(e,n,r),a=Buffer.from(i).toString(`utf-8`).split(`0x`).filter(e=>e.length!==0),s=e=>BigInt(`0x${e}`),c=e=>`0x${e}`,l=a.length>=8,u=l&&s(a[5])===1n,d=l?8:6,f=a[d]?c(a[d]):void 0,p=f?new o.PublicKey(Buffer.from(f.slice(2),`hex`)).toString():void 0;return{amount:s(a[0]),erc20TokenAddress:c(a[1]),randomization:s(a[2]),stealthAddress:c(a[3]),nullifyingKey:t.getShieldedPrivateKey(),timeStamp:s(a[4]).toString(),isNewStyle:u,...u?{H0:[s(a[6]),s(a[7])]}:{},mintAddress:p}},K=(e,t)=>new $(G(e,t));Object.values({preHookContract:`0x0000000000000000000000000000000000000000`,hookContract:`0x0000000000000000000000000000000000000000`,preHookMetadata:`0x00`,postHookMetadata:`0x00`});var q=e=>e&2n**255n-1n,J=e=>e>>255n&1n;Array.from({length:25},()=>`0`);var Y=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=1){n.push([]);for(let i=0;i<e[r].length;i+=1)n[r][i]=t.getSiblingHashesForVerification(BigInt(e[r][i].getCommitment())).map(e=>e.toString())}let r=[];for(let n=0;n<e.length;n+=1){r.push([]);for(let i=0;i<e[n].length;i+=1)r[n][i]=t.getSiblingSides(BigInt(e[n][i].getCommitment())).map(e=>e.toString())}return{inCommitmentSiblings:n,inCommitmentSiblingSides:r}},X=()=>I(31).toString(),Z=async(t,n)=>{if(!e.o)throw Error(`prepareNewStyleUtxoFields is only for React Native crypto bridge`);let r=d();await r.init();let i=await r.call(L.PREPARE_NEW_STYLE_UTXO_FIELDS,{initialRandomization:X(),nullifyingKey:t,spendingPublicKey:n?.map(e=>e.toString())});return{randomization:BigInt(i.randomization),H0:[BigInt(i.H0[0]),BigInt(i.H0[1])],stealthAddress:i.stealthAddress}},Q=t=>e.o&&!!t.isNewStyle&&!!t.nullifyingKey&&t.H0===void 0&&t.randomization===void 0,te=()=>Math.floor(Date.now()/1e3),$=class t{amount;erc20TokenAddress;mintAddress;timeStamp;nullifyingKey;spendingPublicKey;randomization;H0;stealthAddress;encryptionKey;commitment;nullifier;isBlocked;isNewStyle;constructor({amount:e,erc20TokenAddress:t,mintAddress:n,timeStamp:r,nullifyingKey:i,spendingPublicKey:a,randomization:o,H0:s,stealthAddress:c,encryptionKey:l,commitment:u=void 0,nullifier:d=void 0,isBlocked:f=!1,isNewStyle:p=!1}){this.amount=e,this.erc20TokenAddress=t,this.mintAddress=n,this.timeStamp=r??te().toString(),this.nullifyingKey=i,this.spendingPublicKey=a,this.randomization=o??(i?j.findCorrectRandomization(I(31),i):void 0),this.H0=s??(p&&this.randomization?j.findH0(this.randomization,i):void 0),this.stealthAddress=c,this.encryptionKey=l,this.commitment=u,this.nullifier=d,this.isBlocked=f,this.isNewStyle=p}static async createAsync(e){if(Q(e)){let n=await Z(e.nullifyingKey,e.spendingPublicKey);return new t({...e,randomization:n.randomization,H0:n.H0,stealthAddress:n.stealthAddress})}return new t(e)}static createFrom(e,n){return new t({...e.getConstructableParams(),nullifier:void 0,commitment:void 0,...n})}getConstructableParams(){return{amount:this.amount,erc20TokenAddress:this.erc20TokenAddress,mintAddress:this.mintAddress,timeStamp:this.timeStamp,nullifyingKey:this.nullifyingKey,spendingPublicKey:this.spendingPublicKey,randomization:this.randomization,H0:this.H0,stealthAddress:this.stealthAddress,encryptionKey:this.encryptionKey,commitment:this.commitment,nullifier:this.nullifier,isBlocked:this.isBlocked,isNewStyle:this.isNewStyle}}getBasicUtxoParams(){return{amount:this.amount,erc20TokenAddress:this.erc20TokenAddress,mintAddress:this.mintAddress,timeStamp:this.timeStamp,randomization:this.randomization,H0:this.H0,stealthAddress:this.stealthAddress,commitment:this.commitment,nullifier:this.nullifier,isBlocked:this.isBlocked,isNewStyle:this.isNewStyle}}getCommitment(){if(!this.commitment){let e=[this.amount,this.erc20TokenAddress,BigInt(this.getStealthAddress()),this.timeStamp];this.commitment=b(...e)}return this.commitment}getNullifier(){if(!this.nullifier){if(!this.nullifyingKey)throw Error(`No Nullifiers if private key is not provided`);let e=this.getCommitment(),t=b(this.nullifyingKey,e);this.nullifier=b(e,t)}return this.nullifier}getStealthAddress(){if(!this.stealthAddress){if(!this.nullifyingKey)throw Error(`No stealth address in UTXO if private key is not provided`);if(this.isNewStyle){if(!this.H0)throw Error(`No H0 point provided`);this.stealthAddress=j.getStealthAddressNewStyle(this.H0,this.nullifyingKey,this.spendingPublicKey)}else{if(!this.randomization)throw Error(`No randomization provided`);this.stealthAddress=j.getStealthAddress(this.randomization,this.nullifyingKey)}}return this.stealthAddress}getTokenAddress(t){let n=e.r(t)?this.mintAddress:this.erc20TokenAddress;if(!n)throw Error(`No token address provided`);return n}getEncryptionKey(){if(!this.nullifyingKey){if(!this.encryptionKey)throw Error(`No encryption key provided in UTXO`);return this.encryptionKey}return j.getEncryptionKeyPair(this.nullifyingKey).publicKey}},ne=(...t)=>{e.a&&console.log(...t)};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return O}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=``+(typeof document>`u`?require(`url`).pathToFileURL(__dirname+`/../../../../assets/utxoWorkerLauncher-
|
|
1
|
+
var e=``+(typeof document>`u`?require(`url`).pathToFileURL(__dirname+`/../../../../assets/utxoWorkerLauncher-DrByvCnS.js`).href:new URL(`../../../../assets/utxoWorkerLauncher-DrByvCnS.js`,document.currentScript&&document.currentScript.tagName.toUpperCase()===`SCRIPT`&&document.currentScript.src||document.baseURI).href);exports.default=e;
|