npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ever-lmdb-sdk

v1.1.0-alpha.5

Published

Learn how to get ever-lmdb-sdk set up in your project in under thirty minutes. {% .lead %}

Downloads

35

Readme

Everlmdb - Secure Evernode Contract DB.

Learn how to get ever-lmdb-sdk set up in your project in under thirty minutes. {% .lead %}


Quick start

Ever-lmdb-sdk is a powerful library that allows secure data storage and retrieval in Evernode smart contracts using LMDB. In this guide, we will walk you through the steps required to set up Ever-lmdb-sdk in your project.

Installing dependencies

To install Ever-lmdb-sdk, you'll need to have Node.js and Yarn installed on your system. Once you have these dependencies installed, you can install Ever-lmdb-sdk in your Evernode contract and your Evernode client using the following command:

yarn add ever-lmdb-sdk

Configuring the Contract

To configure your contract to work with Ever-lmdb-sdk, you'll need to import the ApiService from the library and create an instance of it inside your contract function.

const HotPocket = require("hotpocket-nodejs-contract");
const { ApiService } = require("ever-lmdb-sdk"); // import ApiService

const contract = async (ctx) => {
  const isReadOnly = ctx.readonly;
  const api = new ApiService(); // init the ApiService
  for (const user of ctx.users.list()) {
    for (const input of user.inputs) {
      const buf = await ctx.users.read(input);
      const request = JSON.parse(buf);
      await api.handleRequest(user, request, isReadOnly); // add the api handler
    }
  }
};
const hpc = new HotPocket.Contract();
hpc.init(contract);

Configuring the Client

To interact with the Ever-lmdb-sdk from your JavaScript client application, you'll first need to import and initialize the necessary components from the library. Here's an example of how this might look:

const HotPocket = require("hotpocket-js-client");
const {
  Sdk,
  EverKeyPair,
  MessageModel,
  decodeModel,
  uint8ArrayToHex
} = require('ever-lmdb-sdk')
const { deriveAddress } = require('ripple-keypairs');

var client = new ClientApp();
  if (await client.init()) {
    
    const everKp = new EverKeyPair(
      uint8ArrayToHex(client.userKeyPair.publicKey), 
      uint8ArrayToHex(client.userKeyPair.privateKey).slice(0, 66)
    )
    const sdk = new Sdk(everKp, client)
    // ...
  }
}

Your first model

Before you can store data using Ever-lmdb-sdk, you'll need to create a custom data model that represents the object you want to store.

The CustomModel is an example of a custom model derived from the BaseModel. This model has two fields: name and age. Other custom models can define their own fields and metadata.

export class CustomModel extends BaseModel {
  name: VarString
  age: UInt64

  constructor(name: string, age: number) {
    super()
    this.name = name
    this.age = age
  }

  getMetadata(): Metadata {
    return [
      { field: 'name', type: 'varString', maxStringLength: 32 },
      { field: 'age', type: 'uint64' }
    ]
  }
}

The getMetadata() method returns an array of metadata elements, each of which defines a field in the model. Each metadata element specifies the name of the field and its type.

Binary models allow efficient serialization and deserialization of complex data structures in binary hex.

Storing Data

Once you have defined your custom data model, you can use the Ever-lmdb-sdk to store it in an Evernode smart contract. Here's an example of how this might look:

// Construct a reference to the collection and document you want 
// to store the data in
const collectionRef = sdk.collection('people');
const documentRef = collectionRef.document('123').convert(CustomModel);

// Create a new instance of your custom model
const person = new CustomModel('Alice Smith', 30);

// Use the `set` function to store the data
await documentRef.set(person);

// You can also retrieve the data by calling `get` on the reference
const response = await documentRef.get();
const decoded = decodeModel(response.snapshot.binary, CustomModel)
console.log(decoded.name); // Output: "Alice Smith"

Retrieving Data

To retrieve data stored in an Evernode smart contract using Ever-lmdb-sdk, you can use the get function on the appropriate reference. Here's an example:

// Construct a reference to the collection and document that 
// contains the data
const collectionRef = sdk.collection('people');
const documentRef = collectionRef.document('123');

// Use the `get` function to retrieve the data
const response = await documentRef.get();

// Decode the binary data using your custom model
const person = decodeModel(response.snapshot.binary, CustomModel);

// Use the data as needed
console.log(person.name); // Output: "Alice Smith"
console.log(person.age); // Output: 30

Getting help

If you have any questions or issues related to this project, please don't hesitate to ask for help. There are several ways to get support:

Submit an issue

If you have encountered a problem or have a question, the best way to get help is by submitting an issue to the project's GitHub repository. To do so, please follow these steps:

  1. Navigate to the Issues section of the repository.
  2. Click on the "New issue" button.
  3. Fill out the issue template with relevant information, including a clear and concise description of the problem or question.
  4. Click "Submit new issue".

A member of the project team will review your issue and provide assistance as soon as possible. Please be respectful and patient as we work to address your concerns.

Get help from the community

If you would like to receive support from the larger community, you can post your question on a relevant forum or message board. Some popular options include:

When posting your question, please provide as much detail as possible, including any error messages or logs that may help others troubleshoot the issue.

Contact the project maintainers

If you have a question or concern that you would like to address directly with the project maintainers, you can contact us via email at [email protected]. We will do our best to respond in a timely manner, but please understand that we may not be able to provide immediate assistance.

Thank you for using our project, and we hope that this information helps you get the support you need.

Google Cloud Logging

  1. Create Google Project

  2. Create Service Account

  • Add Logs Writer Permission
  1. Save JSON credentials.json into project root

LoggerEmitter uses the root directory and looks for credentials.json