From f10ad4a286be10a94973744f5f2b99c220c4248e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren?= Date: Tue, 13 Aug 2024 17:54:30 +0200 Subject: [PATCH] Use different curried functions for the different OASIS instances --- package.json | 4 +- src/components/modals/BuyCryptoModal.vue | 3 +- src/components/modals/SellCryptoModal.vue | 3 +- src/components/swap/SwapNotification.vue | 7 +- .../asset-transfer/useSinpeMovilSwap.ts | 2 +- .../useOasisPayoutStatusUpdater.ts | 16 ++- src/i18n/en.po | 110 ++++++++++-------- src/lib/OasisCrc.ts | 24 ++++ src/lib/OasisEur.ts | 24 ++++ src/main.ts | 9 -- yarn.lock | 44 +++++-- 11 files changed, 162 insertions(+), 84 deletions(-) create mode 100644 src/lib/OasisCrc.ts create mode 100644 src/lib/OasisEur.ts diff --git a/package.json b/package.json index cf7c49288..5c1ea7468 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "@nimiq/fastspot-api": "https://github.com/nimiq/fastspot-api#3a7c4b68529d7ec9ba8955a399412eaae946c528", "@nimiq/hub-api": "file:../hub/client", "@nimiq/iqons": "^1.5.2", - "@nimiq/libswap": "github:nimiq/libswap-js#8f66adf", - "@nimiq/oasis-api": "github:nimiq/oasis-api-js#dbfcdf4707c8a030022b3474126f4596bacbc1c1", + "@nimiq/libswap": "github:nimiq/libswap-js#f868f6407b122806a89f29c71351e8fb8289e879", + "@nimiq/oasis-api": "github:nimiq/oasis-api-js#fbd74179a5b9590f8e6dfe9b08ca47122db2ce1e", "@nimiq/oasis-bank-list": "https://github.com/nimiq/oasis-bank-list#main", "@nimiq/rpc": "^0.4.1", "@nimiq/style": "^0.8.2", diff --git a/src/components/modals/BuyCryptoModal.vue b/src/components/modals/BuyCryptoModal.vue index e10a7a8f0..b39bfdcc9 100644 --- a/src/components/modals/BuyCryptoModal.vue +++ b/src/components/modals/BuyCryptoModal.vue @@ -316,10 +316,8 @@ import { EurHtlcDetails, } from '@nimiq/fastspot-api'; import { - getHtlc, Htlc as OasisHtlc, HtlcStatus, - sandboxMockClearHtlc, TransactionType, SepaClearingInstruction, } from '@nimiq/oasis-api'; @@ -379,6 +377,7 @@ import { useBankStore } from '../../stores/Bank'; import { useKycStore } from '../../stores/Kyc'; import KycPrompt from '../kyc/KycPrompt.vue'; import KycOverlay from '../kyc/KycOverlay.vue'; +import { getHtlc, sandboxMockClearHtlc } from '../../lib/OasisEur'; enum Pages { WELCOME, diff --git a/src/components/modals/SellCryptoModal.vue b/src/components/modals/SellCryptoModal.vue index 61b26b5fe..5d6524b84 100644 --- a/src/components/modals/SellCryptoModal.vue +++ b/src/components/modals/SellCryptoModal.vue @@ -280,8 +280,6 @@ import { Contract, } from '@nimiq/fastspot-api'; import { - getHtlc, - exchangeAuthorizationToken, HtlcStatus, TransactionType as OasisTransactionType, } from '@nimiq/oasis-api'; @@ -344,6 +342,7 @@ import { import { useKycStore } from '../../stores/Kyc'; import KycPrompt from '../kyc/KycPrompt.vue'; import KycOverlay from '../kyc/KycOverlay.vue'; +import { exchangeAuthorizationToken, getHtlc } from '../../lib/OasisEur'; type KycResult = import('../../swap-kyc-handler').SetupSwapWithKycResult['kyc']; diff --git a/src/components/swap/SwapNotification.vue b/src/components/swap/SwapNotification.vue index 93fbb8c15..36b13004c 100644 --- a/src/components/swap/SwapNotification.vue +++ b/src/components/swap/SwapNotification.vue @@ -56,10 +56,8 @@ import { ClearingInfo, ClearingStatus, DeniedReason, - getHtlc, Htlc as OasisHtlc, HtlcStatus, - settleHtlc, SettlementInfo, SettlementStatus, } from '@nimiq/oasis-api'; @@ -88,6 +86,8 @@ import { } from '../../ethers'; import { useUsdcTransactionsStore, Transaction as UsdcTransaction } from '../../stores/UsdcTransactions'; import { POLYGON_BLOCKS_PER_MINUTE } from '../../lib/usdc/OpenGSN'; +import { getHtlc as getEurHtlc, settleHtlc as settleEurHtlc } from '../../lib/OasisEur'; +import { getHtlc as getCrcHtlc, settleHtlc as settleCrcHtlc } from '../../lib/OasisCrc'; enum SwapError { EXPIRED = 'EXPIRED', @@ -285,8 +285,9 @@ export default defineComponent({ }; } case SwapAsset.CRC: + return { getHtlc: getCrcHtlc, settleHtlc: settleCrcHtlc }; case SwapAsset.EUR: - return { getHtlc, settleHtlc }; + return { getHtlc: getEurHtlc, settleHtlc: settleEurHtlc }; default: throw new Error(`Unsupported asset: ${asset}`); } } diff --git a/src/composables/asset-transfer/useSinpeMovilSwap.ts b/src/composables/asset-transfer/useSinpeMovilSwap.ts index a296e7804..f08944c4d 100644 --- a/src/composables/asset-transfer/useSinpeMovilSwap.ts +++ b/src/composables/asset-transfer/useSinpeMovilSwap.ts @@ -34,7 +34,6 @@ import { SinpeMovilHtlcCreationInstructions, } from '@nimiq/hub-api'; import { - getHtlc, HtlcStatus, TransactionType as OasisTransactionType, } from '@nimiq/oasis-api'; @@ -46,6 +45,7 @@ import SinpeUserInfo from '../../components/SinpeUserInfo.vue'; import AddressSelector from '../../components/AddressSelector.vue'; import { AssetTransferOptions, AssetTransferParams } from './types'; import { useConfig } from '../useConfig'; +import { getHtlc } from '../../lib/OasisCrc'; function isCryptoCurrency(currency: any): currency is CryptoCurrency { return Object.values(CryptoCurrency).includes(currency.toLocaleLowerCase() as CryptoCurrency); diff --git a/src/composables/useOasisPayoutStatusUpdater.ts b/src/composables/useOasisPayoutStatusUpdater.ts index e07b8ea43..4232a9b3d 100644 --- a/src/composables/useOasisPayoutStatusUpdater.ts +++ b/src/composables/useOasisPayoutStatusUpdater.ts @@ -1,7 +1,9 @@ import { onUnmounted, Ref, watch } from '@vue/composition-api'; -import { getHtlc, SettlementInfo, SettlementStatus } from '@nimiq/oasis-api'; +import { SettlementInfo, SettlementStatus } from '@nimiq/oasis-api'; import { SwapAsset } from '@nimiq/fastspot-api'; -import { SwapData, SwapEurData, useSwapsStore } from '../stores/Swaps'; +import { SwapCrcData, SwapData, SwapEurData, useSwapsStore } from '../stores/Swaps'; +import { getHtlc as getEurHtlc } from '../lib/OasisEur'; +import { getHtlc as getCrcHtlc } from '../lib/OasisCrc'; // TODO: Remove logging when stable /* eslint-disable no-console */ @@ -16,7 +18,7 @@ export function useOasisPayoutStatusUpdater(swapData: Ref) { return; } - const data = swapData.value as SwapEurData; + const data = swapData.value as SwapEurData | SwapCrcData; const settlement = data.htlc!.settlement!; // Determine check interval @@ -30,7 +32,9 @@ export function useOasisPayoutStatusUpdater(swapData: Ref) { oasisPayoutCheckTimeout = 1; // Ensure no parallel executions console.log('Fetching HTLC now'); - const htlc = await getHtlc(data.htlc!.id); + const htlc = data.asset === SwapAsset.EUR + ? await getEurHtlc(data.htlc!.id) + : await getCrcHtlc(data.htlc!.id); console.log('Got HTLC:', htlc); settlement.status = htlc.settlement.status; @@ -73,10 +77,10 @@ export function useOasisPayoutStatusUpdater(swapData: Ref) { } watch(swapData, (data, previousData) => { // eslint-disable-line consistent-return - if (previousData?.asset === SwapAsset.EUR) { + if (previousData?.asset === SwapAsset.EUR || previousData?.asset === SwapAsset.CRC) { stop(); } - if (data?.asset !== SwapAsset.EUR) return stop(); + if (data?.asset !== SwapAsset.EUR && data?.asset !== SwapAsset.CRC) return stop(); if (data.htlc?.settlement?.status !== SettlementStatus.ACCEPTED) return stop(); if (oasisPayoutCheckTimeout) return; // eslint-disable-line consistent-return checkOasisPayoutStatus(); diff --git a/src/i18n/en.po b/src/i18n/en.po index 509cb268c..612d9deaa 100644 --- a/src/i18n/en.po +++ b/src/i18n/en.po @@ -6,7 +6,7 @@ msgstr "" msgid "‘Digital gold’, the original crypto" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:40 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:40 msgid "({secondsLeft}s)" msgstr "" @@ -66,7 +66,7 @@ msgstr "" msgid "{fee} fee" msgstr "" -#: src/components/modals/AssetTransferModal.vue:37 +#: src/components/modals/AssetTransferModal.vue:53 msgid "{feeAmount} fees" msgstr "" @@ -91,7 +91,7 @@ msgstr "" msgid "{provider} is provided by {companyLogo}" msgstr "" -#: src/components/modals/AssetTransferModal.vue:66 +#: src/components/modals/AssetTransferModal.vue:96 #: src/components/modals/BuyCryptoModal.vue:110 #: src/components/modals/BuyCryptoModal.vue:83 #: src/components/modals/SellCryptoModal.vue:86 @@ -168,7 +168,7 @@ msgstr "" msgid "3" msgstr "" -#: src/components/modals/AssetTransferModal.vue:59 +#: src/components/modals/AssetTransferModal.vue:82 #: src/components/modals/BuyCryptoModal.vue:103 #: src/components/modals/SellCryptoModal.vue:79 #: src/components/swap/SwapModal.vue:93 @@ -304,7 +304,7 @@ msgstr "" msgid "Always backup your Recovery Words, Password and Login Files." msgstr "" -#: src/swap-kyc-handler.ts:281 +#: src/swap-kyc-handler.ts:284 msgid "An error occurred: {message}" msgstr "" @@ -337,7 +337,7 @@ msgstr "" msgid "Apply fee" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:13 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:51 msgid "Approve the sale" msgstr "" @@ -438,7 +438,7 @@ msgstr "" #: src/components/modals/BtcTransactionModal.vue:302 #: src/components/modals/TransactionModal.vue:309 #: src/components/modals/UsdcTransactionModal.vue:270 -#: src/components/swap/SwapAnimation.vue:196 +#: src/components/swap/SwapAnimation.vue:199 #: src/components/swap/SwapAnimation.vue:276 msgid "Block explorer" msgstr "" @@ -472,6 +472,7 @@ msgstr "" #: src/components/modals/BuyCryptoModal.vue:204 #: src/components/modals/BuyCryptoModal.vue:218 #: src/components/modals/BuyCryptoModal.vue:32 +#: src/composables/asset-transfer/useSinpeMovilSwap.ts:483 msgid "Buy Crypto" msgstr "" @@ -608,7 +609,7 @@ msgid "Choose a Validator" msgstr "" #: src/components/modals/AddressSelectorModal.vue:11 -#: src/components/modals/AssetTransferModal.vue:115 +#: src/components/modals/AssetTransferModal.vue:176 #: src/components/modals/BuyCryptoModal.vue:286 #: src/components/modals/SellCryptoModal.vue:250 #: src/components/modals/SendModal.vue:212 @@ -653,7 +654,7 @@ msgstr "" msgid "Comparably high transaction fees/time" msgstr "" -#: src/components/modals/AssetTransferModal.vue:104 +#: src/components/modals/AssetTransferModal.vue:165 #: src/components/SendModalFooter.vue:8 #: src/components/swap/SwapModal.vue:189 #: src/components/swap/SwapModal.vue:194 @@ -665,7 +666,7 @@ msgstr "" msgid "Confirm account" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:39 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:37 msgid "Confirm Number" msgstr "" @@ -673,7 +674,7 @@ msgstr "" msgid "Confirm prestake" msgstr "" -#: src/components/modals/SinpeMovilSellInfoModal.vue:13 +#: src/components/modals/SinpeMovilInfoModal.vue:13 msgid "Confirm Sinpe number" msgstr "" @@ -948,7 +949,7 @@ msgstr "" msgid "Enter IBAN" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:29 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:18 msgid "Enter phone number" msgstr "" @@ -956,7 +957,7 @@ msgstr "" msgid "Enter recipient address..." msgstr "" -#: src/components/modals/SinpeMovilModal.vue:15 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:54 msgid "Enter the code sent to {phoneNumber} to approve." msgstr "" @@ -972,7 +973,7 @@ msgstr "" msgid "Enter your bank details" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:9 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:11 msgid "Enter your Sinpe Móvil phone number." msgstr "" @@ -1174,6 +1175,10 @@ msgstr "" msgid "Get verified for higher limits by authenticating with {provider}. These are the requirements:" msgstr "" +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:3 +msgid "Go back" +msgstr "" + #: src/components/BankCheckInput.vue:94 #: src/components/modals/BtcActivationModal.vue:20 #: src/components/modals/UsdcActivationModal.vue:35 @@ -1251,7 +1256,7 @@ msgstr "" msgid "ID document" msgstr "" -#: src/components/swap/SwapNotification.vue:217 +#: src/components/swap/SwapNotification.vue:219 msgid "If this error persists, check your internet connection or reload the page to reconnect." msgstr "" @@ -1307,7 +1312,7 @@ msgstr "" msgid "Install Web App" msgstr "" -#: src/components/DualCurrencyInput.vue:50 +#: src/components/modals/AssetTransferModal.vue:150 #: src/components/modals/BtcSendModal.vue:79 #: src/components/modals/SellCryptoModal.vue:166 #: src/components/modals/SendModal.vue:189 @@ -1368,7 +1373,7 @@ msgstr "" #: src/components/modals/BuyCryptoModal.vue:26 #: src/components/modals/SellCryptoModal.vue:25 -#: src/components/modals/SinpeMovilSellInfoModal.vue:21 +#: src/components/modals/SinpeMovilInfoModal.vue:20 #: src/components/prestaking/PrestakingWelcomePage.vue:22 msgid "Let's go" msgstr "" @@ -1397,7 +1402,7 @@ msgstr "" msgid "Loading Moonpay..." msgstr "" -#: src/components/modals/AssetTransferModal.vue:64 +#: src/components/modals/AssetTransferModal.vue:91 #: src/components/modals/BuyCryptoModal.vue:108 #: src/components/modals/BuyCryptoModal.vue:92 #: src/components/modals/SellCryptoModal.vue:84 @@ -1405,6 +1410,7 @@ msgstr "" msgid "loading..." msgstr "" +#: src/components/modals/AssetTransferModal.vue:13 #: src/components/modals/ReleaseNotesModal.vue:5 msgid "Loading..." msgstr "" @@ -1448,7 +1454,7 @@ msgstr "" msgid "Many updates like easier address names, more accessible swaps and an improved asset overview await." msgstr "" -#: src/components/DualCurrencyInput.vue:43 +#: src/components/modals/AssetTransferModal.vue:139 #: src/components/modals/BuyCryptoModal.vue:167 #: src/components/modals/SellCryptoModal.vue:156 msgid "Max swappable amount is {amount}" @@ -1528,7 +1534,7 @@ msgstr "" msgid "Nimiq wallet does not support transaction messages for Bitcoin." msgstr "" -#: src/components/swap/SwapNotification.vue:216 +#: src/components/swap/SwapNotification.vue:218 msgid "No connection to {chain} network." msgstr "" @@ -1548,7 +1554,7 @@ msgstr "" msgid "No registration" msgstr "" -#: src/swap-kyc-handler.ts:119 +#: src/swap-kyc-handler.ts:120 msgid "No request received." msgstr "" @@ -1896,11 +1902,11 @@ msgstr "" msgid "Rescan" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:59 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:89 msgid "Resend" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:56 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:82 msgid "Resend ({secondsLeft}s)" msgstr "" @@ -1918,7 +1924,7 @@ msgstr "" msgid "Restake Rewards" msgstr "" -#: src/components/swap/SwapAnimation.vue:638 +#: src/components/swap/SwapAnimation.vue:642 msgid "Restart payout process" msgstr "" @@ -1988,15 +1994,11 @@ msgstr "" msgid "Sell BTC and USDC" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:20 -msgid "Sell crypto" -msgstr "" - #: src/components/modals/SellCryptoModal.vue:180 #: src/components/modals/SellCryptoModal.vue:185 #: src/components/modals/SellCryptoModal.vue:199 #: src/components/modals/SellCryptoModal.vue:31 -#: src/composables/asset-transfer/useSinpeMovilSwap.ts:490 +#: src/composables/asset-transfer/useSinpeMovilSwap.ts:483 msgid "Sell Crypto" msgstr "" @@ -2004,9 +2006,9 @@ msgstr "" msgid "Sell Crypto for Fiat" msgstr "" -#: src/components/DualCurrencyInput.vue:21 -#: src/components/DualCurrencyInput.vue:47 -#: src/components/DualCurrencyInput.vue:50 +#: src/components/DualCurrencyInput.vue:20 +#: src/components/modals/AssetTransferModal.vue:147 +#: src/components/modals/AssetTransferModal.vue:151 #: src/components/modals/SellCryptoModal.vue:134 #: src/components/modals/SellCryptoModal.vue:163 #: src/components/modals/SellCryptoModal.vue:166 @@ -2019,11 +2021,11 @@ msgid "" "SEPA bank account." msgstr "" -#: src/components/modals/SinpeMovilSellInfoModal.vue:11 +#: src/components/modals/SinpeMovilInfoModal.vue:11 msgid "Sell NIM directly to your Sinpe Móvil account." msgstr "" -#: src/components/modals/SinpeMovilSellInfoModal.vue:10 +#: src/components/modals/SinpeMovilInfoModal.vue:10 msgid "Sell NIM using Sinpe Móvil" msgstr "" @@ -2087,7 +2089,7 @@ msgstr "" msgid "Sending Pre-Prestaking Transaction" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:36 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:34 msgid "Sending SMS..." msgstr "" @@ -2151,7 +2153,7 @@ msgstr "" msgid "Set an amount to lock" msgstr "" -#: src/components/modals/SinpeMovilSellInfoModal.vue:14 +#: src/components/modals/SinpeMovilInfoModal.vue:14 msgid "Set an amount to sell" msgstr "" @@ -2376,8 +2378,8 @@ msgstr "" msgid "TEN31 Bank provides a bank account to lock your payment." msgstr "" -#: src/swap-kyc-handler.ts:208 -#: src/swap-kyc-handler.ts:225 +#: src/swap-kyc-handler.ts:211 +#: src/swap-kyc-handler.ts:228 msgid "TEN31 Pass didn't return expected grants." msgstr "" @@ -2393,14 +2395,18 @@ msgstr "" msgid "The bank is processing your transaction." msgstr "" +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:350 +msgid "The code you entered is incorrect. Please try again." +msgstr "" + #: src/lib/swap/utils/BuyUtils.ts:98 -#: src/lib/swap/utils/SellUtils.ts:121 +#: src/lib/swap/utils/SellUtils.ts:122 msgid "The fees (currently {amount}) determine the minimum amount." msgstr "" #: src/components/swap/SwapModal.vue:1042 #: src/lib/swap/utils/BuyUtils.ts:103 -#: src/lib/swap/utils/SellUtils.ts:126 +#: src/lib/swap/utils/SellUtils.ts:127 msgid "The fees determine the minimum amount." msgstr "" @@ -2438,7 +2444,7 @@ msgstr "" msgid "The payment request might have been paid, expired, or cancelled." msgstr "" -#: src/components/modals/AssetTransferModal.vue:21 +#: src/components/modals/AssetTransferModal.vue:34 #: src/components/modals/BuyCryptoModal.vue:44 #: src/components/modals/SellCryptoModal.vue:43 msgid "The rate might change depending on the swap volume." @@ -2473,6 +2479,11 @@ msgstr "" msgid "There is no ‘forgot password’" msgstr "" +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:351 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:359 +msgid "There was an error with the phone verification system. Please try again later." +msgstr "" + #: src/components/swap/SwapNotification.vue:23 msgid "There's a problem" msgstr "" @@ -2628,7 +2639,7 @@ msgstr "" msgid "Unexpected GoCrypto error" msgstr "" -#: src/swap-kyc-handler.ts:214 +#: src/swap-kyc-handler.ts:217 msgid "Unexpected user. This account is currently connected to the TEN31 Pass of {userName}." msgstr "" @@ -2647,12 +2658,12 @@ msgstr "" msgid "Unlike any other crypto, Nimiq connects your wallet directly to peers from all around the world. This makes you a first-class citizen of the blockchain." msgstr "" -#: src/swap-kyc-handler.ts:148 -#: src/swap-kyc-handler.ts:157 +#: src/swap-kyc-handler.ts:150 +#: src/swap-kyc-handler.ts:160 msgid "Unsupported currency" msgstr "" -#: src/swap-kyc-handler.ts:242 +#: src/swap-kyc-handler.ts:245 msgid "Unsupported KYC provider {provider}." msgstr "" @@ -2732,7 +2743,7 @@ msgstr "" msgid "What is your bank called?" msgstr "" -#: src/components/modals/SinpeMovilModal.vue:7 +#: src/components/modals/SinpeMovilMobileVerificationModal.vue:9 msgid "What's your number?" msgstr "" @@ -2783,7 +2794,7 @@ msgstr "" msgid "You can receive more free NIM in {waitTime} hours." msgstr "" -#: src/components/layouts/Sidebar.vue:322 +#: src/components/layouts/Sidebar.vue:326 msgid "" "You can sell NIM\n" "- in the Wallet by swapping NIM to BTC or USDC first, which can then be sold.\n" @@ -2832,6 +2843,10 @@ msgstr "" msgid "You will send {amount} USDC" msgstr "" +#: src/components/swap/SwapAnimation.vue:120 +msgid "Your {fiatCurrency} will be transferred to your bank accountas soon as new limit is available." +msgstr "" + #: src/components/layouts/AccountOverview.vue:9 msgid "Your account is not safe yet!" msgstr "" @@ -2858,7 +2873,6 @@ msgstr "" msgid "Your browser does not support Keyguard popups, or they are disabled in the Settings." msgstr "" -#: src/components/swap/SwapAnimation.vue:119 #: src/components/TransactionDetailOasisPayoutStatus.vue:20 msgid "Your EUR will be transferred to your bank account as soon as new limit is available." msgstr "" diff --git a/src/lib/OasisCrc.ts b/src/lib/OasisCrc.ts new file mode 100644 index 000000000..209cd99e1 --- /dev/null +++ b/src/lib/OasisCrc.ts @@ -0,0 +1,24 @@ +import { + getHtlc as getHtlcOrig, + settleHtlc as settleHtlcOrig, + sandboxMockClearHtlc as sandboxMockClearHtlcOrig, + exchangeAuthorizationToken as exchangeAuthorizationTokenOrig, + type SettlementTokens, +} from '@nimiq/oasis-api'; +import config from 'config'; + +export async function getHtlc(id: string) { + return getHtlcOrig(config.sinpeMovil.apiEndpoint, id); +} + +export async function sandboxMockClearHtlc(id: string) { + return sandboxMockClearHtlcOrig(config.sinpeMovil.apiEndpoint, id); +} + +export async function exchangeAuthorizationToken(token: string) { + return exchangeAuthorizationTokenOrig(config.sinpeMovil.apiEndpoint, token); +} + +export async function settleHtlc(id: string, secret: string, settlementJWS: string, tokens?: SettlementTokens) { + return settleHtlcOrig(config.sinpeMovil.apiEndpoint, id, secret, settlementJWS, tokens); +} diff --git a/src/lib/OasisEur.ts b/src/lib/OasisEur.ts new file mode 100644 index 000000000..ab8fdc625 --- /dev/null +++ b/src/lib/OasisEur.ts @@ -0,0 +1,24 @@ +import { + getHtlc as getHtlcOrig, + settleHtlc as settleHtlcOrig, + sandboxMockClearHtlc as sandboxMockClearHtlcOrig, + exchangeAuthorizationToken as exchangeAuthorizationTokenOrig, + type SettlementTokens, +} from '@nimiq/oasis-api'; +import config from 'config'; + +export async function getHtlc(id: string) { + return getHtlcOrig(config.oasis.apiEndpoint, id); +} + +export async function sandboxMockClearHtlc(id: string) { + return sandboxMockClearHtlcOrig(config.oasis.apiEndpoint, id); +} + +export async function exchangeAuthorizationToken(token: string) { + return exchangeAuthorizationTokenOrig(config.oasis.apiEndpoint, token); +} + +export async function settleHtlc(id: string, secret: string, settlementJWS: string, tokens?: SettlementTokens) { + return settleHtlcOrig(config.oasis.apiEndpoint, id, secret, settlementJWS, tokens); +} diff --git a/src/main.ts b/src/main.ts index dd8b9f6d8..3d399db4a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,6 @@ import VueCompositionApi, { watch } from '@vue/composition-api'; import VueVirtualScroller from 'vue-virtual-scroller'; import { setAssetPublicPath as setVueComponentsAssetPath } from '@nimiq/vue-components'; import { init as initFastspotApi } from '@nimiq/fastspot-api'; -import { init as initOasisApi } from '@nimiq/oasis-api'; import App from './App.vue'; import { serviceWorkerHasUpdate } from './registerServiceWorker'; @@ -99,14 +98,6 @@ async function start() { initFastspotApi(config.fastspot.apiEndpoint, config.fastspot.apiKey); }); - watch(() => { - if (!config.sinpeMovil.apiEndpoint) return; - // TODO We need to look for another solution to support dual enpoints: - // 1. Support to retrieve old tx made with EUR - // 2. Support to work SINPE - initOasisApi(config.sinpeMovil.apiEndpoint); - }); - watch(() => { if (!config.ten31Pass.enabled) return; initKycConnection(); diff --git a/yarn.lock b/yarn.lock index 6e54b8f58..4127eaa43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1510,19 +1510,19 @@ dependencies: dom-parser "^0.1.5" -"@nimiq/libswap@github:nimiq/libswap-js#8f66adf": +"@nimiq/libswap@github:nimiq/libswap-js#f868f6407b122806a89f29c71351e8fb8289e879": version "1.3.0" - resolved "https://codeload.github.com/nimiq/libswap-js/tar.gz/8f66adf05b291e45169a15222c66915bd6b0ad3e" + resolved "https://codeload.github.com/nimiq/libswap-js/tar.gz/f868f6407b122806a89f29c71351e8fb8289e879" dependencies: "@nimiq/core-web" "^1.5.8" "@nimiq/electrum-client" "https://github.com/nimiq/electrum-client#build" - "@nimiq/oasis-api" "github:nimiq/oasis-api-js#dbfcdf4707c8a030022b3474126f4596bacbc1c1" + "@nimiq/oasis-api" "github:nimiq/oasis-api-js#fbd74179a5b9590f8e6dfe9b08ca47122db2ce1e" ethers "^5.7.2" promise.prototype.finally "^3.1.3" -"@nimiq/oasis-api@github:nimiq/oasis-api-js#dbfcdf4707c8a030022b3474126f4596bacbc1c1": +"@nimiq/oasis-api@github:nimiq/oasis-api-js#fbd74179a5b9590f8e6dfe9b08ca47122db2ce1e": version "1.1.1" - resolved "https://codeload.github.com/nimiq/oasis-api-js/tar.gz/dbfcdf4707c8a030022b3474126f4596bacbc1c1" + resolved "https://codeload.github.com/nimiq/oasis-api-js/tar.gz/fbd74179a5b9590f8e6dfe9b08ca47122db2ce1e" "@nimiq/oasis-bank-list@https://github.com/nimiq/oasis-bank-list#main": version "1.0.0" @@ -9765,8 +9765,7 @@ strict-uri-encode@^1.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" integrity sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - name string-width-cjs +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -9792,6 +9791,15 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -9854,8 +9862,7 @@ stringify-object@^3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: - name strip-ansi-cjs +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -9883,6 +9890,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -11612,8 +11626,7 @@ workbox-window@6.4.2: "@types/trusted-types" "^2.0.2" workbox-core "6.4.2" -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: - name wrap-ansi-cjs +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11639,6 +11652,15 @@ wrap-ansi@^5.1.0: string-width "^3.0.0" strip-ansi "^5.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"