Skip to content

Commit

Permalink
ts: Use hex by default for decoding Instruction (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Jul 24, 2021
1 parent 0998422 commit 8dc7bed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ incremented for features.

### Breaking Changes

* ts: Use `hex` by default for decoding Instruction ([#547](https://github.com/project-serum/anchor/pull/547)).
* lang: `CpiAccount::reload` mutates the existing struct instead of returning a new one ([#526](https://github.com/project-serum/anchor/pull/526)).

## [0.11.1] - 2021-07-09
Expand Down
7 changes: 5 additions & 2 deletions ts/src/coder/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ export class InstructionCoder {
/**
* Dewcodes a program instruction.
*/
public decode(ix: Buffer | string): Instruction | null {
public decode(
ix: Buffer | string,
encoding: "hex" | "base58" = "hex"
): Instruction | null {
if (typeof ix === "string") {
ix = bs58.decode(ix);
ix = encoding === "hex" ? Buffer.from(ix, "hex") : bs58.decode(ix);
}
let sighash = bs58.encode(ix.slice(0, 8));
let data = ix.slice(8);
Expand Down

0 comments on commit 8dc7bed

Please sign in to comment.