From 287f8380b6fa2d0e61ea7517c50c3d6758f4375c Mon Sep 17 00:00:00 2001 From: steveluscher Date: Fri, 9 Dec 2022 18:55:17 +0000 Subject: [PATCH] fix: pretty print PublicKey objects in node and in the browser --- web3.js/src/publickey.ts | 4 ++++ web3.js/test/connection.test.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web3.js/src/publickey.ts b/web3.js/src/publickey.ts index e5ca6f0aa32bc5..1a90c5e1c000e8 100644 --- a/web3.js/src/publickey.ts +++ b/web3.js/src/publickey.ts @@ -129,6 +129,10 @@ export class PublicKey extends Struct { return zeroPad; } + get [Symbol.toStringTag](): string { + return `PublicKey(${this.toString()})`; + } + /** * Return the base-58 representation of the public key */ diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index 31fb8ac4f04385..3021ecbc19da52 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -4472,7 +4472,8 @@ describe('Connection', function () { expect(largestAccounts).to.have.length(2); const largestAccount = largestAccounts[0]; - expect(largestAccount.address).to.eql(testTokenAccountPubkey); + expect(largestAccount.address.equals(testTokenAccountPubkey)).to.be + .true; expect(largestAccount.amount).to.eq('11110'); expect(largestAccount.decimals).to.eq(2); expect(largestAccount.uiAmount).to.eq(111.1);