Skip to content

Commit

Permalink
Using federation address for default btc address on quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Apr 5, 2024
1 parent be711ab commit 7154cb2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
5 changes: 0 additions & 5 deletions src/common/providers/EnvironmentContextImplMainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions src/common/providers/EnvironmentContextImplTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/common/providers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export interface EnvironmentContext {
getRskText: () => string;
getBtcLedgerAppName: () => string;
getAddressRegexPattern: () => AddressRegexPattern;
getBitcoinAddress: () => string;
}
57 changes: 29 additions & 28 deletions src/pegout/store/FlyoverPegout/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlyoverPegoutState, RootState> = {
[constants.FLYOVER_PEGOUT_INIT]: async ({ state, dispatch }) => {
Expand All @@ -24,34 +24,35 @@ export const actions: ActionTree<FlyoverPegoutState, RootState> = {
[constants.FLYOVER_PEGOUT_GET_QUOTES]: async (
{ state, commit, dispatch },
rskRefundAddress: string,
) => new Promise<void>((resolve, reject) => {
const quotePromises: Promise<QuotePegOut2WP[]>[] = [];
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<void>((resolve, reject) => {
const quotePromises: Promise<QuotePegOut2WP[]>[] = [];
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<number, QuotePegOut2WP[]> = {};
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<number, QuotePegOut2WP[]> = {};
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);
},
Expand Down

0 comments on commit 7154cb2

Please sign in to comment.