@sabaaa1/common 0.1.5 → 0.1.7

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("ethers-v6h"),g=require("../../private-wallet/emporium.helpers.cjs"),i=require("../../../constants/chains.constants.cjs"),m=async(r,t,c,s,n)=>{const{hinkalAddress:h,hinkalABI:u}=i.networkRegistry[r.getCurrentChainId()].contractData,d=new a.ethers.JsonRpcProvider(i.networkRegistry[r.getCurrentChainId()].fetchRpcUrl),l=new a.ethers.Contract(h,u,d),y="transact";let e={from:s.relay};if(n){const o=g.recoverAuthorizationData(n);o&&(e={...e,authorizationList:[o],type:4})}return await l[y].estimateGas(t[0],t[1],t[2],c,s,e)};exports.estimateGasRelayer=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("ethers-v6h"),g=require("../../private-wallet/emporium.helpers.cjs"),i=require("../../../constants/chains.constants.cjs"),l=async(e,t,c,r,n)=>{const{hinkalAddress:d,hinkalABI:u}=i.networkRegistry[e.getCurrentChainId()].contractData,h=new a.ethers.JsonRpcProvider(i.networkRegistry[e.getCurrentChainId()].fetchRpcUrl),m=new a.ethers.Contract(d,u,h),y="transact";let s={from:r.relay==="0x0000000000000000000000000000000000000000"?await e.getEthereumAddress():r.relay};if(n){const o=g.recoverAuthorizationData(n);o&&(s={...s,authorizationList:[o],type:4})}return await m[y].estimateGas(t[0],t[1],t[2],c,r,s)};exports.estimateGasRelayer=l;
@@ -1,20 +1,20 @@
1
1
  import { ethers as a } from "ethers-v6h";
2
2
  import { recoverAuthorizationData as u } from "../../private-wallet/emporium.helpers.mjs";
3
3
  import { networkRegistry as i } from "../../../constants/chains.constants.mjs";
4
- const C = async (e, t, c, o, s) => {
5
- const { hinkalAddress: m, hinkalABI: h } = i[e.getCurrentChainId()].contractData, p = new a.JsonRpcProvider(i[e.getCurrentChainId()].fetchRpcUrl), d = new a.Contract(m, h, p), f = "transact";
6
- let r = { from: o.relay };
7
- if (s) {
8
- const n = u(s);
9
- n && (r = { ...r, authorizationList: [n], type: 4 });
4
+ const C = async (t, r, c, e, o) => {
5
+ const { hinkalAddress: d, hinkalABI: m } = i[t.getCurrentChainId()].contractData, f = new a.JsonRpcProvider(i[t.getCurrentChainId()].fetchRpcUrl), h = new a.Contract(d, m, f), p = "transact";
6
+ let s = { from: e.relay === "0x0000000000000000000000000000000000000000" ? await t.getEthereumAddress() : e.relay };
7
+ if (o) {
8
+ const n = u(o);
9
+ n && (s = { ...s, authorizationList: [n], type: 4 });
10
10
  }
11
- return await d[f].estimateGas(
12
- t[0],
13
- t[1],
14
- t[2],
11
+ return await h[p].estimateGas(
12
+ r[0],
13
+ r[1],
14
+ r[2],
15
15
  c,
16
- o,
17
- r
16
+ e,
17
+ s
18
18
  );
19
19
  };
20
20
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaaa1/common",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "homepage": "hinkal.pro",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-Dsmwcy9L.js").href:new URL("../../assets/snarkjsWorkerLauncher-Dsmwcy9L.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-CWaDqRaL.js").href:new URL("../../assets/snarkjsWorkerLauncher-CWaDqRaL.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/snarkjsWorkerLauncher-Dsmwcy9L.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/snarkjsWorkerLauncher-CWaDqRaL.js", import.meta.url).href;
2
2
  export {
3
3
  r as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-B330tmvt.js").href:new URL("../../assets/utxoWorkerLauncher-B330tmvt.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-BUhBaUSg.js").href:new URL("../../assets/utxoWorkerLauncher-BUhBaUSg.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const t = "" + new URL("../../assets/utxoWorkerLauncher-B330tmvt.js", import.meta.url).href;
1
+ const e = "" + new URL("../../assets/utxoWorkerLauncher-BUhBaUSg.js", import.meta.url).href;
2
2
  export {
3
- t as default
3
+ e as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("buffer"),T=require("process"),k=require("../../crypto/preProcessing.cjs"),c=require("../../data-structures/crypto-keys/keys.cjs"),v=require("../../data-structures/utxo/Utxo.cjs"),p=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),f=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),w=require("../workerProxy.cjs"),d=require("./utxoWorker.types.cjs");globalThis.process=T;globalThis.Buffer=h.Buffer;const i=new w.WorkerProxy,g=async({data:e})=>{const{utxos:r,nullifiers:s}=e,o=r.filter(t=>{const l=new v.Utxo(t);return!s.has(l.getNullifier())});i.postMessageToMainThread({utxoConstructors:o,stealthPairCache:c.stealthPairCacheDevice.serialize(),stealthAddressCache:c.stealthAddressCacheDevice.serialize()})},U=async({data:e})=>{const r=new c.UserKeys(e.signature),s=r.getShieldedPrivateKey(),o=e.encryptedOutputs.map(t=>{try{return t.isPositive?p.decryptUtxoConstructorArgs(h.Buffer.from(t.value.slice(2),"hex"),r):f.decodeUtxoConstructorArgs(t.value,s)}catch{return}}).filter(t=>t!==void 0&&t.amount!==0n);i.postMessageToMainThread(o)},x=async({data:e})=>{const r=new c.UserKeys(e.signature),s=[],{encryptedOutputs:o}=e;let{lastOutput:t}=e;const l=r.getShieldedPrivateKey();for(let u=0;u<o.length;u+=1){const a=o[u];if(t=a.value,a.isPositive)try{const n=p.decryptUtxo(h.Buffer.from(t.slice(2),"hex"),r);if(!n.erc20TokenAddress||!n.amount||!n.stealthAddress)throw Error("bruh");s.push(a)}catch{}else try{f.checkUtxoSignature(t,l)&&s.push(a)}catch{}}i.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:t})},y=async e=>{try{await k.preProcessing();const{type:r}=e.payload;switch(r){case d.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:await g(e.payload);return;case d.UtxoWorkerActionType.BUILD_UTXOS:await U(e.payload);return;case d.UtxoWorkerActionType.DECIPHER_OUTPUTS:await x(e.payload);return;default:throw Error(`Unknown worker message type ${r}`)}}catch(r){console.error(r),i.postErrorToMainThread(r)}};self.addEventListener("message",async e=>{await y(e.data)});self.addEventListener("error",e=>{console.error("Worker error:",e)});self.addEventListener("unhandledrejection",e=>{console.error("Worker unhandled rejection:",e.reason)});i.attachWorkerSideOnMessage(y);exports.default=i;exports.handleBuildUtxosMessage=U;exports.handleDecipherMessage=x;exports.handleFilterUtxosWithNullifier=g;exports.onWorkerMessage=y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../../crypto/preProcessing.cjs"),a=require("../../data-structures/crypto-keys/keys.cjs"),T=require("../../data-structures/utxo/Utxo.cjs"),h=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),y=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),k=require("../workerProxy.cjs"),d=require("./utxoWorker.types.cjs"),c=new k.WorkerProxy,p=async({data:e})=>{const{utxos:r,nullifiers:s}=e,o=r.filter(t=>{const u=new T.Utxo(t);return!s.has(u.getNullifier())});c.postMessageToMainThread({utxoConstructors:o,stealthPairCache:a.stealthPairCacheDevice.serialize(),stealthAddressCache:a.stealthAddressCacheDevice.serialize()})},U=async({data:e})=>{const r=new a.UserKeys(e.signature),s=r.getShieldedPrivateKey(),o=e.encryptedOutputs.map(t=>{try{return t.isPositive?h.decryptUtxoConstructorArgs(Buffer.from(t.value.slice(2),"hex"),r):y.decodeUtxoConstructorArgs(t.value,s)}catch{return}}).filter(t=>t!==void 0&&t.amount!==0n);c.postMessageToMainThread(o)},x=async({data:e})=>{const r=new a.UserKeys(e.signature),s=[],{encryptedOutputs:o}=e;let{lastOutput:t}=e;const u=r.getShieldedPrivateKey();for(let l=0;l<o.length;l+=1){const n=o[l];if(t=n.value,n.isPositive)try{const i=h.decryptUtxo(Buffer.from(t.slice(2),"hex"),r);if(!i.erc20TokenAddress||!i.amount||!i.stealthAddress)throw Error("bruh");s.push(n)}catch{}else try{y.checkUtxoSignature(t,u)&&s.push(n)}catch{}}c.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:t})},g=async e=>{try{await f.preProcessing();const{type:r}=e.payload;switch(r){case d.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:await p(e.payload);return;case d.UtxoWorkerActionType.BUILD_UTXOS:await U(e.payload);return;case d.UtxoWorkerActionType.DECIPHER_OUTPUTS:await x(e.payload);return;default:throw Error(`Unknown worker message type ${r}`)}}catch(r){console.error(r),c.postErrorToMainThread(r)}};c.attachWorkerSideOnMessage(g);exports.default=c;exports.handleBuildUtxosMessage=U;exports.handleDecipherMessage=x;exports.handleFilterUtxosWithNullifier=p;exports.onWorkerMessage=g;
@@ -1,89 +1,76 @@
1
- import { Buffer as h } from "buffer";
2
- import f from "process";
3
- import { preProcessing as y } from "../../crypto/preProcessing.mjs";
4
- import { stealthPairCacheDevice as m, stealthAddressCacheDevice as g, UserKeys as u } from "../../data-structures/crypto-keys/keys.mjs";
5
- import { Utxo as T } from "../../data-structures/utxo/Utxo.mjs";
6
- import { decryptUtxoConstructorArgs as x, decryptUtxo as U } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
7
- import { decodeUtxoConstructorArgs as v, checkUtxoSignature as w } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
8
- import { WorkerProxy as k } from "../workerProxy.mjs";
1
+ import { preProcessing as u } from "../../crypto/preProcessing.mjs";
2
+ import { stealthPairCacheDevice as p, stealthAddressCacheDevice as y, UserKeys as h } from "../../data-structures/crypto-keys/keys.mjs";
3
+ import { Utxo as f } from "../../data-structures/utxo/Utxo.mjs";
4
+ import { decryptUtxoConstructorArgs as m, decryptUtxo as g } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
5
+ import { decodeUtxoConstructorArgs as x, checkUtxoSignature as U } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
6
+ import { WorkerProxy as T } from "../workerProxy.mjs";
9
7
  import { UtxoWorkerActionType as d } from "./utxoWorker.types.mjs";
10
- globalThis.process = f;
11
- globalThis.Buffer = h;
12
- const n = new k(), P = async ({ data: e }) => {
13
- const { utxos: r, nullifiers: o } = e, s = r.filter((t) => {
14
- const c = new T(t);
15
- return !o.has(c.getNullifier());
8
+ const i = new T(), w = async ({ data: e }) => {
9
+ const { utxos: r, nullifiers: s } = e, o = r.filter((t) => {
10
+ const n = new f(t);
11
+ return !s.has(n.getNullifier());
16
12
  });
17
- n.postMessageToMainThread({
18
- utxoConstructors: s,
19
- stealthPairCache: m.serialize(),
20
- stealthAddressCache: g.serialize()
13
+ i.postMessageToMainThread({
14
+ utxoConstructors: o,
15
+ stealthPairCache: p.serialize(),
16
+ stealthAddressCache: y.serialize()
21
17
  });
22
- }, E = async ({ data: e }) => {
23
- const r = new u(e.signature), o = r.getShieldedPrivateKey(), s = e.encryptedOutputs.map((t) => {
18
+ }, P = async ({ data: e }) => {
19
+ const r = new h(e.signature), s = r.getShieldedPrivateKey(), o = e.encryptedOutputs.map((t) => {
24
20
  try {
25
- return t.isPositive ? x(h.from(t.value.slice(2), "hex"), r) : v(t.value, o);
21
+ return t.isPositive ? m(Buffer.from(t.value.slice(2), "hex"), r) : x(t.value, s);
26
22
  } catch {
27
23
  return;
28
24
  }
29
25
  }).filter((t) => t !== void 0 && t.amount !== 0n);
30
- n.postMessageToMainThread(s);
31
- }, M = async ({ data: e }) => {
32
- const r = new u(e.signature), o = [], { encryptedOutputs: s } = e;
26
+ i.postMessageToMainThread(o);
27
+ }, v = async ({ data: e }) => {
28
+ const r = new h(e.signature), s = [], { encryptedOutputs: o } = e;
33
29
  let { lastOutput: t } = e;
34
- const c = r.getShieldedPrivateKey();
35
- for (let l = 0; l < s.length; l += 1) {
36
- const i = s[l];
37
- if (t = i.value, i.isPositive)
30
+ const n = r.getShieldedPrivateKey();
31
+ for (let l = 0; l < o.length; l += 1) {
32
+ const c = o[l];
33
+ if (t = c.value, c.isPositive)
38
34
  try {
39
- const a = U(h.from(t.slice(2), "hex"), r);
35
+ const a = g(Buffer.from(t.slice(2), "hex"), r);
40
36
  if (!a.erc20TokenAddress || !a.amount || !a.stealthAddress)
41
37
  throw Error("bruh");
42
- o.push(i);
38
+ s.push(c);
43
39
  } catch {
44
40
  }
45
41
  else
46
42
  try {
47
- w(t, c) && o.push(i);
43
+ U(t, n) && s.push(c);
48
44
  } catch {
49
45
  }
50
46
  }
51
- n.postMessageToMainThread({ additionalEncryptedOutputs: o, lastOutput: t });
52
- }, p = async (e) => {
47
+ i.postMessageToMainThread({ additionalEncryptedOutputs: s, lastOutput: t });
48
+ }, k = async (e) => {
53
49
  try {
54
- await y();
50
+ await u();
55
51
  const { type: r } = e.payload;
56
52
  switch (r) {
57
53
  case d.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
58
- await P(e.payload);
54
+ await w(e.payload);
59
55
  return;
60
56
  case d.BUILD_UTXOS:
61
- await E(e.payload);
57
+ await P(e.payload);
62
58
  return;
63
59
  case d.DECIPHER_OUTPUTS:
64
- await M(e.payload);
60
+ await v(e.payload);
65
61
  return;
66
62
  default:
67
63
  throw Error(`Unknown worker message type ${r}`);
68
64
  }
69
65
  } catch (r) {
70
- console.error(r), n.postErrorToMainThread(r);
66
+ console.error(r), i.postErrorToMainThread(r);
71
67
  }
72
68
  };
73
- self.addEventListener("message", async (e) => {
74
- await p(e.data);
75
- });
76
- self.addEventListener("error", (e) => {
77
- console.error("Worker error:", e);
78
- });
79
- self.addEventListener("unhandledrejection", (e) => {
80
- console.error("Worker unhandled rejection:", e.reason);
81
- });
82
- n.attachWorkerSideOnMessage(p);
69
+ i.attachWorkerSideOnMessage(k);
83
70
  export {
84
- n as default,
85
- E as handleBuildUtxosMessage,
86
- M as handleDecipherMessage,
87
- P as handleFilterUtxosWithNullifier,
88
- p as onWorkerMessage
71
+ i as default,
72
+ P as handleBuildUtxosMessage,
73
+ v as handleDecipherMessage,
74
+ w as handleFilterUtxosWithNullifier,
75
+ k as onWorkerMessage
89
76
  };
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-CoKmCKjC.js").href:new URL("../../assets/zkProofWorkerLauncher-CoKmCKjC.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-DlWQP3l9.js").href:new URL("../../assets/zkProofWorkerLauncher-DlWQP3l9.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/zkProofWorkerLauncher-CoKmCKjC.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/zkProofWorkerLauncher-DlWQP3l9.js", import.meta.url).href;
2
2
  export {
3
3
  r as default
4
4
  };