Skip to content

Commit

Permalink
ts: Make opts parameter of AnchorProvider constructor optional (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Mar 14, 2024
1 parent d9a9f19 commit ddcb3b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/reusable-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,12 @@ jobs:
path: tests/declare-id
- cmd: cd tests/typescript && anchor test --skip-lint && npx tsc --noEmit
path: tests/typescript
- cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-sbf
path: tests/zero-copy
# zero-copy tests cause `/usr/bin/ld: final link failed: No space left on device`
# on GitHub runners. It is likely caused by `cargo test-sbf` since all other tests
# don't have this problem.
# TODO: Find a fix.
# - cmd: cd tests/zero-copy && anchor test --skip-lint && cd programs/zero-copy && cargo test-sbf
# path: tests/zero-copy
- cmd: cd tests/chat && anchor test --skip-lint
path: tests/chat
- cmd: cd tests/ido-pool && anchor test --skip-lint
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- idl, ts: Add unit and tuple struct support ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- idl, ts: Add generics support ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- ts: Add `accountsPartial` method to keep the old `accounts` method behavior ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- ts: Make `opts` parameter of `AnchorProvider` constructor optional ([#2843](https://github.com/coral-xyz/anchor/pull/2843)).

### Fixes

Expand All @@ -56,6 +57,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- idl: Fix IDL ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- idl, ts: Make casing consistent ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- ts: Fix not being able to use numbers in instruction, account, or event names in some cases due to case conversion ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- cli: Fix excessive test validator requests ([#2828](https://github.com/coral-xyz/anchor/pull/2828)).

### Breaking

Expand Down
9 changes: 6 additions & 3 deletions ts/packages/anchor/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AnchorProvider implements Provider {
constructor(
readonly connection: Connection,
readonly wallet: Wallet,
readonly opts: ConfirmOptions
readonly opts: ConfirmOptions = AnchorProvider.defaultOptions()
) {
this.publicKey = wallet?.publicKey;
}
Expand All @@ -83,11 +83,14 @@ export class AnchorProvider implements Provider {
*
* (This api is for Node only.)
*/
static local(url?: string, opts?: ConfirmOptions): AnchorProvider {
static local(
url?: string,
opts: ConfirmOptions = AnchorProvider.defaultOptions()
): AnchorProvider {
if (isBrowser) {
throw new Error(`Provider local is not available on browser.`);
}
opts = opts ?? AnchorProvider.defaultOptions();

const connection = new Connection(
url ?? "http://127.0.0.1:8899",
opts.preflightCommitment
Expand Down

0 comments on commit ddcb3b8

Please sign in to comment.