h_test_1 0.0.27 → 0.0.29

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.
Files changed (33) hide show
  1. package/README.md +11 -9
  2. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  3. package/data-structures/Hinkal/Hinkal.mjs +4 -2
  4. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  5. package/data-structures/Hinkal/hinkalDeposit.mjs +57 -61
  6. package/data-structures/provider-adapter/IProviderAdapter.d.ts +1 -0
  7. package/functions/pre-transaction/getKycAndSignatureData.cjs +1 -1
  8. package/functions/pre-transaction/getKycAndSignatureData.mjs +12 -14
  9. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  10. package/functions/snarkjs/constructGeneralZkProof.mjs +99 -105
  11. package/functions/snarkjs/fetchOnChainRootHashes.cjs +1 -1
  12. package/functions/snarkjs/fetchOnChainRootHashes.mjs +4 -4
  13. package/functions/snarkjs/generateZkProof.cjs +1 -1
  14. package/functions/snarkjs/generateZkProof.mjs +9 -9
  15. package/functions/web3/uniswapAPI.cjs +1 -1
  16. package/functions/web3/uniswapAPI.mjs +16 -16
  17. package/package.json +1 -1
  18. package/providers/EthersProviderAdapter.cjs +1 -1
  19. package/providers/EthersProviderAdapter.d.ts +1 -0
  20. package/providers/EthersProviderAdapter.mjs +9 -6
  21. package/providers/SolanaProviderAdapter.cjs +1 -1
  22. package/providers/SolanaProviderAdapter.d.ts +1 -0
  23. package/providers/SolanaProviderAdapter.mjs +9 -6
  24. package/providers/TronProviderAdapter.cjs +1 -1
  25. package/providers/TronProviderAdapter.d.ts +1 -0
  26. package/providers/TronProviderAdapter.mjs +3 -0
  27. package/providers/WagmiProviderAdapter.cjs +1 -1
  28. package/providers/WagmiProviderAdapter.d.ts +2 -1
  29. package/providers/WagmiProviderAdapter.mjs +3 -0
  30. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  31. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  32. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  33. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -28
@@ -1,140 +1,134 @@
1
- import { isTronLike as j, chainIds as x } from "../../constants/chains.constants.mjs";
2
- import { zeroAddress as s, defaultSignatureData as tt } from "../../constants/protocol.constants.mjs";
3
- import { Utxo as at } from "../../data-structures/utxo/Utxo.mjs";
4
- import { randomBigInt as et } from "../web3/etherFunctions.mjs";
5
- import { calcAmountChanges as g, calcEncryptedOutputs as nt, buildOutCommitments as ot, calcPublicSignalCount as mt, getSlippageValues as it, createCallDataHash as rt, calcStealthAddressStructure as st } from "./common.snarkjs.mjs";
6
- import { generateCircomData as dt } from "./generateCircomData.mjs";
7
- import { generateZkProof as ct } from "./generateZkProof.mjs";
8
- import { defaultHinkalLogicArgs as lt } from "../../types/hinkal.types.mjs";
9
- import { generateFeeStructure as kt } from "../utils/fees.utils.mjs";
10
- import { hinkalCheckTronTokenRegistry as ft, hinkalCheckTokenRegistry as pt, createHinkalHelperFromData as St } from "../../data-structures/Hinkal/hinkalCheckTokenRegistry.mjs";
11
- import { Logger as gt } from "../../error-handling/logger.mjs";
12
- import { getDataFromWorkers as Ht } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
13
- const Bt = async (d, G, J, a, o, i, C, D, c, b, P, z = s, r = x.localhost, l = a.map(() => !1), v = a.map(() => 0n), w = void 0, R = !1, m = void 0, k, f = void 0, Q, u = tt, B) => {
14
- const I = g(a, o), p = a.map((t) => t[0].erc20TokenAddress), H = nt(o), A = i.getShieldedPrivateKey(), O = at.findCorrectRandomization(et(31), A), h = j(r) ? await ft(p, g(a, o, !0), r) : await pt(
15
- Q ?? St(r),
16
- p,
17
- g(a, o, !0)
18
- ), y = j(r) ? R || h : R, X = a.map((t) => t.map((e) => e.getConstructableParams()));
19
- console.log("hinkalDeposit sa1", { userKeys: i });
20
- const {
1
+ import { isTronLike as q, chainIds as x } from "../../constants/chains.constants.mjs";
2
+ import { zeroAddress as i, defaultSignatureData as ee } from "../../constants/protocol.constants.mjs";
3
+ import { Utxo as te } from "../../data-structures/utxo/Utxo.mjs";
4
+ import { randomBigInt as ae } from "../web3/etherFunctions.mjs";
5
+ import { calcAmountChanges as p, calcEncryptedOutputs as me, buildOutCommitments as ne, calcPublicSignalCount as oe, getSlippageValues as re, createCallDataHash as ie, calcStealthAddressStructure as de } from "./common.snarkjs.mjs";
6
+ import { generateCircomData as se } from "./generateCircomData.mjs";
7
+ import { generateZkProof as ce } from "./generateZkProof.mjs";
8
+ import { defaultHinkalLogicArgs as le } from "../../types/hinkal.types.mjs";
9
+ import { generateFeeStructure as fe } from "../utils/fees.utils.mjs";
10
+ import { hinkalCheckTronTokenRegistry as ke, hinkalCheckTokenRegistry as Se, createHinkalHelperFromData as He } from "../../data-structures/Hinkal/hinkalCheckTokenRegistry.mjs";
11
+ import { Logger as pe } from "../../error-handling/logger.mjs";
12
+ import { getDataFromWorkers as Ae } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
13
+ const ye = async (d, W, j, t, m, s, C, b, c, h, G, P = i, r = x.localhost, l = t.map(() => !1), z = t.map(() => 0n), D = void 0, v = !1, n = void 0, f, k = void 0, J, w = ee, R) => {
14
+ const u = p(t, m), S = t.map((e) => e[0].erc20TokenAddress), A = me(m), g = s.getShieldedPrivateKey(), y = te.findCorrectRandomization(ae(31), g), B = q(r) ? await ke(S, p(t, m, !0), r) : await Se(
15
+ J ?? He(r),
16
+ S,
17
+ p(t, m, !0)
18
+ ), Q = q(r) ? v || B : v, X = t.map((e) => e.map((a) => a.getConstructableParams())), {
21
19
  inCommitmentSiblings: Y,
22
20
  inCommitmentSiblingSides: _,
23
21
  accessTokenSiblings: $,
24
- accessTokenSiblingSides: M,
25
- rootHashHinkal: E,
26
- rootHashAccessToken: F,
27
- inNullifiers: N
28
- } = await Ht(
22
+ accessTokenSiblingSides: K,
23
+ rootHashHinkal: I,
24
+ rootHashAccessToken: O,
25
+ inNullifiers: E
26
+ } = await Ae(
29
27
  r,
30
- G,
31
- J,
32
- i,
28
+ W,
29
+ j,
30
+ s,
33
31
  X,
34
- y,
35
- h,
32
+ Q,
33
+ B,
36
34
  l,
37
35
  d
38
- );
39
- console.log("hinkalDeposit y1", { userKeys: i, effectivePatchAccessTokenMerkleTree: y, kycRequired: h });
40
- const Z = ot(d, o, l), n = {
41
- rootHashHinkal: E,
42
- shieldedPrivateKey: A,
43
- erc20TokenAddresses: p,
44
- inAmounts: a.map((t) => t.map((e) => e.amount.toString())),
45
- inTimeStamps: a.map((t) => t.map((e) => e.timeStamp)),
46
- inRandomizations: a.map((t) => t.map((e) => e.randomization)),
47
- inNullifiers: N,
36
+ ), F = ne(d, m, l), o = {
37
+ rootHashHinkal: I,
38
+ shieldedPrivateKey: g,
39
+ erc20TokenAddresses: S,
40
+ inAmounts: t.map((e) => e.map((a) => a.amount.toString())),
41
+ inTimeStamps: t.map((e) => e.map((a) => a.timeStamp)),
42
+ inRandomizations: t.map((e) => e.map((a) => a.randomization)),
43
+ inNullifiers: E,
48
44
  inCommitmentSiblings: Y,
49
45
  inCommitmentSiblingSides: _,
50
- outAmounts: o.map((t) => t.map((e) => e.amount.toString())),
51
- outTimeStamp: BigInt(o[0][0].timeStamp),
52
- outPublicKeys: o.map((t) => t.map((e) => e.getStealthAddress())),
53
- extraRandomization: O,
54
- amountChanges: I,
55
- outCommitments: Z,
56
- rootHashAccessToken: F,
46
+ outAmounts: m.map((e) => e.map((a) => a.amount.toString())),
47
+ outTimeStamp: BigInt(m[0][0].timeStamp),
48
+ outPublicKeys: m.map((e) => e.map((a) => a.getStealthAddress())),
49
+ extraRandomization: y,
50
+ amountChanges: u,
51
+ outCommitments: F,
52
+ rootHashAccessToken: O,
57
53
  accessTokenSiblings: $,
58
- accessTokenSiblingSides: M,
54
+ accessTokenSiblingSides: K,
59
55
  calldataHash: 0n
60
- }, S = a.map((t) => t[0].tokenId ?? 0), q = S.reduce((t, e) => t + e, 0) > 0 ? S.length : 0;
61
- q > 0 && (n.tokenIds = S);
62
- const T = mt(
56
+ }, H = t.map((e) => e[0].tokenId ?? 0), N = H.reduce((e, a) => e + a, 0) > 0 ? H.length : 0;
57
+ N > 0 && (o.tokenIds = H);
58
+ const T = oe(
63
59
  C,
64
- n.erc20TokenAddresses,
65
- n.amountChanges,
66
- n.inNullifiers,
67
- n.outCommitments,
68
- q
60
+ o.erc20TokenAddresses,
61
+ o.amountChanges,
62
+ o.inNullifiers,
63
+ o.outCommitments,
64
+ N
69
65
  );
70
- if (!m) {
71
- m = lt(I.length, i), m.interactionAddress = c ?? s;
72
- const t = i.getInHinkalAddress(m.interactionAddress);
73
- m.inHinkalAddress = t;
66
+ if (!n) {
67
+ n = le(u.length, s), n.interactionAddress = c ?? i;
68
+ const e = s.getInHinkalAddress(n.interactionAddress);
69
+ n.inHinkalAddress = e;
74
70
  }
75
71
  if (d === "v1x1") {
76
- if (n.interactionAddress = m?.interactionAddress ?? c ?? s, i.getInHinkalAddress(n.interactionAddress) !== m.inHinkalAddress)
72
+ if (o.interactionAddress = n?.interactionAddress ?? c ?? i, s.getInHinkalAddress(o.interactionAddress) !== n.inHinkalAddress)
77
73
  throw new Error("inHinkalAddress mismatch");
78
- n.externalApprovalAddresses = m.useApprovalUtxoData?.map(
79
- ({ externalApprovalAddresses: t }) => t
80
- ) ?? [s, s, s];
74
+ o.externalApprovalAddresses = n.useApprovalUtxoData?.map(
75
+ ({ externalApprovalAddresses: e }) => e
76
+ ) ?? [i, i, i];
81
77
  }
82
- f || (f = kt(
83
- v,
84
- a.map((t) => t[0].erc20TokenAddress)
78
+ k || (k = fe(
79
+ z,
80
+ t.map((e) => e[0].erc20TokenAddress)
85
81
  ));
86
- const W = g(a, o, !0);
87
- k || (k = it(W, m)), gt.log({ publicSignalCount: T }), n.calldataHash = rt(
82
+ const Z = p(t, m, !0);
83
+ f || (f = re(Z, n)), pe.log({ publicSignalCount: T }), o.calldataHash = ie(
88
84
  d,
89
85
  T,
90
- z,
86
+ P,
91
87
  c,
92
- D,
93
88
  b,
94
- H,
95
- v,
96
- w,
97
- k,
98
- l,
99
- m,
89
+ h,
90
+ A,
91
+ z,
92
+ D,
100
93
  f,
101
- u,
102
- B
103
- ), console.log("hinkalDeposit k2 pre proof", { input: n, generateProofRemotely: P });
104
- const { zkCallData: K } = await ct(d, r, C, n, P);
105
- console.log("hinkalDeposit k2 post proof");
106
- const V = st(O, A), L = dt(
107
- Z,
108
- N,
109
- E,
94
+ l,
95
+ n,
96
+ k,
97
+ w,
98
+ R
99
+ );
100
+ const { zkCallData: M } = await ce(d, r, C, o, G), V = de(y, g), L = se(
110
101
  F,
111
- W,
112
- p,
113
- o,
114
- H,
102
+ E,
103
+ I,
104
+ O,
105
+ Z,
106
+ S,
107
+ m,
108
+ A,
115
109
  T,
116
- D,
117
- c,
118
110
  b,
119
- z,
120
- n.calldataHash,
121
- S,
111
+ c,
112
+ h,
113
+ P,
114
+ o.calldataHash,
115
+ H,
122
116
  V,
123
117
  l,
124
- w,
118
+ D,
125
119
  void 0,
126
- m,
127
- k,
120
+ n,
128
121
  f,
129
- u,
130
- B
122
+ k,
123
+ w,
124
+ R
131
125
  ), U = {
132
- tokenNumber: a.length,
133
- nullifierAmount: a[0].length,
134
- outputAmount: o[0].length
126
+ tokenNumber: t.length,
127
+ nullifierAmount: t[0].length,
128
+ outputAmount: m[0].length
135
129
  };
136
- return { zkCallData: K, circomData: L, dimData: U, encryptedOutputs: H };
130
+ return { zkCallData: M, circomData: L, dimData: U, encryptedOutputs: A };
137
131
  };
138
132
  export {
139
- Bt as constructZkProof
133
+ ye as constructZkProof
140
134
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../types/ethereum-network.types.cjs"),e=require("../web3/getContractMetadata.cjs"),r=async t=>{const a=e.getContractWithFetcherByChainId(t,o.ContractType.HinkalContract),n=e.getContractWithFetcherByChainId(t,o.ContractType.AccessTokenContract),[c,s]=await Promise.all([a.getRootHash(),n.getRootHash()]);return{hinkalRootHash:c.toBigInt(),accessTokenRootHash:s.toBigInt()}};exports.fetchOnChainRootHashes=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../types/ethereum-network.types.cjs"),o=require("../web3/getContractMetadata.cjs"),r=async t=>{const a=o.getContractWithFetcherByChainId(t,e.ContractType.HinkalContract),n=o.getContractWithFetcherByChainId(t,e.ContractType.AccessTokenContract),[c,s]=await Promise.all([a.getRootHash(),n.getRootHash()]);return{hinkalRootHash:c,accessTokenRootHash:s}};exports.fetchOnChainRootHashes=r;
@@ -1,13 +1,13 @@
1
1
  import { ContractType as o } from "../../types/ethereum-network.types.mjs";
2
2
  import { getContractWithFetcherByChainId as a } from "../web3/getContractMetadata.mjs";
3
3
  const i = async (t) => {
4
- const n = a(t, o.HinkalContract), s = a(t, o.AccessTokenContract), [c, e] = await Promise.all([
4
+ const n = a(t, o.HinkalContract), c = a(t, o.AccessTokenContract), [s, e] = await Promise.all([
5
5
  n.getRootHash(),
6
- s.getRootHash()
6
+ c.getRootHash()
7
7
  ]);
8
8
  return {
9
- hinkalRootHash: c.toBigInt(),
10
- accessTokenRootHash: e.toBigInt()
9
+ hinkalRootHash: s,
10
+ accessTokenRootHash: e
11
11
  };
12
12
  };
13
13
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../error-handling/logger.cjs"),c=require("./generateZkProofEnclave.cjs"),g=require("./generateZkProofSelf.cjs"),f=async(e,r,o,t,l)=>{if(l)try{return await c.generateZkProofEnclave(e,r,o,t)}catch(n){console.log("hinkalDeposit k3 enclave proof error",n),a.Logger.error("enclave proof error",n)}return console.log("hinkalDeposit k4 self proof"),g.generateZkProofSelf(e,r,o,t)};exports.generateZkProof=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../../error-handling/logger.cjs"),c=require("./generateZkProofEnclave.cjs"),f=require("./generateZkProofSelf.cjs"),l=async(e,r,o,t,n)=>{if(n)try{return await c.generateZkProofEnclave(e,r,o,t)}catch(a){g.Logger.error("enclave proof error",a)}return f.generateZkProofSelf(e,r,o,t)};exports.generateZkProof=l;
@@ -1,15 +1,15 @@
1
1
  import { Logger as n } from "../../error-handling/logger.mjs";
2
- import { generateZkProofEnclave as a } from "./generateZkProofEnclave.mjs";
3
- import { generateZkProofSelf as c } from "./generateZkProofSelf.mjs";
4
- const s = async (o, r, e, t, l) => {
5
- if (l)
2
+ import { generateZkProofEnclave as c } from "./generateZkProofEnclave.mjs";
3
+ import { generateZkProofSelf as g } from "./generateZkProofSelf.mjs";
4
+ const p = async (r, o, e, t, f) => {
5
+ if (f)
6
6
  try {
7
- return await a(o, r, e, t);
8
- } catch (f) {
9
- console.log("hinkalDeposit k3 enclave proof error", f), n.error("enclave proof error", f);
7
+ return await c(r, o, e, t);
8
+ } catch (a) {
9
+ n.error("enclave proof error", a);
10
10
  }
11
- return console.log("hinkalDeposit k4 self proof"), c(o, r, e, t);
11
+ return g(r, o, e, t);
12
12
  };
13
13
  export {
14
- s as generateZkProof
14
+ p as generateZkProof
15
15
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ethers");require("../../constants/token-data/index.cjs");const d=require("../../constants/chains.constants.cjs"),C=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../constants/schedule.constants.cjs");require("../../constants/tokens.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),P=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const h=require("../../error-handling/logError.cjs"),w=async(s,t,c,r)=>{const o=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await t.getPool(c,r,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(o.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await s.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},q=async(s,t,c,r,o,n)=>{try{if(!d.networkRegistry[t].quoterV2Address)throw Error("No Quoter Contract Provided");return(await s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t].quoterV2Address).quoteExactInputSingle.staticCall({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut}catch(a){throw h.logError(a),a}},A=async(s,t,c,r)=>{try{const o=s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3FactoryContract,d.networkRegistry[t].uniswapV3FactoryAddress),n=s.getContractWithFetcherByChainId(t,u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,o,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},E=async(s,t,c,r,o)=>{try{const n=await A(s,t,r,o),a=g.ethers.AbiCoder.defaultAbiCoder().encode(["uint24"],[n]),i=P.getAmountInWei(r,c);return{tokenPrice:await q(s,t,r,o,n,i),poolFee:a}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=E;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("ethers");require("../../constants/token-data/index.cjs");const d=require("../../constants/chains.constants.cjs"),g=require("../../constants/protocol.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../constants/schedule.constants.cjs");require("../../constants/tokens.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),P=require("./etherFunctions.cjs");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/activities.types.cjs");const h=require("../../error-handling/logError.cjs"),w=async(n,t,c,r)=>{const o=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await t.getPool(c,r,e),fee:e})))).filter(({poolAddress:e})=>e!==g.zeroAddress),s=await Promise.all(o.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:await n.balanceOf(e.poolAddress)}))),i=s.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return s.find(e=>e.token1Balance===i)},q=async(n,t,c,r,o,s)=>{try{if(!d.networkRegistry[t].quoterV2Address)throw Error("No Quoter Contract Provided");return(await n.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t].quoterV2Address).quoteExactInputSingle.staticCall({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:s,sqrtPriceLimitX96:0})).amountOut}catch(a){throw h.logError(a),a}},A=async(n,t,c,r)=>{try{const o=n.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3FactoryContract,d.networkRegistry[t].uniswapV3FactoryAddress),s=n.getContractWithFetcherByChainId(t,u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(s,o,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},E=async(n,t,c,r,o)=>{try{const s=await A(n,t,r,o),a=C.ethers.AbiCoder.defaultAbiCoder().encode(["uint24"],[s]),i=P.getAmountInWei(r,c);return{tokenPrice:await q(n,t,r,o,s,i),poolFee:a}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=E;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
@@ -22,27 +22,27 @@ import "../../types/circom-data.types.mjs";
22
22
  import { ContractType as d } from "../../types/ethereum-network.types.mjs";
23
23
  import "../../types/activities.types.mjs";
24
24
  import { logError as y } from "../../error-handling/logError.mjs";
25
- const C = async (s, o, a, t) => {
25
+ const C = async (n, o, a, t) => {
26
26
  const e = (await Promise.all(
27
27
  [100, 500, 3e3, 1e4].map(async (r) => ({
28
28
  poolAddress: await o.getPool(a, t, r),
29
29
  fee: r
30
30
  }))
31
- )).filter(({ poolAddress: r }) => r !== u), n = await Promise.all(
31
+ )).filter(({ poolAddress: r }) => r !== u), s = await Promise.all(
32
32
  e.map(async (r) => ({
33
33
  poolAddress: r.poolAddress,
34
34
  fee: r.fee,
35
- token1Balance: (await s.balanceOf(r.poolAddress)).toBigInt()
35
+ token1Balance: await n.balanceOf(r.poolAddress)
36
36
  }))
37
- ), i = n.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
37
+ ), i = s.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
38
38
  if (i === 0n)
39
39
  throw new Error(l.UNISWAP_NOT_ENOUGH_LIQUIDITY);
40
- return n.find((r) => r.token1Balance === i);
41
- }, E = async (s, o, a, t, e, n) => {
40
+ return s.find((r) => r.token1Balance === i);
41
+ }, E = async (n, o, a, t, e, s) => {
42
42
  try {
43
43
  if (!p[o].quoterV2Address)
44
44
  throw Error("No Quoter Contract Provided");
45
- return (await s.getContractWithFetcherByChainId(
45
+ return (await n.getContractWithFetcherByChainId(
46
46
  o,
47
47
  d.UniswapV3QuoterContract,
48
48
  p[o].quoterV2Address
@@ -50,24 +50,24 @@ const C = async (s, o, a, t) => {
50
50
  tokenIn: a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
51
51
  tokenOut: t.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
52
52
  fee: e,
53
- amountIn: n,
53
+ amountIn: s,
54
54
  sqrtPriceLimitX96: 0
55
55
  })).amountOut;
56
56
  } catch (c) {
57
57
  throw y(c), c;
58
58
  }
59
- }, P = async (s, o, a, t) => {
59
+ }, P = async (n, o, a, t) => {
60
60
  try {
61
- const e = s.getContractWithFetcherByChainId(
61
+ const e = n.getContractWithFetcherByChainId(
62
62
  o,
63
63
  d.UniswapV3FactoryContract,
64
64
  p[o].uniswapV3FactoryAddress
65
- ), n = s.getContractWithFetcherByChainId(
65
+ ), s = n.getContractWithFetcherByChainId(
66
66
  o,
67
67
  d.ERC20Contract,
68
68
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
69
69
  ), { fee: c } = await C(
70
- n,
70
+ s,
71
71
  e,
72
72
  a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
73
73
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
@@ -76,15 +76,15 @@ const C = async (s, o, a, t) => {
76
76
  } catch (e) {
77
77
  throw console.log("Error in getUniswapFee", e), e;
78
78
  }
79
- }, X = async (s, o, a, t, e) => {
79
+ }, X = async (n, o, a, t, e) => {
80
80
  try {
81
- const n = await P(s, o, t, e), c = w.AbiCoder.defaultAbiCoder().encode(["uint24"], [n]), i = f(t, a);
81
+ const s = await P(n, o, t, e), c = w.AbiCoder.defaultAbiCoder().encode(["uint24"], [s]), i = f(t, a);
82
82
  return { tokenPrice: await E(
83
- s,
83
+ n,
84
84
  o,
85
85
  t,
86
86
  e,
87
- n,
87
+ s,
88
88
  i
89
89
  ), poolFee: c };
90
90
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h_test_1",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "homepage": "hinkal.io",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../constants/chains.constants.cjs"),n=require("../error-handling/error-codes.constants.cjs"),a=require("ethers"),c=require("../functions/web3/getContractMetadata.cjs"),h=require("../functions/utils/create-provider.cjs");class s{signer;chainId;fetchProviders={};chainEventListener;constructor(){i.HINKAL_SUPPORTED_CHAINS.forEach(r=>{!i.isSolanaLike(r)&&!i.isTronLike(r)&&(this.fetchProviders[r]=h.createCustomRpcProvider(r))})}initConnector(){}initSigner(r){this.signer=r}async init(r){if(r&&(this.chainId=r),!this.chainId)throw Error("No Chain Id In Provider Adapter")}async disconnectFromConnector(){}async connectToConnector(){return 0}async waitForTransaction(r,e,t){if((await this.fetchProviders[r]?.waitForTransaction(e,t))?.status)return!0;throw Error(n.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(r){if(!this.signer)throw new Error("IllegalState: no signer");const e=await this.signer.signMessage(r);if(!e)throw new Error(n.transactionErrorCodes.SIGNING_FAILED);if(e.includes("error"))throw new Error(n.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return e}async signTypedData(r,e,t){return this.signer.signTypedData(r,e,t)}async switchNetwork(r){const e=this.fetchProviders[r.chainId];if(!e)throw new Error("switchNetwork illegal state: no provider");this.signer=this.signer?.connect(e),this.chainEventListener?.onChainChanged(r.chainId)}async getAddress(){if(!this.signer)throw new Error("IllegalState: no signer");const r=await this.signer.getAddress();if(!r)throw new Error("IllegalState");return a.ethers.getAddress(r)}setChainEventListener(r){this.chainEventListener=r}onAccountChanged(){return this.init()}onChainChanged(r){return this.init(r)}release(){this.removeListeners()}removeListeners(){this.chainEventListener=void 0}getContract(r,e,t=void 0,o){return c.getContract(e,r,t,o)}getContractWithSigner(r,e,t=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(r,e,t,this.signer)}getContractWithFetcher(r,e,t=void 0){if(!this.fetchProviders[r])throw new Error("fetchProvider not initialized");return this.getContract(r,e,t,this.fetchProviders[r])}async sendTransaction(r){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(r)}async connectAndPatchProvider(){if(!this.signer)throw new Error("IllegalState: no signer");const{chainId:r}=await this.signer.provider.getNetwork();return Number(r)}isPermitterAvailable(){return!1}async getGasPrice(r){const e=(await this.fetchProviders[r]?.getFeeData())?.gasPrice;if(!e)throw Error("Could not fetch gas price in getGasPrice");return e}}const d=new s,g=()=>new s;exports.EthersProviderAdapter=s;exports.default=g;exports.ethersProvierAdapter=d;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../constants/chains.constants.cjs"),n=require("../error-handling/error-codes.constants.cjs"),a=require("ethers"),c=require("../functions/web3/getContractMetadata.cjs"),h=require("../functions/utils/create-provider.cjs");class s{signer;chainId;fetchProviders={};chainEventListener;constructor(){i.HINKAL_SUPPORTED_CHAINS.forEach(r=>{!i.isSolanaLike(r)&&!i.isTronLike(r)&&(this.fetchProviders[r]=h.createCustomRpcProvider(r))})}initConnector(){}initSigner(r){this.signer=r}async init(r){if(r&&(this.chainId=r),!this.chainId)throw Error("No Chain Id In Provider Adapter")}async disconnectFromConnector(){}async connectToConnector(){return 0}async waitForTransaction(r,e,t){if((await this.fetchProviders[r]?.waitForTransaction(e,t))?.status)return!0;throw Error(n.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(r){if(!this.signer)throw new Error("IllegalState: no signer");const e=await this.signer.signMessage(r);if(!e)throw new Error(n.transactionErrorCodes.SIGNING_FAILED);if(e.includes("error"))throw new Error(n.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return e}async signTypedData(r,e,t){return this.signer.signTypedData(r,e,t)}async switchNetwork(r){const e=this.fetchProviders[r.chainId];if(!e)throw new Error("switchNetwork illegal state: no provider");this.signer=this.signer?.connect(e),this.chainEventListener?.onChainChanged(r.chainId)}async getAddress(){if(!this.signer)throw new Error("IllegalState: no signer");const r=await this.signer.getAddress();if(!r)throw new Error("IllegalState");return a.ethers.getAddress(r)}setChainEventListener(r){this.chainEventListener=r}onAccountChanged(){return this.init()}onChainChanged(r){return this.init(r)}release(){this.removeListeners()}removeListeners(){this.chainEventListener=void 0}getContract(r,e,t=void 0,o){return c.getContract(e,r,t,o)}getContractWithSigner(r,e,t=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(r,e,t,this.signer)}getContractWithFetcher(r,e,t=void 0){if(!this.fetchProviders[r])throw new Error("fetchProvider not initialized");return this.getContract(r,e,t,this.fetchProviders[r])}async sendTransaction(r){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(r)}async connectAndPatchProvider(){if(!this.signer)throw new Error("IllegalState: no signer");const{chainId:r}=await this.signer.provider.getNetwork();return Number(r)}getChainId(){return this.chainId}isPermitterAvailable(){return!1}async getGasPrice(r){const e=(await this.fetchProviders[r]?.getFeeData())?.gasPrice;if(!e)throw Error("Could not fetch gas price in getGasPrice");return e}}const d=new s,g=()=>new s;exports.EthersProviderAdapter=s;exports.default=g;exports.ethersProvierAdapter=d;
@@ -27,6 +27,7 @@ export declare class EthersProviderAdapter implements IProviderAdapter<ethers.Si
27
27
  getContractWithFetcher(chainId: number, contract: ContractType, contractAddress?: undefined): ethers.Contract;
28
28
  sendTransaction(tx: ethers.TransactionRequest): Promise<ethers.TransactionResponse>;
29
29
  connectAndPatchProvider(): Promise<number>;
30
+ getChainId(): number | undefined;
30
31
  isPermitterAvailable(): boolean;
31
32
  getGasPrice(chainId: number): Promise<bigint>;
32
33
  }
@@ -1,6 +1,6 @@
1
- import { HINKAL_SUPPORTED_CHAINS as o, isSolanaLike as a, isTronLike as c } from "../constants/chains.constants.mjs";
1
+ import { HINKAL_SUPPORTED_CHAINS as o, isSolanaLike as a, isTronLike as h } from "../constants/chains.constants.mjs";
2
2
  import { transactionErrorCodes as i } from "../error-handling/error-codes.constants.mjs";
3
- import { ethers as h } from "ethers";
3
+ import { ethers as c } from "ethers";
4
4
  import { getContract as g } from "../functions/web3/getContractMetadata.mjs";
5
5
  import { createCustomRpcProvider as d } from "../functions/utils/create-provider.mjs";
6
6
  class s {
@@ -10,7 +10,7 @@ class s {
10
10
  chainEventListener;
11
11
  constructor() {
12
12
  o.forEach((r) => {
13
- !a(r) && !c(r) && (this.fetchProviders[r] = d(r));
13
+ !a(r) && !h(r) && (this.fetchProviders[r] = d(r));
14
14
  });
15
15
  }
16
16
  initConnector() {
@@ -57,7 +57,7 @@ class s {
57
57
  const r = await this.signer.getAddress();
58
58
  if (!r)
59
59
  throw new Error("IllegalState");
60
- return h.getAddress(r);
60
+ return c.getAddress(r);
61
61
  }
62
62
  setChainEventListener(r) {
63
63
  this.chainEventListener = r;
@@ -98,6 +98,9 @@ class s {
98
98
  const { chainId: r } = await this.signer.provider.getNetwork();
99
99
  return Number(r);
100
100
  }
101
+ getChainId() {
102
+ return this.chainId;
103
+ }
101
104
  isPermitterAvailable() {
102
105
  return !1;
103
106
  }
@@ -108,9 +111,9 @@ class s {
108
111
  return t;
109
112
  }
110
113
  }
111
- const u = new s(), C = () => new s();
114
+ const P = new s(), C = () => new s();
112
115
  export {
113
116
  s as EthersProviderAdapter,
114
117
  C as default,
115
- u as ethersProvierAdapter
118
+ P as ethersProvierAdapter
116
119
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../error-handling/error-codes.constants.cjs"),i=require("@coral-xyz/anchor");class a{chainId;connection;wallet;ethereumAddress;chainEventListener;anchorProvider;constructor(r,e,t,n){this.connection=r,this.chainId=e,this.wallet=t,this.ethereumAddress=n,this.initializeAnchorProvider()}initConnector(r){this.wallet=r}async init(r){r&&(this.chainId=r)}async connectToConnector(){return 0}async disconnectFromConnector(){}async connectAndPatchProvider(){if(!this.chainId)throw new Error("No Chain Id In Provider Adapter");return this.chainId}async waitForTransaction(r,e,t){try{return(await this.connection.confirmTransaction(e,"confirmed")).value.err===null}catch{throw Error(o.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}}async signMessage(r){if(!this.wallet?.signMessage)throw new Error(o.transactionErrorCodes.SIGNING_FAILED);const e=typeof r=="string"?new TextEncoder().encode(r):r,{signature:t}=await this.wallet.signMessage(e,"utf8");if(!t)throw new Error(o.transactionErrorCodes.SIGNING_FAILED);return`0x${Buffer.from(t).toString("hex")}`}async getAddress(){const r=this.ethereumAddress??this.wallet?.publicKey.toString();if(!r)throw new Error("IllegalState");return r}setChainEventListener(r){this.chainEventListener=r}async switchNetwork(r){this.chainEventListener?.onChainChanged(r.chainId)}async signTypedData(r,e,t){throw new Error("Typed data signing not supported on Solana")}async onAccountChanged(){return this.init()}async onChainChanged(r){return this.init(r)}release(){this.chainEventListener=void 0}getContract(r,e,t,n){throw new Error("Not implemented from SolanaProviderAdapter")}getContractWithSigner(r,e,t){throw new Error("Not implemented from SolanaProviderAdapter")}getContractWithFetcher(r,e,t){throw new Error("Not implemented from SolanaProviderAdapter")}async sendTransaction(r){throw new Error("Not implemented from SolanaProviderAdapter")}async getGasPrice(r){throw new Error("Not implemented from SolanaProviderAdapter")}isPermitterAvailable(){return!1}getConnection(){return this.connection}initializeAnchorProvider(){if(!this.wallet)throw new Error("No wallet provided");return this.anchorProvider=new i.AnchorProvider(this.connection,this.wallet,{}),this.anchorProvider}getAnchorProvider(){return this.anchorProvider??this.initializeAnchorProvider()}getSolanaProgram(r){return new i.Program(r,this.getAnchorProvider())}getSolanaPublicKey(){if(!this.wallet)throw new Error("No wallet provided");return this.wallet.publicKey}}exports.SolanaProviderAdapter=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../error-handling/error-codes.constants.cjs"),i=require("@coral-xyz/anchor");class a{chainId;connection;wallet;ethereumAddress;chainEventListener;anchorProvider;constructor(r,t,e,n){this.connection=r,this.chainId=t,this.wallet=e,this.ethereumAddress=n,this.initializeAnchorProvider()}initConnector(r){this.wallet=r}async init(r){r&&(this.chainId=r)}async connectToConnector(){return 0}async disconnectFromConnector(){}async connectAndPatchProvider(){if(!this.chainId)throw new Error("No Chain Id In Provider Adapter");return this.chainId}getChainId(){return this.chainId}async waitForTransaction(r,t,e){try{return(await this.connection.confirmTransaction(t,"confirmed")).value.err===null}catch{throw Error(o.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}}async signMessage(r){if(!this.wallet?.signMessage)throw new Error(o.transactionErrorCodes.SIGNING_FAILED);const t=typeof r=="string"?new TextEncoder().encode(r):r,{signature:e}=await this.wallet.signMessage(t,"utf8");if(!e)throw new Error(o.transactionErrorCodes.SIGNING_FAILED);return`0x${Buffer.from(e).toString("hex")}`}async getAddress(){const r=this.ethereumAddress??this.wallet?.publicKey.toString();if(!r)throw new Error("IllegalState");return r}setChainEventListener(r){this.chainEventListener=r}async switchNetwork(r){this.chainEventListener?.onChainChanged(r.chainId)}async signTypedData(r,t,e){throw new Error("Typed data signing not supported on Solana")}async onAccountChanged(){return this.init()}async onChainChanged(r){return this.init(r)}release(){this.chainEventListener=void 0}getContract(r,t,e,n){throw new Error("Not implemented from SolanaProviderAdapter")}getContractWithSigner(r,t,e){throw new Error("Not implemented from SolanaProviderAdapter")}getContractWithFetcher(r,t,e){throw new Error("Not implemented from SolanaProviderAdapter")}async sendTransaction(r){throw new Error("Not implemented from SolanaProviderAdapter")}async getGasPrice(r){throw new Error("Not implemented from SolanaProviderAdapter")}isPermitterAvailable(){return!1}getConnection(){return this.connection}initializeAnchorProvider(){if(!this.wallet)throw new Error("No wallet provided");return this.anchorProvider=new i.AnchorProvider(this.connection,this.wallet,{}),this.anchorProvider}getAnchorProvider(){return this.anchorProvider??this.initializeAnchorProvider()}getSolanaProgram(r){return new i.Program(r,this.getAnchorProvider())}getSolanaPublicKey(){if(!this.wallet)throw new Error("No wallet provided");return this.wallet.publicKey}}exports.SolanaProviderAdapter=a;
@@ -17,6 +17,7 @@ export declare class SolanaProviderAdapter implements IProviderAdapter<SolanaWal
17
17
  connectToConnector(): Promise<number>;
18
18
  disconnectFromConnector(): Promise<void>;
19
19
  connectAndPatchProvider(): Promise<number>;
20
+ getChainId(): number | undefined;
20
21
  waitForTransaction(_chainId: number, transactionHash: string, _confirmations: number): Promise<boolean>;
21
22
  signMessage(message: string | Uint8Array): Promise<string>;
22
23
  getAddress(): Promise<string>;
@@ -1,5 +1,5 @@
1
- import { transactionErrorCodes as o } from "../error-handling/error-codes.constants.mjs";
2
- import { AnchorProvider as i, Program as a } from "@coral-xyz/anchor";
1
+ import { transactionErrorCodes as i } from "../error-handling/error-codes.constants.mjs";
2
+ import { AnchorProvider as o, Program as a } from "@coral-xyz/anchor";
3
3
  class d {
4
4
  chainId;
5
5
  connection;
@@ -27,19 +27,22 @@ class d {
27
27
  throw new Error("No Chain Id In Provider Adapter");
28
28
  return this.chainId;
29
29
  }
30
+ getChainId() {
31
+ return this.chainId;
32
+ }
30
33
  async waitForTransaction(r, t, e) {
31
34
  try {
32
35
  return (await this.connection.confirmTransaction(t, "confirmed")).value.err === null;
33
36
  } catch {
34
- throw Error(o.TRANSACTION_NOT_CONFIRMED);
37
+ throw Error(i.TRANSACTION_NOT_CONFIRMED);
35
38
  }
36
39
  }
37
40
  async signMessage(r) {
38
41
  if (!this.wallet?.signMessage)
39
- throw new Error(o.SIGNING_FAILED);
42
+ throw new Error(i.SIGNING_FAILED);
40
43
  const t = typeof r == "string" ? new TextEncoder().encode(r) : r, { signature: e } = await this.wallet.signMessage(t, "utf8");
41
44
  if (!e)
42
- throw new Error(o.SIGNING_FAILED);
45
+ throw new Error(i.SIGNING_FAILED);
43
46
  return `0x${Buffer.from(e).toString("hex")}`;
44
47
  }
45
48
  async getAddress() {
@@ -91,7 +94,7 @@ class d {
91
94
  initializeAnchorProvider() {
92
95
  if (!this.wallet)
93
96
  throw new Error("No wallet provided");
94
- return this.anchorProvider = new i(this.connection, this.wallet, {}), this.anchorProvider;
97
+ return this.anchorProvider = new o(this.connection, this.wallet, {}), this.anchorProvider;
95
98
  }
96
99
  getAnchorProvider() {
97
100
  return this.anchorProvider ?? this.initializeAnchorProvider();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../error-handling/error-codes.constants.cjs");require("../types/circom-data.types.cjs");require("../constants/chains.constants.cjs");require("../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../constants/kyc.constants.cjs");require("idb-keyval");const s=require("../functions/utils/create-provider.cjs");require("../constants/token-data/index.cjs");require("../constants/tokens.constants.cjs");require("../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../data-structures/crypto-keys/keys.cjs");require("../constants/server.constants.cjs");require("../API/getServerURL.cjs");require("../data-structures/http/HttpClient.cjs");require("axios");require("../constants/vite.constants.cjs");require("tronweb");require("@solana/spl-token");require("tweetnacl");require("bs58");require("buffer");require("libsodium-wrappers");require("lodash");require("../API/enclaveUtxoCalls.cjs");require("../constants/contracts.constants.cjs");require("../constants/coingecko.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../constants/addresses.constants.cjs");require("../constants/token.limits.constants.cjs");require("../constants/presale.constants.cjs");require("../constants/activity.constants.cjs");require("../constants/tasks.constants.cjs");require("../constants/events.constants.cjs");require("../constants/schedule.constants.cjs");require("../functions/utils/userAgent.cjs");require("multiformats");require("async-mutex");require("process");require("./EthersProviderAdapter.cjs");require("node-forge");const a=require("../functions/utils/tron.utils.cjs");require("../functions/web3/events/getInputUtxoAndBalance.cjs");require("../functions/web3/events/getApprovedBalance.cjs");const o=require("../functions/web3/getContractMetadata.cjs");require("../functions/web3/getTokenHolder.cjs");class d{chainId;tronWeb;address;signerAdapter;chainEventListener;accountsChangedHandler;constructor(e,r){this.chainId=r,this.address=e.address,this.signerAdapter=e.signerAdapter,this.tronWeb=this.createSignableTronWeb(r,e.address)}initConnector(e){this.address=e.address,this.signerAdapter=e.signerAdapter,this.chainId&&(this.tronWeb=this.createSignableTronWeb(this.chainId,e.address))}async init(e){e&&(this.chainId=e,this.address&&(this.tronWeb=this.createSignableTronWeb(e,this.address)))}createSignableTronWeb=(e,r)=>{const t=a.createTronWeb(e);return t.setAddress(r),t.trx.sign=async n=>this.signerAdapter.signTransaction(n),t};async connectToConnector(){return 0}async disconnectFromConnector(){}async connectAndPatchProvider(){if(!this.chainId)throw new Error("No Chain Id In Provider Adapter");return this.chainId}async waitForTransaction(e,r,t){const n=r.startsWith("0x")?r:`0x${r}`;if((await s.createCustomRpcProvider(e).waitForTransaction(n,t))?.status===1)return!0;throw new Error(i.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(e){const r=typeof e=="string"?e:new TextDecoder().decode(e),t=await this.signerAdapter.signMessage(r);if(!t)throw new Error(i.transactionErrorCodes.SIGNING_FAILED);return t}async getAddress(){if(!this.address)throw new Error("IllegalState");return this.address}setChainEventListener(e){this.chainEventListener=e,this.accountsChangedHandler&&this.signerAdapter.off("accountsChanged",this.accountsChangedHandler),this.accountsChangedHandler=r=>{this.chainEventListener&&(this.address=r,this.tronWeb?.setAddress(r),this.chainEventListener.onAccountChanged())},this.signerAdapter.on("accountsChanged",this.accountsChangedHandler)}async switchNetwork(e){this.chainEventListener?.onChainChanged(e.chainId)}async signTypedData(e,r,t){throw new Error("Typed data signing not supported on Tron")}async onAccountChanged(){return Promise.resolve()}async onChainChanged(e){return this.init(e)}release(){this.chainEventListener=void 0,this.accountsChangedHandler&&(this.signerAdapter.off("accountsChanged",this.accountsChangedHandler),this.accountsChangedHandler=void 0)}getContract(e,r,t,n){return o.getContract(r,e,t,n)}getContractWithSigner(e,r,t){throw new Error("Not implemented from TronProviderAdapter")}getContractWithFetcher(e,r,t){const n=s.createCustomRpcProvider(e);return this.getContract(e,r,t,n)}async sendTransaction(e){throw new Error("Not implemented from TronProviderAdapter")}async getGasPrice(e){throw new Error("Not implemented from TronProviderAdapter")}isPermitterAvailable(){return!1}getTronWeb(){return this.tronWeb}}exports.TronProviderAdapter=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../error-handling/error-codes.constants.cjs");require("../types/circom-data.types.cjs");require("../constants/chains.constants.cjs");require("../types/activities.types.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("ethers");require("circomlibjs-hinkal-fork");require("../constants/kyc.constants.cjs");require("idb-keyval");const s=require("../functions/utils/create-provider.cjs");require("../constants/token-data/index.cjs");require("../constants/tokens.constants.cjs");require("../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../data-structures/crypto-keys/keys.cjs");require("../constants/server.constants.cjs");require("../API/getServerURL.cjs");require("../data-structures/http/HttpClient.cjs");require("axios");require("../constants/vite.constants.cjs");require("tronweb");require("@solana/spl-token");require("tweetnacl");require("bs58");require("buffer");require("libsodium-wrappers");require("lodash");require("../API/enclaveUtxoCalls.cjs");require("../constants/contracts.constants.cjs");require("../constants/coingecko.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../constants/addresses.constants.cjs");require("../constants/token.limits.constants.cjs");require("../constants/presale.constants.cjs");require("../constants/activity.constants.cjs");require("../constants/tasks.constants.cjs");require("../constants/events.constants.cjs");require("../constants/schedule.constants.cjs");require("../functions/utils/userAgent.cjs");require("multiformats");require("async-mutex");require("process");require("./EthersProviderAdapter.cjs");require("node-forge");const a=require("../functions/utils/tron.utils.cjs");require("../functions/web3/events/getInputUtxoAndBalance.cjs");require("../functions/web3/events/getApprovedBalance.cjs");const o=require("../functions/web3/getContractMetadata.cjs");require("../functions/web3/getTokenHolder.cjs");class d{chainId;tronWeb;address;signerAdapter;chainEventListener;accountsChangedHandler;constructor(e,r){this.chainId=r,this.address=e.address,this.signerAdapter=e.signerAdapter,this.tronWeb=this.createSignableTronWeb(r,e.address)}initConnector(e){this.address=e.address,this.signerAdapter=e.signerAdapter,this.chainId&&(this.tronWeb=this.createSignableTronWeb(this.chainId,e.address))}async init(e){e&&(this.chainId=e,this.address&&(this.tronWeb=this.createSignableTronWeb(e,this.address)))}createSignableTronWeb=(e,r)=>{const t=a.createTronWeb(e);return t.setAddress(r),t.trx.sign=async n=>this.signerAdapter.signTransaction(n),t};async connectToConnector(){return 0}async disconnectFromConnector(){}async connectAndPatchProvider(){if(!this.chainId)throw new Error("No Chain Id In Provider Adapter");return this.chainId}getChainId(){return this.chainId}async waitForTransaction(e,r,t){const n=r.startsWith("0x")?r:`0x${r}`;if((await s.createCustomRpcProvider(e).waitForTransaction(n,t))?.status===1)return!0;throw new Error(i.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(e){const r=typeof e=="string"?e:new TextDecoder().decode(e),t=await this.signerAdapter.signMessage(r);if(!t)throw new Error(i.transactionErrorCodes.SIGNING_FAILED);return t}async getAddress(){if(!this.address)throw new Error("IllegalState");return this.address}setChainEventListener(e){this.chainEventListener=e,this.accountsChangedHandler&&this.signerAdapter.off("accountsChanged",this.accountsChangedHandler),this.accountsChangedHandler=r=>{this.chainEventListener&&(this.address=r,this.tronWeb?.setAddress(r),this.chainEventListener.onAccountChanged())},this.signerAdapter.on("accountsChanged",this.accountsChangedHandler)}async switchNetwork(e){this.chainEventListener?.onChainChanged(e.chainId)}async signTypedData(e,r,t){throw new Error("Typed data signing not supported on Tron")}async onAccountChanged(){return Promise.resolve()}async onChainChanged(e){return this.init(e)}release(){this.chainEventListener=void 0,this.accountsChangedHandler&&(this.signerAdapter.off("accountsChanged",this.accountsChangedHandler),this.accountsChangedHandler=void 0)}getContract(e,r,t,n){return o.getContract(r,e,t,n)}getContractWithSigner(e,r,t){throw new Error("Not implemented from TronProviderAdapter")}getContractWithFetcher(e,r,t){const n=s.createCustomRpcProvider(e);return this.getContract(e,r,t,n)}async sendTransaction(e){throw new Error("Not implemented from TronProviderAdapter")}async getGasPrice(e){throw new Error("Not implemented from TronProviderAdapter")}isPermitterAvailable(){return!1}getTronWeb(){return this.tronWeb}}exports.TronProviderAdapter=d;
@@ -17,6 +17,7 @@ export declare class TronProviderAdapter implements IProviderAdapter<TronWallet>
17
17
  connectToConnector(): Promise<number>;
18
18
  disconnectFromConnector(): Promise<void>;
19
19
  connectAndPatchProvider(): Promise<number>;
20
+ getChainId(): number | undefined;
20
21
  waitForTransaction(_chainId: number, transactionHash: string, confirmations: number): Promise<boolean>;
21
22
  signMessage(message: string | Uint8Array): Promise<string>;
22
23
  getAddress(): Promise<string>;
@@ -77,6 +77,9 @@ class sr {
77
77
  throw new Error("No Chain Id In Provider Adapter");
78
78
  return this.chainId;
79
79
  }
80
+ getChainId() {
81
+ return this.chainId;
82
+ }
80
83
  async waitForTransaction(r, t, e) {
81
84
  const n = t.startsWith("0x") ? t : `0x${t}`;
82
85
  if ((await o(r).waitForTransaction(n, e))?.status === 1)