1.3.1 • Published 9 months ago

@keeex/merkle-rollup v1.3.1

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
9 months ago

KeeeX Merkle Rollup

This library is a little wrapper around @keeex/merkle that helps with defining types for KeeeX Merkle rollups.

Usage

You MUST load a crypto provider so either

  • @keeex/crypto-provider-browser
  • @keeex/crypto-provider-node
  • @keeex/crypto-provider-reactnative

Create a tree

import {createTree} from "@keeex/merkle-rollup/keeexmerkle.js";

const tree = await createTree(
  {
    afterbc: "<afterbc string>",
    date: "2025-01-01T00:00:00Z",
    keeexChain: {
      hash: "<hash of last known block>",
      number: "<number of last known block>",
      timestamp: "<timestamp of last known block>",
    },
  },
  ["idx1", "idx2", "idx3"],
);

Import a tree from a rollup

Note: Only the import of V2 rollup is supported as previous version didn't anchor

import {importTreeFromRollup} from "@keeex/merkle-rollup/keeexmerkle.js";

const res = await importTreeFromRollup(rollupUin8Array);
const tree = res.tree;

For typescript: this function returns a generic response in anticipation for future anchor format. Due to that, you might need to check which version of the tree you have

import {importTreeFromRollup} from "@keeex/merkle-rollup/keeexmerkle.js";
import {isImportRollupV2Result} from "@keeex/merkle-rollup/types.js";

const res = await importTreeFromRollup(rollupUin8Array);
if (isImportRollupV2Result(res)) {
  const tree = res.tree;
}

Tree manipulation

Report to @keeex/merkle lib

1.3.1

9 months ago

1.2.0

1 year ago

1.1.2

1 year ago