@gurge/sdk 0.3.22 → 0.3.23
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/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +43 -24
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +83 -72
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.mjs +21 -10
- package/common/src/functions/snarkjs/generateZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProof.mjs +23 -12
- package/common/src/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProofEnclave.mjs +14 -11
- package/common/src/functions/snarkjs/generateZkProofSelf.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProofSelf.mjs +20 -14
- package/common/src/functions/utils/hinkalTiming.utils.cjs +1 -0
- package/common/src/functions/utils/hinkalTiming.utils.mjs +18 -0
- package/common/src/webworker/package.json +1 -1
- package/common/src/webworker/performTaskWithWorker.cjs +1 -1
- package/common/src/webworker/performTaskWithWorker.mjs +15 -14
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/package.json +1 -1
- package/sdk/package.json.cjs +1 -1
- package/sdk/package.json.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/utils/time.utils.cjs`),a=require(`../../types/external-action.types.cjs`),o=require(`../../functions/utils/tron.utils.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/web3/events/getShieldedBalance.cjs`),l=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),u=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../types/hinkal.types.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/utils/time.utils.cjs`),a=require(`../../types/external-action.types.cjs`),o=require(`../../functions/utils/tron.utils.cjs`),s=require(`../../functions/utils/token-check.utils.cjs`),c=require(`../../functions/web3/events/getShieldedBalance.cjs`),l=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),u=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/getFeeStructure.cjs`),p=require(`../../functions/utils/hinkalTiming.utils.cjs`);require(`../../functions/pre-transaction/index.cjs`);const m=require(`../../functions/utils/fees.utils.cjs`),h=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),g=require(`../../functions/web3/functionCalls/transactCallDirect.cjs`),_=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),v=require(`../../functions/web3/functionCalls/transactCallDirectTron.cjs`),y=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`);var b=async(e,t,n,r)=>{let a=[...await c.addPaddingToUtxos(e,t,n,r)],o=[],s=i.getCurrentTimeInSeconds().toString();for(let t=0;t<n.length;t+=1){let{outputUtxos:n}=l.outputUtxoProcessing(e.userKeys,a[t],r[t],s);o.push(n)}return{inputUtxosArray:a,outputUtxosArray:o}},x=async(i,c,l,x,S,C,w,T)=>{let E=p.createHinkalTiming(`withdraw`),D=s.validateAndGetChainId(c),O=e.isTronLike(D);E.log(`start`,{chainId:D,isRelayerOff:S,tokenCount:c.length});let k=o.addressToHexFormat(await i.getEthereumAddressByChain(D));E.log(`getEthereumAddress`);let A=c.map(e=>e.erc20TokenAddress),j=await u.modifyVolatileTokenAmountChanges(D,c,l);E.log(`modifyVolatileTokenAmountChanges`);let M=c[0];if(!M)throw Error(`Deposit Action: No Token Found`);let N;if(!S){let e=w??await f.getFeeStructure(D,C,A,a.ExternalActionId.Transact);N=await m.calculateModifiedFeeStructure(D,M,-j[0],e),await y.mergeWithFeeStructure(D,A,j,N),E.log(`feeStructure`,{feeToken:C})}let P={externalActionId:0n,externalAddress:o.addressToHexFormat(x),externalActionMetadata:`0x00`},[F,{inputUtxosArray:I,outputUtxosArray:L}]=await Promise.all([i.getRandomRelay(D,!0),b(i,D,A,j)]);if(E.log(`relay+utxos`,{hasRelay:!!F}),!S&&!F)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let{zkCallData:R,circomData:z,dimData:B,commitmentValidationData:V}=await h.constructZkProof(i.merkleTreeHinkalByChain[D],I,L,i.userKeys,P.externalActionId,P.externalAddress,P.externalActionMetadata,i.generateProofRemotely,N??n.zeroFeeStructure,S?t.zeroAddress:F,D,void 0,void 0,S?k:void 0);E.log(`constructZkProof`,{generateProofRemotely:i.generateProofRemotely});let H=O&&S?void 0:await o.reorderZkCallData(O,R,B,z);if(E.log(`reorderZkCallData`),S){if(!M)throw Error(`Withdraw Action: No Token Found`);if(O){let e=await v.transactCallDirectTron(i,D,j[0],M,R,z,B);return E.log(`transactCallDirectTron`,{txid:e}),E.log(`done`),e}let e=await g.transactCallDirect(i,D,j[0],M,R,z,B);return E.log(`transactCallDirect`,{txHash:e.hash}),E.log(`done`),e}let U=await _.transactCallRelayer(D,R,B,z,V,void 0,void 0,d.constructAdminData(T,D,A,j,k),H);return E.log(`transactCallRelayer`,{txHash:U}),E.log(`done`),U};exports.hinkalWithdraw=x;
|
|
@@ -11,15 +11,16 @@ import { outputUtxoProcessing as u } from "../../functions/pre-transaction/outpu
|
|
|
11
11
|
import { modifyVolatileTokenAmountChanges as d } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
|
|
12
12
|
import { constructAdminData as f } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
13
13
|
import { getFeeStructure as p } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
14
|
+
import { createHinkalTiming as m } from "../../functions/utils/hinkalTiming.utils.mjs";
|
|
14
15
|
import "../../functions/pre-transaction/index.mjs";
|
|
15
|
-
import { calculateModifiedFeeStructure as
|
|
16
|
-
import { constructZkProof as
|
|
17
|
-
import { transactCallDirect as
|
|
18
|
-
import { transactCallRelayer as
|
|
19
|
-
import { transactCallDirectTron as
|
|
20
|
-
import { mergeWithFeeStructure as
|
|
16
|
+
import { calculateModifiedFeeStructure as h } from "../../functions/utils/fees.utils.mjs";
|
|
17
|
+
import { constructZkProof as g } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
18
|
+
import { transactCallDirect as _ } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
19
|
+
import { transactCallRelayer as v } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
20
|
+
import { transactCallDirectTron as y } from "../../functions/web3/functionCalls/transactCallDirectTron.mjs";
|
|
21
|
+
import { mergeWithFeeStructure as b } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
21
22
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalWithdraw.ts
|
|
22
|
-
var
|
|
23
|
+
var x = async (e, t, n, r) => {
|
|
23
24
|
let a = [...await l(e, t, n, r)], o = [], s = i().toString();
|
|
24
25
|
for (let t = 0; t < n.length; t += 1) {
|
|
25
26
|
let { outputUtxos: n } = u(e.userKeys, a[t], r[t], s);
|
|
@@ -29,26 +30,44 @@ var b = async (e, t, n, r) => {
|
|
|
29
30
|
inputUtxosArray: a,
|
|
30
31
|
outputUtxosArray: o
|
|
31
32
|
};
|
|
32
|
-
},
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
}, S = async (i, l, u, S, C, w, T, E) => {
|
|
34
|
+
let D = m("withdraw"), O = c(l), k = e(O);
|
|
35
|
+
D.log("start", {
|
|
36
|
+
chainId: O,
|
|
37
|
+
isRelayerOff: C,
|
|
38
|
+
tokenCount: l.length
|
|
39
|
+
});
|
|
40
|
+
let A = o(await i.getEthereumAddressByChain(O));
|
|
41
|
+
D.log("getEthereumAddress");
|
|
42
|
+
let j = l.map((e) => e.erc20TokenAddress), M = await d(O, l, u);
|
|
43
|
+
D.log("modifyVolatileTokenAmountChanges");
|
|
44
|
+
let N = l[0];
|
|
45
|
+
if (!N) throw Error("Deposit Action: No Token Found");
|
|
46
|
+
let P;
|
|
47
|
+
if (!C) {
|
|
48
|
+
let e = T ?? await p(O, w, j, a.Transact);
|
|
49
|
+
P = await h(O, N, -M[0], e), await b(O, j, M, P), D.log("feeStructure", { feeToken: w });
|
|
39
50
|
}
|
|
40
|
-
let
|
|
51
|
+
let F = {
|
|
41
52
|
externalActionId: 0n,
|
|
42
|
-
externalAddress: o(
|
|
53
|
+
externalAddress: o(S),
|
|
43
54
|
externalActionMetadata: "0x00"
|
|
44
|
-
}, [
|
|
45
|
-
if (!
|
|
46
|
-
let { zkCallData:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
}, [I, { inputUtxosArray: L, outputUtxosArray: R }] = await Promise.all([i.getRandomRelay(O, !0), x(i, O, j, M)]);
|
|
56
|
+
if (D.log("relay+utxos", { hasRelay: !!I }), !C && !I) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
57
|
+
let { zkCallData: z, circomData: B, dimData: V, commitmentValidationData: H } = await g(i.merkleTreeHinkalByChain[O], L, R, i.userKeys, F.externalActionId, F.externalAddress, F.externalActionMetadata, i.generateProofRemotely, P ?? n, C ? t : I, O, void 0, void 0, C ? A : void 0);
|
|
58
|
+
D.log("constructZkProof", { generateProofRemotely: i.generateProofRemotely });
|
|
59
|
+
let U = k && C ? void 0 : await s(k, z, V, B);
|
|
60
|
+
if (D.log("reorderZkCallData"), C) {
|
|
61
|
+
if (!N) throw Error("Withdraw Action: No Token Found");
|
|
62
|
+
if (k) {
|
|
63
|
+
let e = await y(i, O, M[0], N, z, B, V);
|
|
64
|
+
return D.log("transactCallDirectTron", { txid: e }), D.log("done"), e;
|
|
65
|
+
}
|
|
66
|
+
let e = await _(i, O, M[0], N, z, B, V);
|
|
67
|
+
return D.log("transactCallDirect", { txHash: e.hash }), D.log("done"), e;
|
|
50
68
|
}
|
|
51
|
-
|
|
69
|
+
let W = await v(O, z, V, B, H, void 0, void 0, f(E, O, j, M, A), U);
|
|
70
|
+
return D.log("transactCallRelayer", { txHash: W }), D.log("done"), W;
|
|
52
71
|
};
|
|
53
72
|
//#endregion
|
|
54
|
-
export {
|
|
73
|
+
export { S as hinkalWithdraw };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../web3/etherFunctions.cjs`),i=require(`../../data-structures/crypto-keys/keys.cjs`),a=require(`../utils/time.utils.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../error-handling/logger.cjs`),c=require(`../utils/bit.operations.cjs`),l=require(`./common.snarkjs.cjs`),ee=require(`./signedMessageHash.cjs`),u=require(`./generateCircomData.cjs`),te=require(`../../data-structures/AccountActions/AccountActions.cjs`),d=require(`./generateMainAndCommitmentZkProof.cjs`),f=require(`./getMerkleTreeSiblingsAndRootHashes.cjs`),p=require(`../private-wallet/emporium.helpers.cjs`);var m=async(m,h,g,_,v,y,b,x,S,C=t.zeroAddress,w=e.chainIds.localhost,T=h.map(()=>!1),E=void 0,D,O)=>{let k=l.getZkProofVerifierName(h,g),
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../crypto/poseidon.cjs`),r=require(`../web3/etherFunctions.cjs`),i=require(`../../data-structures/crypto-keys/keys.cjs`),a=require(`../utils/time.utils.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../error-handling/logger.cjs`),c=require(`../utils/bit.operations.cjs`),l=require(`./common.snarkjs.cjs`),ee=require(`./signedMessageHash.cjs`),u=require(`./generateCircomData.cjs`),te=require(`../../data-structures/AccountActions/AccountActions.cjs`),ne=require(`../utils/hinkalTiming.utils.cjs`),d=require(`./generateMainAndCommitmentZkProof.cjs`),f=require(`./getMerkleTreeSiblingsAndRootHashes.cjs`),p=require(`../private-wallet/emporium.helpers.cjs`);var m=async(m,h,g,_,v,y,b,x,S,C=t.zeroAddress,w=e.chainIds.localhost,T=h.map(()=>!1),E=void 0,D,O)=>{let k=ne.createHinkalTiming(`constructZkProof`),A=l.getZkProofVerifierName(h,g),j=l.calcAmountChanges(h,g),M=h.map(e=>e[0].erc20TokenAddress),N=l.calcEncryptedOutputs(g),P=t.defaultSignatureData,F=_.getShieldedPrivateKey(),{pubSpendingBJJPoint:I}=_.getSpendingKeyPair(),L=l.calcStealthAddressStructure(i.UserKeys.findCorrectRandomization(r.randomBigInt(31),F),F,_.getSpendingKeyPair().pubSpendingBJJPoint),{inCommitmentSiblings:re,inCommitmentSiblingSides:ie,rootHashHinkal:R,inNullifiers:z}=await f.getDataFromWorkers(w,m,h.map(e=>e.map(e=>e.getConstructableParams())));k.log(`getDataFromWorkers`,{verifierName:A,chainId:w});let B=l.buildOutCommitments(g),V=r.randomBigInt(31),H=n.poseidonFunction(V),U=BigInt(g.length>0?g[0][0].timeStamp:a.getCurrentTimeInSeconds()),W={rootHashHinkal:R,spendingPublicKey:I,nullifyingPrivateKey:F,erc20TokenAddresses:M,amountChanges:j,inAmounts:h.map(e=>e.map(e=>e.amount.toString())),inRandomizations:h.map(e=>e.map(e=>l.getUtxoCircuitInRandomization(e))),inH0Ax:h.map(e=>e.map(e=>l.getUtxoCircuitH0Coords(e)[0].toString())),inH0Ay:h.map(e=>e.map(e=>l.getUtxoCircuitH0Coords(e)[1].toString())),isNewStyle:h.map(e=>e.map(e=>!!e.isNewStyle)),inTimeStamps:h.map(e=>e.map(e=>e.timeStamp)),inNullifiers:z,inCommitmentSiblings:re,inCommitmentSiblingSides:ie,outAmounts:g.map(e=>e.map(e=>e.amount.toString())),outTimeStamp:U,outPublicKeys:g.map(e=>e.map(e=>e.getStealthAddress())),outCommitments:B,calldataHash:0n,messageSeed:V,H0Ax:c.takeOffHighestBit(L.extraRandomization),H0Ay:L.H0},G=l.calcPublicSignalCount(A,W.erc20TokenAddresses,W.amountChanges,W.inNullifiers,W.outCommitments),K=l.calcAmountChanges(h,g,!0),q=l.getSlippageValues(K);s.Logger.log({publicSignalCount:G});let J=Array.isArray(b)?b:[b],ae=e.getOnchainChainId(w),oe=O?te.AccountActions.getSignerAddressFromPrivateKey(ae,O):void 0,Y=v===o.ExternalActionId.Emporium?await p.encodeEmporiumMetadata(w,y??t.zeroAddress,O,J,H,oe):await p.encodeEmporiumMetadata(w,t.zeroAddress,void 0,v===0n?[]:J,H,t.zeroAddress);k.log(`encodeEmporiumMetadata`,{externalActionId:v.toString()}),W.calldataHash=l.createCallDataHash(G,C,y,v,Y,N,E,q,T,S,P,D);let X=ee.computeSignedMessageHashEvm({rootHashHinkal:R,erc20TokenAddresses:M,amountChanges:j,outTimeStamp:U,inNullifiers:z,outCommitments:B,calldataHash:W.calldataHash,message:H,outH1Ay:L.H1,H0Ax:W.H0Ax,H0Ay:L.H0}),{R8:Z,S:se}=_.signEddsa(X);W.eddsaSignature=[Z[0],Z[1],se],W.signedMessageHash=X;let Q=A.startsWith(`mainEVMCircuitMin0`),$={outTimeStamp:U,calldataHash:W.calldataHash,messageSeed:V},{zkCallData:ce,commitmentValidationData:le}=await d.generateMainAndCommitmentZkProof(w,_,M,h,A,Q?$:W,x);k.log(`generateMainAndCommitmentZkProof`,{verifierName:A,generateProofRemotely:x});let ue=u.generateCircomData(B,z,R,K,M,g,N,G,v,y,Y,C,W.calldataHash,L,T,E,Q?Number(U):void 0,q,S,P,D),de={tokenNumber:h.length,nullifierAmount:h.length>0?h[0].length:0,outputAmount:g.length>0?g[0].length:0};return k.log(`done`),{zkCallData:ce,circomData:ue,dimData:de,encryptedOutputs:N,commitmentValidationData:le}};exports.constructZkProof=m;
|
|
@@ -3,80 +3,91 @@ import { defaultSignatureData as ee, zeroAddress as n } from "../../constants/pr
|
|
|
3
3
|
import { poseidonFunction as te } from "../../crypto/poseidon.mjs";
|
|
4
4
|
import { randomBigInt as r } from "../web3/etherFunctions.mjs";
|
|
5
5
|
import { UserKeys as i } from "../../data-structures/crypto-keys/keys.mjs";
|
|
6
|
-
import { getCurrentTimeInSeconds as
|
|
7
|
-
import { ExternalActionId as
|
|
8
|
-
import { Logger as
|
|
9
|
-
import { takeOffHighestBit as
|
|
10
|
-
import { buildOutCommitments as
|
|
11
|
-
import { computeSignedMessageHashEvm as
|
|
12
|
-
import { generateCircomData as
|
|
13
|
-
import { AccountActions as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
6
|
+
import { getCurrentTimeInSeconds as ne } from "../utils/time.utils.mjs";
|
|
7
|
+
import { ExternalActionId as re } from "../../types/external-action.types.mjs";
|
|
8
|
+
import { Logger as ie } from "../../error-handling/logger.mjs";
|
|
9
|
+
import { takeOffHighestBit as ae } from "../utils/bit.operations.mjs";
|
|
10
|
+
import { buildOutCommitments as oe, calcAmountChanges as a, calcEncryptedOutputs as se, calcPublicSignalCount as o, calcStealthAddressStructure as s, createCallDataHash as c, getSlippageValues as l, getUtxoCircuitH0Coords as u, getUtxoCircuitInRandomization as ce, getZkProofVerifierName as le } from "./common.snarkjs.mjs";
|
|
11
|
+
import { computeSignedMessageHashEvm as ue } from "./signedMessageHash.mjs";
|
|
12
|
+
import { generateCircomData as de } from "./generateCircomData.mjs";
|
|
13
|
+
import { AccountActions as fe } from "../../data-structures/AccountActions/AccountActions.mjs";
|
|
14
|
+
import { createHinkalTiming as pe } from "../utils/hinkalTiming.utils.mjs";
|
|
15
|
+
import { generateMainAndCommitmentZkProof as me } from "./generateMainAndCommitmentZkProof.mjs";
|
|
16
|
+
import { getDataFromWorkers as d } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
17
|
+
import { encodeEmporiumMetadata as f } from "../private-wallet/emporium.helpers.mjs";
|
|
17
18
|
//#region libs/shared/common/src/functions/snarkjs/constructGeneralZkProof.ts
|
|
18
|
-
var
|
|
19
|
-
let O =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
var p = async (p, m, h, g, _, v, y, b, x, S = n, C = e.localhost, w = m.map(() => !1), T = void 0, E, D) => {
|
|
20
|
+
let O = pe("constructZkProof"), k = le(m, h), A = a(m, h), j = m.map((e) => e[0].erc20TokenAddress), M = se(h), N = ee, P = g.getShieldedPrivateKey(), { pubSpendingBJJPoint: F } = g.getSpendingKeyPair(), I = s(i.findCorrectRandomization(r(31), P), P, g.getSpendingKeyPair().pubSpendingBJJPoint), { inCommitmentSiblings: L, inCommitmentSiblingSides: R, rootHashHinkal: z, inNullifiers: B } = await d(C, p, m.map((e) => e.map((e) => e.getConstructableParams())));
|
|
21
|
+
O.log("getDataFromWorkers", {
|
|
22
|
+
verifierName: k,
|
|
23
|
+
chainId: C
|
|
24
|
+
});
|
|
25
|
+
let V = oe(h), H = r(31), U = te(H), W = BigInt(h.length > 0 ? h[0][0].timeStamp : ne()), G = {
|
|
26
|
+
rootHashHinkal: z,
|
|
27
|
+
spendingPublicKey: F,
|
|
28
|
+
nullifyingPrivateKey: P,
|
|
29
|
+
erc20TokenAddresses: j,
|
|
30
|
+
amountChanges: A,
|
|
31
|
+
inAmounts: m.map((e) => e.map((e) => e.amount.toString())),
|
|
32
|
+
inRandomizations: m.map((e) => e.map((e) => ce(e))),
|
|
33
|
+
inH0Ax: m.map((e) => e.map((e) => u(e)[0].toString())),
|
|
34
|
+
inH0Ay: m.map((e) => e.map((e) => u(e)[1].toString())),
|
|
35
|
+
isNewStyle: m.map((e) => e.map((e) => !!e.isNewStyle)),
|
|
36
|
+
inTimeStamps: m.map((e) => e.map((e) => e.timeStamp)),
|
|
37
|
+
inNullifiers: B,
|
|
38
|
+
inCommitmentSiblings: L,
|
|
39
|
+
inCommitmentSiblingSides: R,
|
|
40
|
+
outAmounts: h.map((e) => e.map((e) => e.amount.toString())),
|
|
41
|
+
outTimeStamp: W,
|
|
42
|
+
outPublicKeys: h.map((e) => e.map((e) => e.getStealthAddress())),
|
|
43
|
+
outCommitments: V,
|
|
38
44
|
calldataHash: 0n,
|
|
39
|
-
messageSeed:
|
|
40
|
-
H0Ax:
|
|
41
|
-
H0Ay:
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
rootHashHinkal:
|
|
48
|
-
erc20TokenAddresses:
|
|
49
|
-
amountChanges:
|
|
50
|
-
outTimeStamp:
|
|
51
|
-
inNullifiers:
|
|
52
|
-
outCommitments:
|
|
53
|
-
calldataHash:
|
|
54
|
-
message:
|
|
55
|
-
outH1Ay:
|
|
56
|
-
H0Ax:
|
|
57
|
-
H0Ay:
|
|
58
|
-
}), { R8:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
],
|
|
64
|
-
let
|
|
65
|
-
outTimeStamp:
|
|
66
|
-
calldataHash:
|
|
67
|
-
messageSeed:
|
|
68
|
-
}, { zkCallData:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
messageSeed: H,
|
|
46
|
+
H0Ax: ae(I.extraRandomization),
|
|
47
|
+
H0Ay: I.H0
|
|
48
|
+
}, K = o(k, G.erc20TokenAddresses, G.amountChanges, G.inNullifiers, G.outCommitments), q = a(m, h, !0), J = l(q);
|
|
49
|
+
ie.log({ publicSignalCount: K });
|
|
50
|
+
let Y = Array.isArray(y) ? y : [y], he = t(C), ge = D ? fe.getSignerAddressFromPrivateKey(he, D) : void 0, X = _ === re.Emporium ? await f(C, v ?? n, D, Y, U, ge) : await f(C, n, void 0, _ === 0n ? [] : Y, U, n);
|
|
51
|
+
O.log("encodeEmporiumMetadata", { externalActionId: _.toString() }), G.calldataHash = c(K, S, v, _, X, M, T, J, w, x, N, E);
|
|
52
|
+
let Z = ue({
|
|
53
|
+
rootHashHinkal: z,
|
|
54
|
+
erc20TokenAddresses: j,
|
|
55
|
+
amountChanges: A,
|
|
56
|
+
outTimeStamp: W,
|
|
57
|
+
inNullifiers: B,
|
|
58
|
+
outCommitments: V,
|
|
59
|
+
calldataHash: G.calldataHash,
|
|
60
|
+
message: U,
|
|
61
|
+
outH1Ay: I.H1,
|
|
62
|
+
H0Ax: G.H0Ax,
|
|
63
|
+
H0Ay: I.H0
|
|
64
|
+
}), { R8: Q, S: _e } = g.signEddsa(Z);
|
|
65
|
+
G.eddsaSignature = [
|
|
66
|
+
Q[0],
|
|
67
|
+
Q[1],
|
|
68
|
+
_e
|
|
69
|
+
], G.signedMessageHash = Z;
|
|
70
|
+
let $ = k.startsWith("mainEVMCircuitMin0"), ve = {
|
|
71
|
+
outTimeStamp: W,
|
|
72
|
+
calldataHash: G.calldataHash,
|
|
73
|
+
messageSeed: H
|
|
74
|
+
}, { zkCallData: ye, commitmentValidationData: be } = await me(C, g, j, m, k, $ ? ve : G, b);
|
|
75
|
+
O.log("generateMainAndCommitmentZkProof", {
|
|
76
|
+
verifierName: k,
|
|
77
|
+
generateProofRemotely: b
|
|
78
|
+
});
|
|
79
|
+
let xe = de(V, B, z, q, j, h, M, K, _, v, X, S, G.calldataHash, I, w, T, $ ? Number(W) : void 0, J, x, N, E), Se = {
|
|
80
|
+
tokenNumber: m.length,
|
|
81
|
+
nullifierAmount: m.length > 0 ? m[0].length : 0,
|
|
82
|
+
outputAmount: h.length > 0 ? h[0].length : 0
|
|
83
|
+
};
|
|
84
|
+
return O.log("done"), {
|
|
85
|
+
zkCallData: ye,
|
|
86
|
+
circomData: xe,
|
|
87
|
+
dimData: Se,
|
|
88
|
+
encryptedOutputs: M,
|
|
89
|
+
commitmentValidationData: be
|
|
79
90
|
};
|
|
80
91
|
};
|
|
81
92
|
//#endregion
|
|
82
|
-
export {
|
|
93
|
+
export { p as constructZkProof };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../pre-transaction/buildCommitmentValidationData.cjs`);require(`../pre-transaction/index.cjs`);const
|
|
1
|
+
const e=require(`../utils/hinkalTiming.utils.cjs`),t=require(`../pre-transaction/buildCommitmentValidationData.cjs`);require(`../pre-transaction/index.cjs`);const n=require(`./generateZkProof.cjs`);var r=async(r,i,a,o,s,c,l)=>{let u=e.createHinkalTiming(`generateMainAndCommitmentZkProof`),d=await t.buildCommitmentValidationData(r,i,a,o);u.log(`buildCommitmentValidationData`,{mainVerifierName:s,hasCommitmentProof:!!d});let f=[s],p=[c];d&&(f.push(d.verifierName),p.push(d.commitmentInput));let m=await n.generateZkProof(r,f,p,l);u.log(`generateZkProof`,{verifierNames:f,generateProofRemotely:l});let{zkCallData:h,publicSignals:g}=m[0];return{zkCallData:h,publicSignals:g,commitmentValidationData:t.buildCommitmentValidationDataFromProof(d,m[1])}};exports.generateMainAndCommitmentZkProof=r;
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHinkalTiming as e } from "../utils/hinkalTiming.utils.mjs";
|
|
2
|
+
import { buildCommitmentValidationData as t, buildCommitmentValidationDataFromProof as n } from "../pre-transaction/buildCommitmentValidationData.mjs";
|
|
2
3
|
import "../pre-transaction/index.mjs";
|
|
3
|
-
import { generateZkProof as
|
|
4
|
+
import { generateZkProof as r } from "./generateZkProof.mjs";
|
|
4
5
|
//#region libs/shared/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var i = async (i, a, o, s, c, l, u) => {
|
|
7
|
+
let d = e("generateMainAndCommitmentZkProof"), f = await t(i, a, o, s);
|
|
8
|
+
d.log("buildCommitmentValidationData", {
|
|
9
|
+
mainVerifierName: c,
|
|
10
|
+
hasCommitmentProof: !!f
|
|
11
|
+
});
|
|
12
|
+
let p = [c], m = [l];
|
|
13
|
+
f && (p.push(f.verifierName), m.push(f.commitmentInput));
|
|
14
|
+
let h = await r(i, p, m, u);
|
|
15
|
+
d.log("generateZkProof", {
|
|
16
|
+
verifierNames: p,
|
|
17
|
+
generateProofRemotely: u
|
|
18
|
+
});
|
|
19
|
+
let { zkCallData: g, publicSignals: _ } = h[0];
|
|
9
20
|
return {
|
|
10
|
-
zkCallData:
|
|
11
|
-
publicSignals:
|
|
12
|
-
commitmentValidationData:
|
|
21
|
+
zkCallData: g,
|
|
22
|
+
publicSignals: _,
|
|
23
|
+
commitmentValidationData: n(f, h[1])
|
|
13
24
|
};
|
|
14
25
|
};
|
|
15
26
|
//#endregion
|
|
16
|
-
export {
|
|
27
|
+
export { i as generateMainAndCommitmentZkProof };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../utils/customEnclaveFunctionsRegister.cjs`),t=require(`../../error-handling/logger.cjs`),n=require(`./getZKFiles.cjs`),
|
|
1
|
+
const e=require(`../utils/customEnclaveFunctionsRegister.cjs`),t=require(`../../error-handling/logger.cjs`),n=require(`../utils/hinkalTiming.utils.cjs`),r=require(`./getZKFiles.cjs`),i=require(`./generateZkProofEnclave.cjs`),a=require(`./generateZkProofSelf.cjs`);var o=async(o,s,c,l)=>{let u=n.createHinkalTiming(`generateZkProof`);if(u.log(`start`,{remotely:!!l,verifierNames:s}),l)try{let t=e.getCustomProofGenerator();if(t){let e=await t(c,s.map(e=>r.getWASMFile(e,o)),s.map(e=>r.getZKeyFile(e,o)));return u.log(`customProofGenerator`,{verifierNames:s}),e.map(({zkCallData:e,publicSignals:t})=>({zkCallData:e,publicSignals:t}))}let n=await i.generateZkProofEnclave(o,s,c);return u.log(`enclave`,{verifierNames:s}),n}catch(e){t.Logger.error(`enclave proof error`,e),u.log(`enclave-failed-fallback-self`)}let d=await Promise.all(s.map((e,t)=>a.generateZkProofSelf(o,e,c[t])));return u.log(`self`,{verifierNames:s}),d};exports.generateZkProof=o;
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { getCustomProofGenerator as e } from "../utils/customEnclaveFunctionsRegister.mjs";
|
|
2
2
|
import { Logger as t } from "../../error-handling/logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { createHinkalTiming as n } from "../utils/hinkalTiming.utils.mjs";
|
|
4
|
+
import { getWASMFile as r, getZKeyFile as i } from "./getZKFiles.mjs";
|
|
5
|
+
import { generateZkProofEnclave as a } from "./generateZkProofEnclave.mjs";
|
|
6
|
+
import { generateZkProofSelf as o } from "./generateZkProofSelf.mjs";
|
|
6
7
|
//#region libs/shared/common/src/functions/snarkjs/generateZkProof.ts
|
|
7
|
-
var
|
|
8
|
-
|
|
8
|
+
var s = async (s, c, l, u) => {
|
|
9
|
+
let d = n("generateZkProof");
|
|
10
|
+
if (d.log("start", {
|
|
11
|
+
remotely: !!u,
|
|
12
|
+
verifierNames: c
|
|
13
|
+
}), u) try {
|
|
9
14
|
let t = e();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
publicSignals: t
|
|
13
|
-
|
|
15
|
+
if (t) {
|
|
16
|
+
let e = await t(l, c.map((e) => r(e, s)), c.map((e) => i(e, s)));
|
|
17
|
+
return d.log("customProofGenerator", { verifierNames: c }), e.map(({ zkCallData: e, publicSignals: t }) => ({
|
|
18
|
+
zkCallData: e,
|
|
19
|
+
publicSignals: t
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
let n = await a(s, c, l);
|
|
23
|
+
return d.log("enclave", { verifierNames: c }), n;
|
|
14
24
|
} catch (e) {
|
|
15
|
-
t.error("enclave proof error", e);
|
|
25
|
+
t.error("enclave proof error", e), d.log("enclave-failed-fallback-self");
|
|
16
26
|
}
|
|
17
|
-
|
|
27
|
+
let f = await Promise.all(c.map((e, t) => o(s, e, l[t])));
|
|
28
|
+
return d.log("self", { verifierNames: c }), f;
|
|
18
29
|
};
|
|
19
30
|
//#endregion
|
|
20
|
-
export {
|
|
31
|
+
export { s as generateZkProof };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./constant.cjs`),t=require(`../../data-structures/http/HttpClient.cjs`);require(`../../data-structures/http/index.cjs`);const n=require(`../utils/encryptInputForEnclave.cjs`),r=require(`./getZKFiles.cjs`);var
|
|
1
|
+
const e=require(`./constant.cjs`),t=require(`../../data-structures/http/HttpClient.cjs`);require(`../../data-structures/http/index.cjs`);const n=require(`../utils/encryptInputForEnclave.cjs`),r=require(`../utils/hinkalTiming.utils.cjs`),i=require(`./getZKFiles.cjs`);var a=e=>{if(e.startsWith(`http`)){let t=e.split(`/`).at(-1);if(!t)throw Error(`invalid verifierName`);return t}return e},o=async(o,s,c)=>{let l=r.createHinkalTiming(`generateZkProofEnclave`),u=s.map(e=>a(i.getWASMFile(e,o))),d=s.map(e=>a(i.getZKeyFile(e,o))),{keyCiphertext:f,inputCiphertext:p}=await n.makeEnclaveHandshakeAndEncryptInput(c);l.log(`handshake+encrypt`,{verifierNames:s});let m={circuit_wasms:u,circuit_zkeys:d,inputs:p,key:f},h=await t.httpClient.post(`${e.ENCLAVE_URL}/generate-proofs`,m);return l.log(`enclave-http`,{verifierNames:s}),h.map(({zk_calldata:e,public_signals:t})=>({zkCallData:e,publicSignals:t}))};exports.generateZkProofEnclave=o;
|
|
@@ -2,26 +2,29 @@ import { ENCLAVE_URL as e } from "./constant.mjs";
|
|
|
2
2
|
import { httpClient as t } from "../../data-structures/http/HttpClient.mjs";
|
|
3
3
|
import "../../data-structures/http/index.mjs";
|
|
4
4
|
import { makeEnclaveHandshakeAndEncryptInput as n } from "../utils/encryptInputForEnclave.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { createHinkalTiming as r } from "../utils/hinkalTiming.utils.mjs";
|
|
6
|
+
import { getWASMFile as i, getZKeyFile as a } from "./getZKFiles.mjs";
|
|
6
7
|
//#region libs/shared/common/src/functions/snarkjs/generateZkProofEnclave.ts
|
|
7
|
-
var
|
|
8
|
+
var o = (e) => {
|
|
8
9
|
if (e.startsWith("http")) {
|
|
9
10
|
let t = e.split("/").at(-1);
|
|
10
11
|
if (!t) throw Error("invalid verifierName");
|
|
11
12
|
return t;
|
|
12
13
|
}
|
|
13
14
|
return e;
|
|
14
|
-
},
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
}, s = async (s, c, l) => {
|
|
16
|
+
let u = r("generateZkProofEnclave"), d = c.map((e) => o(i(e, s))), f = c.map((e) => o(a(e, s))), { keyCiphertext: p, inputCiphertext: m } = await n(l);
|
|
17
|
+
u.log("handshake+encrypt", { verifierNames: c });
|
|
18
|
+
let h = {
|
|
19
|
+
circuit_wasms: d,
|
|
20
|
+
circuit_zkeys: f,
|
|
21
|
+
inputs: m,
|
|
22
|
+
key: p
|
|
23
|
+
}, g = await t.post(`${e}/generate-proofs`, h);
|
|
24
|
+
return u.log("enclave-http", { verifierNames: c }), g.map(({ zk_calldata: e, public_signals: t }) => ({
|
|
22
25
|
zkCallData: e,
|
|
23
26
|
publicSignals: t
|
|
24
27
|
}));
|
|
25
28
|
};
|
|
26
29
|
//#endregion
|
|
27
|
-
export {
|
|
30
|
+
export { s as generateZkProofEnclave };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../webworker/worker.registry.cjs`),t=require(`../../webworker/performTaskWithWorker.cjs`),
|
|
1
|
+
const e=require(`../../webworker/worker.registry.cjs`),t=require(`../utils/hinkalTiming.utils.cjs`),n=require(`../../webworker/performTaskWithWorker.cjs`),r=require(`./getZKFiles.cjs`),i=require(`../../webworker/snarkjsWorker/snarkjsWorker.types.cjs`);var a=async(a,o,s)=>{let c=t.createHinkalTiming(`generateZkProofSelf:${o}`),l=r.getWASMFile(o,a),u=r.getZKeyFile(o,a);c.log(`start`,{chainId:a,wasmFilePath:l});let{publicSignals:d,zkCallData:f}=await n.performTaskWithWorker({type:e.WorkerVariant.SnarkJS,payload:{type:i.SnarkJSWorkerActionType.FULL_PROVE,data:{input:s,chainId:a,wasmFilePath:l,zKeyFilePath:u}}});return c.log(`worker-done`),{zkCallData:f,publicSignals:d}};exports.generateZkProofSelf=a;
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { WorkerVariant as e } from "../../webworker/worker.registry.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createHinkalTiming as t } from "../utils/hinkalTiming.utils.mjs";
|
|
3
|
+
import { performTaskWithWorker as n } from "../../webworker/performTaskWithWorker.mjs";
|
|
4
|
+
import { getWASMFile as r, getZKeyFile as i } from "./getZKFiles.mjs";
|
|
5
|
+
import { SnarkJSWorkerActionType as a } from "../../webworker/snarkjsWorker/snarkjsWorker.types.mjs";
|
|
5
6
|
//#region libs/shared/common/src/functions/snarkjs/generateZkProofSelf.ts
|
|
6
|
-
var
|
|
7
|
-
let
|
|
7
|
+
var o = async (o, s, c) => {
|
|
8
|
+
let l = t(`generateZkProofSelf:${s}`), u = r(s, o), d = i(s, o);
|
|
9
|
+
l.log("start", {
|
|
10
|
+
chainId: o,
|
|
11
|
+
wasmFilePath: u
|
|
12
|
+
});
|
|
13
|
+
let { publicSignals: f, zkCallData: p } = await n({
|
|
8
14
|
type: e.SnarkJS,
|
|
9
15
|
payload: {
|
|
10
|
-
type:
|
|
16
|
+
type: a.FULL_PROVE,
|
|
11
17
|
data: {
|
|
12
|
-
input:
|
|
13
|
-
chainId:
|
|
14
|
-
wasmFilePath:
|
|
15
|
-
zKeyFilePath:
|
|
18
|
+
input: c,
|
|
19
|
+
chainId: o,
|
|
20
|
+
wasmFilePath: u,
|
|
21
|
+
zKeyFilePath: d
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
});
|
|
19
|
-
return {
|
|
20
|
-
zkCallData:
|
|
21
|
-
publicSignals:
|
|
25
|
+
return l.log("worker-done"), {
|
|
26
|
+
zkCallData: p,
|
|
27
|
+
publicSignals: f
|
|
22
28
|
};
|
|
23
29
|
};
|
|
24
30
|
//#endregion
|
|
25
|
-
export {
|
|
31
|
+
export { o as generateZkProofSelf };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`[HinkalTiming]`,t=(t,n,r,i)=>{let a=Date.now(),o=a-r.last,s=a-r.start;r.last=a;let c=i?` ${JSON.stringify(i)}`:``;console.log(`${e} [${t}] ${n} +${o}ms (total ${s}ms)${c}`)},n=e=>{let n={start:Date.now(),last:Date.now()};return{marks:n,log:(r,i)=>t(e,r,n,i)}};exports.createHinkalTiming=n;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region libs/shared/common/src/functions/utils/hinkalTiming.utils.ts
|
|
2
|
+
var e = "[HinkalTiming]", t = (t, n, r, i) => {
|
|
3
|
+
let a = Date.now(), o = a - r.last, s = a - r.start;
|
|
4
|
+
r.last = a;
|
|
5
|
+
let c = i ? ` ${JSON.stringify(i)}` : "";
|
|
6
|
+
console.log(`${e} [${t}] ${n} +${o}ms (total ${s}ms)${c}`);
|
|
7
|
+
}, n = (e) => {
|
|
8
|
+
let n = {
|
|
9
|
+
start: Date.now(),
|
|
10
|
+
last: Date.now()
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
marks: n,
|
|
14
|
+
log: (r, i) => t(e, r, n, i)
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n as createHinkalTiming };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../constants/vite.constants.cjs`),t=require(`../constants/chains.constants.cjs`),n=require(`./workerFactory.cjs`);var
|
|
1
|
+
const e=require(`../constants/vite.constants.cjs`),t=require(`../constants/chains.constants.cjs`),n=require(`./workerFactory.cjs`),r=require(`../functions/utils/hinkalTiming.utils.cjs`);var i=async i=>{let a=r.createHinkalTiming(`worker:${i.type}`),o=await n.WorkerFactory.getWebWorker(i.type);return a.log(`spawned`),new Promise((n,r)=>{let s={};if(typeof window<`u`&&window.location){let{origin:e,protocol:t,host:n,port:r,hostname:i,href:a}=window.location;s={origin:e,protocol:t,host:n,port:r,hostname:i,href:a}}o.onMessage(e=>{a.log(`completed`),n(e),o.terminate()}),o.onError(e=>{a.log(`error`),r(e),o.terminate()});let c={payload:i.payload,metadata:{hostLocation:s,constants:{chains:{chainIds:t.chainIds},isDevelopment:e.isDevelopment}}};o.postMessage(c)})};exports.performTaskWithWorker=i;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { isDevelopment as e } from "../constants/vite.constants.mjs";
|
|
2
2
|
import { chainIds as t } from "../constants/chains.constants.mjs";
|
|
3
3
|
import { WorkerFactory as n } from "./workerFactory.mjs";
|
|
4
|
+
import { createHinkalTiming as r } from "../functions/utils/hinkalTiming.utils.mjs";
|
|
4
5
|
//#region libs/shared/common/src/webworker/performTaskWithWorker.ts
|
|
5
|
-
var
|
|
6
|
-
let i = await n.getWebWorker(
|
|
7
|
-
return new Promise((n,
|
|
8
|
-
let
|
|
6
|
+
var i = async (i) => {
|
|
7
|
+
let a = r(`worker:${i.type}`), o = await n.getWebWorker(i.type);
|
|
8
|
+
return a.log("spawned"), new Promise((n, r) => {
|
|
9
|
+
let s = {};
|
|
9
10
|
if (typeof window < "u" && window.location) {
|
|
10
11
|
let { origin: e, protocol: t, host: n, port: r, hostname: i, href: a } = window.location;
|
|
11
|
-
|
|
12
|
+
s = {
|
|
12
13
|
origin: e,
|
|
13
14
|
protocol: t,
|
|
14
15
|
host: n,
|
|
@@ -17,23 +18,23 @@ var r = async (r) => {
|
|
|
17
18
|
href: a
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
n(e),
|
|
22
|
-
}),
|
|
23
|
-
a(e),
|
|
21
|
+
o.onMessage((e) => {
|
|
22
|
+
a.log("completed"), n(e), o.terminate();
|
|
23
|
+
}), o.onError((e) => {
|
|
24
|
+
a.log("error"), r(e), o.terminate();
|
|
24
25
|
});
|
|
25
|
-
let
|
|
26
|
-
payload:
|
|
26
|
+
let c = {
|
|
27
|
+
payload: i.payload,
|
|
27
28
|
metadata: {
|
|
28
|
-
hostLocation:
|
|
29
|
+
hostLocation: s,
|
|
29
30
|
constants: {
|
|
30
31
|
chains: { chainIds: t },
|
|
31
32
|
isDevelopment: e
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
+
o.postMessage(c);
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
39
|
//#endregion
|
|
39
|
-
export {
|
|
40
|
+
export { i as performTaskWithWorker };
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
|
|
15
15
|
|
|
16
16
|
const n = async () => ({
|
|
17
|
-
[e.ZKProof]: await getWorkerURL(domain + '/0.3.
|
|
18
|
-
[e.SnarkJS]: await getWorkerURL(domain + '/0.3.
|
|
19
|
-
[e.UTXO]: await getWorkerURL(domain + '/0.3.
|
|
17
|
+
[e.ZKProof]: await getWorkerURL(domain + '/0.3.23/' + 'zkProofWorkerLauncher.js'),
|
|
18
|
+
[e.SnarkJS]: await getWorkerURL(domain + '/0.3.23/' + 'snarkjsWorkerLauncher.js'),
|
|
19
|
+
[e.UTXO]: await getWorkerURL(domain + '/0.3.23/' + 'utxoWorkerLauncher.js'),
|
|
20
20
|
});
|
|
21
21
|
exports.getWorkerViteURL = n;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
|
|
15
15
|
|
|
16
16
|
const n = async () => ({
|
|
17
|
-
[e.ZKProof]: await getWorkerURL(domain + '/0.3.
|
|
18
|
-
[e.SnarkJS]: await getWorkerURL(domain + '/0.3.
|
|
19
|
-
[e.UTXO]: await getWorkerURL(domain + '/0.3.
|
|
17
|
+
[e.ZKProof]: await getWorkerURL(domain + '/0.3.23/' + 'zkProofWorkerLauncher.js'),
|
|
18
|
+
[e.SnarkJS]: await getWorkerURL(domain + '/0.3.23/' + 'snarkjsWorkerLauncher.js'),
|
|
19
|
+
[e.UTXO]: await getWorkerURL(domain + '/0.3.23/' + 'utxoWorkerLauncher.js'),
|
|
20
20
|
});
|
|
21
21
|
export { n as getWorkerViteURL };
|
package/package.json
CHANGED
package/sdk/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={name:`@gurge/sdk`,version:`0.3.
|
|
1
|
+
var e={name:`@gurge/sdk`,version:`0.3.22`,homepage:`hinkal.io`,author:{name:`Hinkal Protocol`},keywords:[`blockchain`,`privacy`,`zero-knowledge`,`stealth addresses`],exports:{".":{types:`./index.d.ts`,"react-native":`./index.cjs`,import:`./index.mjs`,default:`./index.cjs`},"./providers/WagmiProviderAdapter":{types:`./providers/WagmiProviderAdapter.d.ts`,"react-native":`./providers/WagmiProviderAdapter.cjs`,import:`./providers/WagmiProviderAdapter.mjs`,default:`./providers/WagmiProviderAdapter.cjs`},"./providers/EthersProviderAdapter":{types:`./providers/EthersProviderAdapter.d.ts`,"react-native":`./providers/EthersProviderAdapter.cjs`,import:`./providers/EthersProviderAdapter.mjs`,default:`./providers/EthersProviderAdapter.cjs`},"./providers/TronProviderAdapter":{types:`./providers/TronProviderAdapter.d.ts`,"react-native":`./providers/TronProviderAdapter.cjs`,import:`./providers/TronProviderAdapter.mjs`,default:`./providers/TronProviderAdapter.cjs`},"./providers/SolanaProviderAdapter":{types:`./providers/SolanaProviderAdapter.d.ts`,"react-native":`./providers/SolanaProviderAdapter.cjs`,import:`./providers/SolanaProviderAdapter.mjs`,default:`./providers/SolanaProviderAdapter.cjs`},"./providers/prepareEthersHinkal":{types:`./providers/prepareEthersHinkal.d.ts`,"react-native":`./providers/prepareEthersHinkal.cjs`,import:`./providers/prepareEthersHinkal.mjs`,default:`./providers/prepareEthersHinkal.cjs`},"./providers/prepareWagmiHinkal":{types:`./providers/prepareWagmiHinkal.d.ts`,"react-native":`./providers/prepareWagmiHinkal.cjs`,import:`./providers/prepareWagmiHinkal.mjs`,default:`./providers/prepareWagmiHinkal.cjs`},"./providers/prepareTronHinkal":{types:`./providers/prepareTronHinkal.d.ts`,"react-native":`./providers/prepareTronHinkal.cjs`,import:`./providers/prepareTronHinkal.mjs`,default:`./providers/prepareTronHinkal.cjs`},"./providers/prepareSolanaHinkal":{types:`./providers/prepareSolanaHinkal.d.ts`,"react-native":`./providers/prepareSolanaHinkal.cjs`,import:`./providers/prepareSolanaHinkal.mjs`,default:`./providers/prepareSolanaHinkal.cjs`},"./react-native/HinkalWebViewWorker":{types:`./react-native/HinkalWebViewWorker.d.ts`,"react-native":`./react-native/HinkalWebViewWorker.cjs`,import:`./react-native/HinkalWebViewWorker.mjs`,default:`./react-native/HinkalWebViewWorker.cjs`},"./react-native/metro-config":`./react-native/metro-config.js`,"./react-native/shims/*":`./react-native/shims/*`},types:`./index.d.ts`,scripts:{prebuild:`nx prebuild:workers`,build:`nx build`,lint:`nx lint`,test:`nx test`},devDependencies:{nx:`22.6.4`,vite:`^8.0.4`,"vite-plugin-dts":`^4.5.4`,"vite-tsconfig-paths":`^6.1.1`},dependencies:{"@coral-xyz/anchor":`^0.31.0`,"@solana/spl-token":`^0.4.14`,"@solana/web3.js":`^1.98.4`,"@solana/wallet-adapter-react":`^0.15.39`,axios:`^1.15.0`,"async-mutex":`^0.4.0`,bs58:`^6.0.0`,buffer:`6.0.3`,"circomlibjs-hinkal-fork":`^0.0.10`,dotenv:`^16.4.5`,ethers:`^6.15.0`,"idb-keyval":`6.2.1`,multiformats:`^9.4.2`,snarkjs:`0.7.5`,"libsodium-wrappers":`^0.8.2`,lodash:`^4.17.21`,tweetnacl:`^1.0.3`,process:`0.11.10`,"ua-parser-js":`^1.0.37`,uuid:`^9.0.1`,"node-forge":`^1.3.1`,"poseidon-lite":`^0.3.0`,tronweb:`^6.2.0`},peerDependencies:{wagmi:`2.13.3`,"@walletconnect/utils":`^2.17.2`,react:`*`,"react-native":`*`,"react-native-webview":`*`},peerDependenciesMeta:{wagmi:{optional:!0},"@walletconnect/utils":{optional:!0},react:{optional:!0},"react-native":{optional:!0},"react-native-webview":{optional:!0}}};exports.default=e;
|