0.0.8 • Published 12 months ago

@flipsidecrypto/pine-sdk v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Pine SDK

The official Flipside Crypto Pine SDK

view on npm API docs

Installation

$ npm install @flipsidecrypto/pine-sdk
$ yarn add @flipsidecrypto/pine-sdk

Usage

import { tracer } from "@flipsidecrypto/pine-sdk";
import type { SDKResponse, TracerEvent } from "@flipsidecrypto/pine-sdk";

const laborMarketTracer = tracer({
  connection: {
    apikey: "11111111-ffff-aaaa-2222-333333333333",
    endpoint: "localhost:8080",
  },
  tracer: {
    namespace: "labor-marker",
    version: "0.0.1",
  },
});

await laborMarketTracer.start();

await laborMarketTracer.consume(
  async (response: SDKResponse<TracerEvent[] | null>) => {
    if (response.status !== "ok") {
      console.error(response.error.msg);
      return false; // will end the process of listening
    }
    if (!response.data) return false; // will request the same event batch again

    // do something custom with events
    await Promise.all(
      response.data.map((event) => {
        if (event.contract.name === "LaborMarketSpawned") {
          return Promise.all(
            Object.values(event.decoded.inputs).map(async (input) => {
              if (input.name === "url") {
                const metadata = await ipfsData(input.value);
              }
            })
          );
        }
      })
    );
    return true; // will request the next batch of events
  },
  { name: "laborMarketListener", batchSize: 100 }
);
0.0.8

12 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago