Skip to content

Commit

Permalink
fix u8ToHex
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Jun 1, 2022
1 parent ceb92b3 commit cea93e6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/transport-grpc/src/send-get-transaction-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const STATUS_MAP = {
5: "EXPIRED",
}

const u8ToHex = (u8, context) => context.Buffer.from(u8).toString("hex")
const nonEmptyU8ToHex = (u8, context) =>
!u8.reduce((empty, b) => empty && !b, true)
? context.Buffer.from(u8).toString("hex")
: null
!u8.reduce((empty, b) => empty && !b, true) ? u8ToHex(u8, context) : null
const hexBuffer = (hex, context) => context.Buffer.from(hex, "hex")

export async function sendGetTransactionStatus(ix, context = {}, opts = {}) {
Expand Down Expand Up @@ -57,7 +56,7 @@ export async function sendGetTransactionStatus(ix, context = {}, opts = {}) {
errorMessage: res.getErrorMessage(),
events: events.map(event => ({
type: event.getType(),
transactionId: nonEmptyU8ToHex(event.getTransactionId_asU8(), context),
transactionId: u8ToHex(event.getTransactionId_asU8(), context),
transactionIndex: event.getTransactionIndex(),
eventIndex: event.getEventIndex(),
payload: JSON.parse(
Expand Down

0 comments on commit cea93e6

Please sign in to comment.