Slave/btc integration #4
@@ -49,6 +49,7 @@
|
|||||||
<el-form-item label="Destination address" prop="destinationAddress">
|
<el-form-item label="Destination address" prop="destinationAddress">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="withdrawForm.destinationAddress"
|
v-model="withdrawForm.destinationAddress"
|
||||||
|
class="withdraw-address-input"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
:placeholder="`${walletStatus.network} Monero address`"
|
:placeholder="`${walletStatus.network} Monero address`"
|
||||||
:disabled="withdrawing"
|
:disabled="withdrawing"
|
||||||
@@ -56,6 +57,17 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Fee priority" prop="priority">
|
||||||
|
<el-select v-model="withdrawForm.priority" class="fee-priority-select" :disabled="withdrawing">
|
||||||
|
<el-option
|
||||||
|
v-for="option in moneroWithdrawPriorityOptions"
|
||||||
|
:key="option.value"
|
||||||
|
:label="option.label"
|
||||||
|
:value="option.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-button type="primary" native-type="submit" :loading="withdrawing">
|
<el-button type="primary" native-type="submit" :loading="withdrawing">
|
||||||
Withdraw all unlocked funds
|
Withdraw all unlocked funds
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -90,9 +102,12 @@
|
|||||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
||||||
import { computed, onBeforeMount, reactive, ref } from 'vue';
|
import { computed, onBeforeMount, reactive, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { moneroWithdrawPriorityOptions } from '@/consts/moneroWallet/moneroWithdrawPriorityOptions';
|
||||||
|
import { MoneroWithdrawPriority } from '@/types/moneroWallet/MoneroWithdrawPriority';
|
||||||
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
||||||
import { useMoneroWalletStore } from '@/stores/moneroWallet';
|
import { useMoneroWalletStore } from '@/stores/moneroWallet';
|
||||||
import { isMoneroStandardAddress } from '@/utils/monero/isMoneroStandardAddress';
|
import { isMoneroStandardAddress } from '@/utils/monero/isMoneroStandardAddress';
|
||||||
|
import { resolveMoneroWithdrawPriorityLabel } from '@/utils/monero/resolveMoneroWithdrawPriorityLabel';
|
||||||
import { resolveAxiosErrorMessage } from '@/utils/resolveAxiosErrorMessage';
|
import { resolveAxiosErrorMessage } from '@/utils/resolveAxiosErrorMessage';
|
||||||
import { resolveWalletSyncStatusLabel } from '@/utils/wallet/resolveWalletSyncStatusLabel';
|
import { resolveWalletSyncStatusLabel } from '@/utils/wallet/resolveWalletSyncStatusLabel';
|
||||||
import { resolveWalletSyncStatusTagType } from '@/utils/wallet/resolveWalletSyncStatusTagType';
|
import { resolveWalletSyncStatusTagType } from '@/utils/wallet/resolveWalletSyncStatusTagType';
|
||||||
@@ -110,7 +125,8 @@ const withdrawing = ref(false);
|
|||||||
const revealingSeed = ref(false);
|
const revealingSeed = ref(false);
|
||||||
const withdrawFormRef = ref<FormInstance>();
|
const withdrawFormRef = ref<FormInstance>();
|
||||||
const withdrawForm = reactive({
|
const withdrawForm = reactive({
|
||||||
destinationAddress: ''
|
destinationAddress: '',
|
||||||
|
priority: MoneroWithdrawPriority.Automatic
|
||||||
});
|
});
|
||||||
const seedDialogVisible = ref(false);
|
const seedDialogVisible = ref(false);
|
||||||
const revealedMnemonic = ref('');
|
const revealedMnemonic = ref('');
|
||||||
@@ -209,11 +225,17 @@ const onWithdrawSubmit = async (): Promise<void> => {
|
|||||||
const trimmedAddress = withdrawForm.destinationAddress.trim();
|
const trimmedAddress = withdrawForm.destinationAddress.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(`Withdraw all unlocked funds to:\n${trimmedAddress}`, 'Confirm withdrawal', {
|
const priorityLabel = resolveMoneroWithdrawPriorityLabel(withdrawForm.priority);
|
||||||
confirmButtonText: 'Continue',
|
|
||||||
cancelButtonText: 'Cancel',
|
await ElMessageBox.confirm(
|
||||||
type: 'warning'
|
`Withdraw all unlocked funds at ${priorityLabel} fee to:\n${trimmedAddress}`,
|
||||||
});
|
'Confirm withdrawal',
|
||||||
|
{
|
||||||
|
confirmButtonText: 'Continue',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -229,6 +251,7 @@ const onWithdrawSubmit = async (): Promise<void> => {
|
|||||||
try {
|
try {
|
||||||
const result = await withdrawAll({
|
const result = await withdrawAll({
|
||||||
destinationAddress: trimmedAddress,
|
destinationAddress: trimmedAddress,
|
||||||
|
priority: withdrawForm.priority,
|
||||||
password
|
password
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -290,3 +313,14 @@ const clearSeed = (): void => {
|
|||||||
revealedMnemonic.value = '';
|
revealedMnemonic.value = '';
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.withdraw-address-input {
|
||||||
|
width: 100%;
|
||||||
|
max-width: min(560px, 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fee-priority-select {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { MoneroWithdrawPriority } from '@/types/moneroWallet/MoneroWithdrawPriority';
|
||||||
|
import type { MoneroWithdrawPriorityLabel } from '@/types/moneroWallet/MoneroWithdrawPriorityLabel';
|
||||||
|
|
||||||
|
export const moneroWithdrawPriorityOptions = [
|
||||||
|
{ value: MoneroWithdrawPriority.Automatic, label: 'Automatic' },
|
||||||
|
{ value: MoneroWithdrawPriority.Slow, label: 'Slow (0.2×)' },
|
||||||
|
{ value: MoneroWithdrawPriority.Normal, label: 'Normal (1×)' },
|
||||||
|
{ value: MoneroWithdrawPriority.Fast, label: 'Fast (5×)' },
|
||||||
|
{ value: MoneroWithdrawPriority.Fastest, label: 'Fastest (200×)' }
|
||||||
|
] as const satisfies ReadonlyArray<{
|
||||||
|
value: MoneroWithdrawPriority;
|
||||||
|
label: MoneroWithdrawPriorityLabel;
|
||||||
|
}>;
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
|
import { MoneroWithdrawPriority } from './MoneroWithdrawPriority';
|
||||||
|
|
||||||
export interface MoneroWalletWithdrawPayload {
|
export interface MoneroWalletWithdrawPayload {
|
||||||
destinationAddress: string;
|
destinationAddress: string;
|
||||||
|
priority: MoneroWithdrawPriority;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export enum MoneroWithdrawPriority {
|
||||||
|
Automatic = 0,
|
||||||
|
Slow = 1,
|
||||||
|
Normal = 2,
|
||||||
|
Fast = 3,
|
||||||
|
Fastest = 4
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export type MoneroWithdrawPriorityLabel =
|
||||||
|
| 'Automatic'
|
||||||
|
| 'Slow (0.2×)'
|
||||||
|
| 'Normal (1×)'
|
||||||
|
| 'Fast (5×)'
|
||||||
|
| 'Fastest (200×)';
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { moneroWithdrawPriorityOptions } from '@/consts/moneroWallet/moneroWithdrawPriorityOptions';
|
||||||
|
import { MoneroWithdrawPriority } from '@/types/moneroWallet/MoneroWithdrawPriority';
|
||||||
|
import type { MoneroWithdrawPriorityLabel } from '@/types/moneroWallet/MoneroWithdrawPriorityLabel';
|
||||||
|
|
||||||
|
export const resolveMoneroWithdrawPriorityLabel = (priority: MoneroWithdrawPriority): MoneroWithdrawPriorityLabel => {
|
||||||
|
const option = moneroWithdrawPriorityOptions.find(({ value }) => value === priority);
|
||||||
|
|
||||||
|
if (!option) {
|
||||||
|
throw new Error(`Invalid Monero withdraw priority: ${priority}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return option.label;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user