Skip to content

Commit

Permalink
project-serum#172 WIP decode jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
gotjoshua committed Sep 30, 2021
1 parent 20a776e commit a628aad
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/serum/src/instructions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ export function encodeInstruction(instruction) {
return b.slice(0, INSTRUCTION_LAYOUT.encode(instruction, b));
}

export function decodeInstruction(message) {
return INSTRUCTION_LAYOUT.decode(message);
/**
* Accepts raw instruction data as a buffer of raw bytes
* eg. from [@solana/web3.js.TransactionInstruction.data](https://solana-labs.github.io/solana-web3.js/classes/TransactionInstruction.html)
* or from decoding the base58 data from [@solana/web3.js.PartiallyDecodedInstruction.data](https://solana-labs.github.io/solana-web3.js/modules.html#PartiallyDecodedInstruction)
* Returns an object that describes the instruction parameters
*
* @param {Uint8Array} instructionData
* @returns {Object} decoded Instruction Object
*/
export function decodeInstruction(instructionData) {
return INSTRUCTION_LAYOUT.decode(instructionData);
}

export class DexInstructions {
Expand Down

0 comments on commit a628aad

Please sign in to comment.