improve compatibility

This commit is contained in:
liangping 2023-12-25 17:13:04 +08:00
parent 5d1b0fba9b
commit 4518d7d108

View File

@ -205,7 +205,7 @@ enum EventType {
Unbond = 'unbond', Unbond = 'unbond',
} }
const selectedEventType = ref(EventType.Unbond) const selectedEventType = ref(EventType.Delegate)
function loadPowerEvents(p: number, type: EventType) { function loadPowerEvents(p: number, type: EventType) {
selectedEventType.value = type selectedEventType.value = type
@ -220,13 +220,21 @@ function pagePowerEvents(page: number) {
loadPowerEvents(page, selectedEventType.value) loadPowerEvents(page, selectedEventType.value)
} }
pagePowerEvents(1)
function mapEvents(events: {type: string, attributes: {key: string, value: string}[]}[]) { function mapEvents(events: {type: string, attributes: {key: string, value: string}[]}[]) {
const attributes = events.filter(x => x.type=== selectedEventType.value).filter(x => x.attributes.findIndex(attr => attr.value === toBase64(stringToUint8Array(validator))) > -1).map(x => { const attributes = events
.filter(x => x.type=== selectedEventType.value)
.filter(x => x.attributes.findIndex(attr => attr.value === validator || attr.value === toBase64(stringToUint8Array(validator))) > -1)
.map(x => {
// check if attributes need to decode // check if attributes need to decode
if(x.attributes.findIndex(a => a.value === `amount`) > -1) return x.attributes
const output = {} as {[key: string]: string } const output = {} as {[key: string]: string }
if(x.attributes.findIndex(a => a.key === `amount`) > -1) {
x.attributes.forEach(attr => { x.attributes.forEach(attr => {
output[attr.key] = attr.value
})
} else x.attributes.forEach(attr => {
output[uint8ArrayToString(fromBase64(attr.key))] = uint8ArrayToString(fromBase64(attr.value)) output[uint8ArrayToString(fromBase64(attr.key))] = uint8ArrayToString(fromBase64(attr.value))
}) })
return output return output