From a211d4623617bfc752678eda2025280753219958 Mon Sep 17 00:00:00 2001 From: marcomariscal Date: Mon, 8 Jul 2024 13:22:46 -0700 Subject: [PATCH] feat: handle sign button instead of needs sig --- frontend/src/components/WithdrawForm.vue | 51 +++++++++++++++++++----- frontend/src/i18n/locales/en-US.json | 2 +- frontend/src/i18n/locales/zh-CN.json | 2 +- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/WithdrawForm.vue b/frontend/src/components/WithdrawForm.vue index ec0f52f1..2dba5ccb 100644 --- a/frontend/src/components/WithdrawForm.vue +++ b/frontend/src/components/WithdrawForm.vue @@ -14,17 +14,14 @@
@@ -123,25 +120,57 @@ export default defineComponent({ }, }, setup(data, { emit }) { - const { NATIVE_TOKEN } = useWalletStore(); + const { NATIVE_TOKEN, getPrivateKeys } = useWalletStore(); const { setIsInWithdrawFlow, isInWithdrawFlow } = useStatusesStore(); const { needSignature } = useWalletStore(); const content = ref(data.destinationAddress || ''); const nativeTokenSymbol = NATIVE_TOKEN.value.symbol; + const isSigningInProgress = ref(false); function emitUpdateDestinationAddress(val: string) { emit('updateDestinationAddress', val); } + function initializeWithdraw() { + // Simple validation + if (!content.value || content.value.length <= 4) return; + + emit('initializeWithdraw'); + setIsInWithdrawFlow(true); + } + + async function handleSubmit() { + if (needSignature.value) { + try { + isSigningInProgress.value = true; + const success = await getPrivateKeys(); + if (success === 'denied') { + console.log('User denied signature request'); + isSigningInProgress.value = false; + return; + } + initializeWithdraw(); + } catch (error) { + console.error('Error getting private keys:', error); + } finally { + isSigningInProgress.value = false; + } + } else { + initializeWithdraw(); + } + } + return { - formatUnits, - humanizeTokenAmount, + content, emit, emitUpdateDestinationAddress, - content, + formatUnits, + handleSubmit, + humanizeTokenAmount, + isInWithdrawFlow, + isSigningInProgress, nativeTokenSymbol, needSignature, - isInWithdrawFlow, setIsInWithdrawFlow, }; }, diff --git a/frontend/src/i18n/locales/en-US.json b/frontend/src/i18n/locales/en-US.json index a238e011..e0758cd6 100644 --- a/frontend/src/i18n/locales/en-US.json +++ b/frontend/src/i18n/locales/en-US.json @@ -358,7 +358,7 @@ "view-on-explorer": "View on explorer" }, "WithdrawForm": { - "need-signature": "Need Signature", + "need-signature": "Sign", "withdraw-address": "Enter address to withdraw funds to", "address": "Address", "fetching-fee-estimate": "Fetching fee estimate...", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index def367d0..6234d9e8 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -357,7 +357,7 @@ "view-on-explorer": "在区块链浏览器上查看" }, "WithdrawForm": { - "need-signature": "此应用程序需要您的签名才能扫描您收到的资金", + "need-signature": "签名", "withdraw-address": "输入提款地址", "address": "地址", "fetching-fee-estimate": "在接收费用估计...",