Skip to content

Commit

Permalink
Refactor and clean un used data and old code
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Oct 24, 2024
1 parent f083b3c commit 6bc9f12
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 251 deletions.
41 changes: 0 additions & 41 deletions src/common/components/exchange/SuccessSend.vue

This file was deleted.

23 changes: 1 addition & 22 deletions src/common/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ async function checkAcceptedTerms(
next: NavigationGuardNext,
) {
const store = useStore();
if (store.state.web3Session.acceptedTerms === undefined) {
await store.dispatch(`web3Session/${constants.SESSION_ADD_TERMS_AND_CONDITIONS_ENABLED}`);
}
if (
!store.state.web3Session.termsAndConditionsEnabled
|| (store.state.web3Session.termsAndConditionsEnabled && store.state.web3Session.acceptedTerms)
) {
if (store.state.web3Session.acceptedTerms) {
next();
} else {
next({ name: 'Home' });
Expand Down Expand Up @@ -92,13 +86,6 @@ const routes: Readonly<RouteRecordRaw[]> = [
component: () => import(/* webpackChunkName: "pegin-create" */ '../../pegin/views/Create.vue'),
beforeEnter: checkAcceptedTerms,
},
{
path: '/pegin/:wallet/success/:txId',
name: 'Success',
component:
() => import(/* webpackChunkName: "pegin-success" */ '../../pegin/views/Success.vue'),
beforeEnter: [checkFromRoute],
},
{
path: '/:type/success/tx/:txId',
name: 'SuccessTx',
Expand All @@ -118,12 +105,4 @@ const router = createRouter({
routes,
});

router.beforeResolve((to, from, next) => {
const store = useStore();
store.dispatch(`view/${constants.VIEW_ADD_CURRENT_VIEW}`, to.name);
const inTxFlow = store.getters[`web3Session/${constants.SESSION_IN_TX_FLOW}`];
if (to.name === 'Create' && !inTxFlow) next({ name: 'Home' });
else next();
});

export default router;
11 changes: 2 additions & 9 deletions src/common/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ export const FLYOVER_PEGOUT_CLEAR_QUOTES = 'FLYOVER_PEGOUT_CLEAR_QUOTES';
export const FLYOVER_PEGOUT_SET_SELECTED_QUOTE_HASH = 'FLYOVER_PEGOUT_SET_SELECTED_QUOTE_HASH';
export const FLYOVER_PEGOUT_CLEAR_QUOTE_DIFFERENCES = 'FLYOVER_PEGOUT_CLEAR_QUOTE_DIFFERENCES';

// View actions
export const VIEW_ADD_CURRENT_VIEW = 'VIEW_ADD_CURRENT_VIEW';

// Flyover PegIn actions

export const FLYOVER_PEGIN_INIT = 'FLYOVER_PEGIN_INIT';
Expand Down Expand Up @@ -164,9 +161,6 @@ export const FLYOVER_PEGOUT_SET_TX_HASH = 'FLYOVER_PEGOUT_SET_TX_HASH';
export const FLYOVER_PEGOUT_SET_SELECTED_QUOTE = 'FLYOVER_PEGOUT_SET_SELECTED_QUOTE';
export const FLYOVER_PEGOUT_SET_QUOTES_DIFFERENCES = 'FLYOVER_PEGOUT_SET_QUOTES_DIFFERENCES';

// View mutations
export const VIEW_SET_CURRENT_VIEW = 'VIEW_SET_CURRENT_VIEW';

// Flyover PegIn mutations

export const FLYOVER_PEGIN_SET_PROVIDERS = 'FLYOVER_PEGIN_SET_PROVIDERS';
Expand Down Expand Up @@ -210,6 +204,8 @@ export const PEGIN_TX_IS_ENOUGH_BALANCE = 'PEGIN_TX_IS_ENOUGH_BALANCE';
export const PEGIN_TX_GET_SELECTED_ACCOUNT_TYPE = 'PEGIN_TX_GET_SELECTED_ACCOUNT_TYPE';
export const PEGIN_TX_GET_ACCOUNT_UTXO_LIST = 'PEGIN_TX_GET_ACCOUNT_UTXO_LIST';
export const PEGIN_TX_GET_SELECTED_UTXO_LIST = 'PEGIN_TX_GET_SELECTED_UTXO_LIST';
export const PEGIN_TX_IS_HD_WALLET = 'PEGIN_TX_IS_HD_WALLET';
export const PEGIN_TX_IS_SF_WALLET = 'PEGIN_TX_IS_SF_WALLET';

// PegOut tx getters
export const PEGOUT_TX_GET_SAFE_TX_FEE = 'PEGOUT_TX_GET_SAFE_TX_FEE';
Expand All @@ -220,9 +216,6 @@ export const PEGOUT_TX_EVENT_TRANSACTION_HASH = 'transactionHash';
export const PEGIN_TX_GET_ENOUGH_FEE_VALUE = 'PEGIN_TX_GET_ENOUGH_FEE_VALUE';

// View getters
export const VIEW_GET_CURRENT_VIEW = 'VIEW_GET_CURRENT_VIEW';
export const PEGIN_TX_IS_HD_WALLET = 'PEGIN_TX_IS_HD_WALLET';
export const PEGIN_TX_IS_SF_WALLET = 'PEGIN_TX_IS_SF_WALLET';

// Session getters
export const SESSION_IN_TX_FLOW = 'SESSION_IN_TX_FLOW';
Expand Down
2 changes: 0 additions & 2 deletions src/common/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { flyoverPegin } from '@/pegin/store/FlyoverPegin';
import { pegOutTx } from '@/pegout/store/pegoutTx';
import { flyoverPegout } from '@/pegout/store/FlyoverPegout';
import { web3Session } from './session';
import { view } from './view';
import pkg from '../../../package.json';

const store: StoreOptions<RootState> = {
Expand All @@ -19,7 +18,6 @@ const store: StoreOptions<RootState> = {
modules: {
pegInTx,
web3Session,
view,
status,
pegOutTx,
flyoverPegout,
Expand Down
9 changes: 0 additions & 9 deletions src/common/store/view/actions.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/common/store/view/getters.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/common/store/view/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/common/store/view/mutations.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/pegin/components/create/ConfirmTx.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default defineComponent({
StatusSummary,
ConfirmationSteps,
},
emits: ['successConfirmation', 'toPegInForm'],
props: {
confirmTxState: {
type: Object as PropType<Machine < 'idle' | 'loading' | 'error' | 'confirming' | 'goingHome' >>,
Expand Down
1 change: 1 addition & 0 deletions src/pegin/components/create/PegInForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default defineComponent({
BtcFeeSelect,
FullTxErrorDialog,
},
emits: ['back', 'createTx'],
setup(_, context) {
const pegInFormState = ref<Machine<'loading' | 'goingHome' | 'fill'>>(new Machine('fill'));
const showWarningMessage = ref(false);
Expand Down
34 changes: 13 additions & 21 deletions src/pegin/store/PeginTx/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ export const getters: GetterTree<PegInTxState, RootState> = {
return address;
},
[constants.PEGIN_TX_GET_REFUND_ADDRESS]:
(state: PegInTxState, localGetters, rootState?:RootState, rootGetters?) => {
(state: PegInTxState, localGetters) => {
let address = '';
const currentView = rootGetters[constants.VIEW_GET_CURRENT_VIEW];
const coin = EnvironmentAccessorService.getEnvironmentVariables().vueAppCoin;
if (currentView && currentView === 'Status') {
address = state.statusInfo.refundAddress;
} else if (localGetters[constants.WALLET_NAME] === constants.WALLET_NAMES.LEATHER.formal_name
if (localGetters[constants.WALLET_NAME] === constants.WALLET_NAMES.LEATHER.formal_name
|| localGetters[constants.WALLET_NAME] === constants.WALLET_NAMES.XVERSE.formal_name
|| localGetters[constants.WALLET_NAME] === constants.WALLET_NAMES.ENKRYPT.formal_name
) {
Expand Down Expand Up @@ -115,25 +112,20 @@ export const getters: GetterTree<PegInTxState, RootState> = {
return publicKey;
},
[constants.PEGIN_TX_GET_SAFE_TX_FEE]:
(state: PegInTxState, localGetters?, rootState?: RootState, rootGetters?)
(state: PegInTxState)
: SatoshiBig => {
let fee: SatoshiBig;
if (!state.normalizedTx.inputs.length) {
const currentView = rootGetters[`view/${constants.VIEW_GET_CURRENT_VIEW}`];
if (currentView && currentView === 'Status') {
fee = state.statusInfo.safeFee;
} else {
switch (state.selectedFee) {
case constants.BITCOIN_SLOW_FEE_LEVEL:
fee = state.calculatedFees.slow.amount;
break;
case constants.BITCOIN_FAST_FEE_LEVEL:
fee = state.calculatedFees.fast.amount;
break;
default:
fee = state.calculatedFees.average.amount;
break;
}
switch (state.selectedFee) {
case constants.BITCOIN_SLOW_FEE_LEVEL:
fee = state.calculatedFees.slow.amount;
break;
case constants.BITCOIN_FAST_FEE_LEVEL:
fee = state.calculatedFees.fast.amount;
break;
default:
fee = state.calculatedFees.average.amount;
break;
}
} else {
const inputsAmonut = state.normalizedTx.inputs
Expand Down
83 changes: 0 additions & 83 deletions src/pegin/views/Success.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</v-row>
<v-row>
<v-col>
<flyover-rbtc-input-amount
<rbtc-input-amount
@getQuotes="getQuotes"
:willReceive="amountToReceive" />
</v-col>
Expand Down Expand Up @@ -101,7 +101,7 @@ import {
} from 'vue';
import * as constants from '@/common/store/constants';
import EnvironmentContextProviderService from '@/common/providers/EnvironmentContextProvider';
import FlyoverRbtcInputAmount from '@/pegout/components/FlyoverRbtcInputAmount.vue';
import RbtcInputAmount from '@/pegout/components/RbtcInputAmount.vue';
import AddressDialog from '@/pegout/components/AddressDialog.vue';
import QuoteDiffDialog from '@/pegout/components/QuoteDiffDialog.vue';
import {
Expand All @@ -122,9 +122,9 @@ import FullTxErrorDialog from '@/common/components/exchange/FullTxErrorDialog.vu
import PegoutOption from './PegoutOption.vue';
export default defineComponent({
name: 'FlyoverPegout',
name: 'PegoutForm',
components: {
FlyoverRbtcInputAmount,
RbtcInputAmount,
AddressDialog,
PegoutOption,
FullTxErrorDialog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ import {
} from '@/common/store/helper';
export default defineComponent({
name: 'FlyoverRbtcInputAmount',
name: 'RbtcInputAmount',
emits: ['get-quotes'],
props: {
willReceive: {
Expand Down
Loading

0 comments on commit 6bc9f12

Please sign in to comment.