@hinkal/common 0.1.32 → 0.1.34
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/fees.constants.cjs +1 -1
- package/constants/fees.constants.mjs +22 -22
- 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.d.ts +1 -0
- package/data-structures/Hinkal/Hinkal.mjs +16 -16
- package/data-structures/Hinkal/IHinkal.d.ts +2 -1
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +49 -53
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
- 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 -4
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +18 -26
- 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 +67 -75
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
- package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
- package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
- 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/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +42 -42
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +5 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
- 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 +37 -39
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +22 -24
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +27 -30
- 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/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +25 -25
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
- 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 +35 -38
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +30 -33
- package/index.cjs +1 -1
- package/index.mjs +281 -277
- package/package.json +3 -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/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
- 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,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
|
};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`),!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return console.log(`Could not add ${e.commitment} at index ${e.index} `),!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../crypto/poseidon.cjs");require("circomlibjs");const c=require("../merkle-tree/MerkleTree.cjs"),u=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,n,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,n,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([i,o])=>[BigInt(i),BigInt(o)]));t=c.MerkleTree.createWithData(r,u.toBigInt(e.merkleTree.index),u.toBigInt(e.merkleTree.count),s.poseidonFunction,25n,0n)}else t=c.MerkleTree.create(s.poseidonFunction,25n,0n);const n=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:n||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:n,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(n),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(n=>n.value).includes(e.encryptedOutput)){if(!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
2
|
-
import "circomlibjs
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
import { toBigInt as m } from "../../functions/utils/amounts.utils.mjs";
|
|
8
|
-
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
9
|
-
class b extends o {
|
|
1
|
+
import { poseidonFunction as s } from "../../crypto/poseidon.mjs";
|
|
2
|
+
import "circomlibjs";
|
|
3
|
+
import { MerkleTree as m } from "../merkle-tree/MerkleTree.mjs";
|
|
4
|
+
import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
|
|
5
|
+
import { AbstractSnapshotService as i } from "./AbstractSnapshotService.mjs";
|
|
6
|
+
class O extends i {
|
|
10
7
|
constructor(e, t, u, r) {
|
|
11
8
|
super(
|
|
12
9
|
e,
|
|
@@ -42,21 +39,21 @@ class b extends o {
|
|
|
42
39
|
let t;
|
|
43
40
|
if (e.latestBlockNumber && e.merkleTree) {
|
|
44
41
|
const r = new Map(
|
|
45
|
-
Object.entries(e.merkleTree.tree).map(([c,
|
|
42
|
+
Object.entries(e.merkleTree.tree).map(([c, p]) => [
|
|
46
43
|
BigInt(c),
|
|
47
|
-
BigInt(
|
|
44
|
+
BigInt(p)
|
|
48
45
|
])
|
|
49
46
|
);
|
|
50
|
-
t =
|
|
47
|
+
t = m.createWithData(
|
|
51
48
|
r,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
n(e.merkleTree.index),
|
|
50
|
+
n(e.merkleTree.count),
|
|
51
|
+
s,
|
|
55
52
|
25n,
|
|
56
53
|
0n
|
|
57
54
|
);
|
|
58
55
|
} else
|
|
59
|
-
t =
|
|
56
|
+
t = m.create(s, 25n, 0n);
|
|
60
57
|
const u = e.encryptedOutputs?.map((r) => ({
|
|
61
58
|
value: r.value,
|
|
62
59
|
isPositive: JSON.parse(r.isPositive)
|
|
@@ -84,20 +81,15 @@ class b extends o {
|
|
|
84
81
|
mapEvent(e) {
|
|
85
82
|
const { commitment: t, index: u, encryptedOutput: r } = e;
|
|
86
83
|
return {
|
|
87
|
-
commitment:
|
|
88
|
-
index:
|
|
84
|
+
commitment: n(t),
|
|
85
|
+
index: n(u),
|
|
89
86
|
encryptedOutput: r
|
|
90
87
|
};
|
|
91
88
|
}
|
|
92
89
|
acceptEvent(e, t) {
|
|
93
90
|
if (!this.encryptedOutputs.map((u) => u.value).includes(e.encryptedOutput)) {
|
|
94
|
-
if (this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
), !this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
|
|
100
|
-
return console.log(`Could not add ${e.commitment} at index ${e.index} `), !1;
|
|
91
|
+
if (!this._merkleTree.insert(e.commitment, e.index >= 0 ? e.index : -1n * e.index))
|
|
92
|
+
return !1;
|
|
101
93
|
const r = {
|
|
102
94
|
value: e.encryptedOutput,
|
|
103
95
|
isPositive: e.index >= 0n
|
|
@@ -108,5 +100,5 @@ class b extends o {
|
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
export {
|
|
111
|
-
|
|
103
|
+
O as AbstractCommitmentsSnapshotService
|
|
112
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 r=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("circomlibjs");require("ethers");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends r.AbstractAccessTokenSnapshotService{constructor(s,e){super(s,0,!1,e)}async fetchSnapshot(){const{chainId:s}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(s);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==s)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(s){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { AbstractAccessTokenSnapshotService as
|
|
1
|
+
import { AbstractAccessTokenSnapshotService as r } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
|
|
2
|
+
import "circomlibjs";
|
|
2
3
|
import "ethers";
|
|
3
|
-
import "circomlibjs-hinkal-fork";
|
|
4
|
-
import "libsodium-wrappers";
|
|
5
|
-
import "process";
|
|
6
|
-
import "buffer";
|
|
7
4
|
import "../../constants/vite.constants.mjs";
|
|
8
5
|
import "../../constants/reorg-depths.constants.mjs";
|
|
9
6
|
import { fetchAccessTokenSnapshot as t } from "../../API/fetchCommitmentsCache.mjs";
|
|
10
|
-
class
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
7
|
+
class h extends r {
|
|
8
|
+
constructor(s, e) {
|
|
9
|
+
super(s, 0, !1, e);
|
|
13
10
|
}
|
|
14
11
|
async fetchSnapshot() {
|
|
15
|
-
const { chainId:
|
|
16
|
-
if (e.accessTokenContractAddress !== this.contract.address || e.chainId !==
|
|
12
|
+
const { chainId: s } = await this.contract.provider.getNetwork(), e = await t(s);
|
|
13
|
+
if (e.accessTokenContractAddress !== this.contract.address || e.chainId !== s)
|
|
17
14
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
18
15
|
return {
|
|
19
16
|
latestBlockNumber: e.latestBlockNumber,
|
|
@@ -22,10 +19,10 @@ class k extends s {
|
|
|
22
19
|
senderAddressIndexMap: e.senderAddressIndexMap
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
persistSnapshot(
|
|
22
|
+
persistSnapshot(s) {
|
|
26
23
|
return Promise.resolve();
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
export {
|
|
30
|
-
|
|
27
|
+
h as ClientAccessTokenSnapshotService
|
|
31
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});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");const r=require("../event-service/AbstractCommitmentsSnapshotService.cjs"),s=require("../../API/fetchCommitmentsCache.cjs");class n extends r.AbstractCommitmentsSnapshotService{constructor(e,t){super(e,0,!1,t)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),t=await s.fetchCommitmentsSnapshot(e);if(t.hinkalAddress!==this.contract.address||t.chainId!==e)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:t.latestBlockNumber,merkleTree:t.merkleTree,encryptedOutputs:t.encryptedOutputs}}persistSnapshot(e){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=n;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
import "circomlibjs";
|
|
1
2
|
import "ethers";
|
|
2
|
-
import "circomlibjs-hinkal-fork";
|
|
3
|
-
import "libsodium-wrappers";
|
|
4
|
-
import "process";
|
|
5
|
-
import "buffer";
|
|
6
3
|
import "../../constants/vite.constants.mjs";
|
|
7
4
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
|
-
import { AbstractCommitmentsSnapshotService as
|
|
5
|
+
import { AbstractCommitmentsSnapshotService as r } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
|
|
9
6
|
import { fetchCommitmentsSnapshot as o } from "../../API/fetchCommitmentsCache.mjs";
|
|
10
|
-
class
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
7
|
+
class h extends r {
|
|
8
|
+
constructor(e, t) {
|
|
9
|
+
super(e, 0, !1, t);
|
|
13
10
|
}
|
|
14
11
|
async fetchSnapshot() {
|
|
15
|
-
const { chainId:
|
|
16
|
-
if (t.hinkalAddress !== this.contract.address || t.chainId !==
|
|
12
|
+
const { chainId: e } = await this.contract.provider.getNetwork(), t = await o(e);
|
|
13
|
+
if (t.hinkalAddress !== this.contract.address || t.chainId !== e)
|
|
17
14
|
throw Error("Commitment Snapshot: incorrect contract or chain id");
|
|
18
15
|
return {
|
|
19
16
|
latestBlockNumber: t.latestBlockNumber,
|
|
@@ -21,10 +18,10 @@ class u extends e {
|
|
|
21
18
|
encryptedOutputs: t.encryptedOutputs
|
|
22
19
|
};
|
|
23
20
|
}
|
|
24
|
-
persistSnapshot(
|
|
21
|
+
persistSnapshot(e) {
|
|
25
22
|
return Promise.resolve();
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
export {
|
|
29
|
-
|
|
26
|
+
h as ClientCommitmentsSnapshotService
|
|
30
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});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");const t=require("../event-service/AbstractNullifierSnapshotService.cjs"),i=require("../../API/fetchNullifiers.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;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import "circomlibjs";
|
|
1
2
|
import "ethers";
|
|
2
|
-
import "circomlibjs-hinkal-fork";
|
|
3
|
-
import "libsodium-wrappers";
|
|
4
|
-
import "process";
|
|
5
|
-
import "buffer";
|
|
6
3
|
import "../../constants/vite.constants.mjs";
|
|
7
4
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
5
|
import { AbstractNullifierSnapshotService as e } from "../event-service/AbstractNullifierSnapshotService.mjs";
|
|
9
6
|
import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
|
|
10
|
-
class
|
|
7
|
+
class u extends e {
|
|
11
8
|
constructor(t, r) {
|
|
12
9
|
super(t, 0, !1, r);
|
|
13
10
|
}
|
|
@@ -23,5 +20,5 @@ class h extends e {
|
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
export {
|
|
26
|
-
|
|
23
|
+
u as ClientNullifierSnapshotService
|
|
27
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const y=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const A=require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const k=require("../../functions/snarkjs/generateZkProof.cjs");require("../../types/circom-data.types.cjs");const q=require("../../types/transactions.types.cjs"),I=require("../../types/time.types.cjs"),x=require("./history/getTxDetails.cjs");require("circomlibjs");const P=require("../../error-handling/error-codes.constants.cjs"),w=require("../crypto-keys/keys.cjs"),C=require("../crypto-keys/encryptDecryptUtxo.cjs"),p=require("../../functions/utils/getDataFromTransaction.cjs"),S=require("../../functions/utils/cacheFunctions.cjs");class v{circuitSize=50;hinkalContract;init(e){this.hinkalContract=e}requireInit(){if(!this.hinkalContract)throw Error("TransactionsManager not initialized")}filterOwnTransactions=async(e,t,r,n)=>{const{transactMethodId:s,transactWithExternalActionMethodId:a,hinkalInterface:i}=A.getHinkalParameters(T.getNonLocalhostChainId(e)),c=o=>"decodedInput"in o,d=t.filter(o=>o.methodId===s||o.methodId===a).map(o=>c(o)?o:{...o,decodedInput:p.decodeTxInput(i,o.input),status:o.isError==="0"?"SUCCESS":"FAILURE"}),h=r.getShieldedPrivateKey();return d.filter(o=>{try{if(c(o)){if(C.decryptUtxo(Buffer.from(o.decodedInput.encryptedOutputs[0].slice(2),"hex"),r),!n&&o.methodId===s){const{extraRandomization:f,H0:g,H1:m}=o.decodedInput.stealthAddressStructure;return w.UserKeys.checkSignature(f,g,m,h)}return!0}return!1}catch{return!1}})};saveTxsInStorage=(e,t,r,n)=>{const s=r.getShieldedPublicKey();return S.saveTxsCache(e,t,s,this.hinkalContract.address,n)};loadTxsFromStorage=async(e,t)=>{const r=t.getShieldedPublicKey();return await S.loadTxsCache(e,r,this.hinkalContract.address)};getAllTransactions=async(e,t,r)=>{if(r){const{transactions:i}=await y.API.userGetTransactions(e,r);return i}const{decodedTxs:n,lastHash:s}=await this.loadTxsFromStorage(e,t),{transactions:a}=await y.API.userGetTransactions(e,r,s);return[...a,...n]};getHinkalHistoryBase=async(e,t,r,n=!1)=>{this.requireInit();const s=await this.getAllTransactions(e,t,r)??[];s.sort((i,c)=>c.timeStamp-i.timeStamp);const a=await this.filterOwnTransactions(e,s,t,n);return!r&&s.length>0&&await this.saveTxsInStorage(a,e,t,s[0].hash),a};getHinkalHistory=async(e,t)=>{const r=await this.getHinkalHistoryBase(e,t,void 0,!0),n=p.decodeTxLogs(e,r);return await Promise.all(n.map(async a=>({...a,status:a.status,details:await x.getTxDetails(e,a.decodedInput,a.utxosArray)})))};sortInBatches=e=>{const t=[];let r=0,n=0;e.forEach(i=>{r===0&&t.push([]),t[n].push(i),r+=1,r===this.circuitSize&&(r=0,n+=1)});const s=t[t.length-1],a=s.length;if(a<this.circuitSize){const i=this.circuitSize-a,c=new Array(i).fill(q.emptyDecodedTx);t[t.length-1]=s.concat(c)}return t};generateTransactionsProof=async(e,t,r)=>{const n=this.sortInBatches(t),s=new Array(n.length).fill([]);for(let a=0;a<n.length;a+=1){const i=n[a].map(u=>u.decodedInput.stealthAddressStructure),c=i.map(u=>u.extraRandomization),l=i.map(u=>u.stealthAddress),d={shieldedPrivateKey:r,extraRandomizations:c,stealthAddresses:l},{zkCallData:h}=await k.generateZkProof(e,"transactionsProver",d);s[a]=h}return{zkCallDataArray:s}};userVerifyTransactions=async(e,t,r,n,s,a)=>await y.API.userVerifyTransactions(e,t,r,n,s,a);processAndSendTransactionsForVerification=async(e,t,r,n)=>{this.requireInit();const s=I.getCurrentWeek(),a=n?s-1:s,i=await this.getHinkalHistoryBase(e,t,a);let c=[],l=[];i.length>0&&({zkCallDataArray:l}=await this.generateTransactionsProof(e,i,t.getShieldedPrivateKey()),c=i.map(g=>g.hash));const d=t.getBackendToken(),{trade:h,transactions:u,lockedDeposit:o,verification:f}=await this.userVerifyTransactions(e,c,l,d,r,a);return{trade:h,transactions:u,lockedDeposit:o,verification:f}};multiProcessAndSendTransactionsForVerification=async(e,t)=>{const r=T.chainIdsByType[T.EthereumNetworkType.Mainnet];let n=!0;for(let s=0;s<r.length;s+=1)try{const{hasCertified:a}=await y.API.verificationStartDate(r[s],t);if(a)continue;const{verification:i}=await this.processAndSendTransactionsForVerification(r[s],e,t,!0);if(n=n&&i,!n)break}catch(a){console.log(`current chain ${r[s]} certification error`,{err:a}),n=!1;break}if(!n)throw Error(P.transactionErrorCodes.MULTI_VERIFICATION_FAILED);return!0}}exports.TransactionsManager=v;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getNonLocalhostChainId as
|
|
1
|
+
import { getNonLocalhostChainId as g, chainIdsByType as y, EthereumNetworkType as S } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import "../../constants/vite.constants.mjs";
|
|
3
3
|
import "axios";
|
|
4
4
|
import "../../constants/coingecko.constants.mjs";
|
|
5
|
-
import { API as
|
|
5
|
+
import { API as f } from "../../API/API.mjs";
|
|
6
6
|
import "ethers";
|
|
7
7
|
import "../../types/curve.types.mjs";
|
|
8
8
|
import { getHinkalParameters as k } from "../../constants/contracts.constants.mjs";
|
|
@@ -15,11 +15,11 @@ import "../../types/circom-data.types.mjs";
|
|
|
15
15
|
import { emptyDecodedTx as I } from "../../types/transactions.types.mjs";
|
|
16
16
|
import { getCurrentWeek as x } from "../../types/time.types.mjs";
|
|
17
17
|
import { getTxDetails as w } from "./history/getTxDetails.mjs";
|
|
18
|
-
import "circomlibjs
|
|
18
|
+
import "circomlibjs";
|
|
19
19
|
import { transactionErrorCodes as C } from "../../error-handling/error-codes.constants.mjs";
|
|
20
20
|
import { UserKeys as P } from "../crypto-keys/keys.mjs";
|
|
21
|
-
import { decryptUtxo as
|
|
22
|
-
import { decodeTxInput as
|
|
21
|
+
import { decryptUtxo as H } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
22
|
+
import { decodeTxInput as v, decodeTxLogs as z } from "../../functions/utils/getDataFromTransaction.mjs";
|
|
23
23
|
import { saveTxsCache as E, loadTxsCache as b } from "../../functions/utils/cacheFunctions.mjs";
|
|
24
24
|
class et {
|
|
25
25
|
circuitSize = 50;
|
|
@@ -31,22 +31,22 @@ class et {
|
|
|
31
31
|
if (!this.hinkalContract)
|
|
32
32
|
throw Error("TransactionsManager not initialized");
|
|
33
33
|
}
|
|
34
|
-
filterOwnTransactions = async (r,
|
|
34
|
+
filterOwnTransactions = async (r, t, e, n) => {
|
|
35
35
|
const { transactMethodId: a, transactWithExternalActionMethodId: s, hinkalInterface: i } = k(
|
|
36
|
-
|
|
37
|
-
), c = (o) => "decodedInput" in o,
|
|
36
|
+
g(r)
|
|
37
|
+
), c = (o) => "decodedInput" in o, h = t.filter(
|
|
38
38
|
(o) => o.methodId === a || o.methodId === s
|
|
39
39
|
).map((o) => c(o) ? o : {
|
|
40
40
|
...o,
|
|
41
|
-
decodedInput:
|
|
41
|
+
decodedInput: v(i, o.input),
|
|
42
42
|
status: o.isError === "0" ? "SUCCESS" : "FAILURE"
|
|
43
|
-
}), u =
|
|
44
|
-
return
|
|
43
|
+
}), u = e.getShieldedPrivateKey();
|
|
44
|
+
return h.filter((o) => {
|
|
45
45
|
try {
|
|
46
46
|
if (c(o)) {
|
|
47
|
-
if (
|
|
48
|
-
const { extraRandomization:
|
|
49
|
-
return P.checkSignature(
|
|
47
|
+
if (H(Buffer.from(o.decodedInput.encryptedOutputs[0].slice(2), "hex"), e), !n && o.methodId === a) {
|
|
48
|
+
const { extraRandomization: m, H0: p, H1: T } = o.decodedInput.stealthAddressStructure;
|
|
49
|
+
return P.checkSignature(m, p, T, u);
|
|
50
50
|
}
|
|
51
51
|
return !0;
|
|
52
52
|
}
|
|
@@ -56,31 +56,31 @@ class et {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
-
saveTxsInStorage = (r,
|
|
60
|
-
const a =
|
|
61
|
-
return E(r,
|
|
59
|
+
saveTxsInStorage = (r, t, e, n) => {
|
|
60
|
+
const a = e.getShieldedPublicKey();
|
|
61
|
+
return E(r, t, a, this.hinkalContract.address, n);
|
|
62
62
|
};
|
|
63
|
-
loadTxsFromStorage = async (r,
|
|
64
|
-
const
|
|
65
|
-
return await b(r,
|
|
63
|
+
loadTxsFromStorage = async (r, t) => {
|
|
64
|
+
const e = t.getShieldedPublicKey();
|
|
65
|
+
return await b(r, e, this.hinkalContract.address);
|
|
66
66
|
};
|
|
67
|
-
getAllTransactions = async (r,
|
|
68
|
-
if (
|
|
69
|
-
const { transactions: i } = await
|
|
67
|
+
getAllTransactions = async (r, t, e) => {
|
|
68
|
+
if (e) {
|
|
69
|
+
const { transactions: i } = await f.userGetTransactions(r, e);
|
|
70
70
|
return i;
|
|
71
71
|
}
|
|
72
|
-
const { decodedTxs: n, lastHash: a } = await this.loadTxsFromStorage(r,
|
|
72
|
+
const { decodedTxs: n, lastHash: a } = await this.loadTxsFromStorage(r, t), { transactions: s } = await f.userGetTransactions(r, e, a);
|
|
73
73
|
return [...s, ...n];
|
|
74
74
|
};
|
|
75
|
-
getHinkalHistoryBase = async (r,
|
|
75
|
+
getHinkalHistoryBase = async (r, t, e, n = !1) => {
|
|
76
76
|
this.requireInit();
|
|
77
|
-
const a = await this.getAllTransactions(r,
|
|
77
|
+
const a = await this.getAllTransactions(r, t, e) ?? [];
|
|
78
78
|
a.sort((i, c) => c.timeStamp - i.timeStamp);
|
|
79
|
-
const s = await this.filterOwnTransactions(r, a,
|
|
80
|
-
return !
|
|
79
|
+
const s = await this.filterOwnTransactions(r, a, t, n);
|
|
80
|
+
return !e && a.length > 0 && await this.saveTxsInStorage(s, r, t, a[0].hash), s;
|
|
81
81
|
};
|
|
82
|
-
getHinkalHistory = async (r,
|
|
83
|
-
const
|
|
82
|
+
getHinkalHistory = async (r, t) => {
|
|
83
|
+
const e = await this.getHinkalHistoryBase(r, t, void 0, !0), n = z(r, e);
|
|
84
84
|
return await Promise.all(
|
|
85
85
|
n.map(async (s) => ({
|
|
86
86
|
...s,
|
|
@@ -90,90 +90,82 @@ class et {
|
|
|
90
90
|
);
|
|
91
91
|
};
|
|
92
92
|
sortInBatches = (r) => {
|
|
93
|
-
const
|
|
94
|
-
let
|
|
93
|
+
const t = [];
|
|
94
|
+
let e = 0, n = 0;
|
|
95
95
|
r.forEach((i) => {
|
|
96
|
-
|
|
96
|
+
e === 0 && t.push([]), t[n].push(i), e += 1, e === this.circuitSize && (e = 0, n += 1);
|
|
97
97
|
});
|
|
98
|
-
const a =
|
|
98
|
+
const a = t[t.length - 1], s = a.length;
|
|
99
99
|
if (s < this.circuitSize) {
|
|
100
100
|
const i = this.circuitSize - s, c = new Array(i).fill(I);
|
|
101
|
-
|
|
101
|
+
t[t.length - 1] = a.concat(c);
|
|
102
102
|
}
|
|
103
|
-
return
|
|
103
|
+
return t;
|
|
104
104
|
};
|
|
105
|
-
generateTransactionsProof = async (r,
|
|
106
|
-
const n = this.sortInBatches(
|
|
105
|
+
generateTransactionsProof = async (r, t, e) => {
|
|
106
|
+
const n = this.sortInBatches(t), a = new Array(n.length).fill([]);
|
|
107
107
|
for (let s = 0; s < n.length; s += 1) {
|
|
108
108
|
const i = n[s].map(
|
|
109
|
-
(
|
|
110
|
-
), c = i.map((
|
|
111
|
-
|
|
112
|
-
const l = {
|
|
113
|
-
shieldedPrivateKey: t,
|
|
109
|
+
(l) => l.decodedInput.stealthAddressStructure
|
|
110
|
+
), c = i.map((l) => l.extraRandomization), d = i.map((l) => l.stealthAddress), h = {
|
|
111
|
+
shieldedPrivateKey: e,
|
|
114
112
|
extraRandomizations: c,
|
|
115
113
|
stealthAddresses: d
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const { zkCallData: u } = await A(r, "transactionsProver", l);
|
|
119
|
-
console.log({ zkCallData: u }), a[s] = u;
|
|
114
|
+
}, { zkCallData: u } = await A(r, "transactionsProver", h);
|
|
115
|
+
a[s] = u;
|
|
120
116
|
}
|
|
121
117
|
return { zkCallDataArray: a };
|
|
122
118
|
};
|
|
123
|
-
userVerifyTransactions = async (r,
|
|
119
|
+
userVerifyTransactions = async (r, t, e, n, a, s) => await f.userVerifyTransactions(
|
|
124
120
|
r,
|
|
125
|
-
e,
|
|
126
121
|
t,
|
|
122
|
+
e,
|
|
127
123
|
n,
|
|
128
124
|
a,
|
|
129
125
|
s
|
|
130
126
|
);
|
|
131
|
-
processAndSendTransactionsForVerification = async (r,
|
|
127
|
+
processAndSendTransactionsForVerification = async (r, t, e, n) => {
|
|
132
128
|
this.requireInit();
|
|
133
|
-
const a = x(), s = n ? a - 1 : a;
|
|
134
|
-
console.log("retrieving transactions in processAndSendTransactionsForVerification", { week: s });
|
|
135
|
-
const i = await this.getHinkalHistoryBase(r, e, s);
|
|
136
|
-
console.log("retrieved transactions", i);
|
|
129
|
+
const a = x(), s = n ? a - 1 : a, i = await this.getHinkalHistoryBase(r, t, s);
|
|
137
130
|
let c = [], d = [];
|
|
138
131
|
i.length > 0 && ({ zkCallDataArray: d } = await this.generateTransactionsProof(
|
|
139
132
|
r,
|
|
140
133
|
i,
|
|
141
|
-
|
|
134
|
+
t.getShieldedPrivateKey()
|
|
142
135
|
), c = i.map((p) => p.hash));
|
|
143
|
-
const
|
|
136
|
+
const h = t.getBackendToken(), {
|
|
144
137
|
trade: u,
|
|
145
|
-
transactions:
|
|
138
|
+
transactions: l,
|
|
146
139
|
lockedDeposit: o,
|
|
147
|
-
verification:
|
|
140
|
+
verification: m
|
|
148
141
|
} = await this.userVerifyTransactions(
|
|
149
142
|
r,
|
|
150
143
|
c,
|
|
151
144
|
d,
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
h,
|
|
146
|
+
e,
|
|
154
147
|
s
|
|
155
148
|
);
|
|
156
|
-
return { trade: u, transactions:
|
|
149
|
+
return { trade: u, transactions: l, lockedDeposit: o, verification: m };
|
|
157
150
|
};
|
|
158
|
-
multiProcessAndSendTransactionsForVerification = async (r,
|
|
159
|
-
|
|
160
|
-
const t = y[S.Mainnet];
|
|
151
|
+
multiProcessAndSendTransactionsForVerification = async (r, t) => {
|
|
152
|
+
const e = y[S.Mainnet];
|
|
161
153
|
let n = !0;
|
|
162
|
-
for (let a = 0; a <
|
|
154
|
+
for (let a = 0; a < e.length; a += 1)
|
|
163
155
|
try {
|
|
164
|
-
const { hasCertified: s } = await
|
|
165
|
-
if (
|
|
156
|
+
const { hasCertified: s } = await f.verificationStartDate(e[a], t);
|
|
157
|
+
if (s)
|
|
166
158
|
continue;
|
|
167
|
-
const {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
159
|
+
const { verification: i } = await this.processAndSendTransactionsForVerification(
|
|
160
|
+
e[a],
|
|
161
|
+
r,
|
|
162
|
+
t,
|
|
163
|
+
!0
|
|
164
|
+
);
|
|
165
|
+
if (n = n && i, !n)
|
|
174
166
|
break;
|
|
175
167
|
} catch (s) {
|
|
176
|
-
console.log(`current chain ${
|
|
168
|
+
console.log(`current chain ${e[a]} certification error`, { err: s }), n = !1;
|
|
177
169
|
break;
|
|
178
170
|
}
|
|
179
171
|
if (!n)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./history.types.cjs");require("../../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./history.types.cjs");require("../../../types/circom-data.types.cjs");const A=require("../../../types/hinkal.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const d=require("../../../functions/utils/erc20tokenFunctions.cjs"),a=require("../../../functions/utils/caseInsensitive.utils.cjs"),v=require("../../../constants/token-data/ERC20Registry.cjs"),E=require("../../volatile-helper/VolatileHelper.cjs"),h=async(o,f,s)=>{const c=v.getERC20Registry(s),{externalActionMetadata:V}=o,{volatileAmounts:k,redirectActionId:q,volatileAction:T}=E.VolatileHelper.decodeVolatileMetadata(V);if(T===A.VolatileAction.Deposit){const r=o.erc20TokenAddresses[0],e=c.find(t=>a.caseInsensitiveEqual(t.sharedAddress,r));if(!e)throw Error("Volatile not found in statistics");return{tokenWithBalance:{token:d.getERC20Token(e.erc20TokenAddress,s)??{erc20TokenAddress:e.erc20TokenAddress},balance:k[0].toBigInt()},type:l.TransactionType.DEPOSIT}}if(T===A.VolatileAction.Withdraw){const r=o.erc20TokenAddresses[0],e=c.find(t=>a.caseInsensitiveEqual(t.sharedAddress,r));if(!e)throw Error("Volatile not found in statistics");return{tokenWithBalance:{token:d.getERC20Token(e.erc20TokenAddress,s)??{erc20TokenAddress:e.erc20TokenAddress},balance:k[0].toBigInt()},type:l.TransactionType.WITHDRAW}}if(T===A.VolatileAction.Swap){const r=o.erc20TokenAddresses[0],e=o.erc20TokenAddresses[1],u=o.amountChanges[0].toBigInt(),i=c.find(n=>a.caseInsensitiveEqual(n.sharedAddress,r)),t=c.find(n=>a.caseInsensitiveEqual(n.sharedAddress,e));if(!i&&!t)throw Error("Volatile not found in swap statistics");const p={token:d.getERC20Token(i?i.erc20TokenAddress:r,s),balance:i?k[0].toBigInt():u},g=f.find(n=>a.caseInsensitiveEqual(n.erc20TokenAddress,e));let y={token:d.getERC20Token(e,s),balance:g?.amount};if(t){const n=await E.VolatileHelper.getVolatileTokenBalance(s,e,g?.amount??0n);y={token:t,balance:n}}return{tokenIn:p,tokenOut:y,type:l.TransactionType.SWAP,protocol:q.toBigInt()}}return{type:l.TransactionType.UNKNOWN}};exports.getVolatileData=h;
|
|
@@ -7,10 +7,10 @@ import { getERC20Token as l } from "../../../functions/utils/erc20tokenFunctions
|
|
|
7
7
|
import { caseInsensitiveEqual as i } from "../../../functions/utils/caseInsensitive.utils.mjs";
|
|
8
8
|
import { getERC20Registry as W } from "../../../constants/token-data/ERC20Registry.mjs";
|
|
9
9
|
import { VolatileHelper as g } from "../../volatile-helper/VolatileHelper.mjs";
|
|
10
|
-
const
|
|
11
|
-
const c = W(s), { externalActionMetadata: B } = n, { volatileAmounts: k, redirectActionId:
|
|
10
|
+
const C = async (n, u, s) => {
|
|
11
|
+
const c = W(s), { externalActionMetadata: B } = n, { volatileAmounts: k, redirectActionId: V, volatileAction: A } = g.decodeVolatileMetadata(B);
|
|
12
12
|
if (A === f.Deposit) {
|
|
13
|
-
const r = n.erc20TokenAddresses[0], e = c.find((
|
|
13
|
+
const r = n.erc20TokenAddresses[0], e = c.find((t) => i(t.sharedAddress, r));
|
|
14
14
|
if (!e)
|
|
15
15
|
throw Error("Volatile not found in statistics");
|
|
16
16
|
return {
|
|
@@ -22,7 +22,7 @@ const N = async (n, u, s) => {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
if (A === f.Withdraw) {
|
|
25
|
-
const r = n.erc20TokenAddresses[0], e = c.find((
|
|
25
|
+
const r = n.erc20TokenAddresses[0], e = c.find((t) => i(t.sharedAddress, r));
|
|
26
26
|
if (!e)
|
|
27
27
|
throw Error("Volatile not found in statistics");
|
|
28
28
|
return {
|
|
@@ -34,22 +34,22 @@ const N = async (n, u, s) => {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
if (A === f.Swap) {
|
|
37
|
-
const r = n.erc20TokenAddresses[0], e = n.erc20TokenAddresses[1], T = n.amountChanges[0].toBigInt(), a = c.find((
|
|
38
|
-
if (!a && !
|
|
37
|
+
const r = n.erc20TokenAddresses[0], e = n.erc20TokenAddresses[1], T = n.amountChanges[0].toBigInt(), a = c.find((o) => i(o.sharedAddress, r)), t = c.find((o) => i(o.sharedAddress, e));
|
|
38
|
+
if (!a && !t)
|
|
39
39
|
throw Error("Volatile not found in swap statistics");
|
|
40
|
-
const
|
|
40
|
+
const E = {
|
|
41
41
|
token: l(a ? a.erc20TokenAddress : r, s),
|
|
42
42
|
balance: a ? k[0].toBigInt() : T
|
|
43
|
-
}, m = u.find((
|
|
43
|
+
}, m = u.find((o) => i(o.erc20TokenAddress, e));
|
|
44
44
|
let p = { token: l(e, s), balance: m?.amount };
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
|
|
45
|
+
if (t) {
|
|
46
|
+
const o = await g.getVolatileTokenBalance(s, e, m?.amount ?? 0n);
|
|
47
|
+
p = { token: t, balance: o };
|
|
48
48
|
}
|
|
49
|
-
return { tokenIn:
|
|
49
|
+
return { tokenIn: E, tokenOut: p, type: d.SWAP, protocol: V.toBigInt() };
|
|
50
50
|
}
|
|
51
51
|
return { type: d.UNKNOWN };
|
|
52
52
|
};
|
|
53
53
|
export {
|
|
54
|
-
|
|
54
|
+
C as getVolatileData
|
|
55
55
|
};
|