Browse Source

Don't use wallet object for account.createInstruction function 2112 (#2116)

* Don't use wallet object for account.createInstruction function 2112

* added publicKey type check

* yarn test pass

* Don't use wallet object for account.createInstruction function 2112

* added publicKey type check

* yarn test pass

Co-authored-by: henrye <henry@notanemail>
Nicolas Bayle 2 years ago
parent
commit
57434279fd
1 changed files with 3 additions and 5 deletions
  1. 3 5
      ts/packages/anchor/src/program/namespace/account.ts

+ 3 - 5
ts/packages/anchor/src/program/namespace/account.ts

@@ -346,16 +346,14 @@ export class AccountClient<
   ): Promise<TransactionInstruction> {
     const size = this.size;
 
-    // @ts-expect-error
-    if (this._provider.wallet === undefined) {
+    if (this._provider.publicKey === undefined) {
       throw new Error(
-        "This function requires the Provider interface implementor to have a 'wallet' field."
+        "This function requires the Provider interface implementor to have a 'publicKey' field."
       );
     }
 
     return SystemProgram.createAccount({
-      // @ts-expect-error
-      fromPubkey: this._provider.wallet.publicKey,
+      fromPubkey: this._provider.publicKey,
       newAccountPubkey: signer.publicKey,
       space: sizeOverride ?? size,
       lamports: