From 0b479066b3d92e4d93b8814c201e283519bd6ce5 Mon Sep 17 00:00:00 2001 From: Nico Schapeler <38372048+cryptopapi997@users.noreply.github.com> Date: Tue, 20 Dec 2022 07:43:53 +0100 Subject: [PATCH] fix: make toBytes actually return the type it's typehint claims (#29313) --- web3.js/src/publickey.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web3.js/src/publickey.ts b/web3.js/src/publickey.ts index 449f90371f5fc8..4d17ae68ca9c05 100644 --- a/web3.js/src/publickey.ts +++ b/web3.js/src/publickey.ts @@ -112,7 +112,8 @@ export class PublicKey extends Struct { * Return the byte array representation of the public key in big endian */ toBytes(): Uint8Array { - return this.toBuffer(); + const buf = this.toBuffer(); + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength); } /**