diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d74720baf..8c8987f344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ The minor version will be incremented upon a breaking change and the patch versi - ts: Remove `base64-js` dependency ([#2635](https://github.com/coral-xyz/anchor/pull/2635)). - syn: `IdlTypeDefinitionTy` enum has a new variant `Alias` ([#2637](https://github.com/coral-xyz/anchor/pull/2637)). - cli, client, lang, spl: Solana `1.14` is no longer supported, minimum required Solana version is `1.16.0` ([#2645](https://github.com/coral-xyz/anchor/pull/2645)). +- ts: Change Provider.publicKey type into `PublicKey | null` instead of `PublicKey | undefined`, `AccountClient.createInstruction(signer: Signer, size?: number)` into `AccountClient.createInstruction(signerPubkey: PublicKey, size?: number)` ([#2665](https://github.com/coral-xyz/anchor/issues/2665)). ## [0.28.0] - 2023-06-09 diff --git a/ts/packages/anchor/package.json b/ts/packages/anchor/package.json index e5bbd40df6..15a65f598f 100644 --- a/ts/packages/anchor/package.json +++ b/ts/packages/anchor/package.json @@ -1,6 +1,6 @@ { "name": "@coral-xyz/anchor", - "version": "0.28.1-beta.2", + "version": "0.28.1-beta.3", "description": "Anchor client", "module": "./dist/esm/index.js", "main": "./dist/cjs/index.js", diff --git a/ts/packages/anchor/src/program/namespace/account.ts b/ts/packages/anchor/src/program/namespace/account.ts index e5e6731743..f8c5800c59 100644 --- a/ts/packages/anchor/src/program/namespace/account.ts +++ b/ts/packages/anchor/src/program/namespace/account.ts @@ -349,12 +349,12 @@ export class AccountClient< * Returns an instruction for creating this account. */ async createInstruction( - signer: Signer, + signerPubkey: PublicKey, sizeOverride?: number ): Promise { - const size = this.size; + const size = sizeOverride ?? this.size; - if (this._provider.publicKey === undefined) { + if (!this._provider.publicKey) { throw new Error( "This function requires the Provider interface implementor to have a 'publicKey' field." ); @@ -362,12 +362,10 @@ export class AccountClient< return SystemProgram.createAccount({ fromPubkey: this._provider.publicKey, - newAccountPubkey: signer.publicKey, - space: sizeOverride ?? size, + newAccountPubkey: signerPubkey, + space: size, lamports: - await this._provider.connection.getMinimumBalanceForRentExemption( - sizeOverride ?? size - ), + await this._provider.connection.getMinimumBalanceForRentExemption(size), programId: this._programId, }); } diff --git a/ts/packages/anchor/src/provider.ts b/ts/packages/anchor/src/provider.ts index 02affbe0e1..e41fdd663e 100644 --- a/ts/packages/anchor/src/provider.ts +++ b/ts/packages/anchor/src/provider.ts @@ -21,7 +21,7 @@ import { export default interface Provider { readonly connection: Connection; - readonly publicKey?: PublicKey; + readonly publicKey: PublicKey | null; send?( tx: Transaction | VersionedTransaction,