Skip to content

Commit

Permalink
ts: Add optional prepend parameter to preInstructions method (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor123 authored Mar 24, 2024
1 parent 7c424ee commit 4393d73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- ts: Make `opts` parameter of `AnchorProvider` constructor optional ([#2843](https://github.com/coral-xyz/anchor/pull/2843)).
- cli: Add `--no-idl` flag to the `build` command ([#2847](https://github.com/coral-xyz/anchor/pull/2847)).
- cli: Add priority fees to idl commands ([#2845](https://github.com/coral-xyz/anchor/pull/2845)).
- ts: Add `prepend` option to MethodBuilder `preInstructions` method ([#2863](https://github.com/coral-xyz/anchor/pull/2863)).

### Fixes

Expand Down
8 changes: 6 additions & 2 deletions ts/packages/anchor/src/program/namespace/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@ export class MethodsBuilder<
return this;
}

public preInstructions(ixs: Array<TransactionInstruction>) {
this._preInstructions = this._preInstructions.concat(ixs);
public preInstructions(ixs: Array<TransactionInstruction>, prepend = false) {
if (prepend) {
this._preInstructions = ixs.concat(this._preInstructions);
} else {
this._preInstructions = this._preInstructions.concat(ixs);
}
return this;
}

Expand Down

0 comments on commit 4393d73

Please sign in to comment.