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>
This commit is contained in:
Nicolas Bayle 2022-12-06 12:14:01 +00:00 committed by GitHub
parent b6ad53f628
commit 57434279fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -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: