add received asset list

This commit is contained in:
liangping 2023-11-13 13:38:22 +08:00
parent d811714165
commit 7b82ec2b59
2 changed files with 53 additions and 0 deletions

View File

@ -32,6 +32,7 @@ const txs = ref({} as TxResponse[]);
const delegations = ref([] as Delegation[]);
const rewards = ref({} as DelegatorRewards);
const balances = ref([] as Coin[]);
const recentReceived = ref([] as TxResponse[]);
const unbonding = ref([] as UnbondingResponses[]);
const unbondingTotal = ref(0);
const chart = {};
@ -110,6 +111,12 @@ function loadAccount(address: string) {
});
});
});
const receivedQuery = `?&pagination.reverse=true&events=coin_received.receiver='${address}'&pagination.limit=5`;
blockchain.rpc.getTxs(receivedQuery, {}).then((x) => {
console.log(x);
recentReceived.value = x.tx_responses;
});
}
function updateEvent() {
@ -536,6 +543,50 @@ function updateEvent() {
</div>
</div>
<!-- Received -->
<div class="bg-base-100 px-4 pt-3 pb-4 rounded mb-4 shadow">
<h2 class="card-title mb-4">{{ $t('account.received') }}</h2>
<div class="overflow-x-auto">
<table class="table w-full text-sm">
<thead>
<tr>
<th class="py-3">{{ $t('account.height') }}</th>
<th class="py-3">{{ $t('account.hash') }}</th>
<th class="py-3">{{ $t('account.amount') }}</th>
<th class="py-3">{{ $t('account.time') }}</th>
</tr>
</thead>
<tbody class="text-sm">
<tr v-if="recentReceived.length === 0"><td colspan="10"><div class="text-center">{{ $t('account.no_transactions') }}</div></td></tr>
<tr v-for="(v, index) in recentReceived" :key="index">
<td class="text-sm py-3">
<RouterLink :to="`/${chain}/block/${v.height}`" class="text-primary dark:invert">{{
v.height
}}</RouterLink>
</td>
<td class="truncate py-3" style="max-width: 200px">
<RouterLink :to="`/${chain}/tx/${v.txhash}`" class="text-primary dark:invert">
{{ v.txhash }}
</RouterLink>
</td>
<td class="flex items-center py-3">
<div class="mr-2">
{{ v.tx.body.messages.map(x => format.formatTokens(x.amount)).join(", ") }}
</div>
<Icon
v-if="v.code === 0"
icon="mdi-check"
class="text-success text-lg"
/>
<Icon v-else icon="mdi-multiply" class="text-error text-lg" />
</td>
<td class="py-3">{{ format.toLocaleDate(v.timestamp) }} <span class=" text-xs">({{ format.toDay(v.timestamp, 'from') }})</span> </td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Account -->
<div class="bg-base-100 px-4 pt-3 pb-4 rounded mb-4 shadow">
<h2 class="card-title mb-4">{{ $t('account.acc') }}</h2>

View File

@ -33,6 +33,8 @@
"btn_index": "Back to Home"
},
"account": {
"amount": "Amount",
"received": "Recent Received",
"type": "Type",
"address": "Address",
"acc": "Account",