Git Product home page Git Product logo

media-metadata-schemas's Introduction

Media Metadata Schemas

Overview

The Zora Protocol requires media that is minted on its smart contracts contain a URI pointing to its metadata.

The Zora Protocol maintains zero opinion about the structure of that metadata. It is explicitly not enforceable at the blockchain level.

As such, this repository will serve as the source of truth of community supported metadata schemas described by JSON Schema, and will generate Types, Parsers, Generators, and Validators that will be served through the Zora Development Kit (ZDK)

Usage

Generate

Given a schema version and some nonformatted json it generates a valid, minified, alphabetized json

const metadata = {
  version: 'zora-20210101',
  name: randomName,
  description: randomDescription,
  mimeType: mimeType,
}
const generator = new Generator(metadata.version)
const minified = generator.generate(metadata)

Validate

const metadata = {
  version: 'zora-20210101',
  name: randomName,
  description: randomDescription,
  mimeType: mimeType,
}

const validator = new Validator(metadata.version)
const validated = validator.validate(metadata)

Parse

const json = `
  {
    version: 'zora-20210101',
    name: randomName,
    description: randomDescription,
    mimeType: mimeType,
  }
`

const parser = new Parser('zora-20210101')
const parsed =  parser.parse(json)

Tests

yarn test

Define a New Schema

To define a new schema version, locate the directory of your project's name in schemas/. If a directory does not already exist create one. Within the project directory create a new file with the desired calendar version as the file name example: schemas/zora/20210101.json

  • Define the schema according to JSON Schema specification.
  • Write some tests in the schema.tests.ts file.
  • run yarn codegen to generate type specifically for your new schema
  • Add your version to the supportedVersions and supportedVersionsTypeMapping in versions.ts
  • Add your version type to the exported types in types.ts

Submit a PR!

Someone on our team will review and merge.

Further Reading

media-metadata-schemas's People

Contributors

sporkspatula avatar iainnash avatar robinsloan avatar tbtstl avatar jzstern avatar tomj avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.