Skip to content

Commit

Permalink
chore: update explorer transaction formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Aug 8, 2024
1 parent a1a6bba commit dc51589
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion layer/transformer/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,30 @@ export const getCoins = ({
}, [] as Coin[])
}

// todo remove once /api/explorer/v1/txs?skip=0&limit=20 add signatures
const getSender = (transaction: ExplorerTransaction): string => {
if (transaction.signatures) {
return transaction.signatures[0].address
}

const message = transaction.messages[0]?.message
const msgs = message.msgs

if (msgs) {
return msgs[0].sender
}

if (message.from_address) {
return message.from_address
}

return message.sender
}

export const toUiTransaction = (
transaction: ExplorerTransaction
): UiExplorerTransaction => {
const sender = transaction.signatures[0].address
const sender = getSender(transaction)

return {
...transaction,
Expand Down

0 comments on commit dc51589

Please sign in to comment.