Skip to content

Commit

Permalink
fix: use Buffer.from(Uint8Array.buffer))
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed May 17, 2024
1 parent 900f52c commit ac22e53
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/beacon-node/src/util/sszBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function getSeenAttDataKeyElectra(electraAttestationBytes: Uint8Array): A
return null;
}

return Buffer.from(electraAttestationBytes.subarray(startIndex, startIndex + seenKeyLength)).toString("base64");
return Buffer.from(electraAttestationBytes.subarray(startIndex, startIndex + seenKeyLength).buffer).toString(
"base64"
);
}

/**
Expand All @@ -102,9 +104,9 @@ export function getSeenAttDataKeyPhase0(data: Uint8Array): AttDataBase64 | null
}

// base64 is a bit efficient than hex
return Buffer.from(data.subarray(VARIABLE_FIELD_OFFSET, VARIABLE_FIELD_OFFSET + ATTESTATION_DATA_SIZE)).toString(
"base64"
);
return Buffer.from(
data.subarray(VARIABLE_FIELD_OFFSET, VARIABLE_FIELD_OFFSET + ATTESTATION_DATA_SIZE).buffer
).toString("base64");
}

/**
Expand Down Expand Up @@ -229,7 +231,7 @@ export function getSeenAttDataKeyFromSignedAggregateAndProofElectra(data: Uint8A
}

// base64 is a bit efficient than hex
return Buffer.from(data.subarray(startIndex, endIndex)).toString("base64");
return Buffer.from(data.subarray(startIndex, endIndex).buffer).toString("base64");
}

/**
Expand All @@ -246,7 +248,7 @@ export function getSeenAttDataKeyFromSignedAggregateAndProofPhase0(data: Uint8Ar
data.subarray(
SIGNED_AGGREGATE_AND_PROOF_SLOT_OFFSET,
SIGNED_AGGREGATE_AND_PROOF_SLOT_OFFSET + ATTESTATION_DATA_SIZE
)
).buffer
).toString("base64");
}

Expand Down

0 comments on commit ac22e53

Please sign in to comment.