Skip to content

NnsDao/nnsdao-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3b77123 · Aug 17, 2022

History

99 Commits
Jun 27, 2022
Jun 7, 2022
Aug 17, 2022
Jun 6, 2022
Jun 2, 2022
Jun 22, 2022
Jul 10, 2022
Jun 7, 2022
Jul 10, 2022
Jul 12, 2022
Jun 2, 2022
Jun 2, 2022
Jul 13, 2022
Jun 26, 2022
Jun 26, 2022
Jun 26, 2022
Jul 12, 2022
Jul 13, 2022

Repository files navigation

Nnsdao Kit

Install

Local dev,install latest

Tag #dev must provide

npm i https://github.com/NnsDao/nnsdao-kit.git#dev

Online prod

Install from Github

npm i https://github.com/NnsDao/nnsdao-kit.git

Install from npm

Config registry

# .npmrc
@nnsdao:registry=https://registry.npmjs.org/
npm install @nnsdao/nnsdao-kit

Install from Github packages

Config registry

# .npmrc
@nnsdao:registry=https://npm.pkg.github.com
npm install @nnsdao/nnsdao-kit

Usage

Connect Plug && Stoic

details
// React Hooks
const verifyConnection = async () => {
  const connected = await window.ic.plug.isConnected();
  if (!connected) await window.ic.plug.requestConnect({ whitelist, host });
};

useEffect(async () => {
verifyConnection();
}, []);

Import Actor,Actor Instance Type

import { idlFactory } from '@nnsdao/nnsdao-kit/market/index';
import type { _SERVICE } from '@nnsdao/nnsdao-kit/market/types';

Config Typescript Path Alias

Config Path alias at tsconfig.json

{
  "compilerOptions": {
    // xxx
    "paths": {
      "@nnsdao/nnsdao-kit/*": ["./node_modules/@nnsdao/nnsdao-kit/src/*"]
      // WARNING
      // if you already have @** config ,then @nnsdao must place before @/*
      // such as
      // "@nnsdao/nnsdao-kit/*": ["./node_modules/@nnsdao/nnsdao-kit/src/*"],
      // "@/*": ["./src/*"],
    }
  }
}

TODO

  1. auto download candid ,binding to another language,update local file