Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pretty print PublicKey objects in node and in the browser #29062

Merged
merged 1 commit into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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);
Expand Down