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

@equilab/api-mainnet

v0.7.3

Published

JS API for equilibrium polkadot substrate mainnet.

Downloads

16

Readme

EQUILIBRIUM API

API bindings to access Equilibruim substrate queries and transactions
NOTE Typescript bindings included

Equilibrium node list

  • Mainnet node: wss://tge.equilibrium.io:9944
  • Testnet node: wss://api.mvp.testnet.equilibrium.io (this node implements latest features)

Getting started

# Testnet version
$ npm i --save @equilab/api     # if you are using npm or  
$ yarn add @equilab/api         # for yarn package manager  

# Mainnet version
$ npm i --save @equilab/api@tge  
$ yarn add @equilab/api@tge       

Usage

API Init

Use createApi(node: string) factory from @equilab/api package

import { createApi } from "@equilab/api";  

(async () => { // async/await usage
  // Connect to TGE node with websocket
  const api = await createApi("wss://tge.equilibrium.io:9944");
  // do the interaction below
  const balance = await api.getBalance("YOUR_ADDRESS", "EQ"); // get EQ tokens
  console.log(balance.toJSON());
})();

createApi("wss://tge.equilibrium.io:9944")
  .then(api => api.getBalance("YOUR_ADDRESS", "EQ"))
  .then(balance => console.log(balance.toJSON())); // Promise usage

Types

type Currency = "Unknown" | "Usd" | "EQ" | "Eth" | "Btc" | "Eos" | "Dot";
type UserGroup = "Unknown" | "Balances" | "Bailsman";
type UnsubscribePromise = Promise<() => void /* call this func to unsubscribe */>;

interface SignedBalance {
  readonly isPositive: boolean;
  readonly asPositive: Balance;
  readonly isNegative: boolean;
  readonly asNegative: Balance;
}

interface DataPoint {
  price: u64;
  account_id: AccountId;
  block_number: BlockNumber;
  timestamp: u64;
}

interface PricePoint {
  block_number: BlockNumber;
  timestamp: u64;
  price: u64;
  data_points: Vec<DataPoint>;
}

API Methods

getAccounts(): Promise<string[]>

Fetch list of addresses in system

getBlockHash(blockNumber: number): Promise<Hash>

Fetch hash of block by its number

subscribeNewBlockHeads(blockHandler: (header: BlockHeader) => Promise<void> | void): UnsubscribePromise

Retrieves the best finalized header via subscription

setSigner(signer: Signer): void

Sets transaction signer, can be used with injected wallet

multi(calls: QueryableStorageMultiArg<"promise">[], callback: (result: Codec[]) => void | Promise<void>): UnsubscribePromise

Allows for the querying of multiple storage entries and the combination thereof into a single result. This is a very optimal way to make multiple queries since it only makes a single connection to the node and retrieves the data over one subscription. Refer to multiple queries section of polkadot.js api docs

getNonce(address: string): Promise<Index>

Fetch next available nonce for this address

API Storage queries

Storage queries are compliant with Polkadot.JS storage interfaces

getBalance(key1: AccountId, key2: Currency): Promise<SignedBalance>

Pallet storage - balances for all accounts

getRate(key: Currency): Promise<PricePoint>

Testnet only
Pallet storage for added price points

getPrices(key1: Currency, key2: PricePeriod): Promise<Vec>

Testnet only
Pallet storage - vectors of prices for every Currency for each PricePeriod

getVested(key: AccountId): Promise<BalanceOf>

Pallet storage: information about already vested balances for given account

getVesting(key: AccountId): Promise<VestingInfo>

Pallet storage: information regarding the vesting of a given account

getClaim(key: EthereumAddress): Promise<BalanceOf>

Pallet storage - stores amount to be claimed by each EthereumAddress

getClaimSigning(key: EthereumAddress): Promise<bool>

Pallet storage - the statement kind that must be signed, if any

getClaimVesting(key: EthereumAddress): Promise<(BalanceOf,BalanceOf,BlockNumber)>

Pallet storage - vesting schedule for a claim.
First balance is the total amount that should be held for vesting.
Second balance is how much should be unlocked per block.
The block number is when the vesting should start.

getTotalClaim(): Promise<BalanceOf>

Pallet storage - total Claims amount

hasGroup(key1: UserGroup, key2: AccountId): Promise<bool>

Testnet only
Pallet storage - stores user groups

aggregatesByGroup(key1: UserGroup, key2: Currency): Promise<TotalAggregates>

Testnet only
Pallet storage - stores aggregates for each user group

API Transaction methods

Transaction methods are compliant with Polkadot.JS transaction interfaces

setBailsman(isBailsman: boolean): SubmittableExtrinsic

Testnet only
Sets the bailsman group to the sender account

transfer(currency: Currency,to: AccountId,value: Balance,): SubmittableExtrinsic

Testnet only
Transfers value amount of currency from trx sender to account id to

sudo(call: Call,): SubmittableExtrinsic

Authenticates the sudo key and dispatches a function call with Root origin.

The dispatch origin for this call must be Signed.

  • O(1).
  • Limited storage reads.
  • One DB write (event).
  • Weight of derivative call execution + 10,000.

setPrice(currency: Currency,price: FixedI64,): SubmittableExtrinsic

Testnet only

vest(): SubmittableExtrinsic

Unlock any vested funds of the sender account.

The dispatch origin for this call must be Signed and the sender must have funds still
locked under this module.

Emits either VestingCompleted or VestingUpdated.

vestTo(target: LookupSource,): SubmittableExtrinsic

Unlock any vested funds of a target account.

The dispatch origin for this call must be Signed.

  • target: The account whose vested funds should be unlocked. Must have funds still
    locked under this module.

Emits either VestingCompleted or VestingUpdated.

claim(dest: AccountId,ethereum_signature: EcdsaSignature,): SubmittableExtrinsic

Make a claim to collect your currency.

The dispatch origin for this call must be None.

Unsigned Validation:
A call to claim is deemed valid if the signature provided matches
the expected signed message of:

Ethereum Signed Message:
(configured prefix string)(address)

and address matches the dest account.

Parameters:

  • dest: The destination account to payout the claim.

  • ethereum_signature: The signature of an ethereum signed message
    matching the format described above.

claimAttest(dest: AccountId,ethereum_signature: EcdsaSignature,statement: Bytes,): SubmittableExtrinsic

Make a claim to collect your currency by signing a statement.

The dispatch origin for this call must be None.

Unsigned Validation:
A call to claim_attest is deemed valid if the signature provided matches
the expected signed message of:

Ethereum Signed Message:
(configured prefix string)(address)(statement)

and address matches the dest account; the statement must match that which is
expected according to your purchase arrangement.

Parameters:

  • dest: The destination account to payout the claim.
  • ethereum_signature: The signature of an ethereum signed message
    matching the format described above.
  • statement: The identity of the statement which is being attested to in the signature.