Skip to content

Commit 6d21bf3

Browse files
authored
ts: Add optional prepend parameter to preInstructions method (otter-sec#2863)
1 parent 762ea1c commit 6d21bf3

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The minor version will be incremented upon a breaking change and the patch versi
3737
- ts: Make `opts` parameter of `AnchorProvider` constructor optional ([#2843](https://github.com/coral-xyz/anchor/pull/2843)).
3838
- cli: Add `--no-idl` flag to the `build` command ([#2847](https://github.com/coral-xyz/anchor/pull/2847)).
3939
- cli: Add priority fees to idl commands ([#2845](https://github.com/coral-xyz/anchor/pull/2845)).
40+
- ts: Add `prepend` option to MethodBuilder `preInstructions` method ([#2863](https://github.com/coral-xyz/anchor/pull/2863)).
4041

4142
### Fixes
4243

ts/packages/anchor/src/program/namespace/methods.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,12 @@ export class MethodsBuilder<
247247
return this;
248248
}
249249

250-
public preInstructions(ixs: Array<TransactionInstruction>) {
251-
this._preInstructions = this._preInstructions.concat(ixs);
250+
public preInstructions(ixs: Array<TransactionInstruction>, prepend = false) {
251+
if (prepend) {
252+
this._preInstructions = ixs.concat(this._preInstructions);
253+
} else {
254+
this._preInstructions = this._preInstructions.concat(ixs);
255+
}
252256
return this;
253257
}
254258

0 commit comments

Comments
 (0)