Skip to content

Commit

Permalink
fix: pretty print PublicKey objects in node and in the browser (#29062)
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Dec 9, 2022
1 parent ecea802 commit ffcebbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions web3.js/src/publickey.ts
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion web3.js/test/connection.test.ts
Expand Up @@ -4518,7 +4518,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);
Expand Down

0 comments on commit ffcebbb

Please sign in to comment.