@hinkal/common 0.1.31 → 0.1.33
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/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +4 -4
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +18 -44
- package/crypto/babyJub.cjs +1 -1
- package/crypto/babyJub.mjs +4 -4
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +12 -12
- package/crypto/preProcessing.cjs +1 -1
- package/crypto/preProcessing.mjs +5 -7
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +3 -6
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -11
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +9 -8
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.mjs +7 -6
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +6 -9
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -14
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +3 -6
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +1 -1
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +2 -0
- package/error-handling/error-codes.constants.mjs +2 -0
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +5 -8
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +10 -13
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +12 -14
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +22 -24
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/process.utils.cjs +1 -1
- package/functions/utils/process.utils.mjs +16 -2
- package/functions/utils/resolve-sync.utils.cjs +1 -1
- package/functions/utils/resolve-sync.utils.d.ts +0 -1
- package/functions/utils/resolve-sync.utils.mjs +3 -12
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +2 -2
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +11 -14
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -10
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +19 -22
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +3 -6
- package/index.cjs +1 -1
- package/index.mjs +281 -277
- package/package.json +2 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +5 -4
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +5 -4
- 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
|
@@ -2247,14 +2247,6 @@ const e = [
|
|
|
2247
2247
|
decimals: 18,
|
|
2248
2248
|
logoURI: "https://assets.coingecko.com/coins/images/38272/standard/USD0LOGO.png?1716962811"
|
|
2249
2249
|
},
|
|
2250
|
-
{
|
|
2251
|
-
chainId: 1,
|
|
2252
|
-
erc20TokenAddress: "0x112a9fCB37cEcbc0682CF76bb00B58651C9C2400",
|
|
2253
|
-
name: "moo hETH/ETH",
|
|
2254
|
-
symbol: "moohETHETH",
|
|
2255
|
-
decimals: 18,
|
|
2256
|
-
logoURI: "https://assets.coingecko.com/coins/images/12704/small/token.png?1601876182"
|
|
2257
|
-
},
|
|
2258
2250
|
{
|
|
2259
2251
|
chainId: 1,
|
|
2260
2252
|
erc20TokenAddress: "0x8A3d8C82aE3d6020Fc789C5abb84b955831B0B0B",
|
|
@@ -2266,7 +2258,7 @@ const e = [
|
|
|
2266
2258
|
},
|
|
2267
2259
|
{
|
|
2268
2260
|
chainId: 1,
|
|
2269
|
-
erc20TokenAddress: "
|
|
2261
|
+
erc20TokenAddress: "0xb206e26D8E62bd0D451291cea0a2fa751b6B3a5e",
|
|
2270
2262
|
underlyingErc20TokenAddress: "0x689440f2Ff927E1f24c72F1087E1FAF471eCe1c8",
|
|
2271
2263
|
name: "Convex crv3Pool",
|
|
2272
2264
|
symbol: "cvxcrv3Pool",
|
|
@@ -2284,7 +2276,7 @@ const e = [
|
|
|
2284
2276
|
},
|
|
2285
2277
|
{
|
|
2286
2278
|
chainId: 1,
|
|
2287
|
-
erc20TokenAddress: "
|
|
2279
|
+
erc20TokenAddress: "0x413Ce3439352A3Ee335e5c9D22aBCCbdFE4c8964",
|
|
2288
2280
|
underlyingErc20TokenAddress: "0x7e880867363A7e321f5d260Cade2B0Bb2F717B02",
|
|
2289
2281
|
name: "Convex fraxUSDC",
|
|
2290
2282
|
symbol: "cvxfraxUSDC",
|
|
@@ -2302,7 +2294,7 @@ const e = [
|
|
|
2302
2294
|
},
|
|
2303
2295
|
{
|
|
2304
2296
|
chainId: 1,
|
|
2305
|
-
erc20TokenAddress: "
|
|
2297
|
+
erc20TokenAddress: "0x4BFc996F947f7125632A4DAD609242D3f2a43288",
|
|
2306
2298
|
underlyingErc20TokenAddress: "0xbD5445402B0a287cbC77cb67B2a52e2FC635dce4",
|
|
2307
2299
|
name: "Convex frxETHCRV",
|
|
2308
2300
|
symbol: "cvxfrxETHCRV",
|
|
@@ -2320,7 +2312,7 @@ const e = [
|
|
|
2320
2312
|
},
|
|
2321
2313
|
{
|
|
2322
2314
|
chainId: 1,
|
|
2323
|
-
erc20TokenAddress: "
|
|
2315
|
+
erc20TokenAddress: "0x08F16CeC7831fe7D0d84bEcc4c0205a4587B8483",
|
|
2324
2316
|
underlyingErc20TokenAddress: "0x6991C1CD588c4e6f6f1de3A0bac5B8BbAb7aAF6d",
|
|
2325
2317
|
name: "Convex crvfraxUSDP",
|
|
2326
2318
|
symbol: "cvxcrvfraxUSDP",
|
|
@@ -2338,7 +2330,7 @@ const e = [
|
|
|
2338
2330
|
},
|
|
2339
2331
|
{
|
|
2340
2332
|
chainId: 1,
|
|
2341
|
-
erc20TokenAddress: "
|
|
2333
|
+
erc20TokenAddress: "0x5AA22a6bFbf0754A8bf5129EEcAe16Db4fd95365",
|
|
2342
2334
|
underlyingErc20TokenAddress: "0x9D5C5E364D81DaB193b72db9E9BE9D8ee669B652",
|
|
2343
2335
|
name: "Convex crv3crypto",
|
|
2344
2336
|
symbol: "cvxcrv3crypto",
|
|
@@ -2365,7 +2357,7 @@ const e = [
|
|
|
2365
2357
|
},
|
|
2366
2358
|
{
|
|
2367
2359
|
chainId: 1,
|
|
2368
|
-
erc20TokenAddress: "
|
|
2360
|
+
erc20TokenAddress: "0xe5b4C9Cab1848ce2EA3F888b189194D42b6fa3C4",
|
|
2369
2361
|
underlyingErc20TokenAddress: "0xC94208D230EEdC4cDC4F80141E21aA485A515660",
|
|
2370
2362
|
name: "Convex crvUsdDola",
|
|
2371
2363
|
symbol: "cvxcrvUsdDola",
|
|
@@ -2383,7 +2375,7 @@ const e = [
|
|
|
2383
2375
|
},
|
|
2384
2376
|
{
|
|
2385
2377
|
chainId: 1,
|
|
2386
|
-
erc20TokenAddress: "
|
|
2378
|
+
erc20TokenAddress: "0xE7405B9A5b5F8CBF54151EeB02dB0eC6D76E21dD",
|
|
2387
2379
|
underlyingErc20TokenAddress: "0x245Ec0d447e7f206B43120Ac292dED5E8bB9fe61",
|
|
2388
2380
|
name: "Convex hyUsdEusd",
|
|
2389
2381
|
symbol: "cvxhyUsdEusd",
|
|
@@ -2401,7 +2393,7 @@ const e = [
|
|
|
2401
2393
|
},
|
|
2402
2394
|
{
|
|
2403
2395
|
chainId: 1,
|
|
2404
|
-
erc20TokenAddress: "
|
|
2396
|
+
erc20TokenAddress: "0x0E9D45a38aD4677c1beEBf4de2c2FceA03DBD0A2",
|
|
2405
2397
|
underlyingErc20TokenAddress: "0x0404d05F3992347d2f0dC3a97bdd147D77C85c1c",
|
|
2406
2398
|
name: "Convex DolaFraxBp",
|
|
2407
2399
|
symbol: "cvxDolaFraxBp",
|
|
@@ -2419,7 +2411,7 @@ const e = [
|
|
|
2419
2411
|
},
|
|
2420
2412
|
{
|
|
2421
2413
|
chainId: 1,
|
|
2422
|
-
erc20TokenAddress: "
|
|
2414
|
+
erc20TokenAddress: "0xeFC7DCB1581AB6884433E9141d4a2B17B6B8b40E",
|
|
2423
2415
|
underlyingErc20TokenAddress: "0xB468dB2E478885B87D7ce0C8DA1D4373A756C138",
|
|
2424
2416
|
name: "Convex EusdFraxBp",
|
|
2425
2417
|
symbol: "cvxEusdFraxBp",
|
|
@@ -2429,24 +2421,6 @@ const e = [
|
|
|
2429
2421
|
{
|
|
2430
2422
|
chainId: 1,
|
|
2431
2423
|
erc20TokenAddress: "0xB727896fB707D3b3a59648A9fDF452cd4f65B90E",
|
|
2432
|
-
underlyingErc20TokenAddress: "0xc548f3ab7bd06fbd968b83f3b197372e641deae3",
|
|
2433
|
-
name: "hETHWETH Gauge",
|
|
2434
|
-
symbol: "hETHWETH-gauge",
|
|
2435
|
-
decimals: 18,
|
|
2436
|
-
logoURI: "https://assets.coingecko.com/coins/images/12124/small/Curve.png?1597369484"
|
|
2437
|
-
},
|
|
2438
|
-
{
|
|
2439
|
-
chainId: 1,
|
|
2440
|
-
erc20TokenAddress: "0x9cE850cb37f0Ffbfe501E61Ec3ac1cb1041bD392",
|
|
2441
|
-
underlyingErc20TokenAddress: "0x9AB157bfaD66De1aE0eFf4802895dD9C8B755e25",
|
|
2442
|
-
name: "Convex hETHWETH",
|
|
2443
|
-
symbol: "cvxhETHWETH",
|
|
2444
|
-
decimals: 18,
|
|
2445
|
-
logoURI: "https://assets.coingecko.com/coins/images/12124/small/Curve.png?1597369484"
|
|
2446
|
-
},
|
|
2447
|
-
{
|
|
2448
|
-
chainId: 1,
|
|
2449
|
-
erc20TokenAddress: "0xb465202Ebb1B713B022612FeFd5012956ada1d03",
|
|
2450
2424
|
underlyingErc20TokenAddress: "0x277d1424a84b35ec0a8108482551b00b4fc1539b",
|
|
2451
2425
|
name: "pxETH-frxETH Gauge",
|
|
2452
2426
|
symbol: "pxETH-frxETH-gauge",
|
|
@@ -2455,7 +2429,7 @@ const e = [
|
|
|
2455
2429
|
},
|
|
2456
2430
|
{
|
|
2457
2431
|
chainId: 1,
|
|
2458
|
-
erc20TokenAddress: "
|
|
2432
|
+
erc20TokenAddress: "0xb465202Ebb1B713B022612FeFd5012956ada1d03",
|
|
2459
2433
|
underlyingErc20TokenAddress: "0xc2fe9d3c761994897594df63b33b6d843ab7b1cf",
|
|
2460
2434
|
name: "FRAX-FXB_2_DEC312024 Gauge",
|
|
2461
2435
|
symbol: "FRAX-FXB_2_DEC312024-gauge",
|
|
@@ -2464,7 +2438,7 @@ const e = [
|
|
|
2464
2438
|
},
|
|
2465
2439
|
{
|
|
2466
2440
|
chainId: 1,
|
|
2467
|
-
erc20TokenAddress: "
|
|
2441
|
+
erc20TokenAddress: "0x3ebff4122a8bAa95f13Fe97F7F260015BB09018F",
|
|
2468
2442
|
underlyingErc20TokenAddress: "0x0e83df148f69965bfe752250835854b0dbeeaf01",
|
|
2469
2443
|
name: "FRAX-FXB_4_DEC312026 Gauge",
|
|
2470
2444
|
symbol: "FRAX-FXB_4_DEC312026-gauge",
|
|
@@ -2473,7 +2447,7 @@ const e = [
|
|
|
2473
2447
|
},
|
|
2474
2448
|
{
|
|
2475
2449
|
chainId: 1,
|
|
2476
|
-
erc20TokenAddress: "
|
|
2450
|
+
erc20TokenAddress: "0xAC8f80Ae7Aea19eA9D000b95D2D63bFCFdB9E3B3",
|
|
2477
2451
|
underlyingErc20TokenAddress: "0x35ad1acf0c4be5d4ba11342128d440fdb9e189eb",
|
|
2478
2452
|
name: "FRAX-FXB_1_JUN302024 Gauge",
|
|
2479
2453
|
symbol: "FRAX-FXB_1_JUN302024-gauge",
|
|
@@ -2482,7 +2456,7 @@ const e = [
|
|
|
2482
2456
|
},
|
|
2483
2457
|
{
|
|
2484
2458
|
chainId: 1,
|
|
2485
|
-
erc20TokenAddress: "
|
|
2459
|
+
erc20TokenAddress: "0x2751ed9D2F6c75066c7879c40743CA75587ecC17",
|
|
2486
2460
|
underlyingErc20TokenAddress: "0xe2c422d954db416a69fb29137fe552cce0e160e9",
|
|
2487
2461
|
name: "crvUSD-FraxlendV1 Gauge",
|
|
2488
2462
|
symbol: "crvUSD-FraxlendV1-gauge",
|
|
@@ -2491,7 +2465,7 @@ const e = [
|
|
|
2491
2465
|
},
|
|
2492
2466
|
{
|
|
2493
2467
|
chainId: 1,
|
|
2494
|
-
erc20TokenAddress: "
|
|
2468
|
+
erc20TokenAddress: "0x9d50aA755Fc808073d01eD98Bf61AF7F4a957A9C",
|
|
2495
2469
|
underlyingErc20TokenAddress: "0x621ef98282ac42d2bf4c20fc73912a16599e12fb",
|
|
2496
2470
|
name: "crvUSD-scrvUSD Gauge",
|
|
2497
2471
|
symbol: "crvUSD-scrvUSD-gauge",
|
|
@@ -2500,7 +2474,7 @@ const e = [
|
|
|
2500
2474
|
},
|
|
2501
2475
|
{
|
|
2502
2476
|
chainId: 1,
|
|
2503
|
-
erc20TokenAddress: "
|
|
2477
|
+
erc20TokenAddress: "0x19797E0F54426c831Fa3a97D85577479F64c1963",
|
|
2504
2478
|
underlyingErc20TokenAddress: "0x8dff75976f22db58d7c3fd7b68d782238b0dbe30",
|
|
2505
2479
|
name: "vETH-WETH Gauge",
|
|
2506
2480
|
symbol: "vETH-WETH-gauge",
|
|
@@ -2509,7 +2483,7 @@ const e = [
|
|
|
2509
2483
|
},
|
|
2510
2484
|
{
|
|
2511
2485
|
chainId: 1,
|
|
2512
|
-
erc20TokenAddress: "
|
|
2486
|
+
erc20TokenAddress: "0x32D7d5822A4913fb82bD29D902D9Ef6529dC48Fd",
|
|
2513
2487
|
underlyingErc20TokenAddress: "0xc2a56e8888786a30a5b56cbe4450a81ddf26ac0c",
|
|
2514
2488
|
name: "USDC-USD0 Gauge",
|
|
2515
2489
|
symbol: "USDC-USD0-gauge",
|
|
@@ -2770,7 +2744,7 @@ const e = [
|
|
|
2770
2744
|
},
|
|
2771
2745
|
{
|
|
2772
2746
|
chainId: 1,
|
|
2773
|
-
erc20TokenAddress: "
|
|
2747
|
+
erc20TokenAddress: "0x910fB112D401fe4F9771657654323C20A8660c20",
|
|
2774
2748
|
underlyingErc20TokenAddress: "0x0000000000000000000000000000000000000000",
|
|
2775
2749
|
decimals: 18,
|
|
2776
2750
|
name: "Hinkal ETH",
|
|
@@ -2780,7 +2754,7 @@ const e = [
|
|
|
2780
2754
|
},
|
|
2781
2755
|
{
|
|
2782
2756
|
chainId: 1,
|
|
2783
|
-
erc20TokenAddress: "
|
|
2757
|
+
erc20TokenAddress: "0x4AB6DF4942c413c6a611791561A373266e699E45",
|
|
2784
2758
|
underlyingErc20TokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
2785
2759
|
decimals: 6,
|
|
2786
2760
|
name: "Hinkal USDC",
|
package/crypto/babyJub.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("circomlibjs");class t{babyjub=void 0;async init(){this.babyjub=await e.buildBabyjub()}getJub(){return this.babyjub}}const b=new t,u=()=>b.getJub();exports.babyJubInstance=u;exports.jubHolder=b;
|
package/crypto/babyJub.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { buildBabyjub as b } from "circomlibjs
|
|
1
|
+
import { buildBabyjub as b } from "circomlibjs";
|
|
2
2
|
class t {
|
|
3
3
|
babyjub = void 0;
|
|
4
4
|
async init() {
|
|
5
|
-
this.babyjub
|
|
5
|
+
this.babyjub = await b();
|
|
6
6
|
}
|
|
7
7
|
getJub() {
|
|
8
8
|
return this.babyjub;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
const u = new t(),
|
|
11
|
+
const u = new t(), n = () => u.getJub();
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
n as babyJubInstance,
|
|
14
14
|
u as jubHolder
|
|
15
15
|
};
|
package/crypto/poseidon.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("circomlibjs"),t=require("ethers"),s=require("../functions/utils/amounts.utils.cjs");class r{poseidon=void 0;async init(){this.poseidon=await i.buildPoseidon()}getPoseidon(){return this.poseidon}}const n=new r;function d(...e){const o=n.getPoseidon();return s.toBigInt(o.F.toString(o(e)))}const c=(...e)=>{const o=n.getPoseidon();return t.BigNumber.from(o.F.toString(o([...e]))).toHexString()};exports.poseidonFunction=d;exports.poseidonHash=c;exports.poseidonHolder=n;
|
package/crypto/poseidon.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { buildPoseidon as t } from "circomlibjs";
|
|
2
|
+
import { BigNumber as e } from "ethers";
|
|
3
|
+
import { toBigInt as s } from "../functions/utils/amounts.utils.mjs";
|
|
4
4
|
class r {
|
|
5
5
|
poseidon = void 0;
|
|
6
6
|
async init() {
|
|
7
|
-
this.poseidon
|
|
7
|
+
this.poseidon = await t();
|
|
8
8
|
}
|
|
9
9
|
getPoseidon() {
|
|
10
10
|
return this.poseidon;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function g(...
|
|
15
|
-
const o =
|
|
16
|
-
return
|
|
13
|
+
const i = new r();
|
|
14
|
+
function g(...n) {
|
|
15
|
+
const o = i.getPoseidon();
|
|
16
|
+
return s(o.F.toString(o(n)));
|
|
17
17
|
}
|
|
18
|
-
const m = (...
|
|
19
|
-
const o =
|
|
20
|
-
return
|
|
18
|
+
const m = (...n) => {
|
|
19
|
+
const o = i.getPoseidon();
|
|
20
|
+
return e.from(o.F.toString(o([...n]))).toHexString();
|
|
21
21
|
};
|
|
22
22
|
export {
|
|
23
23
|
g as poseidonFunction,
|
|
24
24
|
m as poseidonHash,
|
|
25
|
-
|
|
25
|
+
i as poseidonHolder
|
|
26
26
|
};
|
package/crypto/preProcessing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./babyJub.cjs"),i=require("./poseidon.cjs");let e=!1;const o=async()=>{e||(await i.poseidonHolder.init(),await r.jubHolder.init(),e=!0)};exports.preProcessing=o;
|
package/crypto/preProcessing.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { jubHolder as
|
|
1
|
+
import { jubHolder as e } from "./babyJub.mjs";
|
|
2
2
|
import { poseidonHolder as i } from "./poseidon.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const l = async () => {
|
|
7
|
-
(typeof window < "u" || typeof WorkerGlobalScope < "u") && (typeof window < "u" && (window.global = window), globalThis.Buffer = f, globalThis.process = r), await Promise.all([e.ready, i.init(), o.init()]);
|
|
3
|
+
let r = !1;
|
|
4
|
+
const s = async () => {
|
|
5
|
+
r || (await i.init(), await e.init(), r = !0);
|
|
8
6
|
};
|
|
9
7
|
export {
|
|
10
|
-
|
|
8
|
+
s as preProcessing
|
|
11
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),y=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),v=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),T=require("./hinkalSwap.cjs"),m=require("./hinkalWithdraw.cjs"),q=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("circomlibjs
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),y=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),v=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),T=require("./hinkalSwap.cjs"),m=require("./hinkalWithdraw.cjs"),q=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("circomlibjs");const S=require("../../constants/chains.constants.cjs"),g=require("../../error-handling/error-codes.constants.cjs"),f=require("../../API/callMonitor.cjs"),E=require("./hinkalActionLidoEth.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const F=require("../../API/getAxelarGasEstimate.cjs"),p=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");require("../../constants/contracts.constants.cjs");const H=require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const I=require("../transactions-manager/TransactionsManager.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");const M=require("../../functions/utils/reloadPage.cjs"),R=require("./hinkalActionVolatile.cjs"),k=require("./hinkalActionPendleLP.cjs"),L=require("../../API/getConnextReceiveFee.cjs"),W=require("./hinkalActionStake.cjs"),K=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),N=require("./hinkalPrivateWallet.cjs");class x{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;transactionsManager;utxoUtils=K.multiThreadedUtxoUtils;constructor(){this.userKeys=new o.UserKeys(void 0),this.merkleTreeHinkal=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.merkleTreeAccessToken=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.transactionsManager=new I.TransactionsManager}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(){this.userKeys=new o.UserKeys(await this.getProviderAdapter().signMessage(this.signingMessage))}async initUserKeysWithPassword(e){this.userKeys=new o.UserKeys(e)}async resetMerkle(){this.isSelectedNetworkSupported()&&await q.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!S.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(g.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=c.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=c.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),M.reloadPage()}async monitorConnectedAddress(){f.monitor(await this.getEthereumAddress(),this.getCurrentChainId())}async getBalances(){return y.getShieldedBalance(this)}getSupportedPassportLinks(){return H.supportedPassportLinks}checkAccessToken(){return a.checkHinkalAccessToken(this)}async getAxelarEstimate(e,t,r,n){return F.getAxelarGasEstimate(e,t,r,n,this.userKeys.getAccessKey())}async getConnextReceiveFee(e,t){return L.getConnextReceiveFee(this.getCurrentChainId(),e,t)}async mintHinkalAccessToken(e){return a.mintAccessToken(this,e)}async mintHinkalAccessTokenCrossChain(e,t){return a.mintTokenCrossChain(this,e,t)}async getHinkalTreeRootHash(){return this.getContractWithFetcher(h.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){return this.getContractWithFetcher(h.ContractType.CrossChainAccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(g.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&await this.resetMerkle()}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(){return(await p.API.getIdleRelay(this.getCurrentChainId())).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return p.API}async deposit(e,t){return d.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return d.hinkalDepositForOther(this,e,t,r)}async withdraw(e,t,r,n,i=!1){return m.hinkalWithdraw(this,e,t,r,n,i)}async swap(e,t,r,n,i=!1,s=!1){return T.hinkalSwap(this,e,t,r,n,i,s)}async actionCurve(e,t,r,n,i,s=!1){return P.hinkalActionCurve(this,e,t,r,n,i,s)}async actionConvex(e,t,r,n,i=!1){return C.hinkalActionConvex(this,e,t,r,n,i)}async actionBeefy(e,t,r,n,i,s,A=!1){return v.hinkalActionBeefy(this,e,t,r,n,i,s,A)}async actionLido(e,t,r,n,i,s=!1){return E.hinkalActionLido(this,e,t,r,n,i,s)}async actionPendle(e,t,r,n,i=!1){return w.hinkalActionPendle(this,e,t,r,n,i)}async actionPendleLP(e,t,r,n,i=!1){return k.hinkalActionPendleLP(this,e,t,r,n,i)}async actionVolatile(e,t,r,n=!1){return R.hinkalActionVolatile(this,e,t,r,n)}async actionStake(e,t,r,n){return W.hinkalActionStake(this,e,t,r,n)}async actionPrivateWallet(e,t,r,n=[],i,s=!1){return N.hinkalPrivateWallet(this,e,t,r,n,i,s)}async getPendleLPClaimableParams(e,t){return k.hinkalGetPendleLPClaimableParams(this,e,t)}}exports.Hinkal=x;
|
|
@@ -13,10 +13,7 @@ import { hinkalWithdraw as S } from "./hinkalWithdraw.mjs";
|
|
|
13
13
|
import { resetMerkleTrees as E } from "./resetMerkleTrees.mjs";
|
|
14
14
|
import { MerkleTree as h } from "../merkle-tree/MerkleTree.mjs";
|
|
15
15
|
import { poseidonFunction as d } from "../../crypto/poseidon.mjs";
|
|
16
|
-
import "circomlibjs
|
|
17
|
-
import "libsodium-wrappers";
|
|
18
|
-
import "process";
|
|
19
|
-
import "buffer";
|
|
16
|
+
import "circomlibjs";
|
|
20
17
|
import { networkRegistry as H } from "../../constants/chains.constants.mjs";
|
|
21
18
|
import { transactionErrorCodes as p } from "../../error-handling/error-codes.constants.mjs";
|
|
22
19
|
import { monitor as F } from "../../API/callMonitor.mjs";
|
|
@@ -44,7 +41,7 @@ import { getConnextReceiveFee as x } from "../../API/getConnextReceiveFee.mjs";
|
|
|
44
41
|
import { hinkalActionStake as B } from "./hinkalActionStake.mjs";
|
|
45
42
|
import { multiThreadedUtxoUtils as U } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
|
|
46
43
|
import { hinkalPrivateWallet as b } from "./hinkalPrivateWallet.mjs";
|
|
47
|
-
class
|
|
44
|
+
class Le {
|
|
48
45
|
providerAdapter;
|
|
49
46
|
userKeys;
|
|
50
47
|
signingMessage = "Login to Hinkal Protocol";
|
|
@@ -298,5 +295,5 @@ class Ne {
|
|
|
298
295
|
}
|
|
299
296
|
}
|
|
300
297
|
export {
|
|
301
|
-
|
|
298
|
+
Le as Hinkal
|
|
302
299
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const g=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const S=require("../../types/hinkal.stake.types.cjs");require("ethers");const j=require("../crypto-keys/keys.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const g=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const S=require("../../types/hinkal.stake.types.cjs");require("ethers");const j=require("../crypto-keys/keys.cjs");require("../crypto-keys/encryptDecryptUtxo.cjs");const w=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),z=async(t,x,o,s,i)=>{const C=await t.getEthereumAddress(),a=f.getERC20Token(x[0],t.getCurrentChainId());if(!a)throw Error("Deposit Action: No Token Found");const u=s===S.HinkalStakeMode.Stake,n=s===S.HinkalStakeMode.Unstake,{symbol:E}=a;console.log(`${s} token ${E} Start`);const{erc20TokenAddress:H}=a,r=[...await N.addPaddingToUtxos(t,x,o,2,void 0,s!==S.HinkalStakeMode.Deposit)];if(u||n){r[0][0]=y.Utxo.createFrom(r[0][0],{amount:o[0]*(u?1n:-1n),isStakeOrUnstakeInput:!0});for(let e=0;e<r.length;e+=1)for(let c=0;c<r[e].length;c+=1)e===0&&c===0||(r[e][c]=y.Utxo.createFrom(r[e][c],{amount:0n}))}const{outputUtxos:P}=O.outputUtxoProcessing(t.userKeys,r[0],o[0]),d=[P.map(e=>y.Utxo.createFrom(e,{isStake:u,isUnstakeOutput:n}))];n&&(d[0][0]=y.Utxo.createFrom(d[0][0],{amount:0n,isUnstakeOutput:n}));const h=[!1],l=B.randomBigInt(30),K=j.UserKeys.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()),D=p.encryptStake(l,i,T.ownerPublicKey),F=p.encryptStake(l,i,K.publicKey),I=n?0n:p.createStakeCommitment(!0,i,l,H,o[0],BigInt(d[0][0].timeStamp)),v=u?0:1,W=p.encodeHStakeMetadata(v,I,C,D,F),q=t.getContractWithSigner(g.ContractType.HinkalWrapper2),k=t.getContractWithSigner(g.ContractType.HinkalStakeExternalAction);console.log("external action address",k.address);const{zkCallData:A,dimData:U,circomData:m}=await _.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,r,d,t.userKeys,"swapperME1x2x1",M.ExternalActionId.HinkalStake,k.address,W,T.zeroAddress,t.getCurrentChainId(),h,void 0,void 0,{stakedTokenRecipient:i,stakeBlinding:l,mode:s,depositorAddress:C});if(console.log(m),n){const e=f.getHToken(a,t.getCurrentChainId());if(!e)throw new Error("hToken not found");const b=(await t.getContractWithFetcher(g.ContractType.HToken,e.erc20TokenAddress).previewWithdraw(-o[0])).toBigInt();return w.transactCallDirect(t,b,e,A,m,U,k,q)}return w.transactCallDirect(t,o[0],a,A,m,U,k,q)};exports.hinkalActionStake=z;
|
|
@@ -14,7 +14,7 @@ import "../../types/curve.types.mjs";
|
|
|
14
14
|
import { HinkalStakeMode as g } from "../../types/hinkal.stake.types.mjs";
|
|
15
15
|
import "ethers";
|
|
16
16
|
import { UserKeys as J } from "../crypto-keys/keys.mjs";
|
|
17
|
-
import "
|
|
17
|
+
import "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
18
18
|
import { transactCallDirect as w } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
19
19
|
const ut = async (t, y, e, a, c) => {
|
|
20
20
|
const A = await t.getEthereumAddress(), s = N(y[0], t.getCurrentChainId());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const C=require("../../functions/snarkjs/constructEmporiumProof.cjs"),P=require("../../functions/pre-transaction/processAmountChanges.cjs"),R=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),I=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),T=async(e,o,r,d,q=[],p,y=!1)=>{const a=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:a,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],i=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);i.push(E)}const n=await e.getRandomRelay();if(!n)throw Error(x.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{contractData:g}=f.networkRegistry[e.getCurrentChainId()],{emporiumAddress:c}=g;if(!c)throw Error("No Emporium Address Provided");const{zkCallData:u,circomData:l,dimData:m}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,i,e.userKeys,r.length,s[0].length,c,q,n,e.getCurrentChainId(),d,a,p);return y?await U.estimateGasRelayer(e,u,m,l):await I.transactCallRelayer(e.getCurrentChainId(),u,m,l)};exports.hinkalPrivateWallet=T;
|
|
@@ -7,10 +7,7 @@ import "../../types/circom-data.types.mjs";
|
|
|
7
7
|
import { ExternalActionId as w } from "../../types/external-action.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
-
import "circomlibjs
|
|
11
|
-
import "libsodium-wrappers";
|
|
12
|
-
import "process";
|
|
13
|
-
import "buffer";
|
|
10
|
+
import "circomlibjs";
|
|
14
11
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
12
|
import { constructEmporiumProof as R } from "../../functions/snarkjs/constructEmporiumProof.mjs";
|
|
16
13
|
import { processAmountChanges as U } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
@@ -18,7 +15,7 @@ import { outputUtxoProcessing as C } from "../../functions/pre-transaction/outpu
|
|
|
18
15
|
import { addPaddingToUtxos as I } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
19
16
|
import { estimateGasRelayer as P } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
20
17
|
import { transactCallRelayer as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
21
|
-
const
|
|
18
|
+
const M = async (t, e, o, u, d = [], l, E = !1) => {
|
|
22
19
|
const m = e.map((r) => 0n);
|
|
23
20
|
o = U({
|
|
24
21
|
erc20Addresses: e,
|
|
@@ -35,10 +32,10 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
35
32
|
const s = await t.getRandomRelay();
|
|
36
33
|
if (!s)
|
|
37
34
|
throw Error(A.RELAYER_NOT_AVAILABLE);
|
|
38
|
-
const { contractData: x } = g[t.getCurrentChainId()], { emporiumAddress:
|
|
39
|
-
if (!
|
|
35
|
+
const { contractData: x } = g[t.getCurrentChainId()], { emporiumAddress: n } = x;
|
|
36
|
+
if (!n)
|
|
40
37
|
throw Error("No Emporium Address Provided");
|
|
41
|
-
const { zkCallData:
|
|
38
|
+
const { zkCallData: p, circomData: c, dimData: f } = await R(
|
|
42
39
|
t.merkleTreeHinkal,
|
|
43
40
|
t.merkleTreeAccessToken,
|
|
44
41
|
i,
|
|
@@ -46,7 +43,7 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
46
43
|
t.userKeys,
|
|
47
44
|
o.length,
|
|
48
45
|
i[0].length,
|
|
49
|
-
|
|
46
|
+
n,
|
|
50
47
|
d,
|
|
51
48
|
s,
|
|
52
49
|
t.getCurrentChainId(),
|
|
@@ -54,8 +51,8 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
54
51
|
m,
|
|
55
52
|
l
|
|
56
53
|
);
|
|
57
|
-
return E ? await P(t,
|
|
54
|
+
return E ? await P(t, p, f, c) : await T(t.getCurrentChainId(), p, f, c);
|
|
58
55
|
};
|
|
59
56
|
export {
|
|
60
|
-
|
|
57
|
+
M as hinkalPrivateWallet
|
|
61
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("ethers"),f=require("libsodium-wrappers"),l=require("../utxo/Utxo.cjs"),u=require("./keys.cjs");(async()=>await f.ready)();const p=(e,s)=>{const i=[Buffer.from(t.ethers.utils.hexlify(s?0n:e.amount)),Buffer.from(t.ethers.utils.hexlify(e.erc20TokenAddress)),Buffer.from(t.ethers.utils.hexlify(e.randomization)),Buffer.from(e.getStealthAddress()),Buffer.from(t.ethers.utils.hexlify(BigInt(e.timeStamp)))];e.tokenId>0&&i.push(Buffer.from(t.ethers.utils.hexlify(e.tokenId)));const n=Buffer.concat(i);return f.crypto_box_seal(n,t.ethers.utils.arrayify(e.getEncryptionKey()))},d=(e,s)=>{const{publicKey:i,privateKey:n}=u.UserKeys.getEncryptionKeyPair(s.getShieldedPrivateKey()),c=f.crypto_box_seal_open(e,t.ethers.utils.arrayify(i),t.ethers.utils.arrayify(n)),r=Buffer.from(c).toString("utf-8").split("0x").filter(o=>o.length!==0).map((o,y)=>{let a;return[0,2,4,5].includes(y)?a=BigInt(`0x${o}`):[1,3].includes(y)&&(a=`0x${o}`),a});return{amount:r[0],erc20TokenAddress:r[1],randomization:r[2],stealthAddress:r[3],shieldedPrivateKey:s.getShieldedPrivateKey(),timeStamp:r[4].toString(),tokenId:r[5]?Number(r[5]):0}},h=(e,s)=>new l.Utxo(d(e,s));exports.decryptUtxo=h;exports.decryptUtxoConstructorArgs=d;exports.encryptUtxo=p;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ethers as t } from "ethers";
|
|
2
|
-
import
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { UserKeys as
|
|
2
|
+
import a from "libsodium-wrappers";
|
|
3
|
+
import { Utxo as d } from "../utxo/Utxo.mjs";
|
|
4
|
+
import { UserKeys as l } from "./keys.mjs";
|
|
5
|
+
(async () => await a.ready)();
|
|
5
6
|
const B = (e, i) => {
|
|
6
7
|
const o = [
|
|
7
8
|
Buffer.from(t.utils.hexlify(i ? 0n : e.amount)),
|
|
@@ -12,15 +13,15 @@ const B = (e, i) => {
|
|
|
12
13
|
];
|
|
13
14
|
e.tokenId > 0 && o.push(Buffer.from(t.utils.hexlify(e.tokenId)));
|
|
14
15
|
const n = Buffer.concat(o);
|
|
15
|
-
return
|
|
16
|
+
return a.crypto_box_seal(n, t.utils.arrayify(e.getEncryptionKey()));
|
|
16
17
|
}, m = (e, i) => {
|
|
17
|
-
const { publicKey: o, privateKey: n } =
|
|
18
|
+
const { publicKey: o, privateKey: n } = l.getEncryptionKeyPair(i.getShieldedPrivateKey()), y = a.crypto_box_seal_open(
|
|
18
19
|
e,
|
|
19
20
|
t.utils.arrayify(o),
|
|
20
21
|
t.utils.arrayify(n)
|
|
21
|
-
), r = Buffer.from(
|
|
22
|
+
), r = Buffer.from(y).toString("utf-8").split("0x").filter((f) => f.length !== 0).map((f, c) => {
|
|
22
23
|
let s;
|
|
23
|
-
return [0, 2, 4, 5].includes(
|
|
24
|
+
return [0, 2, 4, 5].includes(c) ? s = BigInt(`0x${f}`) : [1, 3].includes(c) && (s = `0x${f}`), s;
|
|
24
25
|
});
|
|
25
26
|
return {
|
|
26
27
|
amount: r[0],
|
|
@@ -32,7 +33,7 @@ const B = (e, i) => {
|
|
|
32
33
|
tokenId: r[5] ? Number(r[5]) : 0
|
|
33
34
|
// tokenId
|
|
34
35
|
};
|
|
35
|
-
}, x = (e, i) => new
|
|
36
|
+
}, x = (e, i) => new d(m(e, i));
|
|
36
37
|
export {
|
|
37
38
|
x as decryptUtxo,
|
|
38
39
|
m as decryptUtxoConstructorArgs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),d=require("libsodium-wrappers"),g=require("../../constants/protocol.constants.cjs"),S=require("../../crypto/babyJub.cjs"),o=require("../../crypto/poseidon.cjs"),h=require("../../functions/utils/memoize.utils.cjs"),c=require("./keyUtils.cjs");(async()=>await d.ready)();const p={privateKey:"",publicKey:""};class K{signature;constructor(e){this.signature=e}getSignature(){return this.requireSignature(),this.signature}setSignature(e){this.signature=e}requireSignature(){if(!this.signature)throw Error("No signature provided")}verifyMessage(e){return this.requireSignature(),u.utils.verifyMessage(e,this.signature)}getShieldedPrivateKey=()=>(this.requireSignature(),u.ethers.utils.keccak256(this.signature));getShieldedPublicKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey()));getAccessKey=()=>(this.requireSignature(),o.poseidonHash(this.getShieldedPrivateKey(),this.getShieldedPublicKey()));getWalletSalt=e=>(this.requireSignature(),o.poseidonHash(this.getShieldedPublicKey(),this.getShieldedPrivateKey(),e));getBackendToken=()=>(this.requireSignature(),o.poseidonHash(this.getAccessKey(),this.getShieldedPublicKey()));static getRandomizedStealthPair=h.memoizeFunc((e,i)=>{const t=S.babyJubInstance(),s=BigInt(i)%g.CIRCOM_P,n=e*s%g.CIRCOM_P,r=t.mulPointEscalar(t.Base8,e),a=t.mulPointEscalar(t.Base8,n),l=[BigInt(t.F.toString(r[0])),BigInt(t.F.toString(r[1]))],y=[BigInt(t.F.toString(a[0])),BigInt(t.F.toString(a[1]))];return{H0:l,H1:y}});static getStealthAddressCompressedPoints=(e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),[n,r]=[t,s].map(a=>BigInt(a[1])+2n**255n*c.getCircomSign(a[0]));return{h0:n,h1:r}};static getStealthAddress=h.memoizeFunc((e,i)=>{const{H0:t,H1:s}=this.getRandomizedStealthPair(e,i),r=[2n*c.getCircomSign(t[0])+c.getCircomSign(s[0]),t[1],s[1]];return o.poseidonHash(...r)});static getStealthAddressWithEKey=(e,i)=>({stealthAddress:this.getStealthAddress(e,i),encryptionKey:this.getEncryptionKeyPair(i).publicKey});static checkSignature=(e,i,t,s)=>{const{h0:n,h1:r}=this.getStealthAddressCompressedPoints(e,s);return i===n&&t===r};static getEncryptionKeyPair=e=>{const i=d.crypto_box_seed_keypair(u.ethers.utils.arrayify(e));return{privateKey:u.ethers.utils.hexlify(i.privateKey),publicKey:u.ethers.utils.hexlify(i.publicKey)}}}exports.EncryptionKeyPairDefaultValue=p;exports.UserKeys=K;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import
|
|
1
|
+
import { utils as S, ethers as o } from "ethers";
|
|
2
|
+
import d from "libsodium-wrappers";
|
|
3
3
|
import { CIRCOM_P as h } from "../../constants/protocol.constants.mjs";
|
|
4
4
|
import { babyJubInstance as m } from "../../crypto/babyJub.mjs";
|
|
5
5
|
import { poseidonHash as u } from "../../crypto/poseidon.mjs";
|
|
6
6
|
import { memoizeFunc as c } from "../../functions/utils/memoize.utils.mjs";
|
|
7
7
|
import { getCircomSign as g } from "./keyUtils.mjs";
|
|
8
|
+
(async () => await d.ready)();
|
|
8
9
|
const q = {
|
|
9
10
|
privateKey: "",
|
|
10
11
|
publicKey: ""
|
|
@@ -25,7 +26,7 @@ class H {
|
|
|
25
26
|
throw Error("No signature provided");
|
|
26
27
|
}
|
|
27
28
|
verifyMessage(t) {
|
|
28
|
-
return this.requireSignature(),
|
|
29
|
+
return this.requireSignature(), S.verifyMessage(t, this.signature);
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* get shielded private key from message signature used to login to the application,
|
|
@@ -53,8 +54,8 @@ class H {
|
|
|
53
54
|
getBackendToken = () => (this.requireSignature(), u(this.getAccessKey(), this.getShieldedPublicKey()));
|
|
54
55
|
static getRandomizedStealthPair = c(
|
|
55
56
|
(t, i) => {
|
|
56
|
-
const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n),
|
|
57
|
-
return { H0:
|
|
57
|
+
const e = m(), r = BigInt(i) % h, n = t * r % h, s = e.mulPointEscalar(e.Base8, t), a = e.mulPointEscalar(e.Base8, n), l = [BigInt(e.F.toString(s[0])), BigInt(e.F.toString(s[1]))], y = [BigInt(e.F.toString(a[0])), BigInt(e.F.toString(a[1]))];
|
|
58
|
+
return { H0: l, H1: y };
|
|
58
59
|
}
|
|
59
60
|
);
|
|
60
61
|
static getStealthAddressCompressedPoints = (t, i) => {
|
|
@@ -76,7 +77,7 @@ class H {
|
|
|
76
77
|
* and must correspond to 32 bytes
|
|
77
78
|
*/
|
|
78
79
|
static getEncryptionKeyPair = (t) => {
|
|
79
|
-
const i =
|
|
80
|
+
const i = d.crypto_box_seed_keypair(o.utils.arrayify(t));
|
|
80
81
|
return {
|
|
81
82
|
privateKey: o.utils.hexlify(i.privateKey),
|
|
82
83
|
publicKey: o.utils.hexlify(i.publicKey)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("circomlibjs
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("circomlibjs");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs"),A=require("./AbstractSnapshotService.cjs");class u extends A.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;if(e.latestBlockNumber&&e.merkleTree){const d=new Map(Object.entries(e.merkleTree.tree).map(([t,a])=>[BigInt(t),BigInt(a)]));s=o.MerkleTree.createWithData(d,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),c.poseidonFunction,25n,0n)}else s=o.MerkleTree.create(c.poseidonFunction,25n,0n);return e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===l.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=u;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
1
|
+
import { zeroAddress as l } from "../../constants/protocol.constants.mjs";
|
|
2
2
|
import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
|
|
3
|
-
import "circomlibjs
|
|
4
|
-
import "libsodium-wrappers";
|
|
5
|
-
import "process";
|
|
6
|
-
import "buffer";
|
|
3
|
+
import "circomlibjs";
|
|
7
4
|
import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
|
|
8
5
|
import { MerkleTree as c } from "../merkle-tree/MerkleTree.mjs";
|
|
9
|
-
import { AbstractSnapshotService as
|
|
10
|
-
class
|
|
6
|
+
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
7
|
+
class M extends o {
|
|
11
8
|
constructor(e, s, r, d) {
|
|
12
9
|
super(
|
|
13
10
|
e,
|
|
@@ -80,7 +77,7 @@ class I extends l {
|
|
|
80
77
|
return this._merkleTree.insert(e.accessKey, e.index), this._senderAddressIndexMap.set(
|
|
81
78
|
e.senderAddress,
|
|
82
79
|
Math.max(Number(e.index), this._senderAddressIndexMap.get(e.senderAddress) ?? 0)
|
|
83
|
-
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress ===
|
|
80
|
+
), this._senderAddresses.includes(e.senderAddress) || this._senderAddresses.push(e.senderAddress), e.accessKey === 0n && e.senderAddress === l && this._merkleTree.remove(e.index), !0;
|
|
84
81
|
} catch (r) {
|
|
85
82
|
return console.error(r), !1;
|
|
86
83
|
}
|
|
@@ -107,5 +104,5 @@ class I extends l {
|
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
106
|
export {
|
|
110
|
-
|
|
107
|
+
M as AbstractAccessTokenSnapshotService
|
|
111
108
|
};
|