diff --git a/src/common/providers/EnvironmentContextImplMainnet.ts b/src/common/providers/EnvironmentContextImplMainnet.ts index dc457119..142a72aa 100644 --- a/src/common/providers/EnvironmentContextImplMainnet.ts +++ b/src/common/providers/EnvironmentContextImplMainnet.ts @@ -38,11 +38,6 @@ export default class EnvironmentContextImpl implements EnvironmentContext { return this.getBtcText(); } - // eslint-disable-next-line class-methods-use-this - getBitcoinAddress() { - return '18PVckZYp5gF7ysFi3G6jA8SLKAeHieRxJ'; - } - // eslint-disable-next-line class-methods-use-this getAddressRegexPattern(): AddressRegexPattern { return { diff --git a/src/common/providers/EnvironmentContextImplTestnet.ts b/src/common/providers/EnvironmentContextImplTestnet.ts index d652dc8a..59e4292c 100644 --- a/src/common/providers/EnvironmentContextImplTestnet.ts +++ b/src/common/providers/EnvironmentContextImplTestnet.ts @@ -39,11 +39,6 @@ export default class EnvironmentContextImplTestnet implements EnvironmentContext return 'Bitcoin Test'; } - // eslint-disable-next-line class-methods-use-this - getBitcoinAddress() { - return 'n1jS4SGpduZB2UVYGZvzrJVWu1PCZheM9C'; - } - // eslint-disable-next-line class-methods-use-this getAddressRegexPattern(): AddressRegexPattern { return { diff --git a/src/common/providers/types.ts b/src/common/providers/types.ts index 94c397a4..6c2460a8 100644 --- a/src/common/providers/types.ts +++ b/src/common/providers/types.ts @@ -11,5 +11,4 @@ export interface EnvironmentContext { getRskText: () => string; getBtcLedgerAppName: () => string; getAddressRegexPattern: () => AddressRegexPattern; - getBitcoinAddress: () => string; } diff --git a/src/pegout/store/FlyoverPegout/actions.ts b/src/pegout/store/FlyoverPegout/actions.ts index 5cb978c1..6960c0be 100644 --- a/src/pegout/store/FlyoverPegout/actions.ts +++ b/src/pegout/store/FlyoverPegout/actions.ts @@ -3,7 +3,7 @@ import { } from '@/common/types'; import { ActionTree } from 'vuex'; import * as constants from '@/common/store/constants'; -import EnvironmentContextProviderService from '@/common/providers/EnvironmentContextProvider'; +import { BridgeService } from '@/common/services/BridgeService'; export const actions: ActionTree = { [constants.FLYOVER_PEGOUT_INIT]: async ({ state, dispatch }) => { @@ -24,34 +24,35 @@ export const actions: ActionTree = { [constants.FLYOVER_PEGOUT_GET_QUOTES]: async ( { state, commit, dispatch }, rskRefundAddress: string, - ) => new Promise((resolve, reject) => { - const quotePromises: Promise[] = []; - state.liquidityProviders.forEach((provider) => { - dispatch(constants.FLYOVER_PEGOUT_USE_LIQUIDITY_PROVIDER, provider.id); - const tempBtcAddress = EnvironmentContextProviderService - .getEnvironmentContext() - .getBitcoinAddress(); - quotePromises.push(state.flyoverService.getPegoutQuotes( - rskRefundAddress, - state.btcRecipientAddress ? state.btcRecipientAddress : tempBtcAddress, - state.btcRecipientAddress ? state.btcRecipientAddress : tempBtcAddress, - state.amountToTransfer, - )); + ) => { + const bridgeService = new BridgeService(); + const tempBtcAddress = await bridgeService.getFederationAddress(); + return new Promise((resolve, reject) => { + const quotePromises: Promise[] = []; + state.liquidityProviders.forEach((provider) => { + dispatch(constants.FLYOVER_PEGOUT_USE_LIQUIDITY_PROVIDER, provider.id); + quotePromises.push(state.flyoverService.getPegoutQuotes( + rskRefundAddress, + state.btcRecipientAddress ? state.btcRecipientAddress : tempBtcAddress, + state.btcRecipientAddress ? state.btcRecipientAddress : tempBtcAddress, + state.amountToTransfer, + )); + }); + let quotesByProvider: Record = {}; + Promise.all(quotePromises) + .then((quotes) => quotes.forEach((providerQuotes, index) => { + quotesByProvider = { + ...quotesByProvider, + [state.liquidityProviders[index].id]: providerQuotes, + }; + })) + .then(() => { + commit(constants.FLYOVER_PEGOUT_SET_QUOTES, quotesByProvider); + resolve(); + }) + .catch(reject); }); - let quotesByProvider: Record = {}; - Promise.all(quotePromises) - .then((quotes) => quotes.forEach((providerQuotes, index) => { - quotesByProvider = { - ...quotesByProvider, - [state.liquidityProviders[index].id]: providerQuotes, - }; - })) - .then(() => { - commit(constants.FLYOVER_PEGOUT_SET_QUOTES, quotesByProvider); - resolve(); - }) - .catch(reject); - }), + }, [constants.FLYOVER_PEGOUT_USE_LIQUIDITY_PROVIDER]: ({ state }, providerId: number) => { state.flyoverService.useLiquidityProvider(providerId); },