Export decode instruction function (#15)

Export decode instruction function
This commit is contained in:
philippe-ftx 2020-09-10 12:17:21 +02:00 committed by GitHub
parent c761068ea1
commit 738c384b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,5 @@
export { Market, Orderbook, OpenOrders } from './market';
export { DexInstructions } from './instructions';
export { DexInstructions, decodeInstruction } from './instructions';
export { TOKEN_MINTS, MARKETS } from './tokens_and_markets';
export { decodeEventQueue, decodeRequestQueue } from './queue';
export * as TokenInstructions from './token-instructions';

View File

@ -60,6 +60,10 @@ export function encodeInstruction(instruction) {
return b.slice(0, INSTRUCTION_LAYOUT.encode(instruction, b));
}
export function decodeInstruction(message) {
return INSTRUCTION_LAYOUT.decode(message);
}
export class DexInstructions {
static initializeMarket({
market,

View File

@ -91,9 +91,9 @@ export class VersionedLayout extends Layout {
}
decode(b, offset = 0) {
if (b.readUInt8(offset) !== this._version) {
throw new Error('invalid version');
}
// if (b.readUInt8(offset) !== this._version) {
// throw new Error('invalid version');
// }
return this.inner.decode(b, offset + 1);
}