From 032e3a298c3f8fa9df7e560812ceba699c0654ca Mon Sep 17 00:00:00 2001 From: Nicolas Schapeler Date: Sat, 17 Dec 2022 15:00:26 +0100 Subject: [PATCH] fix: make toBytes actually return the type it's typehint claims --- 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); } /**