Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/browserify-sign-4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjavabraz authored Nov 8, 2023
2 parents 9851d7c + 010f167 commit 7c5e845
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/common/components/exchange/DeviceErrorDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</v-row>
<v-col cols="12" align-self="center" class="pt-0" v-if="errorType">
<v-col offset="2" cols="8">
<p class="justify-center"><span v-html="errorMessage"></span></p>
<p class="justify-center"><span>{{ errorMessage }}</span></p>
<p class="justify-center" v-if="urlToMoreInformation">
<a target='_blank' :href='urlToMoreInformation'>{{messageToUserOnLink}}</a>
</p>
Expand All @@ -27,7 +27,7 @@
</v-col>
<v-col v-else cols="12" align-self="center" class="pt-0">
<v-col offset="3" cols="6">
<p class="justify-center"><span v-html="errorMessage"></span></p>
<p class="justify-center"><span>{{ errorMessage }}</span></p>
</v-col>
<v-row class="mx-0 my-6" justify="space-around">
<v-btn width="200" height="50" variant="outlined" rounded color="#000000"
Expand Down
44 changes: 25 additions & 19 deletions src/pegout/store/pegoutTx/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MiningSpeedFee, PegOutTxState, RootState, SatoshiBig, SessionState, WeiBig,
} from '@/common/types';
import { EnvironmentAccessorService } from '@/common/services/enviroment-accessor.service';
import { BridgeService } from '@/common/services/BridgeService';
import { getEstimatedFee } from '@/common/utils';

export const actions: ActionTree<PegOutTxState, RootState> = {
[constants.PEGOUT_TX_SELECT_FEE_LEVEL]: ({ commit }, feeLevel: MiningSpeedFee) => {
Expand All @@ -16,26 +16,32 @@ export const actions: ActionTree<PegOutTxState, RootState> = {
commit(constants.PEGOUT_TX_SET_AMOUNT, amountToTransfer);
},
[constants.PEGOUT_TX_CALCULATE_FEE]: async ({ commit, state, rootState }) => {
const bridgeService = new BridgeService();
const web3 = rootState.web3Session?.web3 as Web3;
const sender = rootState.web3Session?.account as string;
// RSK Fee
const gas = await web3.eth.estimateGas({
from: sender,
to: state.pegoutConfiguration.bridgeContractAddress,
value: state.amountToTransfer.toWeiString(),
});
commit(constants.PEGOUT_TX_SET_GAS, gas);
const gasPrice = Number(await web3.eth.getGasPrice());
const calculatedFee = new WeiBig(gasPrice * gas, 'wei');
commit(constants.PEGOUT_TX_SET_RSK_ESTIMATED_FEE, calculatedFee);
// BTC Fee
const [nextPegoutCost, pegoutQueueCount] = await Promise.all([
bridgeService.getEstimatedFeesForNextPegOutEvent(),
bridgeService.getQueuedPegoutsCount(),
]);
const estimatedFee = pegoutQueueCount > 0 ? nextPegoutCost / pegoutQueueCount : 0;
commit(constants.PEGOUT_TX_SET_BTC_ESTIMATED_FEE, new SatoshiBig(estimatedFee, 'satoshi'));

try {
// RSK Fee
const gas = await web3.eth.estimateGas({
from: sender,
to: state.pegoutConfiguration.bridgeContractAddress,
value: state.amountToTransfer.toWeiString(),
});
commit(constants.PEGOUT_TX_SET_GAS, gas);
const gasPrice = Number(await web3.eth.getGasPrice());
const calculatedFee = new WeiBig(gasPrice * gas, 'wei');
commit(constants.PEGOUT_TX_SET_RSK_ESTIMATED_FEE, calculatedFee);
} catch (e) {
commit(constants.PEGOUT_TX_SET_GAS, 0);
commit(constants.PEGOUT_TX_SET_RSK_ESTIMATED_FEE, 0);
}

try {
// BTC Fee
const estimatedFee = await getEstimatedFee();
commit(constants.PEGOUT_TX_SET_BTC_ESTIMATED_FEE, new SatoshiBig(estimatedFee, 'satoshi'));
} catch (e) {
commit(constants.PEGOUT_TX_SET_BTC_ESTIMATED_FEE, new SatoshiBig(0, 'satoshi'));
}
},
[constants.PEGOUT_TX_ADD_PEGOUT_CONFIGURATION]: ({ commit }) => {
commit(constants.PEGOUT_TX_SET_PEGOUT_CONFIGURATION, {
Expand Down
18 changes: 7 additions & 11 deletions src/status/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EnvironmentAccessorService } from '@/common/services/enviroment-accesso
import * as constants from '@/common/store/constants';
import { ApiService } from '@/common/services';
import { BridgeService } from '@/common/services/BridgeService';
import { getEstimatedFee } from '@/common/utils';

export const actions: ActionTree<TxStatus, RootState> = {
[constants.STATUS_CLEAR]: ({ commit }) => {
Expand All @@ -29,18 +30,13 @@ export const actions: ActionTree<TxStatus, RootState> = {
commit(constants.STATUS_SET_TX_TYPE, TxStatusType.UNEXPECTED_ERROR);
});
},
[constants.STATUS_GET_ESTIMATED_FEE]: ({ commit }) => {
const bridgeService = new BridgeService();
Promise.all([
bridgeService.getEstimatedFeesForNextPegOutEvent(),
bridgeService.getQueuedPegoutsCount(),
]).then(([nextPegoutCost, pegoutQueueCount]) => {
const estimatedFee = pegoutQueueCount > 0 ? nextPegoutCost / pegoutQueueCount : 0;
[constants.STATUS_GET_ESTIMATED_FEE]: async ({ commit }) => {
try {
const estimatedFee = await getEstimatedFee();
commit(constants.STATUS_SET_BTC_ESTIMATED_FEE, new SatoshiBig(estimatedFee, 'satoshi'));
})
.catch(() => {
commit(constants.STATUS_SET_BTC_ESTIMATED_FEE, new SatoshiBig(0, 'satoshi'));
});
} catch (e) {
commit(constants.STATUS_SET_BTC_ESTIMATED_FEE, new SatoshiBig(0, 'satoshi'));
}
},
[constants.STATUS_GET_ESTIMATED_RELEASE_TIME_IN_MINUTES]: ({ state, commit })
: Promise<void> => new Promise<void>((resolve, reject) => {
Expand Down

0 comments on commit 7c5e845

Please sign in to comment.