classic-ui/utils/adapters.js
FreezyEx b32527e057 Revert "minor fixes"
This reverts commit 7f8f7c2aa15c8b8c6a7449d177f46f8a417e2f67.
2022-10-13 16:03:54 +02:00

48 lines
1.2 KiB
JavaScript

import { eventsType } from '@/constants'
export function formatEvents(events, type) {
if (type === eventsType.DEPOSIT) {
return events.map(({ blockNumber, transactionHash, returnValues }) => {
const { commitment, leafIndex, timestamp } = returnValues
return {
blockNumber,
transactionHash,
commitment,
leafIndex: Number(leafIndex),
timestamp
}
})
} else {
return events.map(({ blockNumber, transactionHash, returnValues }) => {
const { nullifierHash, to, fee } = returnValues
return {
blockNumber,
transactionHash,
nullifierHash,
to,
fee
}
})
}
}
export function formatEvent(event, type) {
if (type === eventsType.DEPOSIT) {
return {
timestamp: event.timestamp,
commitment: event.commitment,
leafIndex: Number(event.index ? event.index : event.leafIndex),
blockNumber: event.blockNumber,
transactionHash: event.transactionHash
}
} else {
return {
to: event.to,
fee: event.fee,
nullifierHash: event.nullifier ? event.nullifier : event.nullifierHash,
blockNumber: Number(event.blockNumber),
transactionHash: event.transactionHash
}
}
}