@gurge/sdk 0.3.13 → 0.3.15
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/README.md +184 -32
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +0 -5
- package/common/src/API/API.mjs +114 -119
- package/common/src/API/TokenCallsCachedHelper.cjs +1 -0
- package/common/src/API/TokenCallsCachedHelper.d.ts +15 -0
- package/common/src/API/TokenCallsCachedHelper.mjs +62 -0
- package/common/src/API/callLifiAPI.cjs +1 -1
- package/common/src/API/callLifiAPI.mjs +2 -7
- package/common/src/API/enclaveUtxoCalls.cjs +1 -1
- package/common/src/API/enclaveUtxoCalls.mjs +6 -7
- package/common/src/API/getServerURL.cjs +1 -1
- package/common/src/API/getServerURL.mjs +2 -2
- package/common/src/API/scheduled-transactions-calls.cjs +1 -1
- package/common/src/API/scheduled-transactions-calls.mjs +3 -3
- package/common/src/API/token-calls.cjs +1 -1
- package/common/src/API/token-calls.d.ts +1 -1
- package/common/src/API/token-calls.mjs +3 -13
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +1 -0
- package/common/src/constants/chains.constants.mjs +3 -2
- package/common/src/constants/deploy-data/mergeDeployData.cjs +1 -1
- package/common/src/constants/deploy-data/mergeDeployData.mjs +11 -10
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +60 -3517
- package/common/src/constants/events.constants.cjs +1 -1
- package/common/src/constants/events.constants.mjs +3 -1
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.d.ts +0 -3
- package/common/src/constants/index.mjs +0 -3
- package/common/src/constants/lifi.constants.cjs +1 -1
- package/common/src/constants/lifi.constants.mjs +3 -6
- package/common/src/constants/mediaUrls.constants.d.ts +0 -1
- package/common/src/constants/rewards.constants.d.ts +0 -2
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +1 -5
- package/common/src/constants/server.constants.mjs +3 -8
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.d.ts +1 -0
- package/common/src/constants/vite.constants.mjs +3 -3
- package/common/src/crypto/BabyJubRN.cjs +1 -0
- package/common/src/crypto/BabyJubRN.d.ts +18 -0
- package/common/src/crypto/BabyJubRN.mjs +33 -0
- package/common/src/crypto/babyJub.cjs +1 -1
- package/common/src/crypto/babyJub.mjs +7 -5
- package/common/src/crypto/poseidon.cjs +1 -1
- package/common/src/crypto/poseidon.mjs +22 -12
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +10 -6
- package/common/src/data-structures/Hinkal/Hinkal.mjs +104 -113
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +9 -5
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +37 -37
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +8 -5
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +4 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.mjs +4 -4
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +3 -3
- package/common/src/data-structures/Hinkal/hinkalProoflessDepositViaWrapper.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDepositViaWrapper.mjs +15 -15
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +4 -1
- package/common/src/data-structures/Hinkal/index.d.ts +0 -1
- package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.cjs +1 -1
- package/common/src/data-structures/Hinkal/prepareDepositOnChainUtxosZkProof.mjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +29 -31
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +7 -6
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +18 -18
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +43 -43
- package/common/src/data-structures/TokenDBs/PublicTokensDB.cjs +1 -1
- package/common/src/data-structures/TokenDBs/PublicTokensDB.mjs +23 -20
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +1 -0
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.d.ts +9 -0
- package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +41 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +1 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.d.ts +9 -0
- package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +47 -0
- package/common/src/data-structures/TokenDBs/index.cjs +1 -1
- package/common/src/data-structures/TokenDBs/index.d.ts +2 -0
- package/common/src/data-structures/TokenDBs/index.mjs +2 -0
- package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +3 -3
- package/common/src/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +2 -2
- package/common/src/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +2 -2
- package/common/src/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +3 -3
- package/common/src/data-structures/index.d.ts +1 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.cjs +1 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.d.ts +9 -0
- package/common/src/data-structures/private-balances/BalanceChangedHandler.mjs +12 -0
- package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -0
- package/common/src/data-structures/{Hinkal → private-balances}/HinkalPrivateBalanceController.d.ts +4 -2
- package/common/src/data-structures/{Hinkal → private-balances}/HinkalPrivateBalanceController.mjs +34 -90
- package/common/src/data-structures/private-balances/index.cjs +1 -0
- package/common/src/data-structures/private-balances/index.d.ts +3 -0
- package/common/src/data-structures/private-balances/index.mjs +3 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.cjs +1 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.d.ts +2 -0
- package/common/src/data-structures/private-balances/privateBalancesReducer.mjs +73 -0
- package/common/src/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
- package/common/src/data-structures/token-price-fetcher/TokenChecker.mjs +5 -5
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +2 -5
- package/common/src/error-handling/error-codes.constants.mjs +3 -6
- package/common/src/externalABIs/index.cjs +1 -1
- package/common/src/externalABIs/index.d.ts +1 -36
- package/common/src/externalABIs/index.mjs +3 -5
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.d.ts +0 -1
- package/common/src/functions/index.mjs +4 -5
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.cjs +1 -1
- package/common/src/functions/pre-transaction/buildCommitmentValidationData.mjs +37 -36
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.cjs +1 -1
- package/common/src/functions/pre-transaction/merge-with-fee-structure-emporium.mjs +4 -4
- package/common/src/functions/pre-transaction/sendV0Transaction.cjs +2 -2
- package/common/src/functions/pre-transaction/sendV0Transaction.mjs +54 -42
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +17 -17
- package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +16 -16
- package/common/src/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/common/src/functions/snarkjs/common.snarkjs.d.ts +9 -1
- package/common/src/functions/snarkjs/common.snarkjs.mjs +13 -9
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.d.ts +2 -3
- package/common/src/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +49 -32
- package/common/src/functions/utils/abi.utils.cjs +1 -0
- package/common/src/functions/utils/abi.utils.d.ts +3 -0
- package/common/src/functions/utils/abi.utils.mjs +5 -0
- package/common/src/functions/utils/bigint-math.utils.cjs +1 -0
- package/common/src/functions/utils/bigint-math.utils.d.ts +2 -0
- package/common/src/functions/utils/bigint-math.utils.mjs +12 -0
- package/common/src/functions/utils/dispatchBalanceRefreshes.cjs +1 -1
- package/common/src/functions/utils/dispatchBalanceRefreshes.mjs +1 -1
- package/common/src/functions/utils/enclaveHandshakeService.cjs +1 -0
- package/common/src/functions/utils/enclaveHandshakeService.d.ts +10 -0
- package/common/src/functions/utils/enclaveHandshakeService.mjs +22 -0
- package/common/src/functions/utils/encryptInputForEnclave.cjs +1 -1
- package/common/src/functions/utils/encryptInputForEnclave.mjs +23 -25
- package/common/src/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/common/src/functions/utils/erc20tokenFunctions.d.ts +4 -1
- package/common/src/functions/utils/erc20tokenFunctions.mjs +28 -12
- package/common/src/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/common/src/functions/utils/evmNetworkFunctions.d.ts +1 -0
- package/common/src/functions/utils/evmNetworkFunctions.mjs +4 -0
- package/common/src/functions/utils/getUtxosFromReceipt.utils.cjs +1 -1
- package/common/src/functions/utils/getUtxosFromReceipt.utils.mjs +10 -10
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +4 -0
- package/common/src/functions/utils/index.mjs +4 -0
- package/common/src/functions/utils/map.utils.cjs +1 -0
- package/common/src/functions/utils/map.utils.d.ts +1 -0
- package/common/src/functions/utils/map.utils.mjs +9 -0
- package/common/src/functions/utils/mutexes.utils.cjs +1 -1
- package/common/src/functions/utils/mutexes.utils.d.ts +2 -2
- package/common/src/functions/utils/mutexes.utils.mjs +4 -3
- package/common/src/functions/utils/process.utils.cjs +1 -1
- package/common/src/functions/utils/process.utils.d.ts +1 -0
- package/common/src/functions/utils/process.utils.mjs +7 -2
- package/common/src/functions/utils/tron.utils.cjs +1 -1
- package/common/src/functions/utils/tron.utils.d.ts +1 -0
- package/common/src/functions/utils/tron.utils.mjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +26 -26
- package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
- package/common/src/functions/web3/events/getShieldedBalance.mjs +29 -11
- package/common/src/functions/web3/events/index.cjs +1 -1
- package/common/src/functions/web3/events/index.d.ts +0 -1
- package/common/src/functions/web3/events/index.mjs +0 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.mjs +4 -4
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.cjs +1 -1
- package/common/src/functions/web3/functionCalls/waitForErc20Approvals.mjs +10 -10
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.mjs +0 -1
- package/common/src/functions/web3/lifiAPI.cjs +1 -1
- package/common/src/functions/web3/lifiAPI.mjs +7 -38
- package/common/src/functions/web3/oneInchAPI.cjs +1 -1
- package/common/src/functions/web3/oneInchAPI.mjs +10 -10
- package/common/src/functions/web3/uniswapAPI.cjs +1 -1
- package/common/src/functions/web3/uniswapAPI.mjs +16 -16
- package/common/src/mutexes/chainBalanceRwLock.cjs +1 -0
- package/common/src/mutexes/chainBalanceRwLock.d.ts +18 -0
- package/common/src/mutexes/chainBalanceRwLock.mjs +31 -0
- package/common/src/mutexes/index.d.ts +1 -0
- package/common/src/types/cache.types.cjs +1 -1
- package/common/src/types/cache.types.d.ts +2 -0
- package/common/src/types/cache.types.mjs +1 -1
- package/common/src/types/commitments.types.d.ts +0 -10
- package/common/src/types/hinkal.types.cjs +1 -1
- package/common/src/types/hinkal.types.d.ts +4 -7
- package/common/src/types/hinkal.types.mjs +1 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +0 -1
- package/common/src/types/index.mjs +1 -2
- package/common/src/types/new-rewards.type.cjs +1 -1
- package/common/src/types/new-rewards.type.d.ts +0 -1
- package/common/src/types/new-rewards.type.mjs +1 -1
- package/common/src/types/scheduled-transactions.types.d.ts +5 -0
- package/common/src/webworker/logError-BTCYh_YM.js +2 -0
- package/common/src/webworker/package.json +34 -4
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +4 -4
- package/common/src/webworker/viteWorkerURL.constant.mjs +4 -4
- package/common/src/webworker/workerFactory.cjs +1 -1
- package/common/src/webworker/workerFactory.d.ts +1 -0
- package/common/src/webworker/workerFactory.mjs +3 -2
- package/common/src/webworker/workerProxy-DPeuP2Mg.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/functions/index.cjs +1 -1
- package/functions/index.mjs +0 -4
- package/functions/integrations/index.cjs +1 -1
- package/functions/integrations/index.mjs +0 -4
- package/functions/integrations/swapApi.cjs +1 -1
- package/functions/integrations/swapApi.d.ts +21 -7
- package/functions/integrations/swapApi.mjs +29 -10
- package/functions/utils/refreshBalance.cjs +1 -1
- package/functions/utils/refreshBalance.mjs +2 -2
- package/index.cjs +1 -1
- package/index.mjs +4 -8
- package/internal/token.utils.cjs +1 -1
- package/internal/token.utils.d.ts +1 -3
- package/internal/token.utils.mjs +10 -21
- package/package.json +34 -4
- package/react-native/HinkalWebViewWorker.cjs +98 -0
- package/react-native/HinkalWebViewWorker.d.ts +2 -0
- package/react-native/HinkalWebViewWorker.mjs +174 -0
- package/react-native/bridge/HinkalRNWorker.cjs +1 -0
- package/react-native/bridge/HinkalRNWorker.d.ts +13 -0
- package/react-native/bridge/HinkalRNWorker.mjs +26 -0
- package/react-native/bridge/serialization.utils.cjs +1 -0
- package/react-native/bridge/serialization.utils.d.ts +3 -0
- package/react-native/bridge/serialization.utils.mjs +13 -0
- package/react-native/metro-config.js +90 -0
- package/react-native/shims/circomlibjs-hinkal-fork.js +14 -0
- package/react-native/shims/circomlibjs.js +15 -0
- package/react-native/shims/constants.js +7 -0
- package/react-native/shims/crypto.js +103 -0
- package/react-native/shims/ffjavascript.js +5 -0
- package/react-native/shims/fs.js +5 -0
- package/react-native/shims/globals.js +10 -0
- package/react-native/shims/idb-keyval.js +75 -0
- package/react-native/shims/multiformats.js +1 -0
- package/react-native/shims/os.js +7 -0
- package/react-native/shims/path.js +11 -0
- package/react-native/shims/readline.js +6 -0
- package/react-native/shims/snarkjs.js +21 -0
- package/react-native/shims/url.js +5 -0
- package/react-native/shims/web-worker.js +7 -0
- package/react-native/shims/worker_threads.js +6 -0
- package/react-native/shims.d.ts +16 -0
- package/react-native/workerCDNUrls.cjs +1 -0
- package/react-native/workerCDNUrls.d.ts +2 -0
- package/react-native/workerCDNUrls.mjs +14 -0
- package/sdk/package.json.cjs +1 -0
- package/sdk/package.json.mjs +130 -0
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +6 -5
- package/services/Hinkal.mjs +50 -48
- package/types/IHinkal.d.ts +6 -5
- package/common/src/API/kycCalls.cjs +0 -1
- package/common/src/API/kycCalls.d.ts +0 -14
- package/common/src/API/kycCalls.mjs +0 -26
- package/common/src/constants/assets.constants.cjs +0 -1
- package/common/src/constants/assets.constants.d.ts +0 -13
- package/common/src/constants/assets.constants.mjs +0 -4
- package/common/src/constants/kyc.constants.cjs +0 -1
- package/common/src/constants/kyc.constants.d.ts +0 -29
- package/common/src/constants/kyc.constants.mjs +0 -126
- package/common/src/constants/token.limits.constants.cjs +0 -1
- package/common/src/constants/token.limits.constants.d.ts +0 -5
- package/common/src/constants/token.limits.constants.mjs +0 -3
- package/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.cjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.d.ts +0 -28
- package/common/src/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +0 -22
- package/common/src/externalABIs/BabPassport.json.cjs +0 -1
- package/common/src/externalABIs/BabPassport.json.mjs +0 -20
- package/common/src/externalABIs/GalxePassport.json.cjs +0 -1
- package/common/src/externalABIs/GalxePassport.json.mjs +0 -37
- package/common/src/functions/kyc/aiPriseHelper.d.ts +0 -0
- package/common/src/functions/kyc/checkTokenLimitsUSD.cjs +0 -1
- package/common/src/functions/kyc/checkTokenLimitsUSD.d.ts +0 -1
- package/common/src/functions/kyc/checkTokenLimitsUSD.mjs +0 -29
- package/common/src/functions/kyc/index.cjs +0 -1
- package/common/src/functions/kyc/index.d.ts +0 -3
- package/common/src/functions/kyc/index.mjs +0 -3
- package/common/src/functions/kyc/openDefaultPassportWindow.cjs +0 -1
- package/common/src/functions/kyc/openDefaultPassportWindow.d.ts +0 -1
- package/common/src/functions/kyc/openDefaultPassportWindow.mjs +0 -7
- package/common/src/functions/kyc/passportHelper.cjs +0 -1
- package/common/src/functions/kyc/passportHelper.d.ts +0 -3
- package/common/src/functions/kyc/passportHelper.mjs +0 -1
- package/common/src/functions/kyc/zkMeHelper.cjs +0 -1
- package/common/src/functions/kyc/zkMeHelper.d.ts +0 -4
- package/common/src/functions/kyc/zkMeHelper.mjs +0 -42
- package/common/src/functions/web3/events/balanceChangedHandler.cjs +0 -1
- package/common/src/functions/web3/events/balanceChangedHandler.d.ts +0 -5
- package/common/src/functions/web3/events/balanceChangedHandler.mjs +0 -21
- package/common/src/types/kyc.types.cjs +0 -1
- package/common/src/types/kyc.types.d.ts +0 -41
- package/common/src/types/kyc.types.mjs +0 -10
- package/common/src/webworker/logError-CmD5XYI9.js +0 -2
- package/common/src/webworker/workerProxy-C49-EPZz.js +0 -1
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { IHinkal } from '../../types';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export declare const getEvmSwapPrices: (hinkal: IHinkal, chainId: number, inSwapAmount: string, inSwapTokenAddress: string, outSwapTokenAddress: string) => Promise<{
|
|
3
|
+
uniswap: {
|
|
4
|
+
tokenPrice: bigint;
|
|
5
|
+
poolFee: string;
|
|
6
|
+
} | null;
|
|
7
|
+
odos: {
|
|
8
|
+
outSwapAmountValue: bigint;
|
|
9
|
+
odosDataValue: string;
|
|
10
|
+
} | null;
|
|
11
|
+
oneInch: {
|
|
12
|
+
outSwapAmountValue: bigint;
|
|
13
|
+
oneInchDataValue: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const getSolanaSwapPrices: (chainId: number, inSwapAmount: string, inSwapTokenAddress: string, outSwapTokenAddress: string) => Promise<{
|
|
17
|
+
okx: {
|
|
18
|
+
outSwapAmountValue: bigint;
|
|
19
|
+
okxDataValue: string;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
okx: null;
|
|
9
23
|
}>;
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../common/src/functions/
|
|
3
|
-
import "../../common/src/functions/web3/
|
|
4
|
-
import "../../common/src/functions/web3/
|
|
5
|
-
import "../../common/src/functions/web3/
|
|
6
|
-
import {
|
|
1
|
+
import { resolveErc20Tokens as e } from "../../common/src/functions/utils/erc20tokenFunctions.mjs";
|
|
2
|
+
import { withTimeout as t } from "../../common/src/functions/utils/process.utils.mjs";
|
|
3
|
+
import { getUniswapPrice as n } from "../../common/src/functions/web3/uniswapAPI.mjs";
|
|
4
|
+
import { getOdosPrice as r } from "../../common/src/functions/web3/odosAPI.mjs";
|
|
5
|
+
import { getOneInchPrice as i } from "../../common/src/functions/web3/oneInchAPI.mjs";
|
|
6
|
+
import { getOKXPrice as a } from "../../common/src/functions/web3/okxAPI.mjs";
|
|
7
|
+
import "../../common/src/functions/index.mjs";
|
|
7
8
|
//#region libs/shared/sdk/src/functions/integrations/swapApi.ts
|
|
8
|
-
var
|
|
9
|
-
let s =
|
|
10
|
-
return
|
|
9
|
+
var o = async (t, r, i, a, o) => {
|
|
10
|
+
let s = t.hinkalCommon, [c, l] = await e(r, [a, o]);
|
|
11
|
+
return n(s, r, i, c, l);
|
|
12
|
+
}, s = async (n, a, s, c, l) => {
|
|
13
|
+
let [u, d] = await e(a, [c, l]), [f, p, m] = await Promise.allSettled([
|
|
14
|
+
t(o(n, a, s, c, l)),
|
|
15
|
+
t(r(a, u, d, s)),
|
|
16
|
+
t(i(a, u, d, s))
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
uniswap: f.status === "fulfilled" ? f.value : null,
|
|
20
|
+
odos: p.status === "fulfilled" ? p.value : null,
|
|
21
|
+
oneInch: m.status === "fulfilled" ? m.value : null
|
|
22
|
+
};
|
|
23
|
+
}, c = async (n, r, i, o) => {
|
|
24
|
+
let [s, c] = await e(n, [i, o]);
|
|
25
|
+
try {
|
|
26
|
+
return { okx: await t(a(n, s, c, r)) };
|
|
27
|
+
} catch {
|
|
28
|
+
return { okx: null };
|
|
29
|
+
}
|
|
11
30
|
};
|
|
12
31
|
//#endregion
|
|
13
|
-
export {
|
|
32
|
+
export { s as getEvmSwapPrices, c as getSolanaSwapPrices };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../common/src/
|
|
1
|
+
const e=require(`../../common/src/data-structures/private-balances/BalanceChangedHandler.cjs`);var t=t=>{e.balanceChangedHandler.dispatch(t)};exports.refreshBalance=t;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { balanceChangedHandler as e } from "../../common/src/
|
|
1
|
+
import { balanceChangedHandler as e } from "../../common/src/data-structures/private-balances/BalanceChangedHandler.mjs";
|
|
2
2
|
//#region libs/shared/sdk/src/functions/utils/refreshBalance.ts
|
|
3
3
|
var t = (t) => {
|
|
4
|
-
e(t);
|
|
4
|
+
e.dispatch(t);
|
|
5
5
|
};
|
|
6
6
|
//#endregion
|
|
7
7
|
export { t as refreshBalance };
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./common/src/types/external-action.types.cjs`),t=require(`./common/src/types/balances.types.cjs`),n=require(`./common/src/functions/pre-transaction/getFeeStructure.cjs`),r=require(`./common/src/crypto/preProcessing.cjs`),i=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./common/src/types/external-action.types.cjs`),t=require(`./common/src/types/balances.types.cjs`),n=require(`./common/src/functions/pre-transaction/getFeeStructure.cjs`),r=require(`./common/src/crypto/preProcessing.cjs`),i=require(`./services/Hinkal.cjs`);require(`./services/index.cjs`);const a=require(`./functions/utils/refreshBalance.cjs`),o=require(`./functions/integrations/swapApi.cjs`);require(`./functions/index.cjs`),require(`./types/index.cjs`),exports.ExternalActionId=e.ExternalActionId,exports.Hinkal=i.Hinkal,exports.PrivateBalanceUpdateType=t.PrivateBalanceUpdateType,exports.getEvmSwapPrices=o.getEvmSwapPrices,exports.getFeeStructure=n.getFeeStructure,exports.getSolanaSwapPrices=o.getSolanaSwapPrices,exports.preProcessing=r.preProcessing,exports.refreshBalance=a.refreshBalance;
|
package/index.mjs
CHANGED
|
@@ -2,14 +2,10 @@ import { ExternalActionId as e } from "./common/src/types/external-action.types.
|
|
|
2
2
|
import { PrivateBalanceUpdateType as t } from "./common/src/types/balances.types.mjs";
|
|
3
3
|
import { getFeeStructure as n } from "./common/src/functions/pre-transaction/getFeeStructure.mjs";
|
|
4
4
|
import { preProcessing as r } from "./common/src/crypto/preProcessing.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { getOneInchPrice as a } from "./common/src/functions/web3/oneInchAPI.mjs";
|
|
7
|
-
import { getLifiPrice as o } from "./common/src/functions/web3/lifiAPI.mjs";
|
|
8
|
-
import { getOKXPrice as s } from "./common/src/functions/web3/okxAPI.mjs";
|
|
9
|
-
import { Hinkal as c } from "./services/Hinkal.mjs";
|
|
5
|
+
import { Hinkal as i } from "./services/Hinkal.mjs";
|
|
10
6
|
import "./services/index.mjs";
|
|
11
|
-
import { refreshBalance as
|
|
12
|
-
import {
|
|
7
|
+
import { refreshBalance as a } from "./functions/utils/refreshBalance.mjs";
|
|
8
|
+
import { getEvmSwapPrices as o, getSolanaSwapPrices as s } from "./functions/integrations/swapApi.mjs";
|
|
13
9
|
import "./functions/index.mjs";
|
|
14
10
|
import "./types/index.mjs";
|
|
15
|
-
export { e as ExternalActionId,
|
|
11
|
+
export { e as ExternalActionId, i as Hinkal, t as PrivateBalanceUpdateType, o as getEvmSwapPrices, n as getFeeStructure, s as getSolanaSwapPrices, r as preProcessing, a as refreshBalance };
|
package/internal/token.utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../common/src/functions/utils/erc20tokenFunctions.cjs`);
|
|
1
|
+
const e=require(`../common/src/functions/utils/erc20tokenFunctions.cjs`);require(`../common/src/functions/index.cjs`);var t=async(t,n)=>{if(n.length===0)return[];let r=await e.resolveErc20Tokens(t,n.map(({erc20Address:e})=>e));return n.map(({amount:e,nftIds:t},n)=>({token:r[n],amount:e,nftIds:t}))},n=e=>({chainId:e.token.chainId,erc20Address:e.token.erc20TokenAddress,balance:e.balance,timestamp:e.timestamp,isBalanceLoading:e.isBalanceLoading,usdValue:e.usdValue,isUsdValueLoading:e.isUsdValueLoading}),r=e=>({chainId:e.token.chainId,erc20Address:e.token.erc20TokenAddress,balance:e.balance,timestamp:e.timestamp}),i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[Number(e),t?.map(n)]));exports.mapPrivateBalances=i,exports.mapTokenBalance=r,exports.resolveCommonTokenChanges=t;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { PrivateBalancesState as CommonPrivateBalancesState, TokenBalance as CommonTokenBalance, TokenChanges as CommonTokenChanges
|
|
1
|
+
import { PrivateBalancesState as CommonPrivateBalancesState, TokenBalance as CommonTokenBalance, TokenChanges as CommonTokenChanges } from '../common/src/types';
|
|
2
2
|
import { PrivateBalancesState, TokenBalance, TokenChanges } from '../types';
|
|
3
|
-
export declare const resolveErc20Token: (chainId: number, erc20Address: string) => Promise<ERC20Token>;
|
|
4
|
-
export declare const resolveErc20Tokens: (chainId: number, erc20Addresses: string[]) => Promise<ERC20Token[]>;
|
|
5
3
|
export declare const resolveCommonTokenChanges: (chainId: number, tokenChanges: TokenChanges<bigint>[]) => Promise<CommonTokenChanges<bigint>[]>;
|
|
6
4
|
export declare const mapTokenBalance: (balance: CommonTokenBalance) => TokenBalance;
|
|
7
5
|
export declare const mapPrivateBalances: (state: CommonPrivateBalancesState) => PrivateBalancesState;
|
package/internal/token.utils.mjs
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveErc20Tokens as e } from "../common/src/functions/utils/erc20tokenFunctions.mjs";
|
|
2
|
+
import "../common/src/functions/index.mjs";
|
|
2
3
|
//#region libs/shared/sdk/src/internal/token.utils.ts
|
|
3
|
-
var
|
|
4
|
-
let r = await e(t, n);
|
|
5
|
-
if (!r) throw Error(`Token not found: ${n} on chain ${t}`);
|
|
6
|
-
return r;
|
|
7
|
-
}, r = async (e, n) => {
|
|
4
|
+
var t = async (t, n) => {
|
|
8
5
|
if (n.length === 0) return [];
|
|
9
|
-
let r = await t(e
|
|
10
|
-
return n.map((t, n) => {
|
|
11
|
-
|
|
12
|
-
if (!i) throw Error(`Token not found: ${t} on chain ${e}`);
|
|
13
|
-
return i;
|
|
14
|
-
});
|
|
15
|
-
}, i = async (e, t) => {
|
|
16
|
-
if (t.length === 0) return [];
|
|
17
|
-
let n = await r(e, t.map(({ erc20Address: e }) => e));
|
|
18
|
-
return t.map(({ amount: e, nftIds: t }, r) => ({
|
|
19
|
-
token: n[r],
|
|
6
|
+
let r = await e(t, n.map(({ erc20Address: e }) => e));
|
|
7
|
+
return n.map(({ amount: e, nftIds: t }, n) => ({
|
|
8
|
+
token: r[n],
|
|
20
9
|
amount: e,
|
|
21
10
|
nftIds: t
|
|
22
11
|
}));
|
|
23
|
-
},
|
|
12
|
+
}, n = (e) => ({
|
|
24
13
|
chainId: e.token.chainId,
|
|
25
14
|
erc20Address: e.token.erc20TokenAddress,
|
|
26
15
|
balance: e.balance,
|
|
@@ -28,11 +17,11 @@ var n = async (t, n) => {
|
|
|
28
17
|
isBalanceLoading: e.isBalanceLoading,
|
|
29
18
|
usdValue: e.usdValue,
|
|
30
19
|
isUsdValueLoading: e.isUsdValueLoading
|
|
31
|
-
}),
|
|
20
|
+
}), r = (e) => ({
|
|
32
21
|
chainId: e.token.chainId,
|
|
33
22
|
erc20Address: e.token.erc20TokenAddress,
|
|
34
23
|
balance: e.balance,
|
|
35
24
|
timestamp: e.timestamp
|
|
36
|
-
}),
|
|
25
|
+
}), i = (e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [Number(e), t?.map(n)]));
|
|
37
26
|
//#endregion
|
|
38
|
-
export {
|
|
27
|
+
export { i as mapPrivateBalances, r as mapTokenBalance, t as resolveCommonTokenChanges };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurge/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"homepage": "hinkal.io",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hinkal Protocol"
|
|
@@ -14,49 +14,66 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./index.d.ts",
|
|
17
|
+
"react-native": "./index.cjs",
|
|
17
18
|
"import": "./index.mjs",
|
|
18
19
|
"default": "./index.cjs"
|
|
19
20
|
},
|
|
20
21
|
"./providers/WagmiProviderAdapter": {
|
|
21
22
|
"types": "./providers/WagmiProviderAdapter.d.ts",
|
|
23
|
+
"react-native": "./providers/WagmiProviderAdapter.cjs",
|
|
22
24
|
"import": "./providers/WagmiProviderAdapter.mjs",
|
|
23
25
|
"default": "./providers/WagmiProviderAdapter.cjs"
|
|
24
26
|
},
|
|
25
27
|
"./providers/EthersProviderAdapter": {
|
|
26
28
|
"types": "./providers/EthersProviderAdapter.d.ts",
|
|
29
|
+
"react-native": "./providers/EthersProviderAdapter.cjs",
|
|
27
30
|
"import": "./providers/EthersProviderAdapter.mjs",
|
|
28
31
|
"default": "./providers/EthersProviderAdapter.cjs"
|
|
29
32
|
},
|
|
30
33
|
"./providers/TronProviderAdapter": {
|
|
31
34
|
"types": "./providers/TronProviderAdapter.d.ts",
|
|
35
|
+
"react-native": "./providers/TronProviderAdapter.cjs",
|
|
32
36
|
"import": "./providers/TronProviderAdapter.mjs",
|
|
33
37
|
"default": "./providers/TronProviderAdapter.cjs"
|
|
34
38
|
},
|
|
35
39
|
"./providers/SolanaProviderAdapter": {
|
|
36
40
|
"types": "./providers/SolanaProviderAdapter.d.ts",
|
|
41
|
+
"react-native": "./providers/SolanaProviderAdapter.cjs",
|
|
37
42
|
"import": "./providers/SolanaProviderAdapter.mjs",
|
|
38
43
|
"default": "./providers/SolanaProviderAdapter.cjs"
|
|
39
44
|
},
|
|
40
45
|
"./providers/prepareEthersHinkal": {
|
|
41
46
|
"types": "./providers/prepareEthersHinkal.d.ts",
|
|
47
|
+
"react-native": "./providers/prepareEthersHinkal.cjs",
|
|
42
48
|
"import": "./providers/prepareEthersHinkal.mjs",
|
|
43
49
|
"default": "./providers/prepareEthersHinkal.cjs"
|
|
44
50
|
},
|
|
45
51
|
"./providers/prepareWagmiHinkal": {
|
|
46
52
|
"types": "./providers/prepareWagmiHinkal.d.ts",
|
|
53
|
+
"react-native": "./providers/prepareWagmiHinkal.cjs",
|
|
47
54
|
"import": "./providers/prepareWagmiHinkal.mjs",
|
|
48
55
|
"default": "./providers/prepareWagmiHinkal.cjs"
|
|
49
56
|
},
|
|
50
57
|
"./providers/prepareTronHinkal": {
|
|
51
58
|
"types": "./providers/prepareTronHinkal.d.ts",
|
|
59
|
+
"react-native": "./providers/prepareTronHinkal.cjs",
|
|
52
60
|
"import": "./providers/prepareTronHinkal.mjs",
|
|
53
61
|
"default": "./providers/prepareTronHinkal.cjs"
|
|
54
62
|
},
|
|
55
63
|
"./providers/prepareSolanaHinkal": {
|
|
56
64
|
"types": "./providers/prepareSolanaHinkal.d.ts",
|
|
65
|
+
"react-native": "./providers/prepareSolanaHinkal.cjs",
|
|
57
66
|
"import": "./providers/prepareSolanaHinkal.mjs",
|
|
58
67
|
"default": "./providers/prepareSolanaHinkal.cjs"
|
|
59
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"./react-native/HinkalWebViewWorker": {
|
|
70
|
+
"types": "./react-native/HinkalWebViewWorker.d.ts",
|
|
71
|
+
"react-native": "./react-native/HinkalWebViewWorker.cjs",
|
|
72
|
+
"import": "./react-native/HinkalWebViewWorker.mjs",
|
|
73
|
+
"default": "./react-native/HinkalWebViewWorker.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./react-native/metro-config": "./react-native/metro-config.js",
|
|
76
|
+
"./react-native/shims/*": "./react-native/shims/*"
|
|
60
77
|
},
|
|
61
78
|
"types": "./index.d.ts",
|
|
62
79
|
"scripts": {
|
|
@@ -80,7 +97,7 @@
|
|
|
80
97
|
"async-mutex": "^0.4.0",
|
|
81
98
|
"bs58": "^6.0.0",
|
|
82
99
|
"buffer": "6.0.3",
|
|
83
|
-
"circomlibjs-hinkal-fork": "^0.0.
|
|
100
|
+
"circomlibjs-hinkal-fork": "^0.0.10",
|
|
84
101
|
"dotenv": "^16.4.5",
|
|
85
102
|
"ethers": "^6.15.0",
|
|
86
103
|
"idb-keyval": "6.2.1",
|
|
@@ -93,11 +110,15 @@
|
|
|
93
110
|
"ua-parser-js": "^1.0.37",
|
|
94
111
|
"uuid": "^9.0.1",
|
|
95
112
|
"node-forge": "^1.3.1",
|
|
113
|
+
"poseidon-lite": "^0.3.0",
|
|
96
114
|
"tronweb": "^6.2.0"
|
|
97
115
|
},
|
|
98
116
|
"peerDependencies": {
|
|
99
117
|
"wagmi": "2.13.3",
|
|
100
|
-
"@walletconnect/utils": "^2.17.2"
|
|
118
|
+
"@walletconnect/utils": "^2.17.2",
|
|
119
|
+
"react": "*",
|
|
120
|
+
"react-native": "*",
|
|
121
|
+
"react-native-webview": "*"
|
|
101
122
|
},
|
|
102
123
|
"peerDependenciesMeta": {
|
|
103
124
|
"wagmi": {
|
|
@@ -105,6 +126,15 @@
|
|
|
105
126
|
},
|
|
106
127
|
"@walletconnect/utils": {
|
|
107
128
|
"optional": true
|
|
129
|
+
},
|
|
130
|
+
"react": {
|
|
131
|
+
"optional": true
|
|
132
|
+
},
|
|
133
|
+
"react-native": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
136
|
+
"react-native-webview": {
|
|
137
|
+
"optional": true
|
|
108
138
|
}
|
|
109
139
|
}
|
|
110
140
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../common/src/webworker/workerFactory.cjs`),t=require(`./workerCDNUrls.cjs`),n=require(`./bridge/serialization.utils.cjs`),r=require(`./bridge/HinkalRNWorker.cjs`);let i=require(`react`),a=require(`react-native`),o=require(`react-native-webview`),s=require(`react/jsx-runtime`);var c=`${new URL(Object.values(t.WORKER_CDN_URLS)[0]).origin}/`;e.WorkerFactory.rnWorkerFactory=e=>new r.HinkalRNWorker(e);var l=`
|
|
2
|
+
if (!window.__hinkalPageBoot) (function(){
|
|
3
|
+
window.__hinkalPageBoot = true;
|
|
4
|
+
var URLS = ${JSON.stringify(t.WORKER_CDN_URLS)};
|
|
5
|
+
var BLOBS = {};
|
|
6
|
+
|
|
7
|
+
function replacer(_key, value){
|
|
8
|
+
if (typeof value === 'bigint') return { __bigint: value.toString() };
|
|
9
|
+
if (value instanceof Set) return { __set: Array.from(value) };
|
|
10
|
+
if (value instanceof Map) return { __map: Array.from(value.entries()) };
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function revive(value){
|
|
14
|
+
if (value === null || typeof value !== 'object') return value;
|
|
15
|
+
var keys = Object.keys(value);
|
|
16
|
+
if (keys.length === 1) {
|
|
17
|
+
if (typeof value.__bigint === 'string') return BigInt(value.__bigint);
|
|
18
|
+
if (Array.isArray(value.__set)) return new Set(value.__set.map(revive));
|
|
19
|
+
if (Array.isArray(value.__map)) return new Map(value.__map.map(function(entry){ return [revive(entry[0]), revive(entry[1])]; }));
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) return value.map(revive);
|
|
22
|
+
var out = {}; for (var i = 0; i < keys.length; i++) out[keys[i]] = revive(value[keys[i]]); return out;
|
|
23
|
+
}
|
|
24
|
+
function post(payload){ try { window.ReactNativeWebView.postMessage(JSON.stringify(payload, replacer)); } catch(_){} }
|
|
25
|
+
function describe(error){
|
|
26
|
+
if (!error) return 'worker error';
|
|
27
|
+
if (error.message) return error.message;
|
|
28
|
+
if (error.error && error.error.stack) return error.error.stack;
|
|
29
|
+
try { return JSON.stringify(error); } catch(_){ return String(error); }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function blobUrl(url){
|
|
33
|
+
if (BLOBS[url]) return BLOBS[url];
|
|
34
|
+
var response = await fetch(url);
|
|
35
|
+
if (!response.ok) throw new Error('HTTP ' + response.status + ' ' + url);
|
|
36
|
+
var body = await response.text();
|
|
37
|
+
BLOBS[url] = URL.createObjectURL(new Blob([${JSON.stringify(`(function(){
|
|
38
|
+
var post = self.postMessage.bind(self);
|
|
39
|
+
function describe(error){
|
|
40
|
+
if (!error) return 'unknown';
|
|
41
|
+
var parts = [];
|
|
42
|
+
if (error.message) parts.push(error.message);
|
|
43
|
+
if (error.error && error.error.stack) parts.push(error.error.stack);
|
|
44
|
+
if (!parts.length) { try { parts.push(JSON.stringify(error)); } catch(_) { parts.push(String(error)); } }
|
|
45
|
+
return parts.join(' | ');
|
|
46
|
+
}
|
|
47
|
+
self.addEventListener('error', function(event){ try { post({ __hinkalWorkerError: describe(event) }); } catch(_){} });
|
|
48
|
+
self.addEventListener('unhandledrejection', function(event){ try { post({ __hinkalWorkerError: 'unhandledrejection: ' + describe(event && event.reason) }); } catch(_){} });
|
|
49
|
+
try { post({ __hinkalWorkerReady: true }); } catch(_){}
|
|
50
|
+
})();`)}, body], { type: 'application/javascript' }));
|
|
51
|
+
return BLOBS[url];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function spawn(url){
|
|
55
|
+
try { return new Worker(url, { type: 'module' }); } catch(_){ return new Worker(url); }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
window.handleMessage = async function(envelope){
|
|
59
|
+
var requestId = envelope && envelope.requestId;
|
|
60
|
+
var variant = envelope && envelope.variant;
|
|
61
|
+
var message = revive(envelope && envelope.message);
|
|
62
|
+
var url = URLS[variant];
|
|
63
|
+
if (!url) return post({ requestId: requestId, type: 'ERROR', error: 'Unknown variant: ' + variant });
|
|
64
|
+
|
|
65
|
+
var worker;
|
|
66
|
+
try { worker = spawn(await blobUrl(url)); }
|
|
67
|
+
catch (error) { return post({ requestId: requestId, type: 'ERROR', error: 'spawn failed: ' + describe(error) }); }
|
|
68
|
+
|
|
69
|
+
var done = false, ready = false, pending = message;
|
|
70
|
+
function finish(){ if (done) return; done = true; try { worker.terminate(); } catch(_){} }
|
|
71
|
+
|
|
72
|
+
worker.onmessage = function(event){
|
|
73
|
+
var data = event && event.data;
|
|
74
|
+
if (data && typeof data === 'object') {
|
|
75
|
+
if (data.__hinkalWorkerReady) {
|
|
76
|
+
ready = true;
|
|
77
|
+
try { worker.postMessage(pending); pending = null; }
|
|
78
|
+
catch (error) { post({ requestId: requestId, type: 'ERROR', error: 'postMessage failed: ' + describe(error) }); finish(); }
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (typeof data.__hinkalWorkerError === 'string') {
|
|
82
|
+
post({ requestId: requestId, type: 'ERROR', error: data.__hinkalWorkerError });
|
|
83
|
+
finish();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
post({ requestId: requestId, type: 'RESULT', data: data });
|
|
88
|
+
finish();
|
|
89
|
+
};
|
|
90
|
+
worker.onerror = function(event){
|
|
91
|
+
post({ requestId: requestId, type: 'ERROR', error: (ready ? 'worker runtime: ' : 'worker startup: ') + describe(event) });
|
|
92
|
+
finish();
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
post({ type: 'READY' });
|
|
97
|
+
})();
|
|
98
|
+
true;`,u=`<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><script>${l}<\/script></body></html>`,d=a.StyleSheet.create({hiddenHost:{position:`absolute`,height:1,width:1,left:-9999,top:-9999,opacity:0}}),f=()=>{let e=(0,i.useRef)(null),t=(0,i.useRef)({ready:!1,queue:[]}),r=(0,i.useCallback)((t,r,i)=>{let o;try{o=JSON.stringify({requestId:t,variant:r,message:i},n.bigIntReplacer)}catch(e){a.DeviceEventEmitter.emit(`FROM_WEBVIEW_WORKER`,{requestId:t,type:`ERROR`,error:`serialize failed: ${e?.message??e}`});return}e.current?.injectJavaScript(`window.handleMessage && window.handleMessage(${o}); true;`)},[]);(0,i.useEffect)(()=>{let e=a.DeviceEventEmitter.addListener(`TO_WEBVIEW_WORKER`,e=>{let n={requestId:e?.__requestId??``,variant:e?.variant??``,message:e?.message};t.current.ready?r(n.requestId,n.variant,n.message):t.current.queue.push(n)});return()=>e.remove()},[r]);let f=(0,i.useCallback)(e=>{let i;try{i=n.reviveBigInts(JSON.parse(e.nativeEvent.data))}catch(e){a.DeviceEventEmitter.emit(`FROM_WEBVIEW_WORKER`,{type:`ERROR`,error:e?.message??`parse error`});return}if(i?.type===`READY`){t.current.ready=!0;let e=t.current.queue;t.current.queue=[],e.forEach(({requestId:e,variant:t,message:n})=>r(e,t,n));return}a.DeviceEventEmitter.emit(`FROM_WEBVIEW_WORKER`,i)},[r]);return(0,s.jsx)(a.View,{pointerEvents:`none`,style:d.hiddenHost,children:(0,s.jsx)(o.WebView,{ref:e,source:{html:u,baseUrl:c},originWhitelist:[`*`],javaScriptEnabled:!0,domStorageEnabled:!0,androidLayerType:`hardware`,onMessage:f,onLoad:()=>e.current?.injectJavaScript(l)})})};module.exports=f;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { WorkerFactory as e } from "../common/src/webworker/workerFactory.mjs";
|
|
2
|
+
import { WORKER_CDN_URLS as t } from "./workerCDNUrls.mjs";
|
|
3
|
+
import { bigIntReplacer as n, reviveBigInts as r } from "./bridge/serialization.utils.mjs";
|
|
4
|
+
import { HinkalRNWorker as i } from "./bridge/HinkalRNWorker.mjs";
|
|
5
|
+
import { useCallback as a, useEffect as o, useRef as s } from "react";
|
|
6
|
+
import { DeviceEventEmitter as c, StyleSheet as l, View as u } from "react-native";
|
|
7
|
+
import { WebView as d } from "react-native-webview";
|
|
8
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
9
|
+
//#region libs/shared/sdk/src/react-native/HinkalWebViewWorker.tsx
|
|
10
|
+
var p = `${new URL(Object.values(t)[0]).origin}/`;
|
|
11
|
+
e.rnWorkerFactory = (e) => new i(e);
|
|
12
|
+
var m = `
|
|
13
|
+
if (!window.__hinkalPageBoot) (function(){
|
|
14
|
+
window.__hinkalPageBoot = true;
|
|
15
|
+
var URLS = ${JSON.stringify(t)};
|
|
16
|
+
var BLOBS = {};
|
|
17
|
+
|
|
18
|
+
function replacer(_key, value){
|
|
19
|
+
if (typeof value === 'bigint') return { __bigint: value.toString() };
|
|
20
|
+
if (value instanceof Set) return { __set: Array.from(value) };
|
|
21
|
+
if (value instanceof Map) return { __map: Array.from(value.entries()) };
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function revive(value){
|
|
25
|
+
if (value === null || typeof value !== 'object') return value;
|
|
26
|
+
var keys = Object.keys(value);
|
|
27
|
+
if (keys.length === 1) {
|
|
28
|
+
if (typeof value.__bigint === 'string') return BigInt(value.__bigint);
|
|
29
|
+
if (Array.isArray(value.__set)) return new Set(value.__set.map(revive));
|
|
30
|
+
if (Array.isArray(value.__map)) return new Map(value.__map.map(function(entry){ return [revive(entry[0]), revive(entry[1])]; }));
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) return value.map(revive);
|
|
33
|
+
var out = {}; for (var i = 0; i < keys.length; i++) out[keys[i]] = revive(value[keys[i]]); return out;
|
|
34
|
+
}
|
|
35
|
+
function post(payload){ try { window.ReactNativeWebView.postMessage(JSON.stringify(payload, replacer)); } catch(_){} }
|
|
36
|
+
function describe(error){
|
|
37
|
+
if (!error) return 'worker error';
|
|
38
|
+
if (error.message) return error.message;
|
|
39
|
+
if (error.error && error.error.stack) return error.error.stack;
|
|
40
|
+
try { return JSON.stringify(error); } catch(_){ return String(error); }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function blobUrl(url){
|
|
44
|
+
if (BLOBS[url]) return BLOBS[url];
|
|
45
|
+
var response = await fetch(url);
|
|
46
|
+
if (!response.ok) throw new Error('HTTP ' + response.status + ' ' + url);
|
|
47
|
+
var body = await response.text();
|
|
48
|
+
BLOBS[url] = URL.createObjectURL(new Blob([${JSON.stringify("(function(){\n var post = self.postMessage.bind(self);\n function describe(error){\n if (!error) return 'unknown';\n var parts = [];\n if (error.message) parts.push(error.message);\n if (error.error && error.error.stack) parts.push(error.error.stack);\n if (!parts.length) { try { parts.push(JSON.stringify(error)); } catch(_) { parts.push(String(error)); } }\n return parts.join(' | ');\n }\n self.addEventListener('error', function(event){ try { post({ __hinkalWorkerError: describe(event) }); } catch(_){} });\n self.addEventListener('unhandledrejection', function(event){ try { post({ __hinkalWorkerError: 'unhandledrejection: ' + describe(event && event.reason) }); } catch(_){} });\n try { post({ __hinkalWorkerReady: true }); } catch(_){}\n})();")}, body], { type: 'application/javascript' }));
|
|
49
|
+
return BLOBS[url];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function spawn(url){
|
|
53
|
+
try { return new Worker(url, { type: 'module' }); } catch(_){ return new Worker(url); }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
window.handleMessage = async function(envelope){
|
|
57
|
+
var requestId = envelope && envelope.requestId;
|
|
58
|
+
var variant = envelope && envelope.variant;
|
|
59
|
+
var message = revive(envelope && envelope.message);
|
|
60
|
+
var url = URLS[variant];
|
|
61
|
+
if (!url) return post({ requestId: requestId, type: 'ERROR', error: 'Unknown variant: ' + variant });
|
|
62
|
+
|
|
63
|
+
var worker;
|
|
64
|
+
try { worker = spawn(await blobUrl(url)); }
|
|
65
|
+
catch (error) { return post({ requestId: requestId, type: 'ERROR', error: 'spawn failed: ' + describe(error) }); }
|
|
66
|
+
|
|
67
|
+
var done = false, ready = false, pending = message;
|
|
68
|
+
function finish(){ if (done) return; done = true; try { worker.terminate(); } catch(_){} }
|
|
69
|
+
|
|
70
|
+
worker.onmessage = function(event){
|
|
71
|
+
var data = event && event.data;
|
|
72
|
+
if (data && typeof data === 'object') {
|
|
73
|
+
if (data.__hinkalWorkerReady) {
|
|
74
|
+
ready = true;
|
|
75
|
+
try { worker.postMessage(pending); pending = null; }
|
|
76
|
+
catch (error) { post({ requestId: requestId, type: 'ERROR', error: 'postMessage failed: ' + describe(error) }); finish(); }
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (typeof data.__hinkalWorkerError === 'string') {
|
|
80
|
+
post({ requestId: requestId, type: 'ERROR', error: data.__hinkalWorkerError });
|
|
81
|
+
finish();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
post({ requestId: requestId, type: 'RESULT', data: data });
|
|
86
|
+
finish();
|
|
87
|
+
};
|
|
88
|
+
worker.onerror = function(event){
|
|
89
|
+
post({ requestId: requestId, type: 'ERROR', error: (ready ? 'worker runtime: ' : 'worker startup: ') + describe(event) });
|
|
90
|
+
finish();
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
post({ type: 'READY' });
|
|
95
|
+
})();
|
|
96
|
+
true;`, h = `<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><script>${m}<\/script></body></html>`, g = l.create({ hiddenHost: {
|
|
97
|
+
position: "absolute",
|
|
98
|
+
height: 1,
|
|
99
|
+
width: 1,
|
|
100
|
+
left: -9999,
|
|
101
|
+
top: -9999,
|
|
102
|
+
opacity: 0
|
|
103
|
+
} }), _ = () => {
|
|
104
|
+
let e = s(null), t = s({
|
|
105
|
+
ready: !1,
|
|
106
|
+
queue: []
|
|
107
|
+
}), i = a((t, r, i) => {
|
|
108
|
+
let a;
|
|
109
|
+
try {
|
|
110
|
+
a = JSON.stringify({
|
|
111
|
+
requestId: t,
|
|
112
|
+
variant: r,
|
|
113
|
+
message: i
|
|
114
|
+
}, n);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
c.emit("FROM_WEBVIEW_WORKER", {
|
|
117
|
+
requestId: t,
|
|
118
|
+
type: "ERROR",
|
|
119
|
+
error: `serialize failed: ${e?.message ?? e}`
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
e.current?.injectJavaScript(`window.handleMessage && window.handleMessage(${a}); true;`);
|
|
124
|
+
}, []);
|
|
125
|
+
o(() => {
|
|
126
|
+
let e = c.addListener("TO_WEBVIEW_WORKER", (e) => {
|
|
127
|
+
let n = {
|
|
128
|
+
requestId: e?.__requestId ?? "",
|
|
129
|
+
variant: e?.variant ?? "",
|
|
130
|
+
message: e?.message
|
|
131
|
+
};
|
|
132
|
+
t.current.ready ? i(n.requestId, n.variant, n.message) : t.current.queue.push(n);
|
|
133
|
+
});
|
|
134
|
+
return () => e.remove();
|
|
135
|
+
}, [i]);
|
|
136
|
+
let l = a((e) => {
|
|
137
|
+
let n;
|
|
138
|
+
try {
|
|
139
|
+
n = r(JSON.parse(e.nativeEvent.data));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
c.emit("FROM_WEBVIEW_WORKER", {
|
|
142
|
+
type: "ERROR",
|
|
143
|
+
error: e?.message ?? "parse error"
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (n?.type === "READY") {
|
|
148
|
+
t.current.ready = !0;
|
|
149
|
+
let e = t.current.queue;
|
|
150
|
+
t.current.queue = [], e.forEach(({ requestId: e, variant: t, message: n }) => i(e, t, n));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
c.emit("FROM_WEBVIEW_WORKER", n);
|
|
154
|
+
}, [i]);
|
|
155
|
+
return /* @__PURE__ */ f(u, {
|
|
156
|
+
pointerEvents: "none",
|
|
157
|
+
style: g.hiddenHost,
|
|
158
|
+
children: /* @__PURE__ */ f(d, {
|
|
159
|
+
ref: e,
|
|
160
|
+
source: {
|
|
161
|
+
html: h,
|
|
162
|
+
baseUrl: p
|
|
163
|
+
},
|
|
164
|
+
originWhitelist: ["*"],
|
|
165
|
+
javaScriptEnabled: !0,
|
|
166
|
+
domStorageEnabled: !0,
|
|
167
|
+
androidLayerType: "hardware",
|
|
168
|
+
onMessage: l,
|
|
169
|
+
onLoad: () => e.current?.injectJavaScript(m)
|
|
170
|
+
})
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
export { _ as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./serialization.utils.cjs`);let t=require(`react-native`);var n=class{onmessage=null;onerror=null;requestId=e.nextRequestId();subscription;constructor(e){this.variant=e,this.subscription=t.DeviceEventEmitter.addListener(`FROM_WEBVIEW_WORKER`,e=>{!e||e.requestId!==this.requestId||(e.type===`RESULT`?this.onmessage?.({data:e.data}):e.type===`ERROR`&&this.onerror?.(Error(e.error??`WebView worker error`)))})}postMessage(e){t.DeviceEventEmitter.emit(`TO_WEBVIEW_WORKER`,{__requestId:this.requestId,variant:this.variant,message:e})}terminate(){this.subscription?.remove?.(),this.subscription=null}};exports.HinkalRNWorker=n;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkerVariant } from '../../common/src/webworker/worker.registry';
|
|
2
|
+
export declare class HinkalRNWorker {
|
|
3
|
+
private variant;
|
|
4
|
+
onmessage: ((event: {
|
|
5
|
+
data: any;
|
|
6
|
+
}) => void) | null;
|
|
7
|
+
onerror: ((error: any) => void) | null;
|
|
8
|
+
private requestId;
|
|
9
|
+
private subscription;
|
|
10
|
+
constructor(variant: WorkerVariant);
|
|
11
|
+
postMessage(message: unknown): void;
|
|
12
|
+
terminate(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { nextRequestId as e } from "./serialization.utils.mjs";
|
|
2
|
+
import { DeviceEventEmitter as t } from "react-native";
|
|
3
|
+
//#region libs/shared/sdk/src/react-native/bridge/HinkalRNWorker.ts
|
|
4
|
+
var n = class {
|
|
5
|
+
onmessage = null;
|
|
6
|
+
onerror = null;
|
|
7
|
+
requestId = e();
|
|
8
|
+
subscription;
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.variant = e, this.subscription = t.addListener("FROM_WEBVIEW_WORKER", (e) => {
|
|
11
|
+
!e || e.requestId !== this.requestId || (e.type === "RESULT" ? this.onmessage?.({ data: e.data }) : e.type === "ERROR" && this.onerror?.(Error(e.error ?? "WebView worker error")));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
postMessage(e) {
|
|
15
|
+
t.emit("TO_WEBVIEW_WORKER", {
|
|
16
|
+
__requestId: this.requestId,
|
|
17
|
+
variant: this.variant,
|
|
18
|
+
message: e
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
terminate() {
|
|
22
|
+
this.subscription?.remove?.(), this.subscription = null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { n as HinkalRNWorker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(e,t)=>typeof t==`bigint`?{__bigint:t.toString()}:t instanceof Set?{__set:Array.from(t)}:t instanceof Map?{__map:Array.from(t.entries())}:t,t=e=>{if(typeof e!=`object`||!e)return e;let n=Object.keys(e);if(n.length===1){if(typeof e.__bigint==`string`)return BigInt(e.__bigint);if(Array.isArray(e.__set))return new Set(e.__set.map(t));if(Array.isArray(e.__map))return new Map(e.__map.map(e=>[t(e[0]),t(e[1])]))}return Array.isArray(e)?e.map(t):Object.fromEntries(n.map(n=>[n,t(e[n])]))},n=()=>`hinkal-rnw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;exports.bigIntReplacer=e,exports.nextRequestId=n,exports.reviveBigInts=t;
|