@project-serum/anchor#Coder TypeScript Examples

The following examples show how to use @project-serum/anchor#Coder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: events.ts    From zo-client with Apache License 2.0 5 votes vote down vote up
function decodeMsg(coder: Coder<string>, msg: string) {
  const event = coder.events.decode(msg);
  if (event) {
    return event;
  }
  return null;
}
Example #2
Source File: events.ts    From zo-client with Apache License 2.0 5 votes vote down vote up
export function decodeDexEvent(msg: string) {
  try {
    const coder = new Coder(DEX_IDL as Idl);
    return decodeMsg(coder, msg);
  } catch (_) {
    return null;
  }
}
Example #3
Source File: events.ts    From zo-client with Apache License 2.0 5 votes vote down vote up
export function decodeZoEvent(msg: string) {
  try {
    const coder = new Coder(IDL as Idl);
    return decodeMsg(coder, msg);
  } catch (_) {
    return null;
  }
}