withdraw fix

This commit is contained in:
Tim
2024-03-27 22:19:33 -04:00
parent 0271494846
commit 0fc6fc7168
2 changed files with 8 additions and 7 deletions

View File

@@ -97,6 +97,7 @@ import {vaultAddress} from "@/blockchain/contract.js";
import {ensureVault} from "@/blockchain/wallet.js";
import CopyButton from "@/components/CopyButton.vue";
import Withdraw from "@/components/Withdraw.vue";
import {getToken} from "@/blockchain/token.js";
const TokenRow = defineAsyncComponent(()=>import('./TokenRow.vue'))
const s = useStore()
@@ -113,8 +114,8 @@ const exists = computed(()=>s.vaults.length>0)
const withdrawToken = ref(null)
const withdrawShow = ref(false)
function onWithdraw(addr) {
const token = s.tokens[addr]
async function onWithdraw(addr) {
const token = await getToken(s.chainId, addr)
console.log('withdraw', addr, token)
withdrawToken.value = token
withdrawShow.value = true

View File

@@ -2,7 +2,7 @@
<v-dialog :model-value="modelValue" @update:modelValue="$emit('update:modelValue', $event)">
<v-card style="max-width: 25em" class="mx-auto">
<v-card-title>
<v-icon icon="mdi-arrow-down-bold" color="grey-darken-1"/>&nbsp;Withdraw {{ token.symbol }}
<v-icon icon="mdi-arrow-down-bold" color="grey-darken-1"/>&nbsp;Withdraw {{ token.s }}
</v-card-title>
<v-card-item>
<v-text-field class="text-end" type="number" variant="outlined" :min="0" :max="balanceFloat"
@@ -11,7 +11,7 @@
<v-btn variant="text" text="max" @click="floatAmount=balanceFloat"/>
</template>
<template v-slot:append-inner>
<span>{{ token.symbol }}</span>
<span>{{ token.s }}</span>
</template>
</v-text-field>
<v-card-actions>
@@ -45,13 +45,13 @@ const floatAmount = ref(0)
function withdraw() {
const vaultAddr = props.vault
const valueStr = floatAmount.value.toString();
const amount = FixedNumber.fromString(valueStr,{decimals:props.token.decimals, width:256, signed: false}).value;
console.log('pending withdrawl', valueStr, amount, props.token.symbol)
const amount = FixedNumber.fromString(valueStr,{decimals:props.token.d, width:256, signed: false}).value;
console.log('pending withdrawl', valueStr, amount, props.token.s)
if( amount === 0n )
return
pendTransaction(async (signer)=>{
const vault = contractOrNull(vaultAddr, vaultAbi, signer)
return await vault['withdraw(address,uint256)'](props.token.address, amount)
return await vault['withdraw(address,uint256)'](props.token.a, amount)
})
floatAmount.value = 0
emit('update:modelValue', false)