@sabaaa1/common 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +5 -0
- package/.eslintrc.json +18 -0
- package/README.md +164 -0
- package/copyPackageJson.js +81 -0
- package/handleCDNWorkers.js +92 -0
- package/jest.config.ts +10 -0
- package/package.json +101 -0
- package/polyfillWorker.ts +15 -0
- package/project.json +32 -0
- package/src/API/API.ts +203 -0
- package/src/API/admin-calls.ts +8 -0
- package/src/API/ai-calls.ts +48 -0
- package/src/API/brotherhoodCalls.ts +184 -0
- package/src/API/callLifiAPI.ts +41 -0
- package/src/API/callMonitor.ts +9 -0
- package/src/API/callOdosAPI.ts +89 -0
- package/src/API/callOneInchAPI.ts +47 -0
- package/src/API/callRelayer.ts +23 -0
- package/src/API/checkRisk.ts +7 -0
- package/src/API/duneAPI.ts +26 -0
- package/src/API/enclaveCalls.ts +23 -0
- package/src/API/fetchCommitmentsCache.ts +63 -0
- package/src/API/generate-trading-points.ts +77 -0
- package/src/API/get-token-data.ts +12 -0
- package/src/API/getBridgeProtocols.ts +16 -0
- package/src/API/getCoingeckoPrice.ts +59 -0
- package/src/API/getGasEstimates.ts +30 -0
- package/src/API/getLifiStatus.ts +35 -0
- package/src/API/getRelayerURL.ts +27 -0
- package/src/API/getServerURL.ts +116 -0
- package/src/API/getTokenPrice.ts +39 -0
- package/src/API/getWebsiteURL.ts +58 -0
- package/src/API/index.ts +19 -0
- package/src/API/is-tx-stateless.ts +32 -0
- package/src/API/kycCalls.ts +81 -0
- package/src/API/leaderboardCalls.ts +32 -0
- package/src/API/mysteryBoxesCalls.ts +141 -0
- package/src/API/passwordCalls.ts +34 -0
- package/src/API/proxyAccountsCalls.ts +40 -0
- package/src/API/referralsCalls.ts +52 -0
- package/src/API/relayCalls.ts +14 -0
- package/src/API/restoreSnapshots.ts +7 -0
- package/src/API/rewardsUserCalls.ts +124 -0
- package/src/API/send-telegram-callback.ts +17 -0
- package/src/API/simulate-batch-tx.ts +19 -0
- package/src/API/tenderly.api.ts +96 -0
- package/src/API/token-calls.ts +19 -0
- package/src/API/weeklyAnalyticCalls.ts +43 -0
- package/src/constants/activity.constants.ts +10 -0
- package/src/constants/addresses.constants.ts +74 -0
- package/src/constants/assets.constants.ts +15 -0
- package/src/constants/backend.constants.ts +16 -0
- package/src/constants/balance.constants.ts +1 -0
- package/src/constants/bridging.constants.ts +5 -0
- package/src/constants/chains.constants.ts +194 -0
- package/src/constants/coingecko.constants.ts +67 -0
- package/src/constants/contracts.constants.ts +106 -0
- package/src/constants/conversion.constants.ts +1 -0
- package/src/constants/deploy-data/deploy-data-arbMainnet.json +5685 -0
- package/src/constants/deploy-data/deploy-data-arcTestnet.json +6157 -0
- package/src/constants/deploy-data/deploy-data-avalanche.json +5921 -0
- package/src/constants/deploy-data/deploy-data-base.json +5695 -0
- package/src/constants/deploy-data/deploy-data-bnbMainnet.json +5921 -0
- package/src/constants/deploy-data/deploy-data-ethMainnet.json +5922 -0
- package/src/constants/deploy-data/deploy-data-localhost.json +5921 -0
- package/src/constants/deploy-data/deploy-data-optimism.json +5687 -0
- package/src/constants/deploy-data/deploy-data-polygon.json +5695 -0
- package/src/constants/deploy-data/index.ts +21 -0
- package/src/constants/events.constants.ts +10 -0
- package/src/constants/fees.constants.ts +4 -0
- package/src/constants/function-signatures.constants.ts +6 -0
- package/src/constants/index.ts +30 -0
- package/src/constants/kyc.constants.ts +202 -0
- package/src/constants/lifi.constants.ts +1 -0
- package/src/constants/mediaUrls.constants.ts +25 -0
- package/src/constants/mystery-boxes.constants.ts +402 -0
- package/src/constants/oauthUrls.constants.ts +7 -0
- package/src/constants/permit2.constants.ts +28 -0
- package/src/constants/presale.constants.ts +503 -0
- package/src/constants/protocol.constants.ts +65 -0
- package/src/constants/reorg-depths.constants.ts +13 -0
- package/src/constants/rewards.constants.ts +27 -0
- package/src/constants/save-depths.ts +13 -0
- package/src/constants/server.constants.ts +233 -0
- package/src/constants/tasks.constants.ts +205 -0
- package/src/constants/token-data/ERC20Registry.ts +90 -0
- package/src/constants/token-data/arbMainnetRegistry.json +1841 -0
- package/src/constants/token-data/arbMainnetRegistryFixed.json +1841 -0
- package/src/constants/token-data/arcTestnetRegistry.json +436 -0
- package/src/constants/token-data/avalancheRegistry.json +729 -0
- package/src/constants/token-data/avalancheRegistryFixed.json +729 -0
- package/src/constants/token-data/baseRegistry.json +1134 -0
- package/src/constants/token-data/baseRegistryFixed.json +1134 -0
- package/src/constants/token-data/bnbMainnetRegistry.json +900 -0
- package/src/constants/token-data/bnbMainnetRegistryFixed.json +900 -0
- package/src/constants/token-data/ethMainnetRegistry.json +4298 -0
- package/src/constants/token-data/ethMainnetRegistryFixed.json +4298 -0
- package/src/constants/token-data/index.ts +60 -0
- package/src/constants/token-data/localhostRegistry.json +2784 -0
- package/src/constants/token-data/optimismRegistry.json +701 -0
- package/src/constants/token-data/optimismRegistryFixed.json +701 -0
- package/src/constants/token-data/polygonRegistry.json +2309 -0
- package/src/constants/token-data/polygonRegistryFixed.json +2309 -0
- package/src/constants/token-data/popularTokens.constants.ts +11 -0
- package/src/constants/token-data/tokenPricing.consts.ts +2 -0
- package/src/constants/token.limits.constants.ts +31 -0
- package/src/constants/vite.constants.ts +74 -0
- package/src/constants/wallet.constants.ts +9 -0
- package/src/crypto/babyJub.ts +31 -0
- package/src/crypto/index.ts +3 -0
- package/src/crypto/poseidon.ts +36 -0
- package/src/crypto/preProcessing.ts +20 -0
- package/src/data-structures/ApprovalDBs/EventsPublicApprovalsDB.ts +288 -0
- package/src/data-structures/ApprovalDBs/index.ts +1 -0
- package/src/data-structures/Hinkal/Hinkal.ts +746 -0
- package/src/data-structures/Hinkal/IHinkal.ts +315 -0
- package/src/data-structures/Hinkal/handleAutoDepositBack.ts +138 -0
- package/src/data-structures/Hinkal/hinkalActionFundApproveAndTransact.ts +64 -0
- package/src/data-structures/Hinkal/hinkalActionReceive.ts +65 -0
- package/src/data-structures/Hinkal/hinkalActionStake.ts +152 -0
- package/src/data-structures/Hinkal/hinkalApprove.ts +170 -0
- package/src/data-structures/Hinkal/hinkalCheckTokenRegistry.ts +26 -0
- package/src/data-structures/Hinkal/hinkalDeposit.ts +199 -0
- package/src/data-structures/Hinkal/hinkalGetRecipientInfo.ts +12 -0
- package/src/data-structures/Hinkal/hinkalGetZkMeProvider.ts +31 -0
- package/src/data-structures/Hinkal/hinkalInsideTransact.ts +190 -0
- package/src/data-structures/Hinkal/hinkalMultiSend.ts +26 -0
- package/src/data-structures/Hinkal/hinkalPrivateWallet.ts +198 -0
- package/src/data-structures/Hinkal/hinkalProoflessDeposit.ts +91 -0
- package/src/data-structures/Hinkal/hinkalProxySwap.ts +91 -0
- package/src/data-structures/Hinkal/hinkalSignSubAccount.ts +28 -0
- package/src/data-structures/Hinkal/hinkalSwap.ts +157 -0
- package/src/data-structures/Hinkal/hinkalTransfer.ts +171 -0
- package/src/data-structures/Hinkal/hinkalWithdraw.ts +161 -0
- package/src/data-structures/Hinkal/index.ts +9 -0
- package/src/data-structures/Hinkal/resetMerkleTrees.ts +64 -0
- package/src/data-structures/IndexedDB/activity-db.ts +204 -0
- package/src/data-structures/IndexedDB/balances-db.ts +97 -0
- package/src/data-structures/IndexedDB/contact-db.ts +81 -0
- package/src/data-structures/IndexedDB/index.ts +6 -0
- package/src/data-structures/IndexedDB/prices-db.ts +89 -0
- package/src/data-structures/IndexedDB/private-balances-db.ts +31 -0
- package/src/data-structures/IndexedDB/signatures-db.ts +62 -0
- package/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.ts +152 -0
- package/src/data-structures/TokenDBs/AlchemyPublicTokensDB.ts +224 -0
- package/src/data-structures/TokenDBs/ArcPublicTokensDB.ts +198 -0
- package/src/data-structures/TokenDBs/EventsPublicTokensDB.ts +216 -0
- package/src/data-structures/TokenDBs/IPublicTokensDB.ts +7 -0
- package/src/data-structures/TokenDBs/PrivateTokensDB.ts +96 -0
- package/src/data-structures/TokenDBs/PublicTokensDB.ts +49 -0
- package/src/data-structures/TokenDBs/index.ts +4 -0
- package/src/data-structures/TokenDBs/token-visibility-db.ts +154 -0
- package/src/data-structures/ValueCache/ValueCache.ts +29 -0
- package/src/data-structures/ValueCache/index.ts +1 -0
- package/src/data-structures/cacheDevices/AttachableMemoryCacheDevice.ts +33 -0
- package/src/data-structures/cacheDevices/BaseCacheDevice.ts +30 -0
- package/src/data-structures/cacheDevices/FileCacheDevice.ts +59 -0
- package/src/data-structures/cacheDevices/LocalStorageCacheDevice.ts +36 -0
- package/src/data-structures/cacheDevices/index.ts +2 -0
- package/src/data-structures/crypto-keys/decodeUTXO.ts +60 -0
- package/src/data-structures/crypto-keys/encryptDecryptUtxo.ts +74 -0
- package/src/data-structures/crypto-keys/index.ts +4 -0
- package/src/data-structures/crypto-keys/keyUtils.ts +8 -0
- package/src/data-structures/crypto-keys/keys.ts +203 -0
- package/src/data-structures/custom-token-registry/CustomTokenRegistry.ts +49 -0
- package/src/data-structures/event-service/AbstractAccessTokenSnapshotService.ts +142 -0
- package/src/data-structures/event-service/AbstractApprovalsSnapshotService.ts +152 -0
- package/src/data-structures/event-service/AbstractCommitmentsSnapshotService.ts +116 -0
- package/src/data-structures/event-service/AbstractEventService.ts +44 -0
- package/src/data-structures/event-service/AbstractNullifierSnapshotService.ts +76 -0
- package/src/data-structures/event-service/AbstractSnapshotService.ts +63 -0
- package/src/data-structures/event-service/BlockchainEventEmitter.ts +132 -0
- package/src/data-structures/event-service/index.ts +7 -0
- package/src/data-structures/index.ts +18 -0
- package/src/data-structures/merkle-tree/MerkleTree.test.ts +77 -0
- package/src/data-structures/merkle-tree/MerkleTree.ts +253 -0
- package/src/data-structures/merkle-tree/MerkleTreeIncompleteError.ts +6 -0
- package/src/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.ts +24 -0
- package/src/data-structures/merkle-tree/index.ts +3 -0
- package/src/data-structures/presale/PresaleContractWrapper.ts +80 -0
- package/src/data-structures/presale/index.ts +1 -0
- package/src/data-structures/provider-adapter/IProviderAdapter.ts +43 -0
- package/src/data-structures/snapshot/ClientAccessTokenSnapshotService.ts +41 -0
- package/src/data-structures/snapshot/ClientApprovalsSnapshotService.ts +36 -0
- package/src/data-structures/snapshot/ClientCommitmentsSnapshotService.ts +30 -0
- package/src/data-structures/snapshot/ClientNullifierSnapshotService.ts +28 -0
- package/src/data-structures/snapshot/SnapshotFetcherService.ts +68 -0
- package/src/data-structures/snapshot/index.ts +1 -0
- package/src/data-structures/token-price-fetcher/TokenChecker.ts +45 -0
- package/src/data-structures/token-price-fetcher/index.ts +1 -0
- package/src/data-structures/tor/HttpClient.ts +118 -0
- package/src/data-structures/tor/TorAdapter.ts +94 -0
- package/src/data-structures/tor/TorClient.ts +283 -0
- package/src/data-structures/tor/WebSocketDuplex.ts +32 -0
- package/src/data-structures/tor/index.ts +3 -0
- package/src/data-structures/transactions-manager/history/history.types.ts +14 -0
- package/src/data-structures/transactions-manager/index.ts +1 -0
- package/src/data-structures/utxo/Utxo.ts +189 -0
- package/src/error-handling/customErrors/ErrorWithAmount.ts +8 -0
- package/src/error-handling/customErrors/ErrorWithTx.ts +10 -0
- package/src/error-handling/customErrors/FeeOverTransactionValueError.ts +16 -0
- package/src/error-handling/customErrors/SimulationFailureError.ts +9 -0
- package/src/error-handling/customErrors/customErrors.helpers.ts +39 -0
- package/src/error-handling/customErrors/index.ts +5 -0
- package/src/error-handling/error-codes.constants.ts +214 -0
- package/src/error-handling/get-error.message.ts +149 -0
- package/src/error-handling/handleErrorRestore.ts +25 -0
- package/src/error-handling/index.ts +7 -0
- package/src/error-handling/logError.ts +8 -0
- package/src/error-handling/logger.ts +21 -0
- package/src/error-handling/types.ts +10 -0
- package/src/externalABIs/BUSD.ts +516 -0
- package/src/externalABIs/BabPassport.json +24 -0
- package/src/externalABIs/DAI.ts +331 -0
- package/src/externalABIs/ERC1155.json +316 -0
- package/src/externalABIs/ERC20.json +297 -0
- package/src/externalABIs/ERC20.ts +1 -0
- package/src/externalABIs/ERC721.json +205 -0
- package/src/externalABIs/GalxePassport.json +23 -0
- package/src/externalABIs/IQuoterV2.json +211 -0
- package/src/externalABIs/ISwapRouter.json +568 -0
- package/src/externalABIs/IUniswapV3Factory.json +207 -0
- package/src/externalABIs/IUniswapV3Pool.json +999 -0
- package/src/externalABIs/NodeInterfaceABI.json +1 -0
- package/src/externalABIs/OptimismGasPriceOracle.json +1 -0
- package/src/externalABIs/PoLidoNftAbi.json +307 -0
- package/src/externalABIs/SanctionsList.ts +86 -0
- package/src/externalABIs/USDC.ts +718 -0
- package/src/externalABIs/USDR.ts +343 -0
- package/src/externalABIs/USDR3CRV.ts +539 -0
- package/src/externalABIs/USDT.ts +390 -0
- package/src/externalABIs/UniswapV2PoolAbi.json +66 -0
- package/src/externalABIs/WETH.ts +153 -0
- package/src/externalABIs/amToken.ts +347 -0
- package/src/externalABIs/index.ts +53 -0
- package/src/externalABIs/swapAbi.ts +442 -0
- package/src/externalABIs/transactionsProver.json +45 -0
- package/src/functions/index.ts +16 -0
- package/src/functions/kyc/aiPriseHelper.ts +0 -0
- package/src/functions/kyc/authentoHelper.ts +44 -0
- package/src/functions/kyc/index.ts +3 -0
- package/src/functions/kyc/openDefaultPassportWindow.ts +9 -0
- package/src/functions/kyc/passportHelper.ts +13 -0
- package/src/functions/kyc/zkMeHelper.ts +69 -0
- package/src/functions/pre-transaction/constructAdminData.ts +21 -0
- package/src/functions/pre-transaction/getExternalSwapAddress.ts +30 -0
- package/src/functions/pre-transaction/getFeeStructure.ts +44 -0
- package/src/functions/pre-transaction/getFlatFees.ts +88 -0
- package/src/functions/pre-transaction/getSignatureDataForTransact.ts +16 -0
- package/src/functions/pre-transaction/getVolatileTransferAmount.ts +56 -0
- package/src/functions/pre-transaction/index.ts +7 -0
- package/src/functions/pre-transaction/interaction-to-action.ts +17 -0
- package/src/functions/pre-transaction/merge-with-fee-structure-emporium.ts +50 -0
- package/src/functions/pre-transaction/merge-with-fee-structure.ts +35 -0
- package/src/functions/pre-transaction/outputApprovalDataProcessing.ts +95 -0
- package/src/functions/pre-transaction/outputUtxoProcessing.ts +52 -0
- package/src/functions/pre-transaction/process-gas-estimates.ts +36 -0
- package/src/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.ts +15 -0
- package/src/functions/private-wallet/emporium.helpers.ts +296 -0
- package/src/functions/private-wallet/emporium.swap.helpers.ts +284 -0
- package/src/functions/private-wallet/index.ts +3 -0
- package/src/functions/private-wallet/opProducer.ts +33 -0
- package/src/functions/snarkjs/common.snarkjs.ts +377 -0
- package/src/functions/snarkjs/constant.ts +490 -0
- package/src/functions/snarkjs/constructEmporiumProof.ts +301 -0
- package/src/functions/snarkjs/constructGeneralZkProof.ts +281 -0
- package/src/functions/snarkjs/generateCircomData.ts +81 -0
- package/src/functions/snarkjs/generateZkProof.ts +21 -0
- package/src/functions/snarkjs/generateZkProofEnclave.ts +45 -0
- package/src/functions/snarkjs/generateZkProofSelf.ts +29 -0
- package/src/functions/snarkjs/getOriginalSender.ts +4 -0
- package/src/functions/snarkjs/getZKFiles.ts +29 -0
- package/src/functions/snarkjs/index.ts +4 -0
- package/src/functions/staking/index.ts +78 -0
- package/src/functions/utils/addresses.ts +37 -0
- package/src/functions/utils/amounts.utils.test.ts +91 -0
- package/src/functions/utils/amounts.utils.ts +119 -0
- package/src/functions/utils/arraysMatch.ts +4 -0
- package/src/functions/utils/cacheDevice.utils.ts +21 -0
- package/src/functions/utils/cacheFunctions.ts +154 -0
- package/src/functions/utils/caseInsensitive.utils.ts +10 -0
- package/src/functions/utils/convertEmporiumOpToCallInfo.ts +19 -0
- package/src/functions/utils/convertIntegrationProviderToExternalActionId.ts +14 -0
- package/src/functions/utils/create-provider.ts +11 -0
- package/src/functions/utils/encodeTokenWithId.ts +4 -0
- package/src/functions/utils/encryptInputForEnclave.ts +119 -0
- package/src/functions/utils/enum.utils.ts +30 -0
- package/src/functions/utils/erc20tokenFunctions.ts +110 -0
- package/src/functions/utils/ethers-formatter.utils.ts +32 -0
- package/src/functions/utils/evmNetworkFunctions.ts +9 -0
- package/src/functions/utils/external-action.utils.ts +15 -0
- package/src/functions/utils/fees.utils.ts +26 -0
- package/src/functions/utils/get-hinkal-approvals.ts +36 -0
- package/src/functions/utils/get-signature-header.ts +5 -0
- package/src/functions/utils/getBlockExplorerUrl.ts +14 -0
- package/src/functions/utils/getDataFromTransaction.ts +79 -0
- package/src/functions/utils/getRecipientInfoFromUserKeys.ts +28 -0
- package/src/functions/utils/inLogicMetadata.ts +9 -0
- package/src/functions/utils/index.ts +43 -0
- package/src/functions/utils/involves-permit2-op.ts +17 -0
- package/src/functions/utils/ipfs.ts +74 -0
- package/src/functions/utils/is-valid-url.ts +5 -0
- package/src/functions/utils/lifi.utils.ts +3 -0
- package/src/functions/utils/memoize.utils.ts +23 -0
- package/src/functions/utils/merkleTree.utils.ts +27 -0
- package/src/functions/utils/mutexes.utils.ts +3 -0
- package/src/functions/utils/mystery-box-auction.utils.ts +61 -0
- package/src/functions/utils/networks.utils.ts +6 -0
- package/src/functions/utils/nftTokenFunctions.ts +25 -0
- package/src/functions/utils/nickname.utils.ts +4 -0
- package/src/functions/utils/postToOffscreen.ts +6 -0
- package/src/functions/utils/prepareHinkal.ts +78 -0
- package/src/functions/utils/process.utils.ts +23 -0
- package/src/functions/utils/processUseApprovalUtxoData.ts +26 -0
- package/src/functions/utils/publicBalance.utils.ts +131 -0
- package/src/functions/utils/reloadPage.ts +1 -0
- package/src/functions/utils/replaceAddressInCalldata.ts +6 -0
- package/src/functions/utils/requireEnv.ts +10 -0
- package/src/functions/utils/resolve-sync.utils.ts +40 -0
- package/src/functions/utils/rpc-int-encode.ts +7 -0
- package/src/functions/utils/serialize.utils.ts +12 -0
- package/src/functions/utils/string.utils.ts +92 -0
- package/src/functions/utils/time.utils.ts +80 -0
- package/src/functions/utils/token-check.utils.ts +12 -0
- package/src/functions/utils/trimFieldValues.ts +24 -0
- package/src/functions/utils/upToDateState.ts +12 -0
- package/src/functions/utils/userAgent.ts +26 -0
- package/src/functions/utils/walletBalances.utils.ts +117 -0
- package/src/functions/web3/EIP-712.test.ts +302 -0
- package/src/functions/web3/EIP-712.ts +243 -0
- package/src/functions/web3/etherFunctions.test.ts +129 -0
- package/src/functions/web3/etherFunctions.ts +84 -0
- package/src/functions/web3/events/balanceChangedCustomHandler.ts +13 -0
- package/src/functions/web3/events/balanceChangedHandler.ts +10 -0
- package/src/functions/web3/events/getApprovedBalance.ts +154 -0
- package/src/functions/web3/events/getInputUtxoAndBalance.ts +305 -0
- package/src/functions/web3/events/getInputUtxosEnclave.ts +40 -0
- package/src/functions/web3/events/getShieldedBalance.ts +163 -0
- package/src/functions/web3/events/getTransactionLogEvents.ts +55 -0
- package/src/functions/web3/events/index.ts +7 -0
- package/src/functions/web3/events/web3RetrieveEvents.ts +33 -0
- package/src/functions/web3/functionCalls/accessTokenCalls.ts +27 -0
- package/src/functions/web3/functionCalls/approveToken.ts +180 -0
- package/src/functions/web3/functionCalls/approveTokensToHinkal.ts +21 -0
- package/src/functions/web3/functionCalls/estimateGasRelayer.ts +40 -0
- package/src/functions/web3/functionCalls/getRootHash.ts +7 -0
- package/src/functions/web3/functionCalls/inHinkalApprovalCalls.ts +60 -0
- package/src/functions/web3/functionCalls/relayFunctions.ts +12 -0
- package/src/functions/web3/functionCalls/transactCallDirect.ts +71 -0
- package/src/functions/web3/functionCalls/transactCallRelayer.ts +57 -0
- package/src/functions/web3/getContractMetadata.ts +43 -0
- package/src/functions/web3/getPublicAddressBalance.ts +17 -0
- package/src/functions/web3/getTokenHolder.ts +53 -0
- package/src/functions/web3/index.ts +9 -0
- package/src/functions/web3/lifiAPI.ts +41 -0
- package/src/functions/web3/odosAPI.ts +50 -0
- package/src/functions/web3/oneInchAPI.ts +47 -0
- package/src/functions/web3/runContractFunction.ts +116 -0
- package/src/functions/web3/uniswapAPI.ts +156 -0
- package/src/index.ts +9 -0
- package/src/mutexes/index.ts +1 -0
- package/src/mutexes/mutex.ts +3 -0
- package/src/providers/EthersProviderAdapter.ts +230 -0
- package/src/providers/TorExternalProvider.ts +36 -0
- package/src/providers/WagmiProviderAdapter.ts +311 -0
- package/src/providers/exportProviers.ts +11 -0
- package/src/providers/prepareEthersHinkal.ts +18 -0
- package/src/providers/prepareWagmiHinkal.ts +16 -0
- package/src/types/API.types.ts +23 -0
- package/src/types/ICacheDevice.ts +5 -0
- package/src/types/IMultiThreadedUtxoUtils.ts +16 -0
- package/src/types/RewardUserEnums.ts +12 -0
- package/src/types/TransactionSimulator.types.ts +30 -0
- package/src/types/WeeklyAnalytics.types.ts +44 -0
- package/src/types/activities.types.ts +90 -0
- package/src/types/admin.types.ts +30 -0
- package/src/types/all-points.types.ts +8 -0
- package/src/types/approvals.types.ts +45 -0
- package/src/types/balances.types.ts +20 -0
- package/src/types/big-intable.types.ts +3 -0
- package/src/types/bridging.types.ts +30 -0
- package/src/types/brotherhood-user.types.ts +13 -0
- package/src/types/cache.types.ts +42 -0
- package/src/types/circom-data.types.ts +120 -0
- package/src/types/coingecko.types.ts +216 -0
- package/src/types/commitments.types.ts +39 -0
- package/src/types/confirmation-request.types.ts +10 -0
- package/src/types/contacts.types.ts +6 -0
- package/src/types/crypto.types.ts +8 -0
- package/src/types/duneAPI.types.ts +9 -0
- package/src/types/eip5792.types.ts +31 -0
- package/src/types/ethereum-network.types.ts +70 -0
- package/src/types/external-action.types.ts +19 -0
- package/src/types/fee.types.ts +11 -0
- package/src/types/generatePoints.ts +14 -0
- package/src/types/hinkal.stake.types.ts +12 -0
- package/src/types/hinkal.types.ts +150 -0
- package/src/types/index.ts +50 -0
- package/src/types/kyc.types.ts +49 -0
- package/src/types/merch-order.types.ts +18 -0
- package/src/types/message.types.ts +6 -0
- package/src/types/mystery-boxes.types.ts +50 -0
- package/src/types/new-rewards.type.ts +181 -0
- package/src/types/offscreen.types.ts +8 -0
- package/src/types/presaleReferral.types.ts +4 -0
- package/src/types/proxy.types.ts +11 -0
- package/src/types/referral.types.ts +13 -0
- package/src/types/relayer.types.ts +16 -0
- package/src/types/remote-proof.types.ts +18 -0
- package/src/types/rewards.types.ts +53 -0
- package/src/types/routing.types.ts +7 -0
- package/src/types/sandbox.types.ts +246 -0
- package/src/types/session.types.ts +12 -0
- package/src/types/signature.types.ts +11 -0
- package/src/types/slippage.types.ts +3 -0
- package/src/types/snark.types.ts +43 -0
- package/src/types/tenderly.api.types.ts +200 -0
- package/src/types/token-prices.types.ts +8 -0
- package/src/types/token-with-id.types.ts +4 -0
- package/src/types/token.types.ts +86 -0
- package/src/types/transactions.types.ts +120 -0
- package/src/types/wc.types.ts +83 -0
- package/src/types/with-id.types.ts +1 -0
- package/src/webworker/performTaskWithWorker.ts +50 -0
- package/src/webworker/snarkjsWorker/snarkjs.d.ts +2 -0
- package/src/webworker/snarkjsWorker/snarkjsWorker.types.ts +18 -0
- package/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts +19 -0
- package/src/webworker/snarkjsWorker/snarkjsWorkerLogic.ts +90 -0
- package/src/webworker/utxoWorker/utxoWorker.types.ts +41 -0
- package/src/webworker/utxoWorker/utxoWorkerLauncher.ts +19 -0
- package/src/webworker/utxoWorker/utxoWorkerLogic.ts +107 -0
- package/src/webworker/viteWorkerURL.constant.ts +25 -0
- package/src/webworker/worker.registry.ts +11 -0
- package/src/webworker/worker.types.ts +35 -0
- package/src/webworker/workerErrorHandler.ts +10 -0
- package/src/webworker/workerFactory.ts +47 -0
- package/src/webworker/workerProxy.ts +88 -0
- package/src/webworker/zkProofWorker/zkProofWorker.types.ts +52 -0
- package/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts +19 -0
- package/src/webworker/zkProofWorker/zkProofWorkerLogic.ts +84 -0
- package/tsconfig.json +23 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +15 -0
- package/vite.config.ts +97 -0
- package/vite.config.workers.ts +51 -0
package/.env.example
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Hinkal SDK
|
|
2
|
+
|
|
3
|
+
Hinkal is middleware and a set of smart contracts on EVM chains that use ZK-proofs and stealth addresses to enable compliant and private transactions on major dApps. Users can privately store assets and transact on platforms such as Uniswap, Pendle, Lido, Curve, and others.
|
|
4
|
+
|
|
5
|
+
This SDK enables users to perform arbitrary smart contract interactions privately.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Using npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @hinkal/common
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or, yarn:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
yarn add @hinkal/common
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
#### Initialization
|
|
24
|
+
|
|
25
|
+
To get started with Hinkal, initialize it based on the Web3 connection library you’re using:
|
|
26
|
+
|
|
27
|
+
**ethers.js:**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { prepareEthersHinkal } from '@hinkal/common/providers/prepareEthersHinkal';
|
|
31
|
+
// signer: ethers.Signer
|
|
32
|
+
const hinkal = await prepareEthersHinkal(signer);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**wagmi:**
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { prepareWagmiHinkal } from '@hinkal/common/providers/prepareWagmiHinkal';
|
|
39
|
+
// connector: wagmi.Connector
|
|
40
|
+
// config: wagmi.Config
|
|
41
|
+
const hinkal = await prepareWagmiHinkal(connector, config);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Shielded balance
|
|
45
|
+
|
|
46
|
+
Once the Hinkal object is initialized, shielded balances become accessible and can be calculated as needed:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const balances = await hinkal.getBalances();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### Depositing funds to the shielded balance
|
|
53
|
+
|
|
54
|
+
A user can deposit funds to their shielded address using:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
function deposit(erc20addresses: string[], amountChanges: bigint[]): Promise<TransactionObject>;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
where erc20Addresses is an array of token addresses, and amountChanges represents the token amounts for the deposit.
|
|
61
|
+
|
|
62
|
+
#### Interacting with smart contracts privately
|
|
63
|
+
|
|
64
|
+
After a user’s shielded balance is updated, they can perform any smart contract interaction privately using:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
function actionPrivateWallet(
|
|
68
|
+
erc20Addresses: string[],
|
|
69
|
+
amountChanges: bigint[],
|
|
70
|
+
onChainCreation: boolean[],
|
|
71
|
+
ops: string[],
|
|
72
|
+
): Promise<TransactionObject>;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
where onChainCreation indicates the amounts of tokens that are uncertain before the transaction is executed on-chain. The ops array contains encoded user operations.
|
|
76
|
+
|
|
77
|
+
##### User operations
|
|
78
|
+
|
|
79
|
+
To generate user operations (`ops`) you will need the `emporiumOp` function.
|
|
80
|
+
```typescript
|
|
81
|
+
import {emporiumOp} from "@hinkal/common";
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The function accepts the following arguments:
|
|
85
|
+
1. `endpoint` *(required)* - target address or contract instance (with address). The contract instance will be used to properly encode the call function, if any, in the custom operation.
|
|
86
|
+
2. `func` *(optional)* - the name of the function to be called on the target address.
|
|
87
|
+
3. `args` *(optional)* - arguments of the function to be called on the target address.
|
|
88
|
+
4. `invokeWallet` *(optional)* - bool flag that determines the type of transaction. There are two types: stateful and stateless interaction. The default is false (stateless).
|
|
89
|
+
5. `value` *(optional)* - the amount of native currency to transfer to the target address.
|
|
90
|
+
|
|
91
|
+
The `emporiumOp` function will generate data for subsequent calls, supporting both stateful interaction (with state preservation) and stateless interaction (without state preservation). This is determined by the `invokeWallet` flag.
|
|
92
|
+
|
|
93
|
+
To execute on a smart contract, the user operation will be received in the following format:
|
|
94
|
+
```solidity
|
|
95
|
+
(address endpoint, bool invokeWallet, uint256 value, bytes data)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This will make it possible to make that kind of call:
|
|
99
|
+
```solidity
|
|
100
|
+
(bool success, bytes memory err) = endpoint.call{value: value}(data);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
##### Stateless and stateful
|
|
104
|
+
|
|
105
|
+
The best way to demonstrate how this works is with an example.
|
|
106
|
+
|
|
107
|
+
**Stateless interaction**
|
|
108
|
+
|
|
109
|
+
Let's say we need to exchange USDC for ETH using DEX.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const operations = [
|
|
113
|
+
emporiumOp(usdcContractInstance, 'approve', [swapRouterAddress, amountIn]),
|
|
114
|
+
emporiumOp(swapRouterContractInstance, 'exactInputSingle', [swapSingleParams]),
|
|
115
|
+
emporiumOp(wethContractInstance, 'withdraw', [amountOut]),
|
|
116
|
+
];
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
To perform a DEX swap, DEX does not need to know historical data about the calling party (e.g. when and what swaps have been performed from this account in the past). It only needs the current token balance for the exchange.
|
|
120
|
+
|
|
121
|
+
In this case it will be **stateless interaction**, so there is no need to change the default value of the `invokeWallet` flag.
|
|
122
|
+
|
|
123
|
+
**Stateful interaction**
|
|
124
|
+
|
|
125
|
+
Another example is when the protocol with which an account interacts needs to know what actions this account has done before, for example, to gain rewards. In this case, some account state will be required.
|
|
126
|
+
|
|
127
|
+
Let's imagine that you already have Curve LP tokens and need to make a stake.
|
|
128
|
+
|
|
129
|
+
```solidity
|
|
130
|
+
const operations = [
|
|
131
|
+
emporiumOp(lpTokenInstance, 'approve', [gaugeAddressInstance, amount]), // without flag, because is's stateless interaction
|
|
132
|
+
emporiumOp(gaugeAddressInstance, 'deposit', [amount, invokeWalletAddress], true), // with flag, because it's stateful interaction
|
|
133
|
+
];
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
As you can see, in this case `approve` is a stateless interaction, but `deposit` is a stateful interaction, because under the hood Curve will record this address and timestamp in order to calculate the checkpoint correctly in the future.
|
|
137
|
+
|
|
138
|
+
### Access Tokens
|
|
139
|
+
|
|
140
|
+
Before interacting with Hinkal smart contracts, users need to mint an access token after passing compliance checks.
|
|
141
|
+
|
|
142
|
+
To check whether a user already has an access token, use the checkAccessToken function:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
function checkAccessToken(): Promise<boolean>;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If the user does not have an access token, they must use one of the compliance providers to pass the check. To view the available providers:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
function getSupportedPassportLinks(): string[];
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
After passing the compliance check, the user can mint an access token using:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
const { signatureData } = await hinkal.getAPI().getAccessTokenSignature(chainId, ethereumAddress, accessKey);
|
|
158
|
+
await mintAccessToken(this, signatureData);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### References
|
|
162
|
+
|
|
163
|
+
Application: [Hinkal](https://app.hinkal.pro)
|
|
164
|
+
Docs: [Hinkal Documentation](https://hinkal-team.gitbook.io/hinkal)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
// Function to increment the version number
|
|
6
|
+
const incrementVersion = (version) => {
|
|
7
|
+
const versionParts = version.split('.').map(Number); // Split version into [major, minor, patch]
|
|
8
|
+
if (versionParts.length === 3) {
|
|
9
|
+
versionParts[2] += 1; // Increment the patch version
|
|
10
|
+
return versionParts.join('.'); // Return the updated version as a string
|
|
11
|
+
} else {
|
|
12
|
+
throw new Error('Invalid version format in package.json');
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const destPath = '../../../dist/libs/shared/common';
|
|
17
|
+
|
|
18
|
+
const emptyWorkerAssets = () => {
|
|
19
|
+
const workersAssetsPath = path.join(path.join(__dirname, destPath), 'assets');
|
|
20
|
+
const files = fs.readdirSync(workersAssetsPath);
|
|
21
|
+
files.forEach((file) => {
|
|
22
|
+
const filePath = path.join(workersAssetsPath, file);
|
|
23
|
+
fs.unlinkSync(filePath);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const copyWorkers = () => {
|
|
28
|
+
const prebuildWorkerPath = '../../../dist/libs/shared/workers-prebuild';
|
|
29
|
+
const destWorkerPath = destPath + '/webworker';
|
|
30
|
+
|
|
31
|
+
const preBuildWorkersCjs = path.join(path.join(__dirname, prebuildWorkerPath), 'viteWorkerURL.constant.common.js');
|
|
32
|
+
const cjsWorkers = path.join(path.join(__dirname, destWorkerPath), 'viteWorkerURL.constant.cjs');
|
|
33
|
+
fs.copyFileSync(preBuildWorkersCjs, cjsWorkers);
|
|
34
|
+
|
|
35
|
+
const preBuildWorkersMjs = path.join(path.join(__dirname, prebuildWorkerPath), 'viteWorkerURL.constant.es.js');
|
|
36
|
+
const mjsWorkers = path.join(path.join(__dirname, destWorkerPath), 'viteWorkerURL.constant.mjs');
|
|
37
|
+
fs.copyFileSync(preBuildWorkersMjs, mjsWorkers);
|
|
38
|
+
emptyWorkerAssets();
|
|
39
|
+
console.log('Copy Prebuilded workers finished');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const copyPackage = () => {
|
|
43
|
+
return;
|
|
44
|
+
const pkgSrc = path.resolve(__dirname, 'package.json');
|
|
45
|
+
const pkgDest = path.resolve(path.join(__dirname, destPath), 'package.json');
|
|
46
|
+
console.log({ pkgSrc, pkgDest });
|
|
47
|
+
|
|
48
|
+
// Read and parse the package.json file
|
|
49
|
+
const packageJson = JSON.parse(fs.readFileSync(pkgSrc, 'utf-8'));
|
|
50
|
+
|
|
51
|
+
// Increment the version in the source folder's package.json
|
|
52
|
+
packageJson.version = incrementVersion(packageJson.version);
|
|
53
|
+
console.log({ version: packageJson.version });
|
|
54
|
+
|
|
55
|
+
// Write the updated package.json back to the source folder
|
|
56
|
+
fs.writeFileSync(pkgSrc, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
57
|
+
|
|
58
|
+
// Modify the "type" field or any other field in package.json
|
|
59
|
+
// packageJson.type = 'module'; // Example: changing type field to 'module'
|
|
60
|
+
|
|
61
|
+
// Ensure the destination directory exists and write the modified package.json to the destination
|
|
62
|
+
fs.mkdirSync(path.dirname(pkgDest), { recursive: true });
|
|
63
|
+
fs.writeFileSync(pkgDest, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
64
|
+
|
|
65
|
+
// Copy Readme
|
|
66
|
+
fs.copyFileSync(path.resolve(__dirname, 'README.md'), path.join(__dirname, `${destPath}/README.md`));
|
|
67
|
+
console.log('Modified and copied package.json to build folder');
|
|
68
|
+
|
|
69
|
+
// Copying Workers
|
|
70
|
+
copyWorkers();
|
|
71
|
+
|
|
72
|
+
// Navigate to the destination directory
|
|
73
|
+
try {
|
|
74
|
+
console.log('Publishing package to npm...');
|
|
75
|
+
// Execute `npm publish` in the destination directory
|
|
76
|
+
execSync('npm publish --access=public', { cwd: path.join(__dirname, destPath), stdio: 'inherit' });
|
|
77
|
+
console.log('Package successfully published to npm.');
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('Failed to publish package:', error.message);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { config } from 'dotenv';
|
|
5
|
+
config();
|
|
6
|
+
|
|
7
|
+
// Function to increment the version number
|
|
8
|
+
const incrementVersion = (version) => {
|
|
9
|
+
const versionParts = version.split('.').map(Number); // Split version into [major, minor, patch]
|
|
10
|
+
if (versionParts.length === 3) {
|
|
11
|
+
versionParts[2] += 1; // Increment the patch version
|
|
12
|
+
return versionParts.join('.'); // Return the updated version as a string
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error('Invalid version format in package.json');
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const requireEnv = (name) => {
|
|
19
|
+
if (!process.env[name]) throw new Error(`${name} environment variable missing`);
|
|
20
|
+
return process.env[name];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const CDN_URL = requireEnv('CLOUDFRONT_URL');
|
|
24
|
+
const s3Bucket = requireEnv('S3_BUCKET');
|
|
25
|
+
const AWS_ACCESS_KEY_ID = requireEnv('AWS_ACCESS_KEY_ID');
|
|
26
|
+
const AWS_SECRET_ACCESS_KEY = requireEnv('AWS_SECRET_ACCESS_KEY');
|
|
27
|
+
const AWS_DEFAULT_REGION = requireEnv('AWS_DEFAULT_REGION');
|
|
28
|
+
const mjsFileToRewrite = 'viteWorkerURL.constant.es.js';
|
|
29
|
+
const cjsFileToRewrite = 'viteWorkerURL.constant.common.js';
|
|
30
|
+
|
|
31
|
+
if (!CDN_URL || !s3Bucket || !AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY || !AWS_DEFAULT_REGION)
|
|
32
|
+
throw new Error('Necessary Environment variable missing');
|
|
33
|
+
|
|
34
|
+
const fileWithCDNWorkersContent = `
|
|
35
|
+
const domain = '${CDN_URL}';
|
|
36
|
+
|
|
37
|
+
// Returns a blob:// URL which points
|
|
38
|
+
// to a javascript file which will call
|
|
39
|
+
// importScripts with the given URL
|
|
40
|
+
async function getWorkerURL(url) {
|
|
41
|
+
const contentRes = await fetch(url);
|
|
42
|
+
const content = await contentRes.text()
|
|
43
|
+
|
|
44
|
+
return URL.createObjectURL(new Blob([content], { type: "application/javascript" }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var e = /* @__PURE__ */ ((r) => (r.ZKProof = "ZKProof", r.SnarkJS = "SnarkJS", r.UTXO = "UTXO", r))(e || {});
|
|
48
|
+
|
|
49
|
+
const n = async () => ({
|
|
50
|
+
[e.ZKProof]: await getWorkerURL(domain + '____folder____' + 'zkProofWorkerLauncher.js'),
|
|
51
|
+
[e.SnarkJS]: await getWorkerURL(domain + '____folder____' + 'snarkjsWorkerLauncher.js'),
|
|
52
|
+
[e.UTXO]: await getWorkerURL(domain + '____folder____' + 'utxoWorkerLauncher.js'),
|
|
53
|
+
});
|
|
54
|
+
export { n as getWorkerViteURL };
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const proccessCDN = () => {
|
|
58
|
+
const pkgSrc = path.resolve(__dirname, 'package.json');
|
|
59
|
+
const destDir = path.resolve(__dirname, '../../../dist/libs/shared/workers-prebuild'); // Adjust if your build output directory is different
|
|
60
|
+
// Read and parse the package.json file
|
|
61
|
+
const packageJson = JSON.parse(fs.readFileSync(pkgSrc, 'utf-8'));
|
|
62
|
+
|
|
63
|
+
// Increment the version in the source folder's package.json
|
|
64
|
+
const version = incrementVersion(packageJson.version);
|
|
65
|
+
|
|
66
|
+
const assets = fs.readdirSync(path.resolve(destDir, './assets'));
|
|
67
|
+
console.log(version, assets);
|
|
68
|
+
const folder = `/workers/${version}/`;
|
|
69
|
+
|
|
70
|
+
fs.mkdirSync(path.join(destDir, `workers`));
|
|
71
|
+
fs.mkdirSync(path.join(path.resolve(destDir, './workers'), `${version}`));
|
|
72
|
+
|
|
73
|
+
// e.g. of filename utxoWorkerLauncher-BEutOJO3.js, so utxoWorkerLauncher-BEutOJO3.js -> utxoWorkerLauncher.js
|
|
74
|
+
const filesDestinations = assets.map((file) => `${folder}${file.split('.')[0].split('-')[0]}.js`);
|
|
75
|
+
|
|
76
|
+
assets.forEach((file, index) => {
|
|
77
|
+
fs.copyFileSync(path.resolve(destDir, `./assets/${file}`), path.resolve(destDir, `.${filesDestinations[index]}`));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
execSync(
|
|
81
|
+
`AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} aws s3 cp ${path.resolve(destDir, `./workers`)} ${s3Bucket} --recursive --acl=public-read`,
|
|
82
|
+
{ cwd: path.dirname(destDir), stdio: 'inherit' },
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const mjsFileContent = fileWithCDNWorkersContent.replaceAll('____folder____', `/${version}/`);
|
|
86
|
+
const cjsFileContent = fileWithCDNWorkersContent
|
|
87
|
+
.replaceAll('____folder____', `/${version}/`)
|
|
88
|
+
.replace('export { n as getWorkerViteURL };', 'exports.getWorkerViteURL = n;');
|
|
89
|
+
|
|
90
|
+
fs.writeFileSync(path.resolve(destDir, mjsFileToRewrite), mjsFileContent);
|
|
91
|
+
fs.writeFileSync(path.resolve(destDir, cjsFileToRewrite), cjsFileContent);
|
|
92
|
+
};
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: 'shared-common',
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
7
|
+
},
|
|
8
|
+
preset: '../../../jest.preset.js',
|
|
9
|
+
coverageDirectory: '.',
|
|
10
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sabaaa1/common",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"homepage": "hinkal.pro",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Hinkal Protocol"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"blockchain",
|
|
10
|
+
"privacy",
|
|
11
|
+
"zero-knowledge",
|
|
12
|
+
"stealth addresses"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"import": "./index.mjs",
|
|
18
|
+
"default": "./index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./providers/EthersProviderAdapter": {
|
|
21
|
+
"types": "./providers/EthersProviderAdapter.d.ts",
|
|
22
|
+
"import": "./providers/EthersProviderAdapter.mjs",
|
|
23
|
+
"default": "./providers/EthersProviderAdapter.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./providers/WagmiProviderAdapter": {
|
|
26
|
+
"types": "./providers/WagmiProviderAdapter.d.ts",
|
|
27
|
+
"import": "./providers/WagmiProviderAdapter.mjs",
|
|
28
|
+
"default": "./providers/WagmiProviderAdapter.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./providers/prepareEthersHinkal": {
|
|
31
|
+
"types": "./providers/prepareEthersHinkal.d.ts",
|
|
32
|
+
"import": "./providers/prepareEthersHinkal.mjs",
|
|
33
|
+
"default": "./providers/prepareEthersHinkal.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./providers/prepareWagmiHinkal": {
|
|
36
|
+
"types": "./providers/prepareWagmiHinkal.d.ts",
|
|
37
|
+
"import": "./providers/prepareWagmiHinkal.mjs",
|
|
38
|
+
"default": "./providers/prepareWagmiHinkal.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"types": "./index.d.ts",
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prebuild": "nx prebuild:workers",
|
|
44
|
+
"build": "nx build",
|
|
45
|
+
"lint": "nx lint",
|
|
46
|
+
"test": "nx test"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"nx": "18.2.1",
|
|
50
|
+
"vite": "5.1.6",
|
|
51
|
+
"vite-plugin-dts": "3.7.3",
|
|
52
|
+
"vite-tsconfig-paths": "^4.3.2"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@brumewallet/wallet.wasm": "1.0.2",
|
|
56
|
+
"@ethersproject/abi": "^5.4.7",
|
|
57
|
+
"@ethersproject/providers": "^5.4.7",
|
|
58
|
+
"@hazae41/base64url": "1.0.17",
|
|
59
|
+
"@hazae41/binary": "1.3.5",
|
|
60
|
+
"@hazae41/bitwise.wasm": "1.0.6",
|
|
61
|
+
"@hazae41/cadenas": "0.4.2",
|
|
62
|
+
"@hazae41/cascade": "2.2.2",
|
|
63
|
+
"@hazae41/chacha20poly1305": "1.0.8",
|
|
64
|
+
"@hazae41/echalote": "0.4.18",
|
|
65
|
+
"@hazae41/ed25519": "2.1.22",
|
|
66
|
+
"@hazae41/fleche": "1.4.5",
|
|
67
|
+
"@hazae41/sha1": "1.1.14",
|
|
68
|
+
"@hazae41/x25519": "2.2.9",
|
|
69
|
+
"@hazae41/x509": "1.2.10",
|
|
70
|
+
"axios": "^1.6.8",
|
|
71
|
+
"async-mutex": "^0.4.0",
|
|
72
|
+
"buffer": "6.0.3",
|
|
73
|
+
"circomlibjs-hinkal-fork": "^0.0.3",
|
|
74
|
+
"dotenv": "^16.4.5",
|
|
75
|
+
"ethers-v6h": "npm:ethers@^6.15.0",
|
|
76
|
+
"idb-keyval": "6.2.1",
|
|
77
|
+
"multiformats": "^9.4.2",
|
|
78
|
+
"snarkjs": "0.7.5",
|
|
79
|
+
"libsodium-wrappers": "^0.7.10",
|
|
80
|
+
"process": "0.11.10",
|
|
81
|
+
"ua-parser-js": "^1.0.37",
|
|
82
|
+
"uuid": "^9.0.1",
|
|
83
|
+
"node-forge": "^1.3.1",
|
|
84
|
+
"vite-plugin-virtual": "^0.3.0",
|
|
85
|
+
"@zkmelabs/widget": "^0.1.2",
|
|
86
|
+
"@openzeppelin/contracts": "^4.8.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"wagmi": "2.13.3",
|
|
90
|
+
"ethers": "5.x",
|
|
91
|
+
"@walletconnect/utils": "^2.17.2"
|
|
92
|
+
},
|
|
93
|
+
"peerDependenciesMeta": {
|
|
94
|
+
"wagmi": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@walletconnect/utils": {
|
|
98
|
+
"optional": true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import virtual from 'vite-plugin-virtual';
|
|
2
|
+
|
|
3
|
+
const workerPolyfillCode = `
|
|
4
|
+
export class Worker {
|
|
5
|
+
postMessage() {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
terminate() {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
onmessage = null;
|
|
12
|
+
};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const polyfillWorker = () => virtual({ workerPolyfillCode });
|
package/project.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shared-common",
|
|
3
|
+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "libs/shared/common/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"prebuild:workers": {
|
|
9
|
+
"command": "vite build --config ./libs/shared/common/vite.config.workers.ts"
|
|
10
|
+
},
|
|
11
|
+
"build": {
|
|
12
|
+
"executor": "@nx/vite:build",
|
|
13
|
+
"outputs": ["{options.outputPath}"],
|
|
14
|
+
"defaultConfiguration": "production",
|
|
15
|
+
"options": {
|
|
16
|
+
"outputPath": "dist/libs/shared/common",
|
|
17
|
+
"skipTypeCheck": true
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"lint": {
|
|
21
|
+
"executor": "@nx/eslint:lint",
|
|
22
|
+
"outputs": ["{options.outputFile}"]
|
|
23
|
+
},
|
|
24
|
+
"test": {
|
|
25
|
+
"executor": "@nx/jest:jest",
|
|
26
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
27
|
+
"options": {
|
|
28
|
+
"jestConfig": "libs/shared/common/jest.config.ts"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|