Skip to content

Commit

Permalink
fixing vue error and adding the btc price in a session object
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjavabraz committed Mar 27, 2024
1 parent 160826a commit e26bc84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/common/store/session/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ export const actions: ActionTree<SessionState, RootState> = {
.then((response: AxiosResponse) => {
const [result] = response.data;
commit(constants.SESSION_SET_BITCOIN_PRICE, result.current_price);
sessionStorage.setItem('BTC_LAST_PRICE_OBTAINED', result.current_price);
})
.catch(() => {
commit(constants.SESSION_SET_BITCOIN_PRICE, 0);
const lastPrice = Number(sessionStorage.getItem('BTC_LAST_PRICE_OBTAINED'));
commit(constants.SESSION_SET_BITCOIN_PRICE, lastPrice > 0 ? lastPrice : 0);
})
.finally(() => {
commit(constants.SESSION_SET_TX_TYPE, 'PEG_IN_TRANSACTION_TYPE');
Expand Down
12 changes: 7 additions & 5 deletions src/pegout/components/FlyoverPegout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
:formState="pegOutFormState"
:isReadyToSign="isReadyToSign"
:isReadyToCreate="isReadyToCreate"
:authorizedWalletToSignMessage="authorizedWalletToSignMessage"
:pegoutOptionAuthorizedWalletToSign="authorizedWalletToSignMessage"
@openAddressDialog="showAddressDialog = true"
@flyoverInputFocusChanged="handleFlyoverInputFocusChanged"
@send="send(quote.quoteHash)"
Expand Down Expand Up @@ -171,6 +171,7 @@ export default defineComponent({
const pegOutFormState = ref<Machine<'loading' | 'goingHome' | 'fill'>>(new Machine('fill'));
const injectedProvider = ref('');
const isReadyToSign = ref(false);
let authorizedWalletToSignMessage = ref(false);
const showAddressDialog = ref(false);
const flyoverInputFocused = ref(false);
const loadingQuotes = ref(false);
Expand Down Expand Up @@ -252,11 +253,11 @@ export default defineComponent({
return '';
});
const authorizedWalletToSignMessage = computed(
(): boolean => injectedProvider.value === constants.RLOGIN_METAMASK_WALLET
function walletAuthorizedToSign() {
authorizedWalletToSignMessage = injectedProvider.value === constants.RLOGIN_METAMASK_WALLET
|| isLedgerConnected.value
|| session.value.rLogin?.provider.isTrezor,
);
|| session.value.rLogin?.provider.isTrezor;
}
const validAmountToReceive = computed((): boolean => estimatedBtcToReceive.value.gt(0));
Expand Down Expand Up @@ -358,6 +359,7 @@ export default defineComponent({
}
function getQuotes() {
walletAuthorizedToSign();
loadingQuotes.value = true;
getPegoutQuotes(session.value.account)
.catch(handlePegoutError)
Expand Down
12 changes: 9 additions & 3 deletions src/pegout/components/PegoutOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
{{session.btcDerivedAddress}}
</span>
<v-btn v-else
:disabled="!isReadyToSign || !authorizedWalletToSignMessage"
:disabled="!isReadyToSign || !pegoutOptionAuthorizedWalletToSign"
variant="outlined"
rounded
@click="$emit('openAddressDialog')" >
<span>
Get Bitcoin destination address
</span>
</v-btn>
<span v-if="!authorizedWalletToSignMessage" class="text-black pt-1" >
<span v-if="!pegoutOptionAuthorizedWalletToSign" class="text-black pt-1" >
As you are not using MetaMask, Ledger or Trezor, you need to follow
<a :href=constants.DERIVE_BTC_ADDRESS_DOCUMENTATION_URL
class="d-inline-block text-black a"
Expand Down Expand Up @@ -139,7 +139,7 @@ export default defineComponent({
type: Boolean,
required: true,
},
authorizedWalletToSignMessage: {
pegoutOptionAuthorizedWalletToSign: {
type: Boolean,
required: true,
},
Expand Down Expand Up @@ -195,6 +195,12 @@ export default defineComponent({
});
function toUSD(amount: number | string | undefined) {
console.log('getting the value for BTC ');

Check warning on line 198 in src/pegout/components/PegoutOption.vue

View workflow job for this annotation

GitHub Actions / checkout-and-build

Unexpected console statement
console.log('getting the value for BTC ');

Check warning on line 199 in src/pegout/components/PegoutOption.vue

View workflow job for this annotation

GitHub Actions / checkout-and-build

Unexpected console statement
console.log('getting the value for BTC ');

Check warning on line 200 in src/pegout/components/PegoutOption.vue

View workflow job for this annotation

GitHub Actions / checkout-and-build

Unexpected console statement
console.log('getting the value for BTC ');

Check warning on line 201 in src/pegout/components/PegoutOption.vue

View workflow job for this annotation

GitHub Actions / checkout-and-build

Unexpected console statement
console.log('getting the value for BTC ');
console.log(bitcoinPrice.value);
const btcAmount = new SatoshiBig(amount ?? '0', 'btc');
return btcAmount.toUSDFromBTCString(bitcoinPrice.value, fixedUSDDecimals);
}
Expand Down

0 comments on commit e26bc84

Please sign in to comment.