@yaswap/wallet-core 2.0.0
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/CHANGELOG.md +804 -0
- package/README.md +163 -0
- package/dist/package.json +76 -0
- package/dist/src/build.config.d.ts +46 -0
- package/dist/src/build.config.js +237 -0
- package/dist/src/build.config.js.map +1 -0
- package/dist/src/factory/client/clients.d.ts +11 -0
- package/dist/src/factory/client/clients.js +119 -0
- package/dist/src/factory/client/clients.js.map +1 -0
- package/dist/src/factory/client/evm.d.ts +6 -0
- package/dist/src/factory/client/evm.js +71 -0
- package/dist/src/factory/client/evm.js.map +1 -0
- package/dist/src/factory/client/index.d.ts +11 -0
- package/dist/src/factory/client/index.js +38 -0
- package/dist/src/factory/client/index.js.map +1 -0
- package/dist/src/factory/client/nft.d.ts +4 -0
- package/dist/src/factory/client/nft.js +26 -0
- package/dist/src/factory/client/nft.js.map +1 -0
- package/dist/src/factory/index.d.ts +3 -0
- package/dist/src/factory/index.js +7 -0
- package/dist/src/factory/index.js.map +1 -0
- package/dist/src/factory/settings.d.ts +4 -0
- package/dist/src/factory/settings.js +27 -0
- package/dist/src/factory/settings.js.map +1 -0
- package/dist/src/factory/swap/index.d.ts +4 -0
- package/dist/src/factory/swap/index.js +66 -0
- package/dist/src/factory/swap/index.js.map +1 -0
- package/dist/src/index.d.ts +1619 -0
- package/dist/src/index.js +38 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +1 -0
- package/dist/src/index.test.js +187 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/nameResolvers/nameResolver.d.ts +7 -0
- package/dist/src/nameResolvers/nameResolver.js +3 -0
- package/dist/src/nameResolvers/nameResolver.js.map +1 -0
- package/dist/src/nameResolvers/uns.d.ts +12 -0
- package/dist/src/nameResolvers/uns.js +83 -0
- package/dist/src/nameResolvers/uns.js.map +1 -0
- package/dist/src/nameResolvers/uns.test.d.ts +1 -0
- package/dist/src/nameResolvers/uns.test.js +29 -0
- package/dist/src/nameResolvers/uns.test.js.map +1 -0
- package/dist/src/store/actions/acceptTermsAndConditions.d.ts +4 -0
- package/dist/src/store/actions/acceptTermsAndConditions.js +17 -0
- package/dist/src/store/actions/acceptTermsAndConditions.js.map +1 -0
- package/dist/src/store/actions/acceptTermsAndConditions.test.d.ts +1 -0
- package/dist/src/store/actions/acceptTermsAndConditions.test.js +22 -0
- package/dist/src/store/actions/acceptTermsAndConditions.test.js.map +1 -0
- package/dist/src/store/actions/accounts/createAccount.d.ts +7 -0
- package/dist/src/store/actions/accounts/createAccount.js +27 -0
- package/dist/src/store/actions/accounts/createAccount.js.map +1 -0
- package/dist/src/store/actions/accounts/createAccount.test.d.ts +1 -0
- package/dist/src/store/actions/accounts/createAccount.test.js +29 -0
- package/dist/src/store/actions/accounts/createAccount.test.js.map +1 -0
- package/dist/src/store/actions/accounts/index.d.ts +5 -0
- package/dist/src/store/actions/accounts/index.js +9 -0
- package/dist/src/store/actions/accounts/index.js.map +1 -0
- package/dist/src/store/actions/accounts/removeAccount.d.ts +7 -0
- package/dist/src/store/actions/accounts/removeAccount.js +12 -0
- package/dist/src/store/actions/accounts/removeAccount.js.map +1 -0
- package/dist/src/store/actions/accounts/removeAccount.test.d.ts +1 -0
- package/dist/src/store/actions/accounts/removeAccount.test.js +53 -0
- package/dist/src/store/actions/accounts/removeAccount.test.js.map +1 -0
- package/dist/src/store/actions/accounts/toggleAccount.d.ts +8 -0
- package/dist/src/store/actions/accounts/toggleAccount.js +19 -0
- package/dist/src/store/actions/accounts/toggleAccount.js.map +1 -0
- package/dist/src/store/actions/accounts/toggleAccount.test.d.ts +1 -0
- package/dist/src/store/actions/accounts/toggleAccount.test.js +44 -0
- package/dist/src/store/actions/accounts/toggleAccount.test.js.map +1 -0
- package/dist/src/store/actions/accounts/toggleBlockchain.d.ts +9 -0
- package/dist/src/store/actions/accounts/toggleBlockchain.js +14 -0
- package/dist/src/store/actions/accounts/toggleBlockchain.js.map +1 -0
- package/dist/src/store/actions/accounts/updateAccount.d.ts +26 -0
- package/dist/src/store/actions/accounts/updateAccount.js +14 -0
- package/dist/src/store/actions/accounts/updateAccount.js.map +1 -0
- package/dist/src/store/actions/addCustomToken.d.ts +12 -0
- package/dist/src/store/actions/addCustomToken.js +12 -0
- package/dist/src/store/actions/addCustomToken.js.map +1 -0
- package/dist/src/store/actions/addCustomToken.test.d.ts +1 -0
- package/dist/src/store/actions/addCustomToken.test.js +59 -0
- package/dist/src/store/actions/addCustomToken.test.js.map +1 -0
- package/dist/src/store/actions/addExternalConnection.d.ts +9 -0
- package/dist/src/store/actions/addExternalConnection.js +13 -0
- package/dist/src/store/actions/addExternalConnection.js.map +1 -0
- package/dist/src/store/actions/addExternalConnection.test.d.ts +1 -0
- package/dist/src/store/actions/addExternalConnection.test.js +100 -0
- package/dist/src/store/actions/addExternalConnection.test.js.map +1 -0
- package/dist/src/store/actions/analytics.d.ts +21 -0
- package/dist/src/store/actions/analytics.js +58 -0
- package/dist/src/store/actions/analytics.js.map +1 -0
- package/dist/src/store/actions/analytics.test.d.ts +1 -0
- package/dist/src/store/actions/analytics.test.js +33 -0
- package/dist/src/store/actions/analytics.test.js.map +1 -0
- package/dist/src/store/actions/changeActiveNetwork.d.ts +5 -0
- package/dist/src/store/actions/changeActiveNetwork.js +13 -0
- package/dist/src/store/actions/changeActiveNetwork.js.map +1 -0
- package/dist/src/store/actions/changeActiveWalletId.d.ts +5 -0
- package/dist/src/store/actions/changeActiveWalletId.js +11 -0
- package/dist/src/store/actions/changeActiveWalletId.js.map +1 -0
- package/dist/src/store/actions/changeActiveWalletId.test.d.ts +1 -0
- package/dist/src/store/actions/changeActiveWalletId.test.js +40 -0
- package/dist/src/store/actions/changeActiveWalletId.test.js.map +1 -0
- package/dist/src/store/actions/changePassword.d.ts +4 -0
- package/dist/src/store/actions/changePassword.js +13 -0
- package/dist/src/store/actions/changePassword.js.map +1 -0
- package/dist/src/store/actions/changePassword.test.d.ts +1 -0
- package/dist/src/store/actions/changePassword.test.js +22 -0
- package/dist/src/store/actions/changePassword.test.js.map +1 -0
- package/dist/src/store/actions/checkPendingActions.d.ts +5 -0
- package/dist/src/store/actions/checkPendingActions.js +25 -0
- package/dist/src/store/actions/checkPendingActions.js.map +1 -0
- package/dist/src/store/actions/clearErrorLog.d.ts +2 -0
- package/dist/src/store/actions/clearErrorLog.js +10 -0
- package/dist/src/store/actions/clearErrorLog.js.map +1 -0
- package/dist/src/store/actions/createWallet.d.ts +7 -0
- package/dist/src/store/actions/createWallet.js +90 -0
- package/dist/src/store/actions/createWallet.js.map +1 -0
- package/dist/src/store/actions/createWallet.test.d.ts +1 -0
- package/dist/src/store/actions/createWallet.test.js +41 -0
- package/dist/src/store/actions/createWallet.test.js.map +1 -0
- package/dist/src/store/actions/customChainSettings.d.ts +15 -0
- package/dist/src/store/actions/customChainSettings.js +37 -0
- package/dist/src/store/actions/customChainSettings.js.map +1 -0
- package/dist/src/store/actions/disableAssets.d.ts +7 -0
- package/dist/src/store/actions/disableAssets.js +28 -0
- package/dist/src/store/actions/disableAssets.js.map +1 -0
- package/dist/src/store/actions/disableEthereumInjection.d.ts +2 -0
- package/dist/src/store/actions/disableEthereumInjection.js +11 -0
- package/dist/src/store/actions/disableEthereumInjection.js.map +1 -0
- package/dist/src/store/actions/disableEthereumInjection.test.d.ts +1 -0
- package/dist/src/store/actions/disableEthereumInjection.test.js +24 -0
- package/dist/src/store/actions/disableEthereumInjection.test.js.map +1 -0
- package/dist/src/store/actions/enableAssets.d.ts +7 -0
- package/dist/src/store/actions/enableAssets.js +65 -0
- package/dist/src/store/actions/enableAssets.js.map +1 -0
- package/dist/src/store/actions/enableAssets.test.d.ts +1 -0
- package/dist/src/store/actions/enableAssets.test.js +37 -0
- package/dist/src/store/actions/enableAssets.test.js.map +1 -0
- package/dist/src/store/actions/enableDisableAssets.test.d.ts +1 -0
- package/dist/src/store/actions/enableDisableAssets.test.js +79 -0
- package/dist/src/store/actions/enableDisableAssets.test.js.map +1 -0
- package/dist/src/store/actions/enableEthereumInjection.d.ts +2 -0
- package/dist/src/store/actions/enableEthereumInjection.js +11 -0
- package/dist/src/store/actions/enableEthereumInjection.js.map +1 -0
- package/dist/src/store/actions/exportPrivateKey.d.ts +9 -0
- package/dist/src/store/actions/exportPrivateKey.js +12 -0
- package/dist/src/store/actions/exportPrivateKey.js.map +1 -0
- package/dist/src/store/actions/exportPrivateKey.test.d.ts +1 -0
- package/dist/src/store/actions/exportPrivateKey.test.js +36 -0
- package/dist/src/store/actions/exportPrivateKey.test.js.map +1 -0
- package/dist/src/store/actions/fetchTokenDetails.d.ts +11 -0
- package/dist/src/store/actions/fetchTokenDetails.js +22 -0
- package/dist/src/store/actions/fetchTokenDetails.js.map +1 -0
- package/dist/src/store/actions/forgetDappConnections.d.ts +2 -0
- package/dist/src/store/actions/forgetDappConnections.js +11 -0
- package/dist/src/store/actions/forgetDappConnections.js.map +1 -0
- package/dist/src/store/actions/getLockForAsset.d.ts +8 -0
- package/dist/src/store/actions/getLockForAsset.js +34 -0
- package/dist/src/store/actions/getLockForAsset.js.map +1 -0
- package/dist/src/store/actions/getQuotes.d.ts +13 -0
- package/dist/src/store/actions/getQuotes.js +70 -0
- package/dist/src/store/actions/getQuotes.js.map +1 -0
- package/dist/src/store/actions/getQuotes.test.d.ts +1 -0
- package/dist/src/store/actions/getQuotes.test.js +30 -0
- package/dist/src/store/actions/getQuotes.test.js.map +1 -0
- package/dist/src/store/actions/getUnusedAddresses.d.ts +8 -0
- package/dist/src/store/actions/getUnusedAddresses.js +51 -0
- package/dist/src/store/actions/getUnusedAddresses.js.map +1 -0
- package/dist/src/store/actions/hardware-wallet/getLedgerAccounts.d.ts +16 -0
- package/dist/src/store/actions/hardware-wallet/getLedgerAccounts.js +57 -0
- package/dist/src/store/actions/hardware-wallet/getLedgerAccounts.js.map +1 -0
- package/dist/src/store/actions/hardware-wallet/index.d.ts +1 -0
- package/dist/src/store/actions/hardware-wallet/index.js +5 -0
- package/dist/src/store/actions/hardware-wallet/index.js.map +1 -0
- package/dist/src/store/actions/index.d.ts +47 -0
- package/dist/src/store/actions/index.js +51 -0
- package/dist/src/store/actions/index.js.map +1 -0
- package/dist/src/store/actions/initializeAddresses.d.ts +6 -0
- package/dist/src/store/actions/initializeAddresses.js +26 -0
- package/dist/src/store/actions/initializeAddresses.js.map +1 -0
- package/dist/src/store/actions/initializeAddresses.test.d.ts +1 -0
- package/dist/src/store/actions/initializeAddresses.test.js +58 -0
- package/dist/src/store/actions/initializeAddresses.test.js.map +1 -0
- package/dist/src/store/actions/lockWallet.d.ts +2 -0
- package/dist/src/store/actions/lockWallet.js +11 -0
- package/dist/src/store/actions/lockWallet.js.map +1 -0
- package/dist/src/store/actions/lockWallet.test.d.ts +1 -0
- package/dist/src/store/actions/lockWallet.test.js +24 -0
- package/dist/src/store/actions/lockWallet.test.js.map +1 -0
- package/dist/src/store/actions/logError.d.ts +3 -0
- package/dist/src/store/actions/logError.js +10 -0
- package/dist/src/store/actions/logError.js.map +1 -0
- package/dist/src/store/actions/logError.test.d.ts +1 -0
- package/dist/src/store/actions/logError.test.js +27 -0
- package/dist/src/store/actions/logError.test.js.map +1 -0
- package/dist/src/store/actions/newSwap.d.ts +12 -0
- package/dist/src/store/actions/newSwap.js +34 -0
- package/dist/src/store/actions/newSwap.js.map +1 -0
- package/dist/src/store/actions/performNextAction/index.d.ts +7 -0
- package/dist/src/store/actions/performNextAction/index.js +65 -0
- package/dist/src/store/actions/performNextAction/index.js.map +1 -0
- package/dist/src/store/actions/performNextAction/send.d.ts +7 -0
- package/dist/src/store/actions/performNextAction/send.js +54 -0
- package/dist/src/store/actions/performNextAction/send.js.map +1 -0
- package/dist/src/store/actions/performNextAction/sendNFT.d.ts +7 -0
- package/dist/src/store/actions/performNextAction/sendNFT.js +50 -0
- package/dist/src/store/actions/performNextAction/sendNFT.js.map +1 -0
- package/dist/src/store/actions/performNextAction/utils.d.ts +11 -0
- package/dist/src/store/actions/performNextAction/utils.js +42 -0
- package/dist/src/store/actions/performNextAction/utils.js.map +1 -0
- package/dist/src/store/actions/proxyMutation.d.ts +5 -0
- package/dist/src/store/actions/proxyMutation.js +9 -0
- package/dist/src/store/actions/proxyMutation.js.map +1 -0
- package/dist/src/store/actions/removeCustomToken.d.ts +7 -0
- package/dist/src/store/actions/removeCustomToken.js +11 -0
- package/dist/src/store/actions/removeCustomToken.js.map +1 -0
- package/dist/src/store/actions/retrySwap.d.ts +5 -0
- package/dist/src/store/actions/retrySwap.js +23 -0
- package/dist/src/store/actions/retrySwap.js.map +1 -0
- package/dist/src/store/actions/sendNFTTransaction.d.ts +4 -0
- package/dist/src/store/actions/sendNFTTransaction.js +47 -0
- package/dist/src/store/actions/sendNFTTransaction.js.map +1 -0
- package/dist/src/store/actions/sendTransaction.d.ts +17 -0
- package/dist/src/store/actions/sendTransaction.js +51 -0
- package/dist/src/store/actions/sendTransaction.js.map +1 -0
- package/dist/src/store/actions/sendTransaction.test.d.ts +1 -0
- package/dist/src/store/actions/sendTransaction.test.js +80 -0
- package/dist/src/store/actions/sendTransaction.test.js.map +1 -0
- package/dist/src/store/actions/setEthereumInjectionChain.d.ts +5 -0
- package/dist/src/store/actions/setEthereumInjectionChain.js +11 -0
- package/dist/src/store/actions/setEthereumInjectionChain.js.map +1 -0
- package/dist/src/store/actions/setEthereumInjectionChain.test.d.ts +1 -0
- package/dist/src/store/actions/setEthereumInjectionChain.test.js +20 -0
- package/dist/src/store/actions/setEthereumInjectionChain.test.js.map +1 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.d.ts +4 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.js +10 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.js.map +1 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.test.d.ts +1 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.test.js +24 -0
- package/dist/src/store/actions/setWhatsNewModalVersion.test.js.map +1 -0
- package/dist/src/store/actions/showNotification.d.ts +2 -0
- package/dist/src/store/actions/showNotification.js +10 -0
- package/dist/src/store/actions/showNotification.js.map +1 -0
- package/dist/src/store/actions/toggleExperiment.d.ts +5 -0
- package/dist/src/store/actions/toggleExperiment.js +10 -0
- package/dist/src/store/actions/toggleExperiment.js.map +1 -0
- package/dist/src/store/actions/toggleExperiment.test.d.ts +1 -0
- package/dist/src/store/actions/toggleExperiment.test.js +34 -0
- package/dist/src/store/actions/toggleExperiment.test.js.map +1 -0
- package/dist/src/store/actions/toggleNFTStarred.d.ts +8 -0
- package/dist/src/store/actions/toggleNFTStarred.js +10 -0
- package/dist/src/store/actions/toggleNFTStarred.js.map +1 -0
- package/dist/src/store/actions/unlockWallet.d.ts +4 -0
- package/dist/src/store/actions/unlockWallet.js +22 -0
- package/dist/src/store/actions/unlockWallet.js.map +1 -0
- package/dist/src/store/actions/updateAccountBalance.d.ts +7 -0
- package/dist/src/store/actions/updateAccountBalance.js +29 -0
- package/dist/src/store/actions/updateAccountBalance.js.map +1 -0
- package/dist/src/store/actions/updateBalances.d.ts +9 -0
- package/dist/src/store/actions/updateBalances.js +169 -0
- package/dist/src/store/actions/updateBalances.js.map +1 -0
- package/dist/src/store/actions/updateBalances.test.d.ts +1 -0
- package/dist/src/store/actions/updateBalances.test.js +43 -0
- package/dist/src/store/actions/updateBalances.test.js.map +1 -0
- package/dist/src/store/actions/updateCurrenciesInfo.d.ts +5 -0
- package/dist/src/store/actions/updateCurrenciesInfo.js +14 -0
- package/dist/src/store/actions/updateCurrenciesInfo.js.map +1 -0
- package/dist/src/store/actions/updateFees.d.ts +6 -0
- package/dist/src/store/actions/updateFees.js +16 -0
- package/dist/src/store/actions/updateFees.js.map +1 -0
- package/dist/src/store/actions/updateFees.test.d.ts +1 -0
- package/dist/src/store/actions/updateFees.test.js +86 -0
- package/dist/src/store/actions/updateFees.test.js.map +1 -0
- package/dist/src/store/actions/updateFiatRates.d.ts +5 -0
- package/dist/src/store/actions/updateFiatRates.js +15 -0
- package/dist/src/store/actions/updateFiatRates.js.map +1 -0
- package/dist/src/store/actions/updateFiatRates.test.d.ts +1 -0
- package/dist/src/store/actions/updateFiatRates.test.js +43 -0
- package/dist/src/store/actions/updateFiatRates.test.js.map +1 -0
- package/dist/src/store/actions/updateMarketData.d.ts +8 -0
- package/dist/src/store/actions/updateMarketData.js +28 -0
- package/dist/src/store/actions/updateMarketData.js.map +1 -0
- package/dist/src/store/actions/updateMarketData.test.d.ts +1 -0
- package/dist/src/store/actions/updateMarketData.test.js +49 -0
- package/dist/src/store/actions/updateMarketData.test.js.map +1 -0
- package/dist/src/store/actions/updateNFTs.d.ts +7 -0
- package/dist/src/store/actions/updateNFTs.js +39 -0
- package/dist/src/store/actions/updateNFTs.js.map +1 -0
- package/dist/src/store/actions/updateNFTs.test.d.ts +1 -0
- package/dist/src/store/actions/updateNFTs.test.js +32 -0
- package/dist/src/store/actions/updateNFTs.test.js.map +1 -0
- package/dist/src/store/actions/updateTransactionFee.d.ts +11 -0
- package/dist/src/store/actions/updateTransactionFee.js +81 -0
- package/dist/src/store/actions/updateTransactionFee.js.map +1 -0
- package/dist/src/store/broker/notification.d.ts +4 -0
- package/dist/src/store/broker/notification.js +84 -0
- package/dist/src/store/broker/notification.js.map +1 -0
- package/dist/src/store/getters.d.ts +59 -0
- package/dist/src/store/getters.js +350 -0
- package/dist/src/store/getters.js.map +1 -0
- package/dist/src/store/index.d.ts +3524 -0
- package/dist/src/store/index.js +24 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/store/migrations/10_analytics_settings.d.ts +4 -0
- package/dist/src/store/migrations/10_analytics_settings.js +19 -0
- package/dist/src/store/migrations/10_analytics_settings.js.map +1 -0
- package/dist/src/store/migrations/11_12_rsk_legacy_derivation_path.d.ts +8 -0
- package/dist/src/store/migrations/11_12_rsk_legacy_derivation_path.js +22 -0
- package/dist/src/store/migrations/11_12_rsk_legacy_derivation_path.js.map +1 -0
- package/dist/src/store/migrations/13_rsk_fish_token.d.ts +4 -0
- package/dist/src/store/migrations/13_rsk_fish_token.js +19 -0
- package/dist/src/store/migrations/13_rsk_fish_token.js.map +1 -0
- package/dist/src/store/migrations/14_account_set_derivation_path.d.ts +4 -0
- package/dist/src/store/migrations/14_account_set_derivation_path.js +56 -0
- package/dist/src/store/migrations/14_account_set_derivation_path.js.map +1 -0
- package/dist/src/store/migrations/15_accounts_chains_set_enabled.d.ts +4 -0
- package/dist/src/store/migrations/15_accounts_chains_set_enabled.js +25 -0
- package/dist/src/store/migrations/15_accounts_chains_set_enabled.js.map +1 -0
- package/dist/src/store/migrations/16_enable_terra_chain.d.ts +4 -0
- package/dist/src/store/migrations/16_enable_terra_chain.js +10 -0
- package/dist/src/store/migrations/16_enable_terra_chain.js.map +1 -0
- package/dist/src/store/migrations/17_remove_injection_enabled.d.ts +4 -0
- package/dist/src/store/migrations/17_remove_injection_enabled.js +12 -0
- package/dist/src/store/migrations/17_remove_injection_enabled.js.map +1 -0
- package/dist/src/store/migrations/18_enable_avalanche_chain.d.ts +4 -0
- package/dist/src/store/migrations/18_enable_avalanche_chain.js +10 -0
- package/dist/src/store/migrations/18_enable_avalanche_chain.js.map +1 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts.d.ts +4 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts.js +25 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts.js.map +1 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts.state.pre.json +1944 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts_test.d.ts +1 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts_test.js +7 -0
- package/dist/src/store/migrations/19_remove_existing_ledger_accounts_test.js.map +1 -0
- package/dist/src/store/migrations/1_first_migration.d.ts +4 -0
- package/dist/src/store/migrations/1_first_migration.js +11 -0
- package/dist/src/store/migrations/1_first_migration.js.map +1 -0
- package/dist/src/store/migrations/20_fix_accounts.d.ts +4 -0
- package/dist/src/store/migrations/20_fix_accounts.js +68 -0
- package/dist/src/store/migrations/20_fix_accounts.js.map +1 -0
- package/dist/src/store/migrations/21_enable_solana_chain.d.ts +4 -0
- package/dist/src/store/migrations/21_enable_solana_chain.js +10 -0
- package/dist/src/store/migrations/21_enable_solana_chain.js.map +1 -0
- package/dist/src/store/migrations/22_enable_optimism_chain.d.ts +4 -0
- package/dist/src/store/migrations/22_enable_optimism_chain.js +10 -0
- package/dist/src/store/migrations/22_enable_optimism_chain.js.map +1 -0
- package/dist/src/store/migrations/2_set_default_assets.d.ts +4 -0
- package/dist/src/store/migrations/2_set_default_assets.js +20 -0
- package/dist/src/store/migrations/2_set_default_assets.js.map +1 -0
- package/dist/src/store/migrations/3_add_network_custom_tokens.d.ts +4 -0
- package/dist/src/store/migrations/3_add_network_custom_tokens.js +21 -0
- package/dist/src/store/migrations/3_add_network_custom_tokens.js.map +1 -0
- package/dist/src/store/migrations/4_fix_rsk_token_injected_asset.d.ts +4 -0
- package/dist/src/store/migrations/4_fix_rsk_token_injected_asset.js +15 -0
- package/dist/src/store/migrations/4_fix_rsk_token_injected_asset.js.map +1 -0
- package/dist/src/store/migrations/5_multiple_account_support.d.ts +4 -0
- package/dist/src/store/migrations/5_multiple_account_support.js +96 -0
- package/dist/src/store/migrations/5_multiple_account_support.js.map +1 -0
- package/dist/src/store/migrations/6_use_ledger_live_default.d.ts +4 -0
- package/dist/src/store/migrations/6_use_ledger_live_default.js +11 -0
- package/dist/src/store/migrations/6_use_ledger_live_default.js.map +1 -0
- package/dist/src/store/migrations/7_multi_provider_swaps.d.ts +4 -0
- package/dist/src/store/migrations/7_multi_provider_swaps.js +27 -0
- package/dist/src/store/migrations/7_multi_provider_swaps.js.map +1 -0
- package/dist/src/store/migrations/8_remove_use_ledger_live.d.ts +4 -0
- package/dist/src/store/migrations/8_remove_use_ledger_live.js +12 -0
- package/dist/src/store/migrations/8_remove_use_ledger_live.js.map +1 -0
- package/dist/src/store/migrations/9_inject_ethereum_asset_chain.d.ts +4 -0
- package/dist/src/store/migrations/9_inject_ethereum_asset_chain.js +14 -0
- package/dist/src/store/migrations/9_inject_ethereum_asset_chain.js.map +1 -0
- package/dist/src/store/migrations/before_after_migration_script.test.d.ts +1 -0
- package/dist/src/store/migrations/before_after_migration_script.test.js +92 -0
- package/dist/src/store/migrations/before_after_migration_script.test.js.map +1 -0
- package/dist/src/store/migrations/enable_chain.d.ts +3 -0
- package/dist/src/store/migrations/enable_chain.js +71 -0
- package/dist/src/store/migrations/enable_chain.js.map +1 -0
- package/dist/src/store/migrations/index.d.ts +5 -0
- package/dist/src/store/migrations/index.js +78 -0
- package/dist/src/store/migrations/index.js.map +1 -0
- package/dist/src/store/migrations/migration_script.test.d.ts +1 -0
- package/dist/src/store/migrations/migration_script.test.js +59 -0
- package/dist/src/store/migrations/migration_script.test.js.map +1 -0
- package/dist/src/store/mutations.d.ts +209 -0
- package/dist/src/store/mutations.js +348 -0
- package/dist/src/store/mutations.js.map +1 -0
- package/dist/src/store/state.d.ts +3 -0
- package/dist/src/store/state.js +46 -0
- package/dist/src/store/state.js.map +1 -0
- package/dist/src/store/types.d.ts +249 -0
- package/dist/src/store/types.js +64 -0
- package/dist/src/store/types.js.map +1 -0
- package/dist/src/store/utils.d.ts +38 -0
- package/dist/src/store/utils.js +194 -0
- package/dist/src/store/utils.js.map +1 -0
- package/dist/src/swaps/EvmSwapProvider.d.ts +32 -0
- package/dist/src/swaps/EvmSwapProvider.js +118 -0
- package/dist/src/swaps/EvmSwapProvider.js.map +1 -0
- package/dist/src/swaps/SwapProvider.d.ts +35 -0
- package/dist/src/swaps/SwapProvider.js +89 -0
- package/dist/src/swaps/SwapProvider.js.map +1 -0
- package/dist/src/swaps/astroport/AstroportSwapProvider.d.ts +67 -0
- package/dist/src/swaps/astroport/AstroportSwapProvider.js +251 -0
- package/dist/src/swaps/astroport/AstroportSwapProvider.js.map +1 -0
- package/dist/src/swaps/astroport/info.json +7 -0
- package/dist/src/swaps/astroport/queries.d.ts +108 -0
- package/dist/src/swaps/astroport/queries.js +227 -0
- package/dist/src/swaps/astroport/queries.js.map +1 -0
- package/dist/src/swaps/debridge/DeBridgeSwapProvider.d.ts +98 -0
- package/dist/src/swaps/debridge/DeBridgeSwapProvider.js +553 -0
- package/dist/src/swaps/debridge/DeBridgeSwapProvider.js.map +1 -0
- package/dist/src/swaps/debridge/abi/DeBridgeGate.json +1958 -0
- package/dist/src/swaps/debridge/abi/SignatureVerifier.json +925 -0
- package/dist/src/swaps/debridge/info.json +13 -0
- package/dist/src/swaps/fastbtc/FastBTCDepositSwapProvider.d.ts +103 -0
- package/dist/src/swaps/fastbtc/FastBTCDepositSwapProvider.js +292 -0
- package/dist/src/swaps/fastbtc/FastBTCDepositSwapProvider.js.map +1 -0
- package/dist/src/swaps/fastbtc/FastBTCWithdrawSwapProvider.d.ts +108 -0
- package/dist/src/swaps/fastbtc/FastBTCWithdrawSwapProvider.js +306 -0
- package/dist/src/swaps/fastbtc/FastBTCWithdrawSwapProvider.js.map +1 -0
- package/dist/src/swaps/fastbtc/fastBtcBridgeContract.d.ts +19 -0
- package/dist/src/swaps/fastbtc/fastBtcBridgeContract.js +24 -0
- package/dist/src/swaps/fastbtc/fastBtcBridgeContract.js.map +1 -0
- package/dist/src/swaps/fastbtc/info.json +7 -0
- package/dist/src/swaps/hop/HopSwapProvider.d.ts +124 -0
- package/dist/src/swaps/hop/HopSwapProvider.js +479 -0
- package/dist/src/swaps/hop/HopSwapProvider.js.map +1 -0
- package/dist/src/swaps/hop/info.json +12 -0
- package/dist/src/swaps/hop/queries.d.ts +2 -0
- package/dist/src/swaps/hop/queries.js +61 -0
- package/dist/src/swaps/hop/queries.js.map +1 -0
- package/dist/src/swaps/jupiter/JupiterSwapProvider.d.ts +46 -0
- package/dist/src/swaps/jupiter/JupiterSwapProvider.js +189 -0
- package/dist/src/swaps/jupiter/JupiterSwapProvider.js.map +1 -0
- package/dist/src/swaps/jupiter/info.json +7 -0
- package/dist/src/swaps/lifi/LifiSwapProvider.d.ts +76 -0
- package/dist/src/swaps/lifi/LifiSwapProvider.js +313 -0
- package/dist/src/swaps/lifi/LifiSwapProvider.js.map +1 -0
- package/dist/src/swaps/lifi/info.json +7 -0
- package/dist/src/swaps/liquality/LiqualitySwapProvider.d.ts +104 -0
- package/dist/src/swaps/liquality/LiqualitySwapProvider.js +704 -0
- package/dist/src/swaps/liquality/LiqualitySwapProvider.js.map +1 -0
- package/dist/src/swaps/liquality/info.json +7 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostERC20toNative/LiqualityBoostERC20toNative.d.ts +124 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostERC20toNative/LiqualityBoostERC20toNative.js +239 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostERC20toNative/LiqualityBoostERC20toNative.js.map +1 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostERC20toNative/info.json +7 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostNativeToERC20/LiqualityBoostNativeToERC20.d.ts +52 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostNativeToERC20/LiqualityBoostNativeToERC20.js +213 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostNativeToERC20/LiqualityBoostNativeToERC20.js.map +1 -0
- package/dist/src/swaps/liqualityboost/liqualityBoostNativeToERC20/info.json +7 -0
- package/dist/src/swaps/liqualityboost/types.d.ts +17 -0
- package/dist/src/swaps/liqualityboost/types.js +3 -0
- package/dist/src/swaps/liqualityboost/types.js.map +1 -0
- package/dist/src/swaps/oneinch/OneinchSwapProvider.d.ts +86 -0
- package/dist/src/swaps/oneinch/OneinchSwapProvider.js +369 -0
- package/dist/src/swaps/oneinch/OneinchSwapProvider.js.map +1 -0
- package/dist/src/swaps/oneinch/info.json +13 -0
- package/dist/src/swaps/sovryn/SovrynSwapProvider.d.ts +110 -0
- package/dist/src/swaps/sovryn/SovrynSwapProvider.js +369 -0
- package/dist/src/swaps/sovryn/SovrynSwapProvider.js.map +1 -0
- package/dist/src/swaps/sovryn/info.json +7 -0
- package/dist/src/swaps/teleswap/TeleSwapSwapProvider.d.ts +167 -0
- package/dist/src/swaps/teleswap/TeleSwapSwapProvider.js +874 -0
- package/dist/src/swaps/teleswap/TeleSwapSwapProvider.js.map +1 -0
- package/dist/src/swaps/teleswap/info.json +7 -0
- package/dist/src/swaps/thorchain/ThorchainSwapProvider.d.ts +194 -0
- package/dist/src/swaps/thorchain/ThorchainSwapProvider.js +534 -0
- package/dist/src/swaps/thorchain/ThorchainSwapProvider.js.map +1 -0
- package/dist/src/swaps/thorchain/info.json +7 -0
- package/dist/src/swaps/types.d.ts +87 -0
- package/dist/src/swaps/types.js +9 -0
- package/dist/src/swaps/types.js.map +1 -0
- package/dist/src/swaps/uniswap/UniswapSwapProvider.d.ts +117 -0
- package/dist/src/swaps/uniswap/UniswapSwapProvider.js +438 -0
- package/dist/src/swaps/uniswap/UniswapSwapProvider.js.map +1 -0
- package/dist/src/swaps/uniswap/info.json +7 -0
- package/dist/src/swaps/utils.d.ts +92 -0
- package/dist/src/swaps/utils.js +57 -0
- package/dist/src/swaps/utils.js.map +1 -0
- package/dist/src/tsconfig.json +30 -0
- package/dist/src/types.d.ts +29 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/accounts.d.ts +16 -0
- package/dist/src/utils/accounts.js +89 -0
- package/dist/src/utils/accounts.js.map +1 -0
- package/dist/src/utils/address.d.ts +8 -0
- package/dist/src/utils/address.js +17 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +1 -0
- package/dist/src/utils/address.test.js +12 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/asset.d.ts +22 -0
- package/dist/src/utils/asset.js +198 -0
- package/dist/src/utils/asset.js.map +1 -0
- package/dist/src/utils/asset.test.d.ts +1 -0
- package/dist/src/utils/asset.test.js +42 -0
- package/dist/src/utils/asset.test.js.map +1 -0
- package/dist/src/utils/chainify.d.ts +3 -0
- package/dist/src/utils/chainify.js +41 -0
- package/dist/src/utils/chainify.js.map +1 -0
- package/dist/src/utils/coinFormatter.d.ts +13 -0
- package/dist/src/utils/coinFormatter.js +58 -0
- package/dist/src/utils/coinFormatter.js.map +1 -0
- package/dist/src/utils/crypto.d.ts +6 -0
- package/dist/src/utils/crypto.js +70 -0
- package/dist/src/utils/crypto.js.map +1 -0
- package/dist/src/utils/cryptoassets.d.ts +5 -0
- package/dist/src/utils/cryptoassets.js +26 -0
- package/dist/src/utils/cryptoassets.js.map +1 -0
- package/dist/src/utils/derivationPath.d.ts +6 -0
- package/dist/src/utils/derivationPath.js +75 -0
- package/dist/src/utils/derivationPath.js.map +1 -0
- package/dist/src/utils/derivationPath.spec.d.ts +1 -0
- package/dist/src/utils/derivationPath.spec.js +37 -0
- package/dist/src/utils/derivationPath.spec.js.map +1 -0
- package/dist/src/utils/export.d.ts +5 -0
- package/dist/src/utils/export.js +24 -0
- package/dist/src/utils/export.js.map +1 -0
- package/dist/src/utils/fees.d.ts +43 -0
- package/dist/src/utils/fees.js +222 -0
- package/dist/src/utils/fees.js.map +1 -0
- package/dist/src/utils/fees.test.d.ts +1 -0
- package/dist/src/utils/fees.test.js +40 -0
- package/dist/src/utils/fees.test.js.map +1 -0
- package/dist/src/utils/fetchTokenDetails.d.ts +1 -0
- package/dist/src/utils/fetchTokenDetails.js +19 -0
- package/dist/src/utils/fetchTokenDetails.js.map +1 -0
- package/dist/src/utils/history.d.ts +66 -0
- package/dist/src/utils/history.js +135 -0
- package/dist/src/utils/history.js.map +1 -0
- package/dist/src/utils/isTransactionNotFoundError.d.ts +1 -0
- package/dist/src/utils/isTransactionNotFoundError.js +16 -0
- package/dist/src/utils/isTransactionNotFoundError.js.map +1 -0
- package/dist/src/utils/ledger.d.ts +12 -0
- package/dist/src/utils/ledger.js +38 -0
- package/dist/src/utils/ledger.js.map +1 -0
- package/dist/src/utils/moment.d.ts +2 -0
- package/dist/src/utils/moment.js +8 -0
- package/dist/src/utils/moment.js.map +1 -0
- package/dist/src/utils/networks.d.ts +10 -0
- package/dist/src/utils/networks.js +43 -0
- package/dist/src/utils/networks.js.map +1 -0
- package/dist/src/utils/parseTokenTx.d.ts +2 -0
- package/dist/src/utils/parseTokenTx.js +10 -0
- package/dist/src/utils/parseTokenTx.js.map +1 -0
- package/dist/src/utils/quotes.d.ts +5 -0
- package/dist/src/utils/quotes.js +20 -0
- package/dist/src/utils/quotes.js.map +1 -0
- package/dist/src/utils/quotes.test.d.ts +1 -0
- package/dist/src/utils/quotes.test.js +85 -0
- package/dist/src/utils/quotes.test.js.map +1 -0
- package/dist/src/utils/timeline.d.ts +71 -0
- package/dist/src/utils/timeline.js +176 -0
- package/dist/src/utils/timeline.js.map +1 -0
- package/dist/src/walletOptions/defaultOptions.d.ts +3 -0
- package/dist/src/walletOptions/defaultOptions.js +36 -0
- package/dist/src/walletOptions/defaultOptions.js.map +1 -0
- package/dist/src/walletOptions/index.d.ts +7 -0
- package/dist/src/walletOptions/index.js +11 -0
- package/dist/src/walletOptions/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqualitySwapProvider = exports.LiqualityTxTypes = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client_1 = require("@yaswap/client");
|
|
6
|
+
const utils_1 = require("@yaswap/utils");
|
|
7
|
+
const cryptoassets_1 = require("@yaswap/cryptoassets");
|
|
8
|
+
const bignumber_js_1 = tslib_1.__importStar(require("bignumber.js"));
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const package_json_1 = tslib_1.__importDefault(require("../../../package.json"));
|
|
12
|
+
const utils_2 = require("../../store/actions/performNextAction/utils");
|
|
13
|
+
const utils_3 = require("../../store/utils");
|
|
14
|
+
const chainify_1 = require("../../utils/chainify");
|
|
15
|
+
const coinFormatter_1 = require("../../utils/coinFormatter");
|
|
16
|
+
const cryptoassets_2 = tslib_1.__importDefault(require("../../utils/cryptoassets"));
|
|
17
|
+
const fees_1 = require("../../utils/fees");
|
|
18
|
+
const asset_1 = require("../../utils/asset");
|
|
19
|
+
const EvmSwapProvider_1 = require("../EvmSwapProvider");
|
|
20
|
+
const VERSION_STRING = `Wallet ${package_json_1.default.version} (Chainify ${package_json_1.default.dependencies['@yaswap/client']
|
|
21
|
+
.replace('^', '')
|
|
22
|
+
.replace('~', '')})`;
|
|
23
|
+
const headers = {
|
|
24
|
+
'x-requested-with': VERSION_STRING,
|
|
25
|
+
'x-liquality-user-agent': VERSION_STRING,
|
|
26
|
+
};
|
|
27
|
+
var LiqualityTxTypes;
|
|
28
|
+
(function (LiqualityTxTypes) {
|
|
29
|
+
LiqualityTxTypes["SWAP_INITIATION"] = "SWAP_INITIATION";
|
|
30
|
+
LiqualityTxTypes["SWAP_CLAIM"] = "SWAP_CLAIM";
|
|
31
|
+
})(LiqualityTxTypes = exports.LiqualityTxTypes || (exports.LiqualityTxTypes = {}));
|
|
32
|
+
class LiqualitySwapProvider extends EvmSwapProvider_1.EvmSwapProvider {
|
|
33
|
+
constructor(config) {
|
|
34
|
+
super(config);
|
|
35
|
+
this.feeUnits = {
|
|
36
|
+
[LiqualityTxTypes.SWAP_INITIATION]: {
|
|
37
|
+
ETH: 165000,
|
|
38
|
+
RBTC: 165000,
|
|
39
|
+
BNB: 165000,
|
|
40
|
+
NEAR: 10000000000000,
|
|
41
|
+
SOL: 2,
|
|
42
|
+
LUNA: 800000,
|
|
43
|
+
UST: 800000,
|
|
44
|
+
MATIC: 165000,
|
|
45
|
+
ERC20: 200000,
|
|
46
|
+
ARBETH: 2400000,
|
|
47
|
+
AVAX: 165000,
|
|
48
|
+
},
|
|
49
|
+
[LiqualityTxTypes.SWAP_CLAIM]: {
|
|
50
|
+
BTC: 143,
|
|
51
|
+
ETH: 90000,
|
|
52
|
+
RBTC: 90000,
|
|
53
|
+
BNB: 90000,
|
|
54
|
+
MATIC: 90000,
|
|
55
|
+
NEAR: 8000000000000,
|
|
56
|
+
SOL: 1,
|
|
57
|
+
LUNA: 800000,
|
|
58
|
+
UST: 800000,
|
|
59
|
+
ERC20: 110000,
|
|
60
|
+
ARBETH: 680000,
|
|
61
|
+
AVAX: 90000,
|
|
62
|
+
YAC: 11,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
this._httpClient = new client_1.HttpClient({ baseURL: this.config.agent });
|
|
66
|
+
}
|
|
67
|
+
getMarketInfo() {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return this._httpClient.nodeGet('/api/swap/marketinfo', null, { headers });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getAssetLiquidity(asset) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const assetsInfo = yield this._httpClient.nodeGet('api/swap/assetinfo');
|
|
75
|
+
const assetInfo = assetsInfo.find(({ code }) => code === asset);
|
|
76
|
+
if (!assetInfo) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
return assetInfo.balance;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
getSupportedPairs() {
|
|
83
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const markets = yield this.getMarketInfo();
|
|
85
|
+
const pairs = markets
|
|
86
|
+
.filter((market) => cryptoassets_2.default[market.from] && cryptoassets_2.default[market.to])
|
|
87
|
+
.map((market) => ({
|
|
88
|
+
from: market.from,
|
|
89
|
+
to: market.to,
|
|
90
|
+
min: new bignumber_js_1.default((0, cryptoassets_1.unitToCurrency)(cryptoassets_2.default[market.from], market.min)).toFixed(),
|
|
91
|
+
max: new bignumber_js_1.default((0, cryptoassets_1.unitToCurrency)(cryptoassets_2.default[market.from], market.max)).toFixed(),
|
|
92
|
+
rate: new bignumber_js_1.default(market.rate).toFixed(),
|
|
93
|
+
}));
|
|
94
|
+
return pairs;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getQuote({ network, from, to, amount }) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const marketData = this.getMarketData(network);
|
|
100
|
+
const market = marketData.find((market) => market.provider === this.config.providerId && market.to === to && market.from === from);
|
|
101
|
+
if (!market)
|
|
102
|
+
return null;
|
|
103
|
+
const fromAmount = (0, cryptoassets_1.currencyToUnit)(cryptoassets_2.default[from], amount);
|
|
104
|
+
const toAmount = (0, cryptoassets_1.currencyToUnit)(cryptoassets_2.default[to], new bignumber_js_1.default(amount).times(new bignumber_js_1.default(market.rate)));
|
|
105
|
+
return {
|
|
106
|
+
fromAmount: fromAmount.toFixed(),
|
|
107
|
+
toAmount: toAmount.toFixed(),
|
|
108
|
+
min: new bignumber_js_1.default(market.min),
|
|
109
|
+
max: new bignumber_js_1.default(market.max),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
newSwap(swapRequest) {
|
|
114
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const updates = yield this.initiateSwap(swapRequest);
|
|
116
|
+
return Object.assign({ id: (0, uuid_1.v4)() }, updates);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
initiateSwap({ network, walletId, quote: _quote }) {
|
|
120
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
const lockedQuote = yield this._getQuote({
|
|
122
|
+
from: _quote.from,
|
|
123
|
+
to: _quote.to,
|
|
124
|
+
amount: _quote.fromAmount,
|
|
125
|
+
});
|
|
126
|
+
delete lockedQuote.id;
|
|
127
|
+
if (new bignumber_js_1.default(lockedQuote.toAmount).lt(new bignumber_js_1.default(_quote.toAmount).times(0.995))) {
|
|
128
|
+
throw new Error('The quote slippage is too high (> 0.5%). Try again.');
|
|
129
|
+
}
|
|
130
|
+
const quote = Object.assign(Object.assign({}, _quote), lockedQuote);
|
|
131
|
+
if (yield this.hasQuoteExpired(quote)) {
|
|
132
|
+
throw new Error('The quote is expired.');
|
|
133
|
+
}
|
|
134
|
+
quote.fromAddress = yield this.getSwapAddress(network, walletId, quote.from, quote.fromAccountId);
|
|
135
|
+
quote.toAddress = yield this.getSwapAddress(network, walletId, quote.to, quote.toAccountId);
|
|
136
|
+
const fromClient = this.getClient(network, walletId, quote.from, quote.fromAccountId);
|
|
137
|
+
const message = [
|
|
138
|
+
'Creating a swap with following terms:',
|
|
139
|
+
`Send: ${quote.fromAmount} (lowest denomination) ${quote.from}`,
|
|
140
|
+
`Receive: ${quote.toAmount} (lowest denomination) ${quote.to}`,
|
|
141
|
+
`My ${quote.from} Address: ${quote.fromAddress}`,
|
|
142
|
+
`My ${quote.to} Address: ${quote.toAddress}`,
|
|
143
|
+
`Counterparty ${quote.from} Address: ${quote.fromCounterPartyAddress}`,
|
|
144
|
+
`Counterparty ${quote.to} Address: ${quote.toCounterPartyAddress}`,
|
|
145
|
+
`Timestamp: ${quote.swapExpiration}`,
|
|
146
|
+
].join('\n');
|
|
147
|
+
const messageHex = Buffer.from(message, 'utf8').toString('hex');
|
|
148
|
+
const secret = yield fromClient.swap.generateSecret(messageHex);
|
|
149
|
+
const secretHash = (0, utils_1.sha256)(secret);
|
|
150
|
+
const asset = (0, chainify_1.assetsAdapter)(quote.from)[0];
|
|
151
|
+
const fromFundTx = yield fromClient.swap.initiateSwap({
|
|
152
|
+
asset,
|
|
153
|
+
value: new bignumber_js_1.default(quote.fromAmount),
|
|
154
|
+
recipientAddress: quote.fromCounterPartyAddress,
|
|
155
|
+
refundAddress: quote.fromAddress,
|
|
156
|
+
secretHash: secretHash,
|
|
157
|
+
expiration: quote.swapExpiration,
|
|
158
|
+
}, quote.fee);
|
|
159
|
+
return Object.assign(Object.assign({}, quote), { status: 'INITIATED', secret,
|
|
160
|
+
secretHash, fromFundHash: fromFundTx.hash, fromFundTx });
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
estimateFees({ network, walletId, asset, txType, quote, feePrices, max, }) {
|
|
164
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
if (txType === this._txTypes().SWAP_INITIATION && asset === 'BTC') {
|
|
166
|
+
const client = this.getClient(network, walletId, asset, quote.fromAccountId);
|
|
167
|
+
const value = max ? undefined : new bignumber_js_1.default(quote.fromAmount);
|
|
168
|
+
const txs = feePrices.map((fee) => ({ to: '', value, fee }));
|
|
169
|
+
const totalFees = yield client.wallet.getTotalFees(txs, max);
|
|
170
|
+
return (0, lodash_1.mapValues)(totalFees, (f) => (0, cryptoassets_1.unitToCurrency)(cryptoassets_2.default[asset], f));
|
|
171
|
+
}
|
|
172
|
+
if (txType === this._txTypes().SWAP_INITIATION && asset === 'YAC') {
|
|
173
|
+
const client = this.getClient(network, walletId, asset, quote.fromAccountId);
|
|
174
|
+
const value = max ? undefined : new bignumber_js_1.default(quote.fromAmount);
|
|
175
|
+
const txs = feePrices.map((fee) => ({ to: '', value, fee }));
|
|
176
|
+
const totalFees = yield client.wallet.getTotalFees(txs, max);
|
|
177
|
+
return (0, lodash_1.mapValues)(totalFees, (f) => (0, cryptoassets_1.unitToCurrency)(cryptoassets_2.default[asset], f));
|
|
178
|
+
}
|
|
179
|
+
if (txType === this._txTypes().SWAP_INITIATION && asset === 'NEAR') {
|
|
180
|
+
const fees = {};
|
|
181
|
+
const storageFee = new bignumber_js_1.default(0.00125);
|
|
182
|
+
for (const feePrice of feePrices) {
|
|
183
|
+
fees[feePrice] = (0, fees_1.getTxFee)(this.feeUnits[txType], asset, feePrice).plus(storageFee);
|
|
184
|
+
}
|
|
185
|
+
return fees;
|
|
186
|
+
}
|
|
187
|
+
if (txType in this.feeUnits) {
|
|
188
|
+
const fees = {};
|
|
189
|
+
for (const feePrice of feePrices) {
|
|
190
|
+
fees[feePrice] = (0, fees_1.getTxFee)(this.feeUnits[txType], asset, feePrice);
|
|
191
|
+
}
|
|
192
|
+
return fees;
|
|
193
|
+
}
|
|
194
|
+
const fees = {};
|
|
195
|
+
for (const feePrice of feePrices) {
|
|
196
|
+
fees[feePrice] = new bignumber_js_1.BigNumber(0);
|
|
197
|
+
}
|
|
198
|
+
return fees;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
getMin(quoteRequest) {
|
|
202
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
if (quoteRequest) {
|
|
204
|
+
const pairs = yield this.getSupportedPairs();
|
|
205
|
+
for (const pair of pairs) {
|
|
206
|
+
if (pair.from == quoteRequest.from && pair.to == quoteRequest.to) {
|
|
207
|
+
return new bignumber_js_1.default(pair.min);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return new bignumber_js_1.default(0);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
updateOrder(order) {
|
|
215
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
return this._httpClient.nodePost(`/api/swap/order/${order.orderId}`, {
|
|
217
|
+
fromAddress: order.fromAddress,
|
|
218
|
+
toAddress: order.toAddress,
|
|
219
|
+
fromFundHash: (0, cryptoassets_1.remove0x)(order.fromFundHash),
|
|
220
|
+
secretHash: order.secretHash,
|
|
221
|
+
}, { headers });
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
waitForClaimConfirmations({ swap, network, walletId }) {
|
|
225
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const toClient = this.getClient(network, walletId, swap.to, swap.toAccountId);
|
|
227
|
+
try {
|
|
228
|
+
const tx = yield toClient.chain.getTransactionByHash(swap.toClaimHash);
|
|
229
|
+
if (tx && tx.confirmations && tx.confirmations > 0) {
|
|
230
|
+
this.updateBalances(network, walletId, [swap.toAccountId, swap.fromAccountId]);
|
|
231
|
+
return {
|
|
232
|
+
endTime: Date.now(),
|
|
233
|
+
status: 'SUCCESS',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
if (e.name === 'TxNotFoundError')
|
|
239
|
+
console.warn(e);
|
|
240
|
+
else
|
|
241
|
+
throw e;
|
|
242
|
+
}
|
|
243
|
+
const expirationUpdates = yield this.handleExpirations({
|
|
244
|
+
swap,
|
|
245
|
+
network,
|
|
246
|
+
walletId,
|
|
247
|
+
});
|
|
248
|
+
if (expirationUpdates) {
|
|
249
|
+
return expirationUpdates;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
performNextSwapAction(store, { network, walletId, swap }) {
|
|
254
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
switch (swap.status) {
|
|
256
|
+
case 'WAITING_FOR_APPROVE_CONFIRMATIONS_LSP':
|
|
257
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.waitForApproveConfirmations({ swap, network, walletId }); }));
|
|
258
|
+
case 'APPROVE_CONFIRMED_LSP':
|
|
259
|
+
return (0, utils_2.withLock)(store, { item: swap, network, walletId, asset: swap.from }, () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.initiateSwap({ quote: swap, network, walletId }); }));
|
|
260
|
+
case 'INITIATED':
|
|
261
|
+
return this.reportInitiation(swap);
|
|
262
|
+
case 'INITIATION_REPORTED':
|
|
263
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.confirmInitiation({ swap, network, walletId }); }));
|
|
264
|
+
case 'INITIATION_CONFIRMED':
|
|
265
|
+
return (0, utils_2.withLock)(store, { item: swap, network, walletId, asset: swap.from }, () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.fundSwap({ swap, network, walletId }); }));
|
|
266
|
+
case 'FUNDED':
|
|
267
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.findCounterPartyInitiation({ swap, network, walletId }); }));
|
|
268
|
+
case 'CONFIRM_COUNTER_PARTY_INITIATION':
|
|
269
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.confirmCounterPartyInitiation({ swap, network, walletId }); }));
|
|
270
|
+
case 'READY_TO_CLAIM':
|
|
271
|
+
return (0, utils_2.withLock)(store, { item: swap, network, walletId, asset: swap.to }, () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.claimSwap({ swap, network, walletId }); }));
|
|
272
|
+
case 'WAITING_FOR_CLAIM_CONFIRMATIONS':
|
|
273
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.waitForClaimConfirmations({ swap, network, walletId }); }));
|
|
274
|
+
case 'WAITING_FOR_REFUND':
|
|
275
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.waitForRefund({ swap, network, walletId }); }));
|
|
276
|
+
case 'GET_REFUND':
|
|
277
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.refundSwap({ swap, network, walletId }); }));
|
|
278
|
+
case 'WAITING_FOR_REFUND_CONFIRMATIONS':
|
|
279
|
+
return (0, utils_2.withInterval)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.waitForRefundConfirmations({ swap, network, walletId }); }));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
_getStatuses() {
|
|
284
|
+
const baseStatuses = super._getStatuses();
|
|
285
|
+
return {
|
|
286
|
+
WAITING_FOR_APPROVE_CONFIRMATIONS_LSP: baseStatuses.WAITING_FOR_APPROVE_CONFIRMATIONS,
|
|
287
|
+
APPROVE_CONFIRMED_LSP: baseStatuses.APPROVE_CONFIRMED,
|
|
288
|
+
INITIATED: {
|
|
289
|
+
step: 1,
|
|
290
|
+
label: 'Locking {from}',
|
|
291
|
+
filterStatus: 'PENDING',
|
|
292
|
+
},
|
|
293
|
+
INITIATION_REPORTED: {
|
|
294
|
+
step: 1,
|
|
295
|
+
label: 'Locking {from}',
|
|
296
|
+
filterStatus: 'PENDING',
|
|
297
|
+
notification() {
|
|
298
|
+
return {
|
|
299
|
+
message: 'Swap initiated',
|
|
300
|
+
};
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
INITIATION_CONFIRMED: {
|
|
304
|
+
step: 2,
|
|
305
|
+
label: 'Locking {from}',
|
|
306
|
+
filterStatus: 'PENDING',
|
|
307
|
+
},
|
|
308
|
+
FUNDED: {
|
|
309
|
+
step: 2,
|
|
310
|
+
label: 'Locking {to}',
|
|
311
|
+
filterStatus: 'PENDING'
|
|
312
|
+
},
|
|
313
|
+
CONFIRM_COUNTER_PARTY_INITIATION: {
|
|
314
|
+
step: 2,
|
|
315
|
+
label: 'Locking {to}',
|
|
316
|
+
filterStatus: 'PENDING',
|
|
317
|
+
notification(swap) {
|
|
318
|
+
return {
|
|
319
|
+
message: `Counterparty sent ${(0, coinFormatter_1.prettyBalance)(swap.toAmount, swap.to)} ${swap.to} to escrow`,
|
|
320
|
+
};
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
READY_TO_CLAIM: {
|
|
324
|
+
step: 3,
|
|
325
|
+
label: 'Claiming {to}',
|
|
326
|
+
filterStatus: 'PENDING',
|
|
327
|
+
notification() {
|
|
328
|
+
return {
|
|
329
|
+
message: 'Claiming funds',
|
|
330
|
+
};
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
WAITING_FOR_CLAIM_CONFIRMATIONS: {
|
|
334
|
+
step: 3,
|
|
335
|
+
label: 'Claiming {to}',
|
|
336
|
+
filterStatus: 'PENDING',
|
|
337
|
+
},
|
|
338
|
+
WAITING_FOR_REFUND: {
|
|
339
|
+
step: 3,
|
|
340
|
+
label: 'Pending Refund',
|
|
341
|
+
filterStatus: 'PENDING',
|
|
342
|
+
},
|
|
343
|
+
GET_REFUND: {
|
|
344
|
+
step: 3,
|
|
345
|
+
label: 'Refunding {from}',
|
|
346
|
+
filterStatus: 'PENDING',
|
|
347
|
+
},
|
|
348
|
+
WAITING_FOR_REFUND_CONFIRMATIONS: {
|
|
349
|
+
step: 3,
|
|
350
|
+
label: 'Refunding {from}',
|
|
351
|
+
filterStatus: 'PENDING',
|
|
352
|
+
},
|
|
353
|
+
REFUNDED: {
|
|
354
|
+
step: 4,
|
|
355
|
+
label: 'Refunded',
|
|
356
|
+
filterStatus: 'REFUNDED',
|
|
357
|
+
notification(swap) {
|
|
358
|
+
return {
|
|
359
|
+
message: `Swap refunded, ${(0, coinFormatter_1.prettyBalance)(swap.fromAmount, swap.from)} ${swap.from} returned`,
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
SUCCESS: {
|
|
364
|
+
step: 4,
|
|
365
|
+
label: 'Completed',
|
|
366
|
+
filterStatus: 'COMPLETED',
|
|
367
|
+
notification(swap) {
|
|
368
|
+
return {
|
|
369
|
+
message: `Swap completed, ${(0, coinFormatter_1.prettyBalance)(swap.toAmount, swap.to)} ${swap.to} ready to use`,
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
QUOTE_EXPIRED: {
|
|
374
|
+
step: 4,
|
|
375
|
+
label: 'Quote Expired',
|
|
376
|
+
filterStatus: 'REFUNDED',
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
_txTypes() {
|
|
381
|
+
return LiqualityTxTypes;
|
|
382
|
+
}
|
|
383
|
+
_fromTxType() {
|
|
384
|
+
return this._txTypes().SWAP_INITIATION;
|
|
385
|
+
}
|
|
386
|
+
_toTxType() {
|
|
387
|
+
return this._txTypes().SWAP_CLAIM;
|
|
388
|
+
}
|
|
389
|
+
_timelineDiagramSteps() {
|
|
390
|
+
return ['APPROVE', 'INITIATION', 'AGENT_INITIATION', 'CLAIM_OR_REFUND'];
|
|
391
|
+
}
|
|
392
|
+
_totalSteps() {
|
|
393
|
+
return 5;
|
|
394
|
+
}
|
|
395
|
+
_getQuote({ from, to, amount }) {
|
|
396
|
+
var _a, _b;
|
|
397
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
398
|
+
try {
|
|
399
|
+
return this._httpClient.nodePost('/api/swap/order', { from, to, fromAmount: amount }, { headers });
|
|
400
|
+
}
|
|
401
|
+
catch (e) {
|
|
402
|
+
if ((_b = (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) {
|
|
403
|
+
throw new Error(e.response.data.error);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
throw e;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
waitForRefund({ swap, network, walletId }) {
|
|
412
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
413
|
+
if (yield this.canRefund({ swap, network, walletId })) {
|
|
414
|
+
return { status: 'GET_REFUND' };
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
waitForRefundConfirmations({ swap, network, walletId, }) {
|
|
419
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
420
|
+
const fromClient = this.getClient(network, walletId, swap.from, swap.fromAccountId);
|
|
421
|
+
try {
|
|
422
|
+
const tx = yield fromClient.chain.getTransactionByHash(swap.refundHash);
|
|
423
|
+
if (tx && tx.confirmations && tx.confirmations > 0) {
|
|
424
|
+
return {
|
|
425
|
+
endTime: Date.now(),
|
|
426
|
+
status: 'REFUNDED',
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
catch (e) {
|
|
431
|
+
if (e.name === 'TxNotFoundError')
|
|
432
|
+
console.warn(e);
|
|
433
|
+
else
|
|
434
|
+
throw e;
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
refundSwap({ swap, network, walletId }) {
|
|
439
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
440
|
+
const fromClient = this.getClient(network, walletId, swap.from, swap.fromAccountId);
|
|
441
|
+
yield this.sendLedgerNotification(swap.fromAccountId, 'Signing required to refund the swap.');
|
|
442
|
+
const asset = (0, chainify_1.assetsAdapter)(swap.from)[0];
|
|
443
|
+
try {
|
|
444
|
+
const refundTx = yield fromClient.swap.refundSwap({
|
|
445
|
+
asset,
|
|
446
|
+
value: new bignumber_js_1.default(swap.fromAmount),
|
|
447
|
+
recipientAddress: swap.fromCounterPartyAddress,
|
|
448
|
+
refundAddress: swap.fromAddress,
|
|
449
|
+
secretHash: swap.secretHash,
|
|
450
|
+
expiration: swap.swapExpiration,
|
|
451
|
+
}, swap.fromFundHash, swap.fee);
|
|
452
|
+
return {
|
|
453
|
+
refundHash: refundTx.hash,
|
|
454
|
+
refundTx,
|
|
455
|
+
status: 'WAITING_FOR_REFUND_CONFIRMATIONS',
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
catch (e) {
|
|
459
|
+
if (e.name === 'TxNotFoundError')
|
|
460
|
+
console.warn(e);
|
|
461
|
+
else
|
|
462
|
+
throw e;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
reportInitiation(swap) {
|
|
467
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
468
|
+
if (yield this.hasQuoteExpired(swap)) {
|
|
469
|
+
return { status: 'WAITING_FOR_REFUND' };
|
|
470
|
+
}
|
|
471
|
+
yield this.updateOrder(swap);
|
|
472
|
+
return {
|
|
473
|
+
status: 'INITIATION_REPORTED',
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
confirmInitiation({ swap, network, walletId }) {
|
|
478
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
const counterPartyInitiation = yield this.findCounterPartyInitiation({
|
|
480
|
+
swap,
|
|
481
|
+
network,
|
|
482
|
+
walletId,
|
|
483
|
+
});
|
|
484
|
+
if (counterPartyInitiation)
|
|
485
|
+
return counterPartyInitiation;
|
|
486
|
+
const fromClient = this.getClient(network, walletId, swap.from, swap.fromAccountId);
|
|
487
|
+
try {
|
|
488
|
+
const tx = yield fromClient.chain.getTransactionByHash(swap.fromFundHash);
|
|
489
|
+
if (tx && tx.confirmations && tx.confirmations > 0) {
|
|
490
|
+
return {
|
|
491
|
+
status: 'INITIATION_CONFIRMED',
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
catch (e) {
|
|
496
|
+
if (e.name === 'TxNotFoundError')
|
|
497
|
+
console.warn(e);
|
|
498
|
+
else
|
|
499
|
+
throw e;
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
fundSwap({ swap, network, walletId }) {
|
|
504
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
505
|
+
if (yield this.hasQuoteExpired(swap)) {
|
|
506
|
+
return { status: 'WAITING_FOR_REFUND' };
|
|
507
|
+
}
|
|
508
|
+
if (!(0, asset_1.isERC20)(swap.from))
|
|
509
|
+
return { status: 'FUNDED' };
|
|
510
|
+
const asset = (0, chainify_1.assetsAdapter)(swap.from)[0];
|
|
511
|
+
const fromClient = this.getClient(network, walletId, swap.from, swap.fromAccountId);
|
|
512
|
+
yield this.sendLedgerNotification(swap.fromAccountId, 'Signing required to fund the swap.');
|
|
513
|
+
const fundTx = yield fromClient.swap.fundSwap({
|
|
514
|
+
asset,
|
|
515
|
+
value: (0, bignumber_js_1.default)(swap.fromAmount),
|
|
516
|
+
recipientAddress: swap.fromCounterPartyAddress,
|
|
517
|
+
refundAddress: swap.fromAddress,
|
|
518
|
+
secretHash: swap.secretHash,
|
|
519
|
+
expiration: swap.swapExpiration
|
|
520
|
+
}, swap.fromFundHash, swap.fee);
|
|
521
|
+
return {
|
|
522
|
+
fundTxHash: fundTx === null || fundTx === void 0 ? void 0 : fundTx.hash,
|
|
523
|
+
status: 'FUNDED'
|
|
524
|
+
};
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
findCounterPartyInitiation({ swap, network, walletId, }) {
|
|
528
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
529
|
+
const toClient = this.getClient(network, walletId, swap.to, swap.toAccountId);
|
|
530
|
+
const toAsset = cryptoassets_2.default[swap.to];
|
|
531
|
+
const asset = Object.assign(Object.assign({}, toAsset), { isNative: toAsset.type === 'native' });
|
|
532
|
+
try {
|
|
533
|
+
const tx = yield toClient.swap.findInitiateSwapTransaction({
|
|
534
|
+
asset,
|
|
535
|
+
value: new bignumber_js_1.default(swap.toAmount),
|
|
536
|
+
recipientAddress: swap.toAddress,
|
|
537
|
+
refundAddress: swap.toCounterPartyAddress,
|
|
538
|
+
secretHash: swap.secretHash,
|
|
539
|
+
expiration: swap.nodeSwapExpiration,
|
|
540
|
+
});
|
|
541
|
+
if (tx) {
|
|
542
|
+
const toFundHash = tx.hash;
|
|
543
|
+
const isVerified = yield toClient.swap.verifyInitiateSwapTransaction({
|
|
544
|
+
asset,
|
|
545
|
+
value: new bignumber_js_1.default(swap.toAmount),
|
|
546
|
+
recipientAddress: swap.toAddress,
|
|
547
|
+
refundAddress: swap.toCounterPartyAddress,
|
|
548
|
+
secretHash: swap.secretHash,
|
|
549
|
+
expiration: swap.nodeSwapExpiration,
|
|
550
|
+
}, toFundHash);
|
|
551
|
+
const fundingTransaction = yield toClient.swap.findFundSwapTransaction({
|
|
552
|
+
asset,
|
|
553
|
+
value: (0, bignumber_js_1.default)(swap.toAmount),
|
|
554
|
+
recipientAddress: swap.toAddress,
|
|
555
|
+
refundAddress: swap.toCounterPartyAddress,
|
|
556
|
+
secretHash: swap.secretHash,
|
|
557
|
+
expiration: swap.nodeSwapExpiration
|
|
558
|
+
}, toFundHash);
|
|
559
|
+
let fundingConfirmed = false;
|
|
560
|
+
if (fundingTransaction) {
|
|
561
|
+
if (fundingTransaction.confirmations && fundingTransaction.confirmations >=
|
|
562
|
+
(0, cryptoassets_1.getChain)(network, cryptoassets_2.default[swap.to].chain).safeConfirmations) {
|
|
563
|
+
fundingConfirmed = true;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
fundingConfirmed = true;
|
|
568
|
+
}
|
|
569
|
+
if (isVerified && fundingConfirmed) {
|
|
570
|
+
return {
|
|
571
|
+
toFundHash,
|
|
572
|
+
status: 'CONFIRM_COUNTER_PARTY_INITIATION',
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
catch (e) {
|
|
578
|
+
if (['BlockNotFoundError', 'PendingTxError', 'TxNotFoundError'].includes(e.name))
|
|
579
|
+
console.warn(e);
|
|
580
|
+
else
|
|
581
|
+
throw e;
|
|
582
|
+
}
|
|
583
|
+
const expirationUpdates = yield this.handleExpirations({
|
|
584
|
+
swap,
|
|
585
|
+
network,
|
|
586
|
+
walletId,
|
|
587
|
+
});
|
|
588
|
+
if (expirationUpdates) {
|
|
589
|
+
return expirationUpdates;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
confirmCounterPartyInitiation({ swap, network, walletId, }) {
|
|
594
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
595
|
+
const toClient = this.getClient(network, walletId, swap.to, swap.toAccountId);
|
|
596
|
+
const tx = yield toClient.chain.getTransactionByHash(swap.toFundHash);
|
|
597
|
+
if (tx &&
|
|
598
|
+
tx.confirmations &&
|
|
599
|
+
tx.confirmations >= (0, cryptoassets_1.getChain)(network, cryptoassets_2.default[swap.to].chain).safeConfirmations) {
|
|
600
|
+
return {
|
|
601
|
+
status: 'READY_TO_CLAIM',
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
const expirationUpdates = yield this.handleExpirations({
|
|
605
|
+
swap,
|
|
606
|
+
network,
|
|
607
|
+
walletId,
|
|
608
|
+
});
|
|
609
|
+
if (expirationUpdates) {
|
|
610
|
+
return expirationUpdates;
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
claimSwap({ swap, network, walletId }) {
|
|
615
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
616
|
+
const expirationUpdates = yield this.handleExpirations({
|
|
617
|
+
swap,
|
|
618
|
+
network,
|
|
619
|
+
walletId,
|
|
620
|
+
});
|
|
621
|
+
if (expirationUpdates) {
|
|
622
|
+
return expirationUpdates;
|
|
623
|
+
}
|
|
624
|
+
const toClient = this.getClient(network, walletId, swap.to, swap.toAccountId);
|
|
625
|
+
yield this.sendLedgerNotification(swap.toAccountId, 'Signing required to claim the swap.');
|
|
626
|
+
const asset = (0, chainify_1.assetsAdapter)(swap.to)[0];
|
|
627
|
+
const toClaimTx = yield toClient.swap.claimSwap({
|
|
628
|
+
asset,
|
|
629
|
+
value: new bignumber_js_1.default(swap.toAmount),
|
|
630
|
+
recipientAddress: swap.toAddress,
|
|
631
|
+
refundAddress: swap.toCounterPartyAddress,
|
|
632
|
+
secretHash: swap.secretHash,
|
|
633
|
+
expiration: swap.nodeSwapExpiration,
|
|
634
|
+
}, swap.toFundHash, swap.secret, swap.claimFee);
|
|
635
|
+
return {
|
|
636
|
+
toClaimHash: toClaimTx.hash,
|
|
637
|
+
toClaimTx,
|
|
638
|
+
status: 'WAITING_FOR_CLAIM_CONFIRMATIONS',
|
|
639
|
+
};
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
hasQuoteExpired(swap) {
|
|
643
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
644
|
+
return (0, utils_3.timestamp)() >= swap.expiresAt;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
hasChainTimePassed({ network, walletId, asset, timestamp, accountId, }) {
|
|
648
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
649
|
+
const client = this.getClient(network, walletId, asset, accountId);
|
|
650
|
+
const maxTries = 3;
|
|
651
|
+
let tries = 0;
|
|
652
|
+
while (tries < maxTries) {
|
|
653
|
+
try {
|
|
654
|
+
const blockNumber = yield client.chain.getBlockHeight();
|
|
655
|
+
const latestBlock = yield client.chain.getBlockByNumber(blockNumber);
|
|
656
|
+
return latestBlock.timestamp > timestamp;
|
|
657
|
+
}
|
|
658
|
+
catch (e) {
|
|
659
|
+
tries++;
|
|
660
|
+
if (tries >= maxTries)
|
|
661
|
+
throw e;
|
|
662
|
+
else {
|
|
663
|
+
console.warn(e);
|
|
664
|
+
yield (0, utils_3.wait)(2000);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
canRefund({ network, walletId, swap }) {
|
|
671
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
672
|
+
return this.hasChainTimePassed({
|
|
673
|
+
network,
|
|
674
|
+
walletId,
|
|
675
|
+
asset: swap.from,
|
|
676
|
+
timestamp: swap.swapExpiration,
|
|
677
|
+
accountId: swap.fromAccountId,
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
hasSwapExpired({ network, walletId, swap }) {
|
|
682
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
683
|
+
return this.hasChainTimePassed({
|
|
684
|
+
network,
|
|
685
|
+
walletId,
|
|
686
|
+
asset: swap.to,
|
|
687
|
+
timestamp: swap.nodeSwapExpiration,
|
|
688
|
+
accountId: swap.toAccountId,
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
handleExpirations({ network, walletId, swap }) {
|
|
693
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
694
|
+
if (yield this.canRefund({ swap, network, walletId })) {
|
|
695
|
+
return { status: 'GET_REFUND' };
|
|
696
|
+
}
|
|
697
|
+
if (yield this.hasSwapExpired({ swap, network, walletId })) {
|
|
698
|
+
return { status: 'WAITING_FOR_REFUND' };
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
exports.LiqualitySwapProvider = LiqualitySwapProvider;
|
|
704
|
+
//# sourceMappingURL=LiqualitySwapProvider.js.map
|