Giter Club home page Giter Club logo

metadata's Introduction

โš ๏ธ WARNING
YOU SHOULD STOP USING THIS REPOSITORY. The package has been moved to the monorepo, and the packages are being automatically published to npmjs.

Superfluid Metadata

Contains metadata around the Superfluid framework.
The goal of this repository is to make it as easy as possible to reference contained metadata from various contexts (e.g. backend script or browser page) and independently of the tech stack used there. Convenience wrappers are provided for JS/TS, other environments can fall back to parsing plain JSON files.

Making Changes

When adding new changes (new addresses), add it to networks.json and make sure to run ./build.sh before pushing so that both the list files in main and module are updated. If you are adding a new property, please also modify the .d.ts files in the module folder accordingly as well.

Networks

List of EVM networks with the Superfluid protocol deployed. Example uses

Use in an HTML page

This example uses the jsDelivr CDN in order to always reference the latest version of the networks list.
You can of course also self-host a copy or use another service, anything signalling the right mime type and with a compatible CORS policy should work.

<script type="module">
  import networks from "https://cdn.jsdelivr.net/gh/superfluid-finance/metadata/module/networks/index.js";
  // example use
  const network = networks.getNetworkByChainId(networkId);

Use in a nodejs project using ES modules

Nodejs has stable support for ES modules since version 14.
In order to switch a project to using ES modules by default, the package.json needs to contain a field

"type": "module"

(for other ways to enable ES modules, see the nodejs docs)

If that's the case, you can use the networks metadata like this:

import sfMeta from "@superfluid-finance/metadata";

// example use
const network = sfMeta.getNetworkByName("eth-goerli");

Use in a nodejs project using CommonJS (legacy)

Nodejs projects still using CommonJS (if you're unsure, check the docs), can use ES modules using the syntax of dynamic imports:

import("@superfluid-finance/metadata").then(module => {
  const sfMeta = module;

  // example use
  const network = sfMeta.getNetworkByName("eth-goerli");
}

Alternative using await:

const sfMetaPromise = import("@superfluid-finance/metadata");
(async () => {
  const sfMeta = (await sfMetaPromise).default;

  // example use
  const network = sfMeta.getNetworkByName("eth-goerli");
}

Use in a node REPL:

The repl uses CommonJS too, thus usage looks like this:

let sfMeta
import("@superfluid-finance/metadata").then(module => sfMeta = module)
> sfMeta.networks.length
12
> sfMeta.testnets.length
7
> sfMeta.mainnets.length
5
> sfMeta.mainnets.filter(n => n.nativeTokenSymbol === "ETH").map(n => n.name)
[
  'eth-goerli',
  'optimism-goerli',
  'arbitrum-goerli',
  'optimism-mainnet',
  'arbitrum-one'
]
> m.getNetworkByChainId(10)
{
  name: 'optimism-mainnet',
  isTestnet: false,
  networkId: 10,
  chainId: 10,
  shortName: 'optimism',
  nativeTokenSymbol: 'ETH',
  contractsV1: {
    resolver: '0x743B5f46BC86caF41bE4956d9275721E0531B186',
    host: '0x567c4B141ED61923967cA25Ef4906C8781069a10',
    governance: '0x0170FFCC75d178d426EBad5b1a31451d00Ddbd0D',
    cfaV1: '0x204C6f131bb7F258b2Ea1593f5309911d8E458eD',
    idaV1: '0xc4ce5118C3B20950ee288f086cb7FC166d222D4c',
    superTokenFactory: '0x8276469A443D5C6B7146BED45e2abCaD3B6adad9',
    superfluidLoader: '0x8E310ce29Ab7Fa2878944A65BB0eaF97B1853d40',
    toga: '0xA3c8502187fD7a7118eAD59dc811281448946C8f'
  },
  startBlockV1: 4300000,
  logsQueryRange: 50000,
  explorer: 'https://optimistic.etherscan.io',
  subgraphV1: {
    name: 'protocol-v1-optimism-mainnet',
    hostedEndpoint: 'https://api.thegraph.com/subgraphs/name/superfluid-finance/protocol-v1-optimism-mainnet'
  }
}

Use in a bash script

With the help of jq, it's also possible to parse metadata from within a bash script. Here's an example:

#!/bin/bash

# exit on error or undefined var
set -eu

metadata=$(curl -f -s "https://raw.githubusercontent.com/superfluid-finance/metadata/master/networks.json")
testnets=$(echo "$metadata" | jq -r '.[] | select(.isTestnet == false).name')

for network in $testnets; do
        host=$(echo "$metadata" | jq -r '.[] | select(.name == "'$network'").contractsV1.host')
        native_token_wrapper=$(echo "$metadata" | jq -r '.[] | select(.name == "'$network'").nativeTokenWrapper')

        echo "$network | host address: $host, native token wrapper address: $native_token_wrapper"
done

metadata's People

Contributors

0xdavinchee avatar d10r avatar hellwolf avatar ngmachado avatar tokdaniel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

metadata's Issues

Deprecate metadata repository

metadata was moved to the protocol-monorepo.
The dedicated repository shall be archived, with a prominent note about the moving added to the README.
Consider adding a dependency which makes future install attempts fail with a useful error message.

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.