Skip to content

Commit

Permalink
Enable transfer for coins
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed Jul 19, 2024
1 parent 9f6cd93 commit e5b5bf9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions apps/api/src/app/services/ERC20Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ import {
import TransactionService from './TransactionService';
import PoolService from './PoolService';
import { fromWei } from 'web3-utils';
import { NODE_ENV } from '../config/secrets';

async function decorate(token: ERC20TokenDocument, wallet: WalletDocument) {
const erc20 = await getById(token.erc20Id);
if (!erc20 || erc20.chainId !== wallet.chainId) return;
if (!erc20) {
throw new Error(`ERC20 not found for ${token.erc20Id}`);
}

if (erc20.chainId !== wallet.chainId) {
throw new Error(`ERC20 chain ${erc20.chainId} not equal walllet chain ${wallet.chainId}`);
}

const walletBalanceInWei = await erc20.contract.methods.balanceOf(wallet.address).call();
const walletBalance = fromWei(walletBalanceInWei, 'ether');
Expand Down
9 changes: 7 additions & 2 deletions apps/app/src/components/card/BaseCardERC20.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
</template>

<template #dropdown-items>
<b-dropdown-item disabled @click="isModalTransferShown = true"> Transfer </b-dropdown-item>
<b-dropdown-item :disabled="isDisabledTransfer" @click="isModalTransferShown = true">
Transfer
</b-dropdown-item>
<b-dropdown-item :href="blockExplorerURL"> Block Explorer </b-dropdown-item>
<BaseModalERC20Transfer
:id="`modalERC20Transfer${token.erc20._id}`"
Expand All @@ -36,7 +38,7 @@ import { useWalletStore } from '../../stores/Wallet';
import { useAccountStore } from '../../stores/Account';
import { toast } from '../../utils/toast';
import { fromWei } from 'web3-utils';
import { RewardVariant } from '@thxnetwork/common/enums';
import { RewardVariant, WalletVariant } from '@thxnetwork/common/enums';
import { chainList } from '@thxnetwork/app/utils/chains';
export default defineComponent({
Expand Down Expand Up @@ -69,6 +71,9 @@ export default defineComponent({
return chainList[chainId].blockExplorer + '/token/' + this.token.erc20.address + '?a=' + wallet.address;
},
isDisabledTransfer() {
return this.walletStore.wallet?.variant !== WalletVariant.Safe;
},
},
methods: {
onToastClose() {
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/components/card/BaseCardPayment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
</template>
<slot name="dropdown-items"></slot>
<b-dropdown-divider />
<b-dropdown-text v-if="createdAt" class="text-end small text-opaque">
{{ format(new Date(createdAt), 'MMMM do hh:mm') }}
<b-dropdown-text v-if="createdAt" class="text-end small text-opaque py-0">
{{ format(new Date(createdAt), 'MM do hh:mm') }}
</b-dropdown-text>
</b-dropdown>
</div>
Expand Down

0 comments on commit e5b5bf9

Please sign in to comment.