From 8dc7bed4efb16aac7e3f1574078148bdce79f27c Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Sat, 24 Jul 2021 20:59:12 +0300 Subject: [PATCH] ts: Use hex by default for decoding Instruction (#547) --- CHANGELOG.md | 1 + ts/src/coder/instruction.ts | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6895f370..bad98b8560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ts/src/coder/instruction.ts b/ts/src/coder/instruction.ts index 8540ad3f3a..a6a9f8dc2d 100644 --- a/ts/src/coder/instruction.ts +++ b/ts/src/coder/instruction.ts @@ -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);