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

oip-protobufjs

v1.6.16

Published

This library provides builder functions to create OIP v0.5 records by serializing data into chain-ready protobuf data

Downloads

25

Readme

oip-protobufjs

This library provides builder functions to create OIP v0.5 records by serializing data into chain-ready protobuf data

Overview

OIP v0.5 creates records through Record Templates. A Record Template defines the schema for a given record (i.e: I can create a Record Template called Audio Track with the following fields: title, artist, genre and then create an Audio Track record using the created template by filling out the given fields). We use protobuf.js to create these templates by following the proto3 message standard.

Creating A Record Template

As per the example above we'll create a Record Template called Audio Track. A template consists of three fields: title, description, and fileDescriptor. The fileDescriptor is a description of a proto file and will be used to define the schema used for the template, so we'll start with that.

Building a Record Template

// first, define the schema
const schema = [
  { name: 'title', type: 'string' },
  { name: 'artist', type: 'string' },
  { name: 'genre', type: 'string' }
]

// second, build the fileDescriptor
const fileDescriptor = buildDescriptor(schema)

// third, define the template name and description of the record template
const templateName = 'Audio Track'
const description = 'Basic audio track details'

// fourth, build the record template
const { templateBuffer, template64, templateMessage } = buildRecordTemplate({
  friendlyName: templateName,
  description,
  DescriptorSetProto: fileDescriptor
})

// buildRecordTemplate returns the template in buffer format, base64, and as a protobuf.js message
Creating a Record

As per the record.proto schema found in src/messages/oipProto, there are four fields we can include: tags, payment, details, and permissions. We only need to pass details of type OipDetails to create a record. In the same record.proto file we see that OipDetails is defined as: repeated google.protobuf.Any details = 1; which means we can pass an array containing values of any type to it. We use this field to pass in the values of the record as defined by the record template schema. It is necessary to have a repeated ANY field so that a record can contain multiple data from multiple templates. Mixing and matching templates is the core power of oip v0.5.

After you create a FileDescriptor, you use it to create the OipDetails; doing this is akin to filling out the template with actual data.

Important!! You need to first publish the Record Template before you can use it to create a record so that you can get its template name which contains part of the txid