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

icon-crosschain-setup-utils

v1.0.2

Published

A tooling that enhances the developer experience for developers using xCall

Downloads

13

Readme

ICON FOUNDATION's XCALL Cross-Chain Setup Utility Tool for Developers

This tool helps developers to simplify redundant tasks when implementing the xcall's cross-chain protocol in their projects. This document provides you with an information of installation and API specifications.

Table of Contents

Installation

Usage in Node.js

Install icon-crosschain-setup-utils module using yarn.

yarn add icon-crosschain-setup-utils

Import icon-crosschain-setup-utils module.

const IconSetupUtils = require("icon-crosschain-setup-utils");

Usage in browser

Install icon-crosschain-setup-utils module using yarn,

yarn add icon-crosschain-setup-utils
import IconSetupUtils from "icon-crosschain-setup-utils";

Usage in react-native environment

Install icon-crosschain-setup-utils module using yarn,

yarn add icon-crosschain-setup-utils

Then, import icon-crosschain-setup-utils module.

import IconSetupUtils from "icon-crosschain-setup-utils";

API Specification - Introduction

IconSetupUtils is a root object of icon-crosschain-setup-utils, which provides functions to execute common tasks on the xcall protocol. Details of functions are as below:

IconSetupUtils

IconSetupUtils is an object which all the exported utility functions. To use a function, you can either use the destructure the function from the object by name or use the dot notaion.

Example

const IconSetupUtils = require("icon-crosschain-setup-utils");

// To use a utility function that checks if a contract is deployed using dot notation
const checkDeploymentStatus = IconSetupUtils.isDeployed(deploymentsPath);

// To use a utility function that checks if a contract is deployed using object destructuring
const { isDeployed } = IconSetupUtils;

IconSetupUtils.getIconContractByteCode

getIconContractByteCode() is a function that returns the byte code of a contract specified by the parameter jarPath. It throws an error if there is an error reading the contract.

Parameters

| Parameter | Type | Description | | --------- | -------- | --------------------- | | jarPath | string | file path of contract |

Example

const { getIconContractByteCode } = IconSetupUtils;

console.log(getIconContractByteCode(jarPath));

IconSetupUtils.isDeployed

isDeployed() is a function that checks if the contract is deployed using the specified parameter deploymentsPath. It returns true if the contract is deployed, false if otherwise. It throws an error if there is an error checking the deployments.

Parameters

| Parameter | Type | Description | | --------------- | -------- | ---------------------------- | | deploymentsPath | string | file path of deployment.json |

Example

const { isDeployed } = IconSetupUtils;

console.log(isDeployed(deploymentsPath));

IconSetupUtils.saveDeployments

saveDeployments() is a function that saves the address of the contracts deployed using the specified parameter deploymentsPath and deployments. It throws an error if there is an error saving the deployments.

Parameters

| Parameter | Type | Description | | --------------- | -------- | ------------------------------- | | deploymentsPath | string | file path of deployment.json | | deployments | object | addresses of deployed contracts |

Example

const { saveDeployments } = IconSetupUtils;

console.log(saveDeployments(deploymentsPath, deployments));

IconSetupUtils.getDeployments

getDeployments() is a function gets the deployed contracts using the specified parameter deploymentsPath. It throws an error if there is an error reading the deployments. It returns an object containing the deployed contracts.

Parameters

| Parameter | Type | Description | | --------------- | -------- | ---------------------------- | | deploymentsPath | string | file path of deployment.json |

Example

const { getDeployments } = IconSetupUtils;

console.log(getDeployments(deploymentsPath));

IconSetupUtils.getEvmContract

getEvmContract() is a function that returns the EVM contract using the specified parameter abiPath. It throws an error if there is an error reading the EVM contract. It returns an object containing the contract.

Parameters

| Parameter | Type | Description | | --------- | -------- | ---------------------------- | | abiPath | string | path to the EVM contract abi |

Example

const { getEvmContract } = IconSetupUtils;

console.log(getEvmContract(abiPath));

IconSetupUtils.getDappContract

getDappContract() is a function that returns the Dapp contract using the specified parameter solPath. It throws an error if reading the Dapp contract wasn't successful. It returns an object containing the Dapp contract.

Parameters

| Parameter | Type | Description | | --------- | -------- | ------------------------------------------- | | solPath | string | path to the compiled EVM contract json file |

Example

const { getDappContract } = IconSetupUtils;

console.log(getDappContract(solPath));

IconSetupUtils.getXcallContract

getXcallContract() is a function that returns the Xcall contract using the specified parameter xcallAbiPath. It throws an error if there is an error reading the Xcall contract. It returns an object containing the Xcall contract.

Parameters

| Parameter | Type | Description | | ------------ | -------- | -------------------------- | | xcallAbiPath | string | path to xcallAbi.json file |

Example

const { getXcallContract } = IconSetupUtils;

console.log(getXcallContract(xcallAbiPath));

IconSetupUtils.getIconDappDeploymentsParams

getIconDappDeploymentsParams() is a function that returns the params for the Icon contract using the specified parameters label, dappContract and XCALL_PRIMARY. It throws an error if there is an error getting the params.

Parameters

| Parameter | Type | Description | | ------------- | -------- | ---------------------------------- | | label | string | the label of the network | | dappContract | string | the address of the Dapp contract | | XCALL_PRIMARY | string | the address of the primary network |

Example

const { getIconDappDeploymentsParams } = IconSetupUtils;

console.log(getIconDappDeploymentsParams(label, dappContract, XCALL_PRIMARY));

IconSetupUtils.getBtpAddress

getBtpAddress() is a function that returns the BTP address using the specified parameters label and address. It throws an error if there is an error reading the BTP address.

Parameters

| Parameter | Type | Description | | --------- | -------- | --------------------------- | | label | string | the label of the network | | address | string | the address of the contract |

Example

const { getBtpAddress } = IconSetupUtils;

console.log(getBtpAddress(label, address));

IconSetupUtils.filterEventICON

filterEventICON() is a function that returns an object of the filtered event logs using the specified parameters eventlogs, sig and address. It throws an error if there is an error filtering the event logs.

Parameters

| Parameter | Type | Description | | --------- | -------- | --------------------------- | | eventlogs | object | the event logs | | sig | string | the signature of the event | | address | string | the address of the contract |

Example

const { filterEventICON } = IconSetupUtils;

console.log(filterEventICON(eventlogs, sig, address));

IconSetupUtils.filterCallMessageSentEvent

filterCallMessageSentEvent() is a function that filters the CallMessageSent event logs and returns an object of the filtered event logs using the specified parameters eventlogs, and XCALL_PRIMARY. It throws an error if there is an error filtering the event logs.

Parameters

| Parameter | Type | Description | | ------------- | -------- | ---------------------------------- | | eventlogs | object | the event logs | | XCALL_PRIMARY | string | the address of the primary network |

Example

const { filterCallMessageSentEvent } = IconSetupUtils;

console.log(filterCallMessageSentEvent(eventlogs, XCALL_PRIMARY));

IconSetupUtils.sleep

sleep() is a function that causes sleep (pause) in the program for the specified time using the parameter, ms. It returns an async function.

Parameters

| Parameter | Type | Description | | --------- | -------- | ----------------- | | ms | number | the time to sleep |

Example

const { sleep } = IconSetupUtils;

console.log(sleep(ms));

IconSetupUtils.strToHex

strToHex() is a function that converts a string to hex using the parameter, str. It returns a hex string and throws an error if there is an error converting the string.

Parameters

| Parameter | Type | Description | | --------- | -------- | --------------------- | | str | string | the string to convert |

Example

const { strToHex } = IconSetupUtils;

console.log(strToHex(str));

IconSetupUtils.strToHexPadded

strToHexPadded() is a function that converts a string to hex and pads it. It accepts the parameter, str. It returns a padded hex string and throws an error if there is an error converting the string.

Parameters

| Parameter | Type | Description | | --------- | -------- | --------------------- | | str | string | the string to convert |

Example

const { strToHexPadded } = IconSetupUtils;

console.log(strToHexPadded(str));

IconSetupUtils.isValidEVMAddress

isValidEVMAddress() is a function that checks if a contract address is valid. It accepts the parameter, address. It returns true if the address is valid or false if otherwise.

Parameters

| Parameter | Type | Description | | --------- | -------- | ----------------------- | | address | string | the address to validate |

Example

const { isValidEVMAddress } = IconSetupUtils;

console.log(isValidEVMAddress(address));

IconSetupUtils.fileExists

fileExists() is a function that checks if a file exists. It accepts the parameter, path. It returns true if the address is valid or false if otherwise. It throws an error if there is an error checking the file.

Parameters

| Parameter | Type | Description | | --------- | -------- | ----------- | | path | string | file path |

Example

const { fileExists } = IconSetupUtils;

console.log(fileExists(path));

IconSetupUtils.parseEventResponseFromTracker

parseEventResponseFromTracker() is a function that parses the event response from the network tracker. It accepts the parameter, response. It returns an array of objects containing details of the parsed event response from the tracker.

Parameters

| Parameter | Type | Description | | --------- | ---------- | --------------------------------------------------------------------- | | response | [object] | an array of objects containing details of event response from tracker |

Example

const { parseEventResponseFromTracker } = IconSetupUtils;

console.log(parseEventResponseFromTracker(response));