h_test_1 0.0.26 → 0.0.28

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 (36) hide show
  1. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  2. package/data-structures/Hinkal/Hinkal.mjs +4 -2
  3. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  4. package/data-structures/Hinkal/hinkalDeposit.mjs +57 -61
  5. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +1 -1
  6. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +8 -13
  7. package/data-structures/provider-adapter/IProviderAdapter.d.ts +1 -0
  8. package/functions/pre-transaction/getKycAndSignatureData.cjs +1 -1
  9. package/functions/pre-transaction/getKycAndSignatureData.mjs +12 -14
  10. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  11. package/functions/snarkjs/constructGeneralZkProof.mjs +99 -105
  12. package/functions/snarkjs/generateZkProof.cjs +1 -1
  13. package/functions/snarkjs/generateZkProof.mjs +9 -9
  14. package/functions/snarkjs/generateZkProofSelf.cjs +1 -1
  15. package/functions/snarkjs/generateZkProofSelf.mjs +10 -12
  16. package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
  17. package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +86 -106
  18. package/package.json +1 -1
  19. package/providers/EthersProviderAdapter.cjs +1 -1
  20. package/providers/EthersProviderAdapter.d.ts +1 -0
  21. package/providers/EthersProviderAdapter.mjs +9 -6
  22. package/providers/SolanaProviderAdapter.cjs +1 -1
  23. package/providers/SolanaProviderAdapter.d.ts +1 -0
  24. package/providers/SolanaProviderAdapter.mjs +9 -6
  25. package/providers/TronProviderAdapter.cjs +1 -1
  26. package/providers/TronProviderAdapter.d.ts +1 -0
  27. package/providers/TronProviderAdapter.mjs +3 -0
  28. package/providers/WagmiProviderAdapter.cjs +1 -1
  29. package/providers/WagmiProviderAdapter.d.ts +2 -1
  30. package/providers/WagmiProviderAdapter.mjs +3 -0
  31. package/webworker/performTaskWithWorker.cjs +1 -1
  32. package/webworker/performTaskWithWorker.mjs +21 -21
  33. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  34. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  35. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  36. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +26 -28
@@ -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)
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../constants/chains.constants.cjs"),a=require("../error-handling/error-codes.constants.cjs"),c=require("ethers"),v=require("wagmi"),o=require("wagmi/actions"),C=require("../functions/web3/getContractMetadata.cjs"),d=require("../types/eip5792.types.cjs"),P=require("../error-handling/logger.cjs");class l{connector;chainId;originalProvider;fetchProviders={};signer;chainEventListener;config;unsubscribeFns=[];constructor(){h.HINKAL_SUPPORTED_CHAINS.forEach(t=>{if(h.isSolanaLike(t))return;const{fetchRpcUrl:r}=h.networkRegistry[t];if(!r)throw Error("No Fetch RPC URL In Provider Adapter");this.fetchProviders[t]=r.includes("wss")?new c.ethers.WebSocketProvider(r):new c.ethers.JsonRpcProvider(r,void 0,{staticNetwork:!0})})}initConnector(t){this.connector=t}initConfig(t){this.config=t}async init(t){if(!this.connector)throw Error("No Connector In Provider Adapter");if(t&&(this.chainId=t),!this.chainId)throw Error("No Chain Id In Provider Adapter");const r=await this.connector.getProvider();this.originalProvider=new c.ethers.BrowserProvider(r);const i=(await this.connector.getAccounts())?.[0];if(!i){this.chainEventListener&&this.chainEventListener.onChainChanged();return}this.signer=await this.walletClientToSigner({transport:r,account:i},this.chainId)}async disconnectFromConnector(){if(!this.config)throw new Error("No Config In Provider Adapter");this.release(),await o.disconnect(this.config)}async connectToConnector(t){if(!this.config)throw new Error("No Config In Provider Adapter");if(t.id==="walletConnect")try{await o.reconnect(this.config,{connectors:[t]}),await o.disconnect(this.config)}catch{}try{return(await o.connect(this.config,{connector:t})).chainId}catch(r){if(r instanceof v.ConnectorAlreadyConnectedError)return t.getChainId();let e=a.transactionErrorCodes.CONNECTION_FAILED;throw r?.code===4001&&(e=a.UserFriendlyErrorCodes.YOU_CANCELED_REQUEST),new Error(e)}}async waitForTransaction(t,r,e){if((await this.fetchProviders[t]?.waitForTransaction(r,e))?.status)return!0;throw Error(a.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(t){if(!this.config)throw new Error("No Config In Provider Adapter");const r=await o.signMessage(this.config,{message:t});if(!r)throw new Error(a.transactionErrorCodes.SIGNING_FAILED);if(r.includes("error"))throw new Error(a.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return r}async signTypedData(t,r,e){return this.signer.signTypedData(t,r,e)}async switchNetwork(t){if(!this.config)throw new Error("No Config In Provider Adapter");return o.switchChain(this.config,{chainId:t.chainId})}async getAddress(){if(!this.config)throw new Error("No Config In Provider Adapter");const{address:t}=o.getAccount(this.config);if(!t)throw new Error("IllegalState");return c.ethers.getAddress(t)}setChainEventListener(t){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=t,this.chainEventListener&&(this.unsubscribeFns.push(o.watchAccount(this.config,{onChange:({address:r},{address:e})=>{this.chainEventListener&&r!==e&&this.chainEventListener.onAccountChanged()}})),this.unsubscribeFns.push(o.watchChainId(this.config,{onChange:r=>{this.chainEventListener&&this.chainEventListener.onChainChanged(r)}})))}onAccountChanged(){return this.init()}onChainChanged(t){return this.init(t)}release(){this.removeListeners()}removeListeners(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}getContract(t,r,e=void 0,i){return C.getContract(r,t,e,i)}getContractWithSigner(t,r,e=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(t,r,e,this.signer)}getContractWithFetcher(t,r,e=void 0){const i=this.fetchProviders[t];if(!i)throw new Error("fetchProvider not initialized");return this.getContract(t,r,e,i)}async sendTransaction(t){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(t)}async connectAndPatchProvider(t){return await this.connectToConnector(t)}isPermitterAvailable(){if(!this.chainId)throw new Error("Illegal state: no chainId");return!!h.networkRegistry[this.chainId]?.contractData?.permitterAddress}async getGasPrice(t){const e=(await this.fetchProviders[t]?.getFeeData())?.gasPrice;if(!e)throw Error("Could not fetch gas price in getGasPrice");return e}async walletClientToSigner(t,r){const{account:e,transport:i}=t;return new c.ethers.BrowserProvider(i).getSigner(e)}async supportsBatchCall(t){if(!this.originalProvider)return!1;try{const r=await this.getAddress(),e=`0x${t.toString(16)}`,i=await this.originalProvider.send("wallet_getCapabilities",[r,[e]]),n=i?.[e]||i?.["0x0"];if(!n?.atomic)return!1;const s=typeof n.atomic=="string"?n.atomic:n.atomic?.status;return s==="supported"||s==="ready"}catch{return!1}}async waitForBatchTransactionStatus(t){if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=1e3,e=60;for(let i=0;i<e;i+=1){await new Promise(n=>{setTimeout(()=>n(),r)});try{const n=await this.originalProvider.send("wallet_getCallsStatus",[t]);if(n.status===d.CallsStatus.Confirmed&&n.receipts?.[0]?.transactionHash)return n.receipts[0].transactionHash;if(n.status===d.CallsStatus.OffchainFailure||n.status===d.CallsStatus.ChainFailure||n.status===d.CallsStatus.PartialFailure)break}catch(n){P.Logger.log("waitForBatchTransactionStatus:",n)}}throw new Error("Batch transaction timed out or failed")}async sendBatchCallsTransaction(t,r){if(!this.fetchProviders[t])throw new Error("WagmiProviderAdapter: fetchProvider not initialized");if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const i=await this.getAddress(),s={version:"2.0.0",chainId:`0x${t.toString(16)}`,from:i,atomicRequired:!0,calls:r},u=await this.originalProvider.send("wallet_sendCalls",[s]),g=u?.id||u;if(!g||typeof g!="string")throw new Error("Invalid batch ID received from wallet_sendCalls");const f=await this.waitForBatchTransactionStatus(g),w=await this.fetchProviders[t].getTransaction(f);if(!w)throw new Error("Transaction not found");return w}}const E=new l,p=()=>new l;exports.WagmiProviderAdapter=l;exports.default=p;exports.wagmiProviderAdapter=E;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../constants/chains.constants.cjs"),a=require("../error-handling/error-codes.constants.cjs"),c=require("ethers"),v=require("wagmi"),o=require("wagmi/actions"),C=require("../functions/web3/getContractMetadata.cjs"),d=require("../types/eip5792.types.cjs"),P=require("../error-handling/logger.cjs");class u{connector;chainId;originalProvider;fetchProviders={};signer;chainEventListener;config;unsubscribeFns=[];constructor(){h.HINKAL_SUPPORTED_CHAINS.forEach(t=>{if(h.isSolanaLike(t))return;const{fetchRpcUrl:r}=h.networkRegistry[t];if(!r)throw Error("No Fetch RPC URL In Provider Adapter");this.fetchProviders[t]=r.includes("wss")?new c.ethers.WebSocketProvider(r):new c.ethers.JsonRpcProvider(r,void 0,{staticNetwork:!0})})}initConnector(t){this.connector=t}initConfig(t){this.config=t}async init(t){if(!this.connector)throw Error("No Connector In Provider Adapter");if(t&&(this.chainId=t),!this.chainId)throw Error("No Chain Id In Provider Adapter");const r=await this.connector.getProvider();this.originalProvider=new c.ethers.BrowserProvider(r);const i=(await this.connector.getAccounts())?.[0];if(!i){this.chainEventListener&&this.chainEventListener.onChainChanged();return}this.signer=await this.walletClientToSigner({transport:r,account:i},this.chainId)}async disconnectFromConnector(){if(!this.config)throw new Error("No Config In Provider Adapter");this.release(),await o.disconnect(this.config)}async connectToConnector(t){if(!this.config)throw new Error("No Config In Provider Adapter");if(t.id==="walletConnect")try{await o.reconnect(this.config,{connectors:[t]}),await o.disconnect(this.config)}catch{}try{return(await o.connect(this.config,{connector:t})).chainId}catch(r){if(r instanceof v.ConnectorAlreadyConnectedError)return t.getChainId();let e=a.transactionErrorCodes.CONNECTION_FAILED;throw r?.code===4001&&(e=a.UserFriendlyErrorCodes.YOU_CANCELED_REQUEST),new Error(e)}}getChainId(){return this.chainId}async waitForTransaction(t,r,e){if((await this.fetchProviders[t]?.waitForTransaction(r,e))?.status)return!0;throw Error(a.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(t){if(!this.config)throw new Error("No Config In Provider Adapter");const r=await o.signMessage(this.config,{message:t});if(!r)throw new Error(a.transactionErrorCodes.SIGNING_FAILED);if(r.includes("error"))throw new Error(a.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return r}async signTypedData(t,r,e){return this.signer.signTypedData(t,r,e)}async switchNetwork(t){if(!this.config)throw new Error("No Config In Provider Adapter");return o.switchChain(this.config,{chainId:t.chainId})}async getAddress(){if(!this.config)throw new Error("No Config In Provider Adapter");const{address:t}=o.getAccount(this.config);if(!t)throw new Error("IllegalState");return c.ethers.getAddress(t)}setChainEventListener(t){if(!this.config)throw new Error("No Config In Provider Adapter");this.chainEventListener=t,this.chainEventListener&&(this.unsubscribeFns.push(o.watchAccount(this.config,{onChange:({address:r},{address:e})=>{this.chainEventListener&&r!==e&&this.chainEventListener.onAccountChanged()}})),this.unsubscribeFns.push(o.watchChainId(this.config,{onChange:r=>{this.chainEventListener&&this.chainEventListener.onChainChanged(r)}})))}onAccountChanged(){return this.init()}onChainChanged(t){return this.init(t)}release(){this.removeListeners()}removeListeners(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}getContract(t,r,e=void 0,i){return C.getContract(r,t,e,i)}getContractWithSigner(t,r,e=void 0){if(!this.signer)throw new Error("IllegalState: no signer");return this.getContract(t,r,e,this.signer)}getContractWithFetcher(t,r,e=void 0){const i=this.fetchProviders[t];if(!i)throw new Error("fetchProvider not initialized");return this.getContract(t,r,e,i)}async sendTransaction(t){if(!this.signer)throw new Error("IllegalState: no signer");return await this.signer.sendTransaction(t)}async connectAndPatchProvider(t){return await this.connectToConnector(t)}isPermitterAvailable(){if(!this.chainId)throw new Error("Illegal state: no chainId");return!!h.networkRegistry[this.chainId]?.contractData?.permitterAddress}async getGasPrice(t){const e=(await this.fetchProviders[t]?.getFeeData())?.gasPrice;if(!e)throw Error("Could not fetch gas price in getGasPrice");return e}async walletClientToSigner(t,r){const{account:e,transport:i}=t;return new c.ethers.BrowserProvider(i).getSigner(e)}async supportsBatchCall(t){if(!this.originalProvider)return!1;try{const r=await this.getAddress(),e=`0x${t.toString(16)}`,i=await this.originalProvider.send("wallet_getCapabilities",[r,[e]]),n=i?.[e]||i?.["0x0"];if(!n?.atomic)return!1;const s=typeof n.atomic=="string"?n.atomic:n.atomic?.status;return s==="supported"||s==="ready"}catch{return!1}}async waitForBatchTransactionStatus(t){if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const r=1e3,e=60;for(let i=0;i<e;i+=1){await new Promise(n=>{setTimeout(()=>n(),r)});try{const n=await this.originalProvider.send("wallet_getCallsStatus",[t]);if(n.status===d.CallsStatus.Confirmed&&n.receipts?.[0]?.transactionHash)return n.receipts[0].transactionHash;if(n.status===d.CallsStatus.OffchainFailure||n.status===d.CallsStatus.ChainFailure||n.status===d.CallsStatus.PartialFailure)break}catch(n){P.Logger.log("waitForBatchTransactionStatus:",n)}}throw new Error("Batch transaction timed out or failed")}async sendBatchCallsTransaction(t,r){if(!this.fetchProviders[t])throw new Error("WagmiProviderAdapter: fetchProvider not initialized");if(!this.originalProvider)throw new Error("WagmiProviderAdapter: Provider not initialized");const i=await this.getAddress(),s={version:"2.0.0",chainId:`0x${t.toString(16)}`,from:i,atomicRequired:!0,calls:r},l=await this.originalProvider.send("wallet_sendCalls",[s]),g=l?.id||l;if(!g||typeof g!="string")throw new Error("Invalid batch ID received from wallet_sendCalls");const f=await this.waitForBatchTransactionStatus(g),w=await this.fetchProviders[t].getTransaction(f);if(!w)throw new Error("Transaction not found");return w}}const E=new u,p=()=>new u;exports.WagmiProviderAdapter=u;exports.default=p;exports.wagmiProviderAdapter=E;
@@ -5,7 +5,7 @@ import { type Connector } from 'wagmi';
5
5
  import { Call } from '../types/eip5792.types';
6
6
  export declare class WagmiProviderAdapter implements IProviderAdapter<Connector> {
7
7
  private connector;
8
- chainId: number | undefined;
8
+ private chainId;
9
9
  private originalProvider;
10
10
  private fetchProviders;
11
11
  private signer;
@@ -18,6 +18,7 @@ export declare class WagmiProviderAdapter implements IProviderAdapter<Connector>
18
18
  init(chainId?: number): Promise<void>;
19
19
  disconnectFromConnector(): Promise<void>;
20
20
  connectToConnector(connector: Connector): Promise<number>;
21
+ getChainId(): number | undefined;
21
22
  waitForTransaction(chainId: number, transactionHash: string, confirmations: number): Promise<boolean>;
22
23
  signMessage(message: string): Promise<string>;
23
24
  signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
@@ -69,6 +69,9 @@ class l {
69
69
  throw r?.code === 4001 && (i = P.YOU_CANCELED_REQUEST), new Error(i);
70
70
  }
71
71
  }
72
+ getChainId() {
73
+ return this.chainId;
74
+ }
72
75
  async waitForTransaction(t, r, i) {
73
76
  if ((await this.fetchProviders[t]?.waitForTransaction(r, i))?.status)
74
77
  return !0;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("../constants/chains.constants.cjs"),h=require("../constants/vite.constants.cjs"),k=require("./workerFactory.cjs"),d=async r=>{const e=await k.WorkerFactory.getWebWorker(r.type);return console.log("performTaskWithWorker a1",{worker:e,workerData:r}),new Promise((s,a)=>{let t={};if(typeof window<"u"&&window.location){const{origin:o,protocol:i,host:c,port:l,hostname:m,href:p}=window.location;t={origin:o,protocol:i,host:c,port:l,hostname:m,href:p}}e.onmessage=o=>{console.log("performTaskWithWorker a3",{result:o}),s(o.data),e.terminate()},e.onerror=o=>{console.error("performTaskWithWorker a2",{err:o}),a(o),e.terminate()};const n={payload:r.payload,metadata:{hostLocation:t,constants:{chains:{chainIds:W.chainIds},isDevelopment:h.isDevelopment}}};console.log("performTaskWithWorker a4",{message:n}),e.postMessage(n)})};exports.performTaskWithWorker=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../constants/chains.constants.cjs"),h=require("../constants/vite.constants.cjs"),w=require("./workerFactory.cjs"),y=async t=>{const e=await w.WorkerFactory.getWebWorker(t.type);return new Promise((r,s)=>{let n={};if(typeof window<"u"&&window.location){const{origin:o,protocol:i,host:c,port:d,hostname:m,href:p}=window.location;n={origin:o,protocol:i,host:c,port:d,hostname:m,href:p}}e.onmessage=o=>{r(o.data),e.terminate()},e.onerror=o=>{s(o),e.terminate()};const a={payload:t.payload,metadata:{hostLocation:n,constants:{chains:{chainIds:l.chainIds},isDevelopment:h.isDevelopment}}};e.postMessage(a)})};exports.performTaskWithWorker=y;
@@ -1,41 +1,41 @@
1
- import { chainIds as W } from "../constants/chains.constants.mjs";
2
- import { isDevelopment as f } from "../constants/vite.constants.mjs";
1
+ import { chainIds as f } from "../constants/chains.constants.mjs";
2
+ import { isDevelopment as w } from "../constants/vite.constants.mjs";
3
3
  import { WorkerFactory as h } from "./workerFactory.mjs";
4
- const w = async (r) => {
5
- const e = await h.getWebWorker(r.type);
6
- return console.log("performTaskWithWorker a1", { worker: e, workerData: r }), new Promise((n, s) => {
7
- let t = {};
4
+ const W = async (e) => {
5
+ const o = await h.getWebWorker(e.type);
6
+ return new Promise((n, a) => {
7
+ let r = {};
8
8
  if (typeof window < "u" && window.location) {
9
- const { origin: o, protocol: i, host: m, port: c, hostname: p, href: l } = window.location;
10
- t = {
11
- origin: o,
9
+ const { origin: t, protocol: i, host: m, port: c, hostname: p, href: d } = window.location;
10
+ r = {
11
+ origin: t,
12
12
  protocol: i,
13
13
  host: m,
14
14
  port: c,
15
15
  hostname: p,
16
- href: l
16
+ href: d
17
17
  };
18
18
  }
19
- e.onmessage = (o) => {
20
- console.log("performTaskWithWorker a3", { result: o }), n(o.data), e.terminate();
21
- }, e.onerror = (o) => {
22
- console.error("performTaskWithWorker a2", { err: o }), s(o), e.terminate();
19
+ o.onmessage = (t) => {
20
+ n(t.data), o.terminate();
21
+ }, o.onerror = (t) => {
22
+ a(t), o.terminate();
23
23
  };
24
- const a = {
25
- payload: r.payload,
24
+ const s = {
25
+ payload: e.payload,
26
26
  metadata: {
27
- hostLocation: t,
27
+ hostLocation: r,
28
28
  constants: {
29
29
  chains: {
30
- chainIds: W
30
+ chainIds: f
31
31
  },
32
- isDevelopment: f
32
+ isDevelopment: w
33
33
  }
34
34
  }
35
35
  };
36
- console.log("performTaskWithWorker a4", { message: a }), e.postMessage(a);
36
+ o.postMessage(s);
37
37
  });
38
38
  };
39
39
  export {
40
- w as performTaskWithWorker
40
+ W as performTaskWithWorker
41
41
  };
@@ -1 +1 @@
1
- "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-DA6ytEz_.js").href:new URL("../../assets/snarkjsWorkerLauncher-DA6ytEz_.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
1
+ "use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-BaRacf89.js").href:new URL("../../assets/snarkjsWorkerLauncher-BaRacf89.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
@@ -1,4 +1,4 @@
1
- const r = "" + new URL("../../assets/snarkjsWorkerLauncher-DA6ytEz_.js", import.meta.url).href;
1
+ const r = "" + new URL("../../assets/snarkjsWorkerLauncher-BaRacf89.js", import.meta.url).href;
2
2
  export {
3
3
  r as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("../workerProxy.cjs"),i=require("../../constants/vite.constants.cjs"),M=require("snarkjs"),O=require("../../data-structures/http/HttpClient.cjs");require("axios");const y=require("../../constants/chains.constants.cjs");function W(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const b=W(M),c=new j.WorkerProxy,w=async e=>new Uint8Array(await O.httpClient.get(e,{responseType:"arraybuffer"})),$=async e=>{try{const{input:o,wasmFilePath:t,zKeyFilePath:r,chainId:n}=e.payload.data,{hostLocation:{origin:h},constants:{isDevelopment:v,chains:{chainIds:l}}}=e.metadata;let s=t,a=r,f,g;const u=s.startsWith("https://");if(console.log("hinkalDeposit k6 snarkjs worker logic",{isNode:i.isNode,isOnline:u,isWebpack:i.isWebpack}),i.isNode&&!u){i.isWebpack?(s=`libs/hardhat/test/circuits/${t}`,a=`libs/hardhat/test/circuits/${r}`):!i.isWebpack&&v&&(n===y.chainIds.solanaLocalnet?(s=`tests/circuits/${t}`,a=`tests/circuits/${r}`):(s=`test/circuits/${t}`,a=`test/circuits/${r}`));const k=require("path");s=k.resolve(s),a=k.resolve(a)}i.isNode&&u?(f=await w(s),g=await w(a)):(n===l.localhost||n===y.chainIds.solanaLocalnet||n===l.tronLocalnet)&&!i.isNode&&(s=`${h}/${t}`,a=`${h}/${r}`),console.log("pre pr ",{chainId:n});const{proof:d,publicSignals:p}=await b.groth16.fullProve(o,f??s,g??a,void 0,void 0,i.isNode&&n===l.tronLocalnet?{singleThread:!0}:void 0);console.log("post proof",{proof:d,publicSignals:p});const P=await b.groth16.exportSolidityCallData(d,p),m=JSON.parse(`[${P}]`);c.postMessageToMainThread({zkCallData:m,proof:d,publicSignals:p})}catch(o){console.error("snarkjs worker logic error",o),c.postErrorToMainThread(o)}};c.attachWorkerSideOnMessage($);exports.default=c;exports.onWorkerMessage=$;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("../workerProxy.cjs"),i=require("../../constants/vite.constants.cjs"),O=require("snarkjs"),F=require("../../data-structures/http/HttpClient.cjs");require("axios");const b=require("../../constants/chains.constants.cjs");function S(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const w=S(O),c=new M.WorkerProxy,k=async e=>new Uint8Array(await F.httpClient.get(e,{responseType:"arraybuffer"})),$=async e=>{try{const{input:a,wasmFilePath:t,zKeyFilePath:r,chainId:n}=e.payload.data,{hostLocation:{origin:u},constants:{isDevelopment:v,chains:{chainIds:l}}}=e.metadata;let s=t,o=r,d,h;const f=s.startsWith("https://");if(i.isNode&&!f){i.isWebpack?(s=`libs/hardhat/test/circuits/${t}`,o=`libs/hardhat/test/circuits/${r}`):!i.isWebpack&&v&&(n===b.chainIds.solanaLocalnet?(s=`tests/circuits/${t}`,o=`tests/circuits/${r}`):(s=`test/circuits/${t}`,o=`test/circuits/${r}`));const g=require("path");s=g.resolve(s),o=g.resolve(o)}i.isNode&&f?(d=await k(s),h=await k(o)):(n===l.localhost||n===b.chainIds.solanaLocalnet||n===l.tronLocalnet)&&!i.isNode&&(s=`${u}/${t}`,o=`${u}/${r}`);const{proof:p,publicSignals:y}=await w.groth16.fullProve(a,d??s,h??o,void 0,void 0,i.isNode&&n===l.tronLocalnet?{singleThread:!0}:void 0),P=await w.groth16.exportSolidityCallData(p,y),m=JSON.parse(`[${P}]`);c.postMessageToMainThread({zkCallData:m,proof:p,publicSignals:y})}catch(a){console.error(a),c.postErrorToMainThread(a)}};c.attachWorkerSideOnMessage($);exports.default=c;exports.onWorkerMessage=$;
@@ -1,44 +1,42 @@
1
1
  import { WorkerProxy as T } from "../workerProxy.mjs";
2
- import { isNode as s, isWebpack as f } from "../../constants/vite.constants.mjs";
3
- import * as w from "snarkjs";
2
+ import { isNode as n, isWebpack as w } from "../../constants/vite.constants.mjs";
3
+ import * as $ from "snarkjs";
4
4
  import { httpClient as b } from "../../data-structures/http/HttpClient.mjs";
5
5
  import "axios";
6
- import { chainIds as y } from "../../constants/chains.constants.mjs";
7
- const d = new T(), $ = async (i) => new Uint8Array(await b.get(i, { responseType: "arraybuffer" })), z = async (i) => {
6
+ import { chainIds as g } from "../../constants/chains.constants.mjs";
7
+ const c = new T(), k = async (o) => new Uint8Array(await b.get(o, { responseType: "arraybuffer" })), z = async (o) => {
8
8
  try {
9
- const { input: l, wasmFilePath: r, zKeyFilePath: a, chainId: o } = i.payload.data, {
10
- hostLocation: { origin: u },
9
+ const { input: i, wasmFilePath: e, zKeyFilePath: s, chainId: r } = o.payload.data, {
10
+ hostLocation: { origin: h },
11
11
  constants: {
12
12
  isDevelopment: F,
13
- chains: { chainIds: n }
13
+ chains: { chainIds: l }
14
14
  }
15
- } = i.metadata;
16
- let t = r, e = a, m, g;
17
- const c = t.startsWith("https://");
18
- if (console.log("hinkalDeposit k6 snarkjs worker logic", { isNode: s, isOnline: c, isWebpack: f }), s && !c) {
19
- f ? (t = `libs/hardhat/test/circuits/${r}`, e = `libs/hardhat/test/circuits/${a}`) : !f && F && (o === y.solanaLocalnet ? (t = `tests/circuits/${r}`, e = `tests/circuits/${a}`) : (t = `test/circuits/${r}`, e = `test/circuits/${a}`));
20
- const k = require("path");
21
- t = k.resolve(t), e = k.resolve(e);
15
+ } = o.metadata;
16
+ let t = e, a = s, p, f;
17
+ const d = t.startsWith("https://");
18
+ if (n && !d) {
19
+ w ? (t = `libs/hardhat/test/circuits/${e}`, a = `libs/hardhat/test/circuits/${s}`) : !w && F && (r === g.solanaLocalnet ? (t = `tests/circuits/${e}`, a = `tests/circuits/${s}`) : (t = `test/circuits/${e}`, a = `test/circuits/${s}`));
20
+ const y = require("path");
21
+ t = y.resolve(t), a = y.resolve(a);
22
22
  }
23
- s && c ? (m = await $(t), g = await $(e)) : (o === n.localhost || o === y.solanaLocalnet || o === n.tronLocalnet) && !s && (t = `${u}/${r}`, e = `${u}/${a}`), console.log("pre pr ", { chainId: o });
24
- const { proof: h, publicSignals: p } = await w.groth16.fullProve(
25
- l,
26
- m ?? t,
27
- g ?? e,
23
+ n && d ? (p = await k(t), f = await k(a)) : (r === l.localhost || r === g.solanaLocalnet || r === l.tronLocalnet) && !n && (t = `${h}/${e}`, a = `${h}/${s}`);
24
+ const { proof: u, publicSignals: m } = await $.groth16.fullProve(
25
+ i,
26
+ p ?? t,
27
+ f ?? a,
28
28
  void 0,
29
29
  void 0,
30
- s && o === n.tronLocalnet ? { singleThread: !0 } : void 0
30
+ n && r === l.tronLocalnet ? { singleThread: !0 } : void 0
31
31
  // snarkjs hangs in tronbox enviroment if singleThread: true is not provided, which is weird, since if incorrect input is provided it will error out
32
- );
33
- console.log("post proof", { proof: h, publicSignals: p });
34
- const v = await w.groth16.exportSolidityCallData(h, p), P = JSON.parse(`[${v}]`);
35
- d.postMessageToMainThread({ zkCallData: P, proof: h, publicSignals: p });
36
- } catch (l) {
37
- console.error("snarkjs worker logic error", l), d.postErrorToMainThread(l);
32
+ ), v = await $.groth16.exportSolidityCallData(u, m), P = JSON.parse(`[${v}]`);
33
+ c.postMessageToMainThread({ zkCallData: P, proof: u, publicSignals: m });
34
+ } catch (i) {
35
+ console.error(i), c.postErrorToMainThread(i);
38
36
  }
39
37
  };
40
- d.attachWorkerSideOnMessage(z);
38
+ c.attachWorkerSideOnMessage(z);
41
39
  export {
42
- d as default,
40
+ c as default,
43
41
  z as onWorkerMessage
44
42
  };