init
This commit is contained in:
commit
44f31f8b9f
402 changed files with 47865 additions and 0 deletions
47
utils/adapters.js
Normal file
47
utils/adapters.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue