@hinkal/common 0.1.35 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/rewards.constants.d.ts +1 -1
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.d.ts +3 -2
- package/constants/vite.constants.mjs +15 -14
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +31 -31
- package/data-structures/event-service/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/AbstractEventService.mjs +17 -8
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +14 -9
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +14 -9
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +8 -3
- package/error-handling/logError.cjs +1 -1
- package/error-handling/logError.mjs +3 -3
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.mjs +11 -12
- package/functions/utils/process.utils.cjs +1 -1
- package/functions/utils/process.utils.d.ts +0 -2
- package/functions/utils/process.utils.mjs +8 -10
- package/index.cjs +1 -1
- package/index.mjs +490 -491
- package/package.json +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../functions/utils/enum.utils.cjs"),s=typeof process<"u"&&process?.release?.name==="node",g=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,y=typeof __webpack_require__<"u";var r=(e=>(e.DEVELOPMENT="development",e.STAGING="staging",e.PLAYGROUND="playground",e.PRODUCTION="production",e))(r||{});const o={development:["localhost","192.","127."],playground:["playground"],staging:["working-branch"]};function t(e,l){return l.some(p=>e.includes(p))}const m=()=>(require("dotenv").config({path:"DOTENV_OVERRIDE"in process.env?process.env.DOTENV_OVERRIDE:void 0}),a.toEnumValue(r,process.env.DEPLOYMENT_MODE)||"development"),v=()=>{if(!s&&typeof window>"u")return;if(s)return m();const e=window?.location?.host;return t(e,o.development)?"development":t(e,o.playground)?"playground":t(e,o.staging)?"staging":"production"},n=v(),i=n==="staging",d=n==="playground",u=n==="development",c=i||u||d,f=c||n==="production"&&s;exports.DEPLOYMENT_MODE=r;exports.deploymentMode=n;exports.isDevelopment=u;exports.isNode=g;exports.isNotClientProduction=f;exports.isNotProduction=c;exports.isPlayground=d;exports.isStaging=i;exports.isWebpack=y;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
export declare const isNode: boolean;
|
|
2
|
+
export declare const isWebpack: boolean;
|
|
1
3
|
export declare enum DEPLOYMENT_MODE {
|
|
2
4
|
DEVELOPMENT = "development",
|
|
3
5
|
STAGING = "staging",
|
|
4
6
|
PLAYGROUND = "playground",
|
|
5
7
|
PRODUCTION = "production"
|
|
6
8
|
}
|
|
7
|
-
export declare const isNode: boolean;
|
|
8
|
-
export declare const isWebpack: boolean;
|
|
9
9
|
export declare const deploymentMode: DEPLOYMENT_MODE | undefined;
|
|
10
10
|
export declare const isStaging: boolean;
|
|
11
11
|
export declare const isPlayground: boolean;
|
|
12
12
|
export declare const isDevelopment: boolean;
|
|
13
13
|
export declare const isNotProduction: boolean;
|
|
14
|
+
export declare const isNotClientProduction: boolean;
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import { toEnumValue as p } from "../functions/utils/enum.utils.mjs";
|
|
2
|
-
|
|
2
|
+
const r = typeof process < "u" && process?.release?.name === "node", y = typeof process < "u" && process.versions != null && process.versions.node != null, f = typeof __webpack_require__ < "u";
|
|
3
3
|
var s = /* @__PURE__ */ ((e) => (e.DEVELOPMENT = "development", e.STAGING = "staging", e.PLAYGROUND = "playground", e.PRODUCTION = "production", e))(s || {});
|
|
4
|
-
const
|
|
4
|
+
const o = {
|
|
5
5
|
development: ["localhost", "192.", "127."],
|
|
6
6
|
playground: ["playground"],
|
|
7
7
|
// The code deployed to the 'playground' branch is hosted by Netlify at 'hinkal-playground.netlify.app'
|
|
8
8
|
staging: ["working-branch"]
|
|
9
9
|
// The code deployed to the 'new' branch is hosted by Netlify at 'working-branch.netlify.app'
|
|
10
10
|
};
|
|
11
|
-
function
|
|
11
|
+
function t(e, i) {
|
|
12
12
|
return i.some((d) => e.includes(d));
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const c = () => (require("dotenv").config({
|
|
15
15
|
// allow overriding .env file path, see startServer.sh script for explenation on why it is needed
|
|
16
16
|
path: "DOTENV_OVERRIDE" in process.env ? process.env.DOTENV_OVERRIDE : void 0
|
|
17
|
-
}), p(s, process.env.DEPLOYMENT_MODE) || "development"),
|
|
18
|
-
if (!r
|
|
17
|
+
}), p(s, process.env.DEPLOYMENT_MODE) || "development"), u = () => {
|
|
18
|
+
if (!r && typeof window > "u")
|
|
19
19
|
return;
|
|
20
|
-
if (r
|
|
21
|
-
return
|
|
20
|
+
if (r)
|
|
21
|
+
return c();
|
|
22
22
|
const e = window?.location?.host;
|
|
23
|
-
return
|
|
24
|
-
},
|
|
23
|
+
return t(e, o.development) ? "development" : t(e, o.playground) ? "playground" : t(e, o.staging) ? "staging" : "production";
|
|
24
|
+
}, n = u(), l = n === "staging", a = n === "playground", g = n === "development", m = l || g || a, N = m || n === "production" && r;
|
|
25
25
|
export {
|
|
26
26
|
s as DEPLOYMENT_MODE,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
n as deploymentMode,
|
|
28
|
+
g as isDevelopment,
|
|
29
29
|
y as isNode,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
N as isNotClientProduction,
|
|
31
|
+
m as isNotProduction,
|
|
32
|
+
a as isPlayground,
|
|
32
33
|
l as isStaging,
|
|
33
34
|
f as isWebpack
|
|
34
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../utxo/Utxo.cjs"),u=require("../../webworker/utxoWorker/utxoWorker.types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../utxo/Utxo.cjs"),u=require("../../webworker/utxoWorker/utxoWorker.types.cjs"),d=require("../../webworker/performTaskWithWorker.cjs"),y=require("../../webworker/worker.registry.cjs"),m=require("../../constants/vite.constants.cjs");class U{NUM_WORKERS;NUM_WORKERS_BATCH_PROCESS;constructor(){m.isNode?(this.NUM_WORKERS=1,this.NUM_WORKERS_BATCH_PROCESS=1):(this.NUM_WORKERS=3,this.NUM_WORKERS_BATCH_PROCESS=Math.ceil(navigator.deviceMemory??4))}async createUtxoPromise(e){return await d.performTaskWithWorker({type:y.WorkerVariant.UTXO,payload:e})}async batchFilterUtxosWithNullifier(e,s){const i=this.sliceArrayIntoParts(e,this.NUM_WORKERS).map(t=>this.createUtxoPromise({type:u.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER,data:{utxos:t.map(r=>r.getConstructableParams()),nullifiers:s}}));return(await Promise.all(i)).flat().map(t=>new p.Utxo(t))}async buildBatchProcess(e,s){const i=this.sliceArrayIntoParts(e,this.NUM_WORKERS).map(r=>this.createUtxoPromise({type:u.UtxoWorkerActionType.BUILD_UTXOS,data:{signature:s.getSignature(),encryptedOutputs:r}}));return(await Promise.all(i)).flat().map(r=>new p.Utxo(r))}sliceArrayIntoParts(e,s){const o=Math.ceil(e.length/s);return Array.from({length:s},(c,t)=>e.slice(o*t,o*(t+1)))}async batchProcess(e,s,o){const c=this.sliceArrayIntoParts(e,this.NUM_WORKERS_BATCH_PROCESS).map(a=>{const n={type:u.UtxoWorkerActionType.DECIPHER_OUTPUTS,data:{encryptedOutputs:a,lastOutput:s,signature:o.getSignature()}};return this.createUtxoPromise(n)}),t=await Promise.all(c),r=t.map(({additionalEncryptedOutputs:a})=>a).flat(),l=new Set,h=r.reduce((a,n)=>l.has(n.value)?a:(l.add(n.value),[...a,n]),[]),R=t.length?t[t.length-1]?.lastOutput:void 0;return{additionalEncryptedOutputs:h,lastOutput:R??s}}}const S=new U;exports.MultiThreadedUtxoUtils=U;exports.multiThreadedUtxoUtils=S;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import { Utxo as p } from "../utxo/Utxo.mjs";
|
|
2
2
|
import { UtxoWorkerActionType as u } from "../../webworker/utxoWorker/utxoWorker.types.mjs";
|
|
3
|
-
import { performTaskWithWorker as
|
|
4
|
-
import { WorkerVariant as
|
|
5
|
-
import { isNode as
|
|
6
|
-
class
|
|
3
|
+
import { performTaskWithWorker as h } from "../../webworker/performTaskWithWorker.mjs";
|
|
4
|
+
import { WorkerVariant as U } from "../../webworker/worker.registry.mjs";
|
|
5
|
+
import { isNode as d } from "../../constants/vite.constants.mjs";
|
|
6
|
+
class S {
|
|
7
7
|
NUM_WORKERS;
|
|
8
8
|
NUM_WORKERS_BATCH_PROCESS;
|
|
9
9
|
constructor() {
|
|
10
|
-
|
|
10
|
+
d ? (this.NUM_WORKERS = 1, this.NUM_WORKERS_BATCH_PROCESS = 1) : (this.NUM_WORKERS = 3, this.NUM_WORKERS_BATCH_PROCESS = Math.ceil(navigator.deviceMemory ?? 4));
|
|
11
11
|
}
|
|
12
|
-
async createUtxoPromise(
|
|
13
|
-
return await
|
|
14
|
-
type:
|
|
15
|
-
payload:
|
|
12
|
+
async createUtxoPromise(s) {
|
|
13
|
+
return await h({
|
|
14
|
+
type: U.UTXO,
|
|
15
|
+
payload: s
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
async batchFilterUtxosWithNullifier(
|
|
19
|
-
const i = this.sliceArrayIntoParts(
|
|
20
|
-
(
|
|
18
|
+
async batchFilterUtxosWithNullifier(s, e) {
|
|
19
|
+
const i = this.sliceArrayIntoParts(s, this.NUM_WORKERS).map(
|
|
20
|
+
(t) => this.createUtxoPromise({
|
|
21
21
|
type: u.BATCH_FILTER_UTXOS_WITH_NULLIFIER,
|
|
22
22
|
data: {
|
|
23
|
-
utxos:
|
|
24
|
-
nullifiers:
|
|
23
|
+
utxos: t.map((r) => r.getConstructableParams()),
|
|
24
|
+
nullifiers: e
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
);
|
|
28
|
-
return (await Promise.all(i)).flat().map((
|
|
28
|
+
return (await Promise.all(i)).flat().map((t) => new p(t));
|
|
29
29
|
}
|
|
30
|
-
async buildBatchProcess(
|
|
31
|
-
const i = this.sliceArrayIntoParts(
|
|
30
|
+
async buildBatchProcess(s, e) {
|
|
31
|
+
const i = this.sliceArrayIntoParts(s, this.NUM_WORKERS).map(
|
|
32
32
|
(r) => this.createUtxoPromise({
|
|
33
33
|
type: u.BUILD_UTXOS,
|
|
34
|
-
data: { signature:
|
|
34
|
+
data: { signature: e.getSignature(), encryptedOutputs: r }
|
|
35
35
|
})
|
|
36
36
|
);
|
|
37
37
|
return (await Promise.all(i)).flat().map((r) => new p(r));
|
|
38
38
|
}
|
|
39
|
-
sliceArrayIntoParts(
|
|
40
|
-
const a = Math.ceil(
|
|
39
|
+
sliceArrayIntoParts(s, e) {
|
|
40
|
+
const a = Math.ceil(s.length / e);
|
|
41
41
|
return Array.from(
|
|
42
|
-
{ length:
|
|
43
|
-
(c,
|
|
42
|
+
{ length: e },
|
|
43
|
+
(c, t) => s.slice(a * t, a * (t + 1))
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
-
async batchProcess(
|
|
47
|
-
const c = this.sliceArrayIntoParts(
|
|
46
|
+
async batchProcess(s, e, a) {
|
|
47
|
+
const c = this.sliceArrayIntoParts(s, this.NUM_WORKERS_BATCH_PROCESS).map((o) => {
|
|
48
48
|
const n = {
|
|
49
49
|
type: u.DECIPHER_OUTPUTS,
|
|
50
50
|
data: {
|
|
51
51
|
encryptedOutputs: o,
|
|
52
|
-
lastOutput:
|
|
52
|
+
lastOutput: e,
|
|
53
53
|
// doesn't matter what we pass here, it will not be used regardless
|
|
54
54
|
signature: a.getSignature()
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
return this.createUtxoPromise(n);
|
|
58
|
-
}),
|
|
58
|
+
}), t = await Promise.all(c), r = t.map(({ additionalEncryptedOutputs: o }) => o).flat(), l = /* @__PURE__ */ new Set(), m = r.reduce((o, n) => l.has(n.value) ? o : (l.add(n.value), [...o, n]), []), R = t.length ? t[t.length - 1]?.lastOutput : void 0;
|
|
59
59
|
return {
|
|
60
|
-
additionalEncryptedOutputs:
|
|
61
|
-
lastOutput:
|
|
60
|
+
additionalEncryptedOutputs: m,
|
|
61
|
+
lastOutput: R ?? e
|
|
62
62
|
// keep the last output the same if no new output is present
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
const
|
|
66
|
+
const T = new S();
|
|
67
67
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
S as MultiThreadedUtxoUtils,
|
|
69
|
+
T as multiThreadedUtxoUtils
|
|
70
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../constants/reorg-depths.constants.cjs"),o=require("../../functions/utils/resolve-sync.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");const u=require("../../error-handling/logError.cjs");class g{contract;eventConfig;_latestBlockNumber;maxPageSize;isReady=!1;_onNewEvent;isServer;intervalId;inProgress;constructor(e,r,t,s,n){this.contract=e,this.eventConfig=r,this._latestBlockNumber=t,this.maxPageSize=n,this.isServer=s,this.inProgress=!1}get latestBlockNumber(){return this._latestBlockNumber}set onNewEvent(e){this._onNewEvent=e}intervalClear(){this.isReady=!1,this._onNewEvent=void 0,clearInterval(this.intervalId)}async init(){if(this.isReady)throw new Error("Already initialized");this.isReady=!0,await this.retrieveEvents(this._latestBlockNumber+1),this.intervalId=setInterval(async()=>{await this.retrieveEvents(this.latestBlockNumber)},3500)}requireReady(){if(!this.isReady)throw new Error("Not ready")}emitNewEvent(e){this._onNewEvent?.(e)}getLastBlockNumberForEventRequest=async()=>{const e=await this.contract.provider.getBlockNumber();if(!this.isServer)return e;const{chainId:r}=await this.contract.provider.getNetwork();return Math.max(this.latestBlockNumber,e-v.blockReorgDepth[r]+1)};async retrieveEvents(e,r=!1){try{if(this.requireReady(),this.inProgress&&!r)return!1;this.inProgress=!0;const t=await this.getLastBlockNumberForEventRequest();if(t<e)return this.inProgress=!1,!1;const s=o.getSequence(e,t,this.maxPageSize);return await o.resolveSync(s.map(({from:n,to:i})=>async()=>{const c=await this.contract.queryFilter(this.contract.filters[this.eventConfig.name](),n,i);let a=[];c.length>0&&(a=await this.processEventsPage(c)),this._latestBlockNumber=i,await this.afterEventsAccepted(),a.length>0&&this.emitNewEvent()})),this.inProgress=!1,!0}catch(t){return u.logError("retrieveEvents error:",{err:t}),this.inProgress=!1,!1}}async processEventsPage(e){const r=[];return await o.resolveSync(e.map(t=>async()=>{const{args:s,blockNumber:n}=t;if(!s)throw new Error("Wrong event structure");const i=this.mapEvent(s);await this.acceptEvent(i,n)&&r.push(i)})),r}handleEvent=async(...e)=>{const{args:r}=this.eventConfig,{blockNumber:t}=e[e.length-1],s=e.slice(0,r.length),n=r.reduce((a,l,h)=>(a[l]=s[h],a),{});if(!t)throw new Error("Wrong event structure");const i=this.mapEvent(n);if(!await this.acceptEvent(i,t))throw new Error("Failed to retrieve events");this._latestBlockNumber=t,await this.afterEventsAccepted(),this.emitNewEvent(i)}}exports.AbstractEventService=g;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { blockReorgDepth as v } from "../../constants/reorg-depths.constants.mjs";
|
|
2
|
-
import { getSequence as u, resolveSync as
|
|
3
|
-
|
|
2
|
+
import { getSequence as u, resolveSync as c } from "../../functions/utils/resolve-sync.utils.mjs";
|
|
3
|
+
import "ethers";
|
|
4
|
+
import "axios";
|
|
5
|
+
import "../../constants/chains.constants.mjs";
|
|
6
|
+
import "../../constants/vite.constants.mjs";
|
|
7
|
+
import "../../types/circom-data.types.mjs";
|
|
8
|
+
import "../../types/transactions.types.mjs";
|
|
9
|
+
import "../../types/curve.types.mjs";
|
|
10
|
+
import "circomlibjs";
|
|
11
|
+
import { logError as m } from "../../error-handling/logError.mjs";
|
|
12
|
+
class R {
|
|
4
13
|
contract;
|
|
5
14
|
eventConfig;
|
|
6
15
|
_latestBlockNumber;
|
|
@@ -53,24 +62,24 @@ class w {
|
|
|
53
62
|
if (t < e)
|
|
54
63
|
return this.inProgress = !1, !1;
|
|
55
64
|
const r = u(e, t, this.maxPageSize);
|
|
56
|
-
return await
|
|
65
|
+
return await c(
|
|
57
66
|
r.map(({ from: n, to: i }) => async () => {
|
|
58
|
-
const
|
|
67
|
+
const o = await this.contract.queryFilter(
|
|
59
68
|
this.contract.filters[this.eventConfig.name](),
|
|
60
69
|
n,
|
|
61
70
|
i
|
|
62
71
|
);
|
|
63
72
|
let a = [];
|
|
64
|
-
|
|
73
|
+
o.length > 0 && (a = await this.processEventsPage(o)), this._latestBlockNumber = i, await this.afterEventsAccepted(), a.length > 0 && this.emitNewEvent();
|
|
65
74
|
})
|
|
66
75
|
), this.inProgress = !1, !0;
|
|
67
76
|
} catch (t) {
|
|
68
|
-
return
|
|
77
|
+
return m("retrieveEvents error:", { err: t }), this.inProgress = !1, !1;
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
80
|
async processEventsPage(e) {
|
|
72
81
|
const s = [];
|
|
73
|
-
return await
|
|
82
|
+
return await c(
|
|
74
83
|
e.map((t) => async () => {
|
|
75
84
|
const { args: r, blockNumber: n } = t;
|
|
76
85
|
if (!r)
|
|
@@ -91,5 +100,5 @@ class w {
|
|
|
91
100
|
};
|
|
92
101
|
}
|
|
93
102
|
export {
|
|
94
|
-
|
|
103
|
+
R as AbstractEventService
|
|
95
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { AbstractAccessTokenSnapshotService as
|
|
1
|
+
import { AbstractAccessTokenSnapshotService as t } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
|
|
2
2
|
import "circomlibjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "../../constants/vite.constants.mjs";
|
|
5
5
|
import "../../constants/reorg-depths.constants.mjs";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import "axios";
|
|
7
|
+
import "../../constants/chains.constants.mjs";
|
|
8
|
+
import "../../types/circom-data.types.mjs";
|
|
9
|
+
import "../../types/transactions.types.mjs";
|
|
10
|
+
import "../../types/curve.types.mjs";
|
|
11
|
+
import { fetchAccessTokenSnapshot as s } from "../../API/fetchCommitmentsCache.mjs";
|
|
12
|
+
class A extends t {
|
|
13
|
+
constructor(r, e) {
|
|
14
|
+
super(r, 0, !1, e);
|
|
10
15
|
}
|
|
11
16
|
async fetchSnapshot() {
|
|
12
|
-
const { chainId:
|
|
13
|
-
if (e.accessTokenContractAddress !== this.contract.address || e.chainId !==
|
|
17
|
+
const { chainId: r } = await this.contract.provider.getNetwork(), e = await s(r);
|
|
18
|
+
if (e.accessTokenContractAddress !== this.contract.address || e.chainId !== r)
|
|
14
19
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
15
20
|
return {
|
|
16
21
|
latestBlockNumber: e.latestBlockNumber,
|
|
@@ -19,10 +24,10 @@ class h extends r {
|
|
|
19
24
|
senderAddressIndexMap: e.senderAddressIndexMap
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
|
-
persistSnapshot(
|
|
27
|
+
persistSnapshot(r) {
|
|
23
28
|
return Promise.resolve();
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
export {
|
|
27
|
-
|
|
32
|
+
A as ClientAccessTokenSnapshotService
|
|
28
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const r=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const r=require("../../API/fetchCommitmentsCache.cjs"),s=require("../event-service/AbstractCommitmentsSnapshotService.cjs");class i extends s.AbstractCommitmentsSnapshotService{constructor(t,e){super(t,0,!1,e)}async fetchSnapshot(){const{chainId:t}=await this.contract.provider.getNetwork(),e=await r.fetchCommitmentsSnapshot(t);if(e.hinkalAddress!==this.contract.address||e.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,encryptedOutputs:e.encryptedOutputs}}persistSnapshot(t){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=i;
|
|
@@ -2,15 +2,20 @@ import "circomlibjs";
|
|
|
2
2
|
import "ethers";
|
|
3
3
|
import "../../constants/vite.constants.mjs";
|
|
4
4
|
import "../../constants/reorg-depths.constants.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import "axios";
|
|
6
|
+
import "../../constants/chains.constants.mjs";
|
|
7
|
+
import "../../types/circom-data.types.mjs";
|
|
8
|
+
import "../../types/transactions.types.mjs";
|
|
9
|
+
import "../../types/curve.types.mjs";
|
|
10
|
+
import { fetchCommitmentsSnapshot as e } from "../../API/fetchCommitmentsCache.mjs";
|
|
11
|
+
import { AbstractCommitmentsSnapshotService as o } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
|
|
12
|
+
class f extends o {
|
|
13
|
+
constructor(r, t) {
|
|
14
|
+
super(r, 0, !1, t);
|
|
10
15
|
}
|
|
11
16
|
async fetchSnapshot() {
|
|
12
|
-
const { chainId:
|
|
13
|
-
if (t.hinkalAddress !== this.contract.address || t.chainId !==
|
|
17
|
+
const { chainId: r } = await this.contract.provider.getNetwork(), t = await e(r);
|
|
18
|
+
if (t.hinkalAddress !== this.contract.address || t.chainId !== r)
|
|
14
19
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
15
20
|
return {
|
|
16
21
|
latestBlockNumber: t.latestBlockNumber,
|
|
@@ -18,10 +23,10 @@ class h extends r {
|
|
|
18
23
|
encryptedOutputs: t.encryptedOutputs
|
|
19
24
|
};
|
|
20
25
|
}
|
|
21
|
-
persistSnapshot(
|
|
26
|
+
persistSnapshot(r) {
|
|
22
27
|
return Promise.resolve();
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
export {
|
|
26
|
-
|
|
31
|
+
f as ClientCommitmentsSnapshotService
|
|
27
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const i=require("../../API/fetchNullifiers.cjs"),t=require("../event-service/AbstractNullifierSnapshotService.cjs");class s extends t.AbstractNullifierSnapshotService{constructor(e,r){super(e,0,!1,r)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),r=await i.fetchNullifiers(e);return{latestBlockNumber:r.latestBlockNumber,nullifiers:r.nullifiers}}persistSnapshot(e){return Promise.resolve()}}exports.ClientNullifierSnapshotService=s;
|
|
@@ -2,9 +2,14 @@ import "circomlibjs";
|
|
|
2
2
|
import "ethers";
|
|
3
3
|
import "../../constants/vite.constants.mjs";
|
|
4
4
|
import "../../constants/reorg-depths.constants.mjs";
|
|
5
|
-
import
|
|
5
|
+
import "axios";
|
|
6
|
+
import "../../constants/chains.constants.mjs";
|
|
7
|
+
import "../../types/circom-data.types.mjs";
|
|
8
|
+
import "../../types/transactions.types.mjs";
|
|
9
|
+
import "../../types/curve.types.mjs";
|
|
6
10
|
import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
|
|
7
|
-
|
|
11
|
+
import { AbstractNullifierSnapshotService as e } from "../event-service/AbstractNullifierSnapshotService.mjs";
|
|
12
|
+
class N extends e {
|
|
8
13
|
constructor(t, r) {
|
|
9
14
|
super(t, 0, !1, r);
|
|
10
15
|
}
|
|
@@ -20,5 +25,5 @@ class u extends e {
|
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
export {
|
|
23
|
-
|
|
28
|
+
N as ClientNullifierSnapshotService
|
|
24
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../constants/vite.constants.cjs"),r=(...o)=>{t.isNotClientProduction&&console.log(...o)};exports.logError=r;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
1
|
+
import { isNotClientProduction as r } from "../constants/vite.constants.mjs";
|
|
2
|
+
const i = (...o) => {
|
|
3
3
|
r && console.log(...o);
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
i as logError
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../webworker/performTaskWithWorker.cjs"),l=require("../../webworker/snarkjsWorker/snarkjsWorker.types.cjs"),c=require("../../webworker/worker.registry.cjs"),t=require("./getZKFiles.cjs"),y=async(e,r,o)=>{const a=t.getWASMFile(r,e),s=t.getZKeyFile(r,e),{publicSignals:n,zkCallData:i}=await k.performTaskWithWorker({type:c.WorkerVariant.SnarkJS,payload:{type:l.SnarkJSWorkerActionType.FULL_PROVE,data:{input:o,chainId:e,wasmFilePath:a,zKeyFilePath:s}}});return{zkCallData:i,publicSignals:n}};exports.generateZkProof=y;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { performTaskWithWorker as
|
|
2
|
-
import { SnarkJSWorkerActionType as
|
|
3
|
-
import { WorkerVariant as
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type: c.SnarkJS,
|
|
1
|
+
import { performTaskWithWorker as n } from "../../webworker/performTaskWithWorker.mjs";
|
|
2
|
+
import { SnarkJSWorkerActionType as l } from "../../webworker/snarkjsWorker/snarkjsWorker.types.mjs";
|
|
3
|
+
import { WorkerVariant as m } from "../../webworker/worker.registry.mjs";
|
|
4
|
+
import { getWASMFile as k, getZKeyFile as s } from "./getZKFiles.mjs";
|
|
5
|
+
const F = async (t, r, o) => {
|
|
6
|
+
const a = k(r, t), e = s(r, t), { publicSignals: p, zkCallData: i } = await n({
|
|
7
|
+
type: m.SnarkJS,
|
|
9
8
|
payload: {
|
|
10
|
-
type:
|
|
11
|
-
data: { input:
|
|
9
|
+
type: l.FULL_PROVE,
|
|
10
|
+
data: { input: o, chainId: t, wasmFilePath: a, zKeyFilePath: e }
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
return
|
|
13
|
+
return { zkCallData: i, publicSignals: p };
|
|
15
14
|
};
|
|
16
15
|
export {
|
|
17
|
-
|
|
16
|
+
F as generateZkProof
|
|
18
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>new Promise(t=>{setTimeout(t,e)});function c(e,t){let o;return function(...u){const i=()=>{clearTimeout(o),e(...u)};clearTimeout(o),o=setTimeout(i,t)}}exports.debounce=c;exports.wait=n;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const isOnServer: () => boolean;
|
|
2
|
-
export declare const isOnClient: () => boolean;
|
|
3
1
|
/** pause execution for a number of miliseconds */
|
|
4
2
|
export declare const wait: (miliseconds: number) => Promise<unknown>;
|
|
5
3
|
/** only call function once with a given number of milliseconds
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const c = (e) => new Promise((t) => {
|
|
2
2
|
setTimeout(t, e);
|
|
3
3
|
});
|
|
4
|
-
function
|
|
5
|
-
let
|
|
6
|
-
return function(...
|
|
7
|
-
const
|
|
8
|
-
clearTimeout(
|
|
4
|
+
function r(e, t) {
|
|
5
|
+
let o;
|
|
6
|
+
return function(...n) {
|
|
7
|
+
const u = () => {
|
|
8
|
+
clearTimeout(o), e(...n);
|
|
9
9
|
};
|
|
10
|
-
clearTimeout(
|
|
10
|
+
clearTimeout(o), o = setTimeout(u, t);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
|
-
|
|
15
|
-
s as isOnClient,
|
|
16
|
-
u as isOnServer,
|
|
14
|
+
r as debounce,
|
|
17
15
|
c as wait
|
|
18
16
|
};
|