Skip to content

Commit

Permalink
ts: Improve error message of unsupported view method (#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto committed Aug 17, 2024
1 parent 2a7d943 commit 275b28a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Fix installation with `--locked` argument using Rust v1.80 due to `time` crate issue ([#3143](https://github.com/coral-xyz/anchor/pull/3143)).
- lang: Fix compilation warnings due to unused deprecated program id macros ([#3170](https://github.com/coral-xyz/anchor/pull/3170)).
- ts: Remove `crypto-hash` dependency ([#3171](https://github.com/coral-xyz/anchor/pull/3171)).
- ts: Improve error message of unsupported `view` method ([#3177](https://github.com/coral-xyz/anchor/pull/3177)).

### Breaking

Expand Down
7 changes: 6 additions & 1 deletion ts/packages/anchor/src/program/namespace/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ export class MethodsBuilder<
}

if (!this._viewFn) {
throw new Error("Method does not support views");
throw new Error(
[
"Method does not support views.",
"The instruction should return a value, and its accounts must be read-only",
].join(" ")
);
}

// @ts-ignore
Expand Down

0 comments on commit 275b28a

Please sign in to comment.