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

@allianceblock/abridge-sdk

v1.2.5

Published

NPM package for the AB Bridge SDK

Downloads

111

Readme

RouterSDK

constructor

Initializes the RouterSDK

constructor(signerOrProvider, optionalParams)
- signerOrProvider - JsonRpcSigner (userWallet) | JsonRpcProvider
- optionalParams:
    - routerABI: RouterContractABI 
    - erc20ABI: ERC20Permit 
    - routerAddress: address
    - validators: array
    - threshold: number
    - validatorTargetVersion: string
    - blackListedTokens: array
      i.e. [{chainId: 1, tokenAddress: '0x123qwe'}]

setParams(optionalParams)

Checks if some of the optional parameters are given and sets them, if there is a missing optional parameter a default value is used

setValidator(url)

Set validatorUrl

getRandomProperty(obj)

This method receives an object and returns a random property from it

async send(targetChainId, tokenAddress, amount, receiver, feeTokenAddress, bridgedTokenIsNativeToken)

Send transaction. The nativeToken is retrieved and based on the chainId of the nativeToken, one of the following methods in the Router contract are called:

- lock 
- burnAndTransfer
- burn

Please Note: The feeTokenAddress needs to be passed if not native fee (ALBT/WALBT) is chosen. Please Note: If we want to bridge nativeCurrency, we need to pass bridgedTokenIsNativeToken Returns unsigned lock/burnAndTransfer/burn transaction which should be signed.

- targetChainId: string - ID of the target chain  
- tokenAddress: string - Address of the deployed token
- amount: number - Amount of token to be send
- receiver - Recipient wallet address 
- feeTokenAddress - Address of the fee token
- bridgedTokenIsNativeToken - Boolean (in case that we are bridging native currency)

async sendWithPermit(targetChainId, tokenAddress, amount, receiver, v, r, s, deadline, feeTokenAddress, bridgedTokenIsNativeToken)

Send transaction with Permit enabled. The nativeToken is retrieved and based on the chainId of the nativeToken, one of the following methods in the Router contract are called: Returns unsigned lockWithPermit/burnWithPermit transaction Please Note: The feeTokenAddress needs to be passed if not native fee (ALBT/WALBT) is chosen. Please Note: If we want to bridge nativeCurrency, we need to pass bridgedTokenIsNativeToken

- targetChainId: string - ID of the target chain  
- tokenAddress: string - Address of the deployed token
- amount: number - Amount of token to be send
- receiver - Recipient wallet address 
- v: number
- r: any
- s: string
- deadline: number - Milliseconds
- feeTokenAddress - Address of the fee token
- bridgedTokenIsNativeToken - Boolean (in case that we are bridging native currency)

v, r, s represent one signature with different formatting

async claim(transfer)

Mints wrapped token or unlocks the native one Returns unsigned claim transaction

- transfer: info needed claim the transaction

async balanceOf(tokenAddress, userAddress)

Returns the amount of token with this tokenAddress of the user ({ balance, tokenDecimals })

- tokenAddress: string - Address of the deployed token
- userAddress: string - User wallet address 

async allowance(tokenAddress, userAddress)

Returns the maximum approved amount of a token Returns ({ balance, tokenDecimals })

- tokenAddress: string - Address of the deployed token
- userAddress: string - User wallet address 

async isTokenApproved(tokenAddress, userAddress, bridgedTokenIsNativeTokenOrNonDefaultFee, threshold)

Checks if the token has been approved Returns boolean

- tokenAddress: string - Address of the deployed token
- userAddress: string - User wallet address
- bridgedTokenIsNativeTokenOrNonDefaultFee - Boolean
- (optional) threshold: number

async approve(tokenAddress, amount, bridgedTokenIsNativeTokenOrNonDefaultFee)

Approve amount of token Returns unsigned transaction

- tokenAddress: string - Address of the deployed token
- amount: number - Amount of token to be approved
- bridgedTokenIsNativeTokenOrNonDefaultFee - Boolean

async approveMaxInt(tokenAddress, bridgedTokenIsNativeTokenOrNonDefaultFee)

Calls approve with ethers.constants.MaxUint256 amount Returns unsigned transaction

- tokenAddress: string - Address of the deployed token
- bridgedTokenIsNativeTokenOrNonDefaultFee - Boolean

async getServiceFee()

Returns the amount of service fee in WEI

async getExternalFee()

Returns the amount of external fee in WEI

async getClaims(userAddress, targetChainId, page)

Returns all the transactions for userAddress held in the specified chain If page is not specified, all claims are returned. The header returns two additional params:

x-total-count: Number of total results
x-total-pages: Number of all pages
- userAddress: string - User wallet address
- targetChainId: string - ID of the target chain  
- page [optional] Get the claims per page and return the requested page

async getValidatorVersion()

Returns the version of the current validator that is attached to.

async getWrappedTokens(chainId)

Returns all the wrapped tokens from the specified chainId

- chainId: string - ID of the chain  

async isClaimed(transfer)

Returns the claimed status of the transfer

- transfer - single transfer object

async getTokenName(tokenAddress)

Returns the token name by given token address

- tokenAddress: string - Address of the deployed token

async getTokenSymbol(tokenAddress)

Returns the token symbol by given token address

- tokenAddress: string - Address of the deployed token

async getTokenDecimals(tokenAddress)

Returns the token decimals by given token address

- tokenAddress: string - Address of the deployed token

async getTokenDetails(tokenAddress)

Returns the token name, symbol and decimals by given token address

- tokenAddress: string - Address of the deployed token

async getProxyFee(tokenAddress)

Returns the fee amount for the chosen token

- tokenAddress: string - Address of the token

async getWrappedTokenDetails(nativeTokenAddress, nativeChainId)

Returns the address, name, symbol and decimals of the wrapped token

- nativeTokenAddress: string - Address of the deployed native token
- nativeChainId: string - ID of the source chain

async getNativeTokenByWrappedAddress(wrappedTokenAddress)

Returns the native token

- wrappedTokenAddress: string - Address of the deployed wrapped token

async getALBTToken()

Returns the address, name, symbol and decimals of the ALBT token used for token FEE into the different networks

fixSignatures(signatures)

Formats the given signatures and returns the fixed ones

- signatures: signature[] - Signatures list of the validators