0.0.30 • Published 6 months ago

@entangle-labs/uip-sdk v0.0.30

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

UIP SDK Documentation

Utilities for UIP.

Table of Contents

Installation

Using npm:

npm install @entangle-labs/uip-sdk

API

Currently SDK include Fees module for fees calculation and network activity checks. Also it is possible to calculate message hash from source network transaction

EVM

Main method for estimation:

public async estimateExecutionWithGas({
  srcChainId: bigint,
  destChainId: bigint,
  gasLimit: bigint
})

Solana method for estimation:

public async estimateExecutionSolana(
  input: SimulateExecuteLiteInput
)

export type SimulateExecuteLiteInput = {
  connection: Connection;
  payload: Buffer;
  srcChain: bigint;
  senderAddr: Buffer;
  destChain: bigint;
  destAddr: PublicKey;
  accounts: AccountMeta[];
  payerOverride?: PublicKey;
  computeUnits?: number;
};

Examples

Mode

SDK is made for both testnet and mainnet usage. Default mode set is mainnet.

If you want to switch to testnet mode, use:

const provider = new UIPProvider("https://json-rpc.entangle.fi")
const feesEvm = new FeesEvm(provider)
feesEvm.mode = "testnet"
feesEvm.EIBName = "teib"

For switch to mainnet:

const provider = new UIPProvider("https://evm-testnet.entangle.fi")
const feesEvm = new FeesEvm(provider)
feesEvm.mode = "mainnet"
feesEvm.EIBName = "eib"

Network config

SDK use public RPC providers by default. If you want to use your own personal config, redefine config with:

const feesSdkConfigured = new FeesEvm(provider, config as Chain[])

Where config is array of Chain objects:

{
  id: BigInt(11155111),
  name: "ethereum_sepolia",
  hexId: "0xAA36A7",
  type: "evm",
  mode: "testnet",
  rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
  nativeCurrency: {
    name: "Sepolia Ether",
    symbol: "ETH",
    decimals: 18,
  },
  blockExplorerUrl: "https://sepolia.etherscan.io",
}

EVM usage

import { FeesEvm, FeesSolana, UIPProvider } from "@entangle-labs/uip-sdk"

const provider = new UIPProvider("https://json-rpc.entangle.fi")
const feesEvm = new FeesEvm(provider)

async function getDstChainFee() {
  const fee = await feesSdk.estimateExecutionWithGas({
    srcChainId: 11155111n,
    destChainId: 33133n,
    gasLimit: 200000n,
  });
  console.log("Estimated price:", fee)
}
  import { generateReceiptHash } from "@entangle-labs/uip-sdk"
  // ... get receipt

  const msgHash = await generateReceiptHash(BigInt(33133), receipt)

Solana usage

import { FeesSolana } from "@entangle-labs/uip-sdk"

const feesSolana = new FeesSolana()

fee = await feesSolana.estimateExecutionSolana({
  connection: new Connection(srcChain.rpcUrl),
  payload: Buffer.from(payloadOriginal),
  srcChain: BigInt(srcChainId),
  senderAddr: Buffer.from(senderContractAddr),
  destChain: BigInt(dstChainId),
  destAddr: new PublicKey(destAddr),
  accounts: [
    // Provide the accounts required for execution on the destination address
  ],
})
0.0.30

6 months ago

0.0.29

6 months ago

0.0.28

8 months ago

0.0.27

8 months ago

0.0.26

8 months ago

0.0.25

8 months ago

0.0.24

8 months ago

0.0.23

8 months ago

0.0.22

8 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago