0.1.0-next.32 • Published 3 years ago

ethpm v0.1.0-next.32

Weekly downloads
960
License
MIT
Repository
-
Last release
3 years ago

ethpm.js

API Documentation Build Status

Work in progress library for interacting with EthPM packages in Javascript and TypeScript.

Check out a short guided tutorial here.

Usage Example

const ethpm: Session = await EthPM.configure<HasManifests>({
  manifests: "ethpm/manifests/v3",
}).connect();

const pkg = await ethpm.manifests.read(examples["wallet-with-send"]);

Available APIs

There are multiple APIs that you can enable on your ethpm instance. Each api can be enabled by passing it's corresponding string into your ethpm object's configuration.

ethpm/manifests/v3

Description: Enables reading & writing of V3 manifests to/from JSON and Package instances.

Configuration:

const ethpm = await EthPM.configure({
  manifests: "ethpm/manifests/v3",
}).connect();

Usage:

// to generate a `Package` instance from a manifest JSON string
const package = await v3.read(manifestJson);

// to generate a manifest JSON string from a `Package` instance
const manifestJson = await v3.write(package)

ethpm/installer/truffle

Description: Writes ethpm package assets to disk, according to the written specification.

Configuration:

const ethpm = await EthPM.configure({
  installer: "ethpm/installer/truffle",
  storage: "ethpm/storage/ipfs",
}).connect({
  workingDirectory: '/path/to/working/directory',
  ipfs: {
    host: 'ipfs.infura.io',
	port: '5001',
	protocol: 'https'
  }
});

Usage:

  • Currently only IPFS uris are supported.
// to install the target package in the working directory
var manifestUri = "ipfs://Qm..."
var registryAddress = "0x123abc..."
await ethpm.install(manifestUri, registryAddress)

// to install the target package under an alias in the working directory
var alias = "alternate-name"
await ethpm.install(manifestUri, registryAddress, alias)

ethpm/storage/ipfs

Description: Reads & writes files from IPFS.

Configuration:

const ethpm = await EthPM.configure({
  storage: "ethpm/storage/ipfs",
}).connect({
  ipfs: {
    host: 'ipfs.infura.io',
	port: '5001',
	protocol: 'https'
  }
});

Usage:

const content = "wordswordswordswordspunchline"

const uri = await ethpm.storage.write(content)

const readContent = await ethpm.storage.read(uri)

const predictedUri = await ethpm.storage.predictUri(content)

const hash = await ethpm.storage.hash(content)

ethpm/registries/web3

Description: Publishes packages to on-chain package registries, and fetches release data from these registries.

Configuration:

const ethpm = await EthPM.configure({
  registries: "ethpm/registries/web3",
}).connect({
  provider: web3,
  registryAddress: '0x123abc...'
});

Usage:

// list all packages
const packages = await ethpm.registries.packages()

// list all release data for a particular package's releases
const ownedReleases = await ethpm.registries.package('owned').releases()

// get manifest uri for a specific release
const manifestUri = await ethpm.registries.package('owned').release('1.0.0')

// cut a release to the connected registry
await ethpm.registries.publish('owned', '1.0.0', 'ipfs://Qm...')

ethpm URI util

import { EthpmURI } from 'ethpm/utils/uri';

const rawUri = 'ethpm://snakecharmers.eth/owned@1.0.0'
const ethpmUri = new EthpmURI(rawUri)

ethpmUri.raw
> 'ethpm://snakecharmers.eth/owned@1.0.0'

ethpmUri.scheme
> 'ethpm'

ethpmUri.address
> 'snakecharmers.eth'

// defaults to 1 if no chain id included in rawUri
ethpmUri.chainId
> 1

ethpmUri.packageName
> 'owned'

ethpmUri.version
> '1.0.0'

ethpmUri.namespacedAsset
> ''
0.1.0-next.32

3 years ago

0.1.0-next.31

3 years ago

0.1.0-next.30

4 years ago

0.1.0-next.29

4 years ago

0.1.0-next.28

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.1.0-next.27

4 years ago

0.0.17

4 years ago

0.1.0-next.26

4 years ago

0.1.0-next.25

4 years ago

0.1.0-next.24

4 years ago

0.1.0-next.23

4 years ago

0.1.0-next.22

4 years ago

0.1.0-next.21

4 years ago

0.1.0-next.20

4 years ago

0.1.0-next.19

4 years ago

0.1.0-next.18

4 years ago

0.1.0-next.17

4 years ago

0.1.0-next.16

4 years ago

0.1.0-next.15

4 years ago

0.1.0-next.14

4 years ago

0.1.0-next.13

4 years ago

0.1.0-next.12

4 years ago

0.1.0-next.11

4 years ago

0.1.0-next.10

5 years ago

0.1.0-next.9

6 years ago

0.1.0-next.8

6 years ago

0.1.0-next.7

6 years ago

0.1.0-next.6

6 years ago

0.1.0-next.5

6 years ago

0.1.0-next.4

6 years ago

0.1.0-next.3

6 years ago

0.1.0-next.2

6 years ago

0.1.0-next.1

6 years ago

0.1.0-next.0

6 years ago

0.0.16

6 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago