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

@jmgayosso/afloat-client

v0.0.18

Published

This client api is used to provide methods to interact with gatedMarketplace, uniques and fruniques pallets and go through Afloat specific flow.

Downloads

3

Readme

Afloat Client Api

This client api is used to provide methods to interact with gatedMarketplace, uniques and fruniques pallets and go through Afloat specific flow.

To install the afloat-client-api, run the following command:

npm i --save @jmgayosso/afloat-client or yarn add @jmgayosso/afloat-client

To connect to 'hashed chain' through Hashed Confidential Docs we must import HCD package hashed-confidential-docs-client that handles the connection and provides methods to sign tx, login, requestUsers from polkadotJS and sign and verify messages.

Setup

To install hcd run the following command.

npm i --save @smontero/hashed-confidential-docs or yarn add @smontero/hashed-confidential-docs

The following is an example of basic config to create HCD instance, please see HCD documentation to more configs.

import {
  HashedConfidentialDocs,
  Polkadot,
  LocalAccountFaucet,
  BalancesApi
} from '@smontero/hashed-confidential-docs'
import { Keyring } from '@polkadot/api'

const _polkadot = new Polkadot({ wss: chainURI, appName })
await _polkadot.connect()

const keyring = new Keyring()
const faucet = new LocalAccountFaucet({
  balancesApi: new BalancesApi(this._polkadot._api, () => {}),
  signer: keyring.addFromUri(this._signer, {}, 'sr25519'),
  amount: 1000000000
})
const _hcd = new HashedConfidentialDocs({
  ipfsURL: _ipfsURL,
  polkadot: _polkadot,
  faucet,
  ipfsAuthHeader: _ipfsAuthHeader
})

HCD is requeried to create an instance of AfloatApi, this class provides the following methods: createAssets, getAllAssetsInCollection, getAssets, getFromIpfs.

import { AfloatApi } from '@jmgayosso/afloat-client'

const ipfsURL = `Basic ${Buffer.from(`${process.env.IPFS_PROJECT_ID}:${process.env.IPFS_PROJECT_SECRET}`).toString('base64')}`

const afloatApi = new AfloatApi({
  ipfsURL: process.env.IPFS_URL,
  ipfsAuthHeader,
  polkadot: _polkadot
})

Once an instance of AfloatApi is created, the following methods can be accessed.

Methods

  • createAsset: Create a new frunique/NFT asset.

    Params

    • @param {u64} collectionId Collection ID used in the uniques pallet; represents a group of Uniques
    • @param {u64} assetId [optional] Asset ID used in the uniques pallet; represents a single asset. If not provided, the next available unique ID will be automatically selected.
    • @param {Object} uniquesPublicAttributes mapping of key/value pairs to be set in the public metadata in the uniques pallet
    • @param {Object} saveToIPFS payload and/or files to be saved to IPFS, and the resulting CIDs are added to the uniquesPublicMetadata, anchoring the data to the NFT.
    • @param {Object} cidFromHCD cidFromHCD cid got from the ConfidentialDocs API
    • @param {Function} subTrigger Function to trigger when subscrsption detect changes

    Example

    await afloatApi.createAsset({
      "collectionId": undefined, 
      "assetId": 0,
      "uniquesPublicAttributes": {
          "Lorem ": "Plaintext"
      },
      "saveToIPFS": {
          "data": {
              "label2": "ipfs plain"
          },
          "files": {
              "label 3": "cid"
          }
      },
      "cidFromHCD": {
          "data": {
              "label4": "cid saved on HCD"
           },
          "files": {
              "label5": "cid saved on HCD"
           }
      },
      admin
    })

    Notes

    To save a file in HCD you must go from HCD Documentation

  • getAllAssetsInCollection: Get all assets in collection.

    Params

    • @param {u64} collectionId Collection ID used in the uniques pallet; represents a group of Uniques
    • @param {u64} startKey Asset ID, index, or key to start the query
    • @param {int} pageSize maximum number of assets to retrieve per request
    • @param {Function} subTrigger Function to trigger when subscription detect changes

    Example

    await afloatApi.getAllAssetsInCollection({
      collectionId,
      startKey,
      pageSize
    })
  • getAsset: Get a specific asset by collectionId.

    Params

    • @param {String} [collectionId] Collection Id
    • @param {String} [instanceId] Instance Id

    Example

    await afloatApi.getAsset({ collectionId, instanceId })
  • getFromIPFS: Get Text or File from IPFS.

    Params

    • @param {String} [cid] Unique IPFS identifier

    Example

    await afloatApi.getFromIPFS(cid)