Skip to content

Commit

Permalink
Register txs
Browse files Browse the repository at this point in the history
  • Loading branch information
lserra-iov authored and alexjavabraz committed Nov 8, 2023
1 parent ecd202d commit 4de925d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/common/services/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,18 @@ export default class ApiService {
.catch(reject);
});
}

static registerTx({
txHash, type, value, wallet, fee,
}: {
txHash: string, type: string, value: number, wallet: string, fee: number,
}): Promise<void> {
return new Promise<void>((resolve, reject) => {
axios.post(`${ApiService.baseURL}/register`, {
txHash, type, value, wallet, fee,
})
.then(() => resolve())
.catch(reject);
});
}
}
7 changes: 7 additions & 0 deletions src/pegin/components/ledger/ConfirmLedgerTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ export default defineComponent({
.broadcast(tx.signedTx))
.then((id) => {
txId.value = id;
ApiService.registerTx({
txHash: txId.value,
type: 'pegin',
value: Number(pegInTxState.value.amountToTransfer.toBTCTrimmedString()),
wallet: 'ledger',
fee: Number(safeFee.value.toBTCTrimmedString()),
});
})
.catch((err) => {
props.confirmTxState?.send('error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ export default defineComponent({
.broadcast(liqualitySignedTx.signedTx))
.then((txHash) => {
txId.value = txHash;
ApiService.registerTx({
txHash: txId.value,
type: 'pegin',
value: Number(pegInTxState.value.amountToTransfer.toBTCTrimmedString()),
wallet: 'liquality',
fee: Number(safeFee.value.toBTCTrimmedString()),
});
})
.catch((err) => {
props.confirmTxState.send('error');
Expand Down
7 changes: 7 additions & 0 deletions src/pegin/components/trezor/ConfirmTrezorTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ export default defineComponent({
.broadcast(trezorSignedTx.payload.serializedTx))
.then((id) => {
txId.value = id;
ApiService.registerTx({
txHash: txId.value,
type: 'pegin',
value: Number(pegInTxState.value.amountToTransfer.toBTCTrimmedString()),
wallet: 'trezor',
fee: Number(safeFee.value.toBTCTrimmedString()),
});
})
.catch((err) => {
props.confirmTxState.send('error');
Expand Down
26 changes: 25 additions & 1 deletion src/pegout/components/PegOutForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import {
} from '@/common/types';
import TxSummaryFixed from '@/common/components/exchange/TxSummaryFixed.vue';
import { useAction, useGetter, useState } from '@/common/store/helper';
import { ApiService } from '@/common/services';
export default defineComponent({
name: 'PegOutForm',
Expand Down Expand Up @@ -161,7 +162,23 @@ export default defineComponent({
const estimatedBtcToReceive = useGetter<SatoshiBig>('pegOutTx', constants.PEGOUT_TX_GET_ESTIMATED_BTC_TO_RECEIVE);
// eslint-disable-next-line max-len
const isLedgerConnected = useGetter<boolean>('web3Session', constants.SESSION_IS_LEDGER_CONNECTED);
const isTrezorConnected = useGetter<boolean>('web3Session', constants.SESSION_IS_TREZOR_CONNECTED);
const isMetamaskConnected = useGetter<boolean>('web3Session', constants.SESSION_IS_METAMASK_CONNECTED);
const currentWallet = computed(() => {
if (isLedgerConnected.value) {
return 'ledger';
}
if (isTrezorConnected.value) {
return 'trezor';
}
if (isMetamaskConnected.value) {
return 'metamask';
}
if (injectedProvider.value === appConstants.RLOGIN_LIQUALITY_WALLET) {
return 'liquality';
}
return '';
});
const authorizedWalletToSignMessage = computed(
(): boolean => injectedProvider.value === appConstants.RLOGIN_METAMASK_WALLET
|| isLedgerConnected.value
Expand Down Expand Up @@ -203,6 +220,13 @@ export default defineComponent({
pegOutFormState.value.send('loading');
sendTx()
.then(() => {
ApiService.registerTx({
txHash: pegOutTxState.value.txHash as string,
type: 'pegout',
value: Number(pegOutTxState.value.amountToTransfer.toRBTCTrimmedString()),
wallet: currentWallet.value,
fee: Number(pegOutTxState.value.calculatedFee.toRBTCTrimmedString()),
});
changePage();
})
.catch((error:Error) => {
Expand Down

0 comments on commit 4de925d

Please sign in to comment.