orderspec refactor for server and web
This commit is contained in:
27
src/components/TokenAmount.vue
Normal file
27
src/components/TokenAmount.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<span>{{fmtAmount}} {{ token.symbol || '' }}</span>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {useStore} from "@/store/store";
|
||||
import {getToken} from "@/blockchain/token.js";
|
||||
import {FixedNumber} from "ethers";
|
||||
import {computed, ref} from "vue";
|
||||
|
||||
const s = useStore()
|
||||
const props = defineProps(['addr', 'amount'])
|
||||
const token = await getToken(props.addr)
|
||||
const fmtAmount = computed(() => {
|
||||
if( props.amount === null || props.amount === undefined )
|
||||
return ''
|
||||
return FixedNumber.fromValue(props.amount, token.decimals, {
|
||||
width: 256,
|
||||
decimals: token.decimals
|
||||
}).toUnsafeFloat().toPrecision(5) // todo precision
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use "src/styles/vars" as *;
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user