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

@likecoin/iscn-js

v0.6.10

Published

> Query and submit ISCN via javascript sdk

Downloads

158

Readme

ISCN-js

Query and submit ISCN via javascript sdk

NPM Version

Install

npm i -S cosmjs-types @cosmjs/stargate @likecoin/iscn-js

Usage

Please refer to *.spec.ts test cases for more example

Query

import { ISCNQueryClient } from '@likecoin/iscn-js';
const client = new ISCNQueryClient();

// optional custom rpc
// await client.connect('https://mainnet-node.like.co/rpc/')

// Query ISCN by ID
const res = await client.queryRecordsById('iscn://likecoin-chain/dLbKMa8EVO9RF4UmoWKk2ocUq7IsxMcnQL1_Ps5Vg80/1');

// Query ISCN by owner
const res = await client.queryRecordsByOwner('cosmos1sf2sc6t37xhd3m0dcaq6h5dz22mtru2ugdwp0v');

Signing

import { ISCNQueryClient, ISCNSigningClient } from '@likecoin/iscn-js';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { SigningStargateClient, StargateClient } from '@cosmjs/stargate';
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';

(async() => {
  // Use mnemonic
  const mnemonic = 'surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put';
  const signer = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic);
  const [wallet] = await signer.getAccounts();

  /* For Keplr, use suggestChain API and config found in
    https://github.com/likecoin/mainnet/ or
    https://github.com/likecoin/testnets/ */

  // await window.keplr.experimentalSuggestChain(config);
  // await window.keplr.enable('likecoin-mainnet-2');
  // const signer = window.getOfflineSigner('likecoin-mainnet-2');
  // const [wallet] = await signer.getAccounts();

  const client = new ISCNQueryClient();
  const signingClient = new ISCNSigningClient();
  await signingClient.connectWithSigner('https://mainnet-node.like.co/rpc/', signer);

  const ISCNPayload = {
    'contentFingerprints': [
      'hash://sha256/9564b85669d5e96ac969dd0161b8475bbced9e5999c6ec598da718a3045d6f2e'
    ],
    'stakeholders': [
      {
        'entity': {
          '@id': 'did:cosmos:5sy29r37gfxvxz21rh4r0ktpuc46pzjrmz29g45',
          'name': 'Chung Wu'
        },
        'rewardProportion': 95,
        'contributionType': 'http://schema.org/author'
      }
    ],
    'type': 'Article',
    'name': '使用矩陣計算遞歸關係式',
    'usageInfo': 'https://creativecommons.org/licenses/by/4.0',
    'keywords': ['matrix', 'recursion'],
  }

  const res = await signingClient.createISCNRecord(wallet.address, ISCNPayload);

  const iscnID = await client.queryISCNIdsByTx(res.transactionHash);


  // Or sign only mode

  const signedTxRaw = await signingClient.createISCNRecord(wallet.address, ISCNPayload, { broadcast: false });
  const txBytes = TxRaw.encode(signedTxRaw).finish();
  const res2 = await signingClient.getSigningStargateClient().broadcastTx(txBytes);
})()