h_test_1 0.0.29 → 0.0.30
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/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +36 -13
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +31 -39
- package/functions/utils/enum.utils.cjs +1 -0
- package/functions/utils/enum.utils.mjs +14 -0
- package/package.json +3 -13
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.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"});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../functions/utils/enum.utils.cjs");var t=(e=>(e.DEVELOPMENT="development",e.PLAYGROUND="playground",e.PRODUCTION="production",e.STAGING="staging",e))(t||{});const i={development:["localhost","192.","127."],playground:["playground"],staging:["working","staging"]},r=typeof process<"u"&&process?.release?.name==="node",u=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,y=!u&&typeof window<"u"&&window.origin==="null",f=typeof __webpack_require__<"u",m=typeof window<"u"&&window?.location?.protocol==="chrome-extension:";function s(e,n){return n.some(g=>e.includes(g))}const v=()=>(require("dotenv").config({path:"DOTENV_OVERRIDE"in process.env?process.env.DOTENV_OVERRIDE:void 0}),process.env.DEPLOYMENT_MODE?.startsWith("production")?"production":d.toEnumValue(t,process.env.DEPLOYMENT_MODE)||"development"),E=()=>{if(!r&&typeof window>"u")return;if(r)return v();if(window?.location?.protocol==="chrome-extension:"){const n=d.toEnumValue(t,WALLET_DEPLOYMENT_MODE);return n||"staging"}const e=window?.location?.host;return s(e,i.development)?"development":s(e,i.playground)?"playground":s(e,i.staging)?"staging":"production"},o=E(),c=o==="development",l=o==="playground",p=o==="staging",a=p||c||l,w=a||r&&o==="production";exports.DEPLOYMENT_MODE=t;exports.deploymentMode=o;exports.isDevelopment=c;exports.isExtension=m;exports.isNode=u;exports.isNotClientProduction=w;exports.isNotProduction=a;exports.isPlayground=l;exports.isSandbox=y;exports.isStaging=p;exports.isWebpack=f;
|
|
@@ -1,15 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { toEnumValue as d } from "../functions/utils/enum.utils.mjs";
|
|
2
|
+
var s = /* @__PURE__ */ ((n) => (n.DEVELOPMENT = "development", n.PLAYGROUND = "playground", n.PRODUCTION = "production", n.STAGING = "staging", n))(s || {});
|
|
3
|
+
const t = {
|
|
4
|
+
development: ["localhost", "192.", "127."],
|
|
5
|
+
playground: ["playground"],
|
|
6
|
+
staging: ["working", "staging"]
|
|
7
|
+
}, i = typeof process < "u" && process?.release?.name === "node", p = typeof process < "u" && process.versions != null && process.versions.node != null, v = !p && typeof window < "u" && window.origin === "null", w = typeof __webpack_require__ < "u", E = typeof window < "u" && window?.location?.protocol === "chrome-extension:";
|
|
8
|
+
function r(n, o) {
|
|
9
|
+
return o.some((c) => n.includes(c));
|
|
10
|
+
}
|
|
11
|
+
const u = () => (require("dotenv").config({
|
|
12
|
+
// allow overriding .env file path, see startServer.sh script for explenation on why it is needed
|
|
13
|
+
path: "DOTENV_OVERRIDE" in process.env ? process.env.DOTENV_OVERRIDE : void 0
|
|
14
|
+
}), process.env.DEPLOYMENT_MODE?.startsWith("production") ? "production" : d(s, process.env.DEPLOYMENT_MODE) || "development"), l = () => {
|
|
15
|
+
if (!i && typeof window > "u")
|
|
16
|
+
return;
|
|
17
|
+
if (i)
|
|
18
|
+
return u();
|
|
19
|
+
if (window?.location?.protocol === "chrome-extension:") {
|
|
20
|
+
const o = d(s, WALLET_DEPLOYMENT_MODE);
|
|
21
|
+
return o || "staging";
|
|
22
|
+
}
|
|
23
|
+
const n = window?.location?.host;
|
|
24
|
+
return r(n, t.development) ? "development" : r(n, t.playground) ? "playground" : r(n, t.staging) ? "staging" : "production";
|
|
25
|
+
}, e = l(), a = e === "development", g = e === "playground", f = e === "staging", m = f || a || g, D = m || i && e === "production";
|
|
3
26
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
s as DEPLOYMENT_MODE,
|
|
28
|
+
e as deploymentMode,
|
|
29
|
+
a as isDevelopment,
|
|
30
|
+
E as isExtension,
|
|
31
|
+
p as isNode,
|
|
32
|
+
D as isNotClientProduction,
|
|
33
|
+
m as isNotProduction,
|
|
34
|
+
g as isPlayground,
|
|
35
|
+
v as isSandbox,
|
|
36
|
+
f as isStaging,
|
|
37
|
+
w as isWebpack
|
|
15
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../error-handling/error-codes.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../error-handling/error-codes.constants.cjs"),U=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),E=require("../../functions/web3/events/getShieldedBalance.cjs"),R=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),L=require("../../functions/pre-transaction/getFeeStructure.cjs"),k=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),H=require("../../types/hinkal.types.cjs"),B=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),K=require("../../types/ethereum-network.types.cjs"),F=require("../../functions/pre-transaction/getKycAndSignatureData.cjs"),I=require("../../functions/pre-transaction/getExternalSwapAddress.cjs"),M=require("../../functions/utils/time.utils.cjs"),N=require("../../constants/protocol.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../constants/tokens.constants.cjs");require("../../constants/chains.constants.cjs");const W=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("tweetnacl");require("bs58");require("buffer");require("../crypto-keys/keys.cjs");require("libsodium-wrappers");require("lodash");const O=require("../../functions/utils/token-check.utils.cjs"),b=async(r,s,t,o)=>{const i=[...await E.addPaddingToUtxos(r,s,t,o)],c=[],n=H.defaultHinkalLogicArgs(o.length,r.userKeys),d=M.getCurrentTimeInSeconds().toString();for(let e=0;e<t.length;e+=1){const{outputUtxos:a}=U.outputUtxoProcessing(r.userKeys,i[e],o[e],d,void 0,!1);c.push(a);const{useApprovalUtxoData:u}=B.outputApprovalDataProcessing(r,s,i[e],o[e]);u&&(n.useApprovalUtxoData[e]=u,n.doPreTxApproval=!0)}return{inputUtxosArray:i,outputUtxosArray:c,hinkalLogicArgs:n}},G=async(r,s,t,o,i,c,n,d)=>{const e=O.validateAndGetChainId(s),a=s.map(f=>f.erc20TokenAddress),u=await r.getEthereumAddressByChain(e),l=n??await L.getFeeStructure(e,c,a,o,void 0,N.HINKAL_SWAP_VARIABLE_RATE);k.mergeWithFeeStructure(e,a,t,l);const A=I.getExternalSwapAddress(e,o),g={externalActionId:o,externalAddress:A,externalActionMetadata:i},[p,{patchAccessTokenMerkleTree:y,signatureData:x},{inputUtxosArray:q,outputUtxosArray:S,hinkalLogicArgs:h}]=await Promise.all([r.getRandomRelay(e,!0),F.getKycAndSignatureData(r,e,a,t,u),b(r,e,a,t)]);if(!p)throw Error(P.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const C=`swapperM${t.length.toString()}x${q[0].length}x1`,v=[!1,!0,!1].slice(0,t.length),{zkCallData:m,circomData:D,dimData:w}=await _.constructZkProof("v1x1",r.merkleTreeHinkalByChain[e],r.merkleTreeAccessTokenByChain[e],q,S,r.userKeys,C,g.externalActionId,g.externalAddress,g.externalActionMetadata,r.generateProofRemotely,p,e,v,void 0,void 0,y,h,void 0,l,r.getContractWithFetcher(e,K.ContractType.HinkalHelperContract),x),T=W.constructAdminData(d,e,a,t,u,s);return await R.transactCallRelayer(e,m,w,D,void 0,void 0,T)};exports.hinkalSwap=G;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { transactionErrorCodes as
|
|
1
|
+
import { transactionErrorCodes as E } from "../../error-handling/error-codes.constants.mjs";
|
|
2
2
|
import { outputUtxoProcessing as L } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
3
3
|
import { constructZkProof as P } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
4
|
import { addPaddingToUtxos as R } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
5
|
import { transactCallRelayer as H } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
6
|
-
import { getFeeStructure as
|
|
7
|
-
import { mergeWithFeeStructure as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { HINKAL_SWAP_VARIABLE_RATE as V } from "../../constants/protocol.constants.mjs";
|
|
6
|
+
import { getFeeStructure as B } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
7
|
+
import { mergeWithFeeStructure as I } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
8
|
+
import { defaultHinkalLogicArgs as K } from "../../types/hinkal.types.mjs";
|
|
9
|
+
import { outputApprovalDataProcessing as _ } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
10
|
+
import { ContractType as M } from "../../types/ethereum-network.types.mjs";
|
|
11
|
+
import { getKycAndSignatureData as F } from "../../functions/pre-transaction/getKycAndSignatureData.mjs";
|
|
12
|
+
import { getExternalSwapAddress as N } from "../../functions/pre-transaction/getExternalSwapAddress.mjs";
|
|
13
|
+
import { getCurrentTimeInSeconds as W } from "../../functions/utils/time.utils.mjs";
|
|
14
|
+
import { HINKAL_SWAP_VARIABLE_RATE as O } from "../../constants/protocol.constants.mjs";
|
|
16
15
|
import "../../types/circom-data.types.mjs";
|
|
17
16
|
import "../../types/activities.types.mjs";
|
|
18
17
|
import "../../constants/server.constants.mjs";
|
|
@@ -24,7 +23,7 @@ import "ethers";
|
|
|
24
23
|
import "../../constants/token-data/index.mjs";
|
|
25
24
|
import "../../constants/tokens.constants.mjs";
|
|
26
25
|
import "../../constants/chains.constants.mjs";
|
|
27
|
-
import { constructAdminData as
|
|
26
|
+
import { constructAdminData as V } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
28
27
|
import "@coral-xyz/anchor";
|
|
29
28
|
import "@solana/web3.js";
|
|
30
29
|
import "circomlibjs-hinkal-fork";
|
|
@@ -35,9 +34,9 @@ import "buffer";
|
|
|
35
34
|
import "../crypto-keys/keys.mjs";
|
|
36
35
|
import "libsodium-wrappers";
|
|
37
36
|
import "lodash";
|
|
38
|
-
import { validateAndGetChainId as
|
|
39
|
-
const
|
|
40
|
-
const s = [...await R(r, i, o, e)], n = [], p =
|
|
37
|
+
import { validateAndGetChainId as $ } from "../../functions/utils/token-check.utils.mjs";
|
|
38
|
+
const k = async (r, i, o, e) => {
|
|
39
|
+
const s = [...await R(r, i, o, e)], n = [], p = K(e.length, r.userKeys), c = W().toString();
|
|
41
40
|
for (let t = 0; t < o.length; t += 1) {
|
|
42
41
|
const { outputUtxos: a } = L(
|
|
43
42
|
r.userKeys,
|
|
@@ -48,36 +47,29 @@ const z = async (r, i, o, e) => {
|
|
|
48
47
|
!1
|
|
49
48
|
);
|
|
50
49
|
n.push(a);
|
|
51
|
-
const { useApprovalUtxoData: m } =
|
|
50
|
+
const { useApprovalUtxoData: m } = _(r, i, s[t], e[t]);
|
|
52
51
|
m && (p.useApprovalUtxoData[t] = m, p.doPreTxApproval = !0);
|
|
53
52
|
}
|
|
54
53
|
return { inputUtxosArray: s, outputUtxosArray: n, hinkalLogicArgs: p };
|
|
55
|
-
},
|
|
56
|
-
const t =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
a,
|
|
60
|
-
K.Transact,
|
|
61
|
-
void 0,
|
|
62
|
-
V
|
|
63
|
-
);
|
|
64
|
-
B(t, a, o, d);
|
|
65
|
-
const f = W(t, e), u = {
|
|
54
|
+
}, Lt = async (r, i, o, e, s, n, p, c) => {
|
|
55
|
+
const t = $(i), a = i.map((U) => U.erc20TokenAddress), m = await r.getEthereumAddressByChain(t), d = p ?? await B(t, n, a, e, void 0, O);
|
|
56
|
+
I(t, a, o, d);
|
|
57
|
+
const A = N(t, e), u = {
|
|
66
58
|
externalActionId: e,
|
|
67
|
-
externalAddress:
|
|
59
|
+
externalAddress: A,
|
|
68
60
|
externalActionMetadata: s
|
|
69
|
-
}, [g, { patchAccessTokenMerkleTree: l, signatureData: x }, { inputUtxosArray:
|
|
61
|
+
}, [g, { patchAccessTokenMerkleTree: l, signatureData: x }, { inputUtxosArray: f, outputUtxosArray: y, hinkalLogicArgs: v }] = await Promise.all([
|
|
70
62
|
r.getRandomRelay(t, !0),
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
F(r, t, a, o, m),
|
|
64
|
+
k(r, t, a, o)
|
|
73
65
|
]);
|
|
74
66
|
if (!g)
|
|
75
|
-
throw Error(
|
|
76
|
-
const C = `swapperM${o.length.toString()}x${
|
|
67
|
+
throw Error(E.RELAYER_NOT_AVAILABLE);
|
|
68
|
+
const C = `swapperM${o.length.toString()}x${f[0].length}x1`, h = [!1, !0, !1].slice(0, o.length), { zkCallData: T, circomData: D, dimData: S } = await P(
|
|
77
69
|
"v1x1",
|
|
78
70
|
r.merkleTreeHinkalByChain[t],
|
|
79
71
|
r.merkleTreeAccessTokenByChain[t],
|
|
80
|
-
|
|
72
|
+
f,
|
|
81
73
|
y,
|
|
82
74
|
r.userKeys,
|
|
83
75
|
C,
|
|
@@ -87,18 +79,18 @@ const z = async (r, i, o, e) => {
|
|
|
87
79
|
r.generateProofRemotely,
|
|
88
80
|
g,
|
|
89
81
|
t,
|
|
90
|
-
|
|
82
|
+
h,
|
|
91
83
|
void 0,
|
|
92
84
|
void 0,
|
|
93
85
|
l,
|
|
94
86
|
v,
|
|
95
87
|
void 0,
|
|
96
88
|
d,
|
|
97
|
-
r.getContractWithFetcher(t,
|
|
89
|
+
r.getContractWithFetcher(t, M.HinkalHelperContract),
|
|
98
90
|
x
|
|
99
|
-
), w =
|
|
100
|
-
return await H(t,
|
|
91
|
+
), w = V(c, t, a, o, m, i);
|
|
92
|
+
return await H(t, T, S, D, void 0, void 0, w);
|
|
101
93
|
};
|
|
102
94
|
export {
|
|
103
|
-
|
|
95
|
+
Lt as hinkalSwap
|
|
104
96
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e,n){return Object.values(e).includes(n)}function u(e,n,t=!1){if(r(e,n))return n;const i=`Value ${JSON.stringify(n)} is not a valid member of enum ${JSON.stringify(e)}.`;if(t)throw new Error(i)}exports.isInEnum=r;exports.toEnumValue=u;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function e(r, n) {
|
|
2
|
+
return Object.values(r).includes(n);
|
|
3
|
+
}
|
|
4
|
+
function o(r, n, i = !1) {
|
|
5
|
+
if (e(r, n))
|
|
6
|
+
return n;
|
|
7
|
+
const t = `Value ${JSON.stringify(n)} is not a valid member of enum ${JSON.stringify(r)}.`;
|
|
8
|
+
if (i)
|
|
9
|
+
throw new Error(t);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
e as isInEnum,
|
|
13
|
+
o as toEnumValue
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h_test_1",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"homepage": "hinkal.io",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hinkal Protocol"
|
|
@@ -36,22 +36,12 @@
|
|
|
36
36
|
"types": "./providers/prepareWagmiHinkal.d.ts",
|
|
37
37
|
"import": "./providers/prepareWagmiHinkal.mjs",
|
|
38
38
|
"default": "./providers/prepareWagmiHinkal.cjs"
|
|
39
|
-
},
|
|
40
|
-
"./providers/SolanaProviderAdapter": {
|
|
41
|
-
"types": "./providers/SolanaProviderAdapter.d.ts",
|
|
42
|
-
"import": "./providers/SolanaProviderAdapter.mjs",
|
|
43
|
-
"default": "./providers/SolanaProviderAdapter.cjs"
|
|
44
|
-
},
|
|
45
|
-
"./providers/TronProviderAdapter": {
|
|
46
|
-
"types": "./providers/TronProviderAdapter.d.ts",
|
|
47
|
-
"import": "./providers/TronProviderAdapter.mjs",
|
|
48
|
-
"default": "./providers/TronProviderAdapter.cjs"
|
|
49
39
|
}
|
|
50
40
|
},
|
|
51
41
|
"types": "./index.d.ts",
|
|
52
42
|
"scripts": {
|
|
53
|
-
"prebuild": "
|
|
54
|
-
"build": "
|
|
43
|
+
"prebuild": "nx prebuild:workers",
|
|
44
|
+
"build": "nx build",
|
|
55
45
|
"lint": "nx lint",
|
|
56
46
|
"test": "nx test"
|
|
57
47
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-B6wGkEBo.js").href:new URL("../../assets/snarkjsWorkerLauncher-B6wGkEBo.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-CFkGjOsh.js").href:new URL("../../assets/utxoWorkerLauncher-CFkGjOsh.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-BgtIIi8u.js").href:new URL("../../assets/zkProofWorkerLauncher-BgtIIi8u.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|