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

@multiplechain/types

v0.1.55

Published

It is a suite of types defined to provide cross-network standardization in the MultipleChain project.

Downloads

1,237

Readme

MultipleChain Types

It is a suite of types defined to provide cross-network standardization in the MultipleChain project.

Installation

npm install @multiplechain/types

Usage

You can import all of the types at once:

import type * as types from '@multiplechain/types';

Or you import the types one by one:

import type {
    // Providers
    ProviderInterface,
    NetworkConfigInterface,

    // Models
    TransactionInterface,
    ContractTransactionInterface,
    AssetTransactionInterface,
    CoinTransactionInterface,
    TokenTransactionInterface,
    NftTransactionInterface,

    // Assets
    AssetInterface,
    ContractInterface,
    CoinInterface,
    TokenInterface,
    NftInterface,

    // Enums
    AssetDirectionEnum,
    TransactionTypeEnum,
    TransactionStatusEnum,

    // Transaction Listeners
    TransactionListenerInterface,
    DynamicTransactionType

    // Transaction Signer
    TransactionSignerInterface
} from '@multiplechain/types';

Types

Provider

ProviderInterface

Provider is the main class that will be used for every network (EVM, Solana, Tron, etc.)

ProviderInterface is the interface of Provider class.

NetworkConfigInterface

update() and constructor() methods of Provider class takes a config parameter. Interface of this config parameter is defined as NetworkConfigInterface.

Models

There are 6 types of transaction models:

TransactionInterface

TransactionInterface is the most comprehensive interface compared to others. Every other interface extends TransactionInterface.

This interface has ID management of transactions since each transaction and each transaction type has its own unique ID, and also has helper functions that is being used in every other transaction types such as getBlockNumber and getStatus

ContractTransactionInterface

Inherits TransactionInterface. Used for smart contracts transactions. Token and NFT transactions inherits ContractTransactionInterface.

On top of TransactionInterface, lets developers to grab smart contract address used in transaction.

getAddress: () => string // Smart contract address of the transaction

AssetTransactionInterface

Inherits TransactionInterface. Used for asset transactions.

CoinTransactionInterface

Used for transactions on blockchain done with native currency of the network. In other words, supports transaction data done on Layer-1 networks (Tron, Ethereum, Solana, etc.)

TokenTransactionInterface

Used for token transactions. Adds a support for verification of approvement on top of AssetTransactionInterface.

NftTransactionInterface

Used for NFT transactions. NFT transactions has a pointer property to NFT ID, NftTransactionInterface adds a helper method named getNftId() to grab that ID.

Also just like TokenTransactionInterface there is an approvement verification method in NftTransactionInterface too.

Assets

There are 5 types of asset interfaces

AssetInterface

AssetInterface is the most comprehensive interface compared to others. Every other interface except ContractInterface extends TransactionInterface.

It has helper methods like starting a transfer. transfer() method is available for every asset type (COINs, TOKENs, NFTs).

ContractInterface

ContractInterface is inherited by TokenInterface and NftInterface. It has helper methods like grabbing contract addresses.

CoinInterface

Used for coin assets. Currently adds a helper method to get decimal value of the asset on top of AssetInterface.

TokenInterface

Contains helper methods that can be used for grabbing token data like getTotalSupply().

NftInterface

Contains helper methods for NFT type of assets. Unlike the other asset interfaces, NftInterface overrides the transfer() method since it needs an nftId parameter instead of a amount parameter.

Enums

AssetDirectionEnum

Asset transactions (COIN, TOKEN, NFT) has two directions

enum AssetDirectionEnum {
    INCOMING,
    OUTGOING
}

TransactionTypeEnum

There are six types of transactions at the moment. COIN, TOKEN, and NFT transactions are called ASSET transactions

enum TransactionTypeEnum {
    GENERAL,
    CONTRACT,
    ASSET,
    COIN,
    TOKEN,
    NFT
}

TransactionStatusEnum

There are 3 available transaction statuses:

  • FAILED: When a transaction is failed
  • PENDING: When a transaction has not been concluded
  • CONFIRMED: When a transaction is confirmed
enum TransactionStatusEnum {
    FAILED,
    PENDING,
    CONFIRMED
}

Transaction Listener

TransactionListenerInterface

In order to listen to transactions whether they are PENDING or FAILED for instance, there needs to be a class providing methods for transaction listening.

TransactionListenerInterface is the interface of the TransactionListener class which supports gathering transaction status, stopping the transaction, and callbacks after a transaction status change.

DynamicTransactionType

There are different types of transactions, in order to listen correct transaction, correct transaction type needs to be provided. DynamicTransactionType is a helper interface that connects transaction types to their corresponding transaction interfaces

export type DynamicTransactionType<T extends TransactionTypeEnum> =
    T extends TransactionTypeEnum.GENERAL
        ? TransactionInterface
        : T extends TransactionTypeEnum.CONTRACT
          ? ContractTransactionInterface
          : T extends TransactionTypeEnum.COIN
            ? CoinTransactionInterface
            : T extends TransactionTypeEnum.TOKEN
              ? TokenTransactionInterface
              : T extends TransactionTypeEnum.NFT
                ? NftTransactionInterface
                : never

DynamicTransactionListenerFilterType

filter is an object that has values depending on transaction listener type. It has properties such as sender, receiver, etc.

Just like DynamicTransactionType, DynamicTransactionListenerFilterType is a helper interface to get correct filter type.

Transaction Signer

TransactionSignerInterface

Provides a class to sign and send transactions. TransactionSignerInterface has all of the methods to audit a signature.

Methods of TransactionSignerInterface are as follows:

Signs the transaction:

sign: (privateKey: string) => TransactionSignerInterface

Sends the signed transaction:

send: () => Promise<TransactionInterface | Error>

Returns unsigned transaction data

getRawData: () => any

Returns signed transaction data

getSignedData: () => any