ts: Use hex by default for decoding Instruction (#547)
This commit is contained in:
parent
0998422348
commit
8dc7bed4ef
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue