How to use @truffle/decoder - 4 common examples

To help you get started, we’ve selected a few @truffle/decoder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / drizzle-utils / packages / contract-state-stream / index.js View on Github external
const createContractState$ = options => {
  const { newBlock$, artifact, provider } = options;
  if (!newBlock$)
    throw new Error("The options object with newBlock$ is required");
  if (!artifact)
    throw new Error("The options object with artifact is required");
  if (!provider)
    throw new Error("The options object with provider is required");

  // Setting up decoder instance
  // TODO - support contract inheritance (the 2nd arg)
  const decoder = TruffleDecoder.forContract(artifact, [], provider);
  decoder.init();

  // for each new block, we decode the state
  const observable = newBlock$.pipe(
    map(block => block.number),
    distinctUntilChanged(),
    concatMap(() => from(decoder.state())),
  );

  return observable;
};

@truffle/decoder

A decoder for Solidity variables of all sorts

MIT
Latest version published 1 year ago

Package Health Score

50 / 100
Full package analysis

Popular @truffle/decoder functions