change tx api

This commit is contained in:
liangping 2022-04-23 13:41:23 +08:00
parent a10fa99674
commit 7cf7ae9a1e
4 changed files with 9 additions and 6 deletions

View File

@ -89,8 +89,8 @@ export default class ChainFetch {
return this.get(`/cosmos/tx/v1beta1/txs/${hash}`).then(data => WrapStdTx.create(data, ver))
}
async getTxsBySender(sender, page = 1) {
return this.get(`/cosmos/tx/v1beta1/txs?events=message.sender='${sender}'&page=${page}&limit=20`)
async getTxsBySender(sender) {
return this.get(`/cosmos/tx/v1beta1/txs?events=message.sender='${sender}'&pagination.reverse=true&order_by=ORDER_BY_DESC`)
}
async getTxsByRecipient(recipient) {

View File

@ -300,6 +300,9 @@ export function abbrMessage(msg) {
})
return output.join(', ')
}
if (msg['@type']) {
return msg['@type'].substring(msg['@type'].lastIndexOf('.') + 1).replace('Msg', '')
}
if (msg.typeUrl) {
return msg.typeUrl.substring(msg.typeUrl.lastIndexOf('.') + 1).replace('Msg', '')
}

View File

@ -337,10 +337,10 @@ export default {
computed: {
txs() {
if (this.transactions.txs) {
return this.transactions.txs.map(x => ({
return this.transactions.tx_responses.map(x => ({
height: Number(x.height),
txhash: x.txhash,
msgs: abbrMessage(x.tx.value ? x.tx.value.msg : x.tx.msg),
msgs: abbrMessage(x.tx.body.messages),
time: toDay(x.timestamp),
}))
}

View File

@ -492,10 +492,10 @@ export default {
},
txs() {
if (this.transactions.txs) {
return this.transactions.txs.map(x => ({
return this.transactions.tx_responses.map(x => ({
height: Number(x.height),
txhash: x.txhash,
msgs: abbrMessage(x.tx.msg ? x.tx.msg : x.tx.value.msg),
msgs: abbrMessage(x.tx.body.messages),
time: toDay(x.timestamp),
}))
}