Browse Source

add wallet publickey to Provider (#1845)

Tommy Johnson 3 years ago
parent
commit
0011e22b91
2 changed files with 7 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 6 1
      ts/src/provider.ts

+ 1 - 0
CHANGELOG.md

@@ -24,6 +24,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 
 * cli: Move `overflow-checks` into workspace `Cargo.toml` so that it will not be ignored by compiler ([#1806](https://github.com/project-serum/anchor/pull/1806)).
 * lang: Fix missing account name information when deserialization fails when using `init` or `zero` ([#1800](https://github.com/project-serum/anchor/pull/1800)).
+* ts: Expose the wallet's publickey on the Provider ([#1845](https://github.com/project-serum/anchor/pull/1845)).
 
 ## [0.24.2] - 2022-04-13
 

+ 6 - 1
ts/src/provider.ts

@@ -20,6 +20,7 @@ import {
 
 export default interface Provider {
   readonly connection: Connection;
+  readonly publicKey: PublicKey;
 
   send?(
     tx: Transaction,
@@ -48,6 +49,8 @@ export default interface Provider {
  * by the provider.
  */
 export class AnchorProvider implements Provider {
+  readonly publicKey: PublicKey;
+
   /**
    * @param connection The cluster connection where the program is deployed.
    * @param wallet     The wallet used to pay for and sign all transactions.
@@ -57,7 +60,9 @@ export class AnchorProvider implements Provider {
     readonly connection: Connection,
     readonly wallet: Wallet,
     readonly opts: ConfirmOptions
-  ) {}
+  ) {
+    this.publicKey = wallet.publicKey;
+  }
 
   static defaultOptions(): ConfirmOptions {
     return {