1.0.4 • Published 3 years ago

abridge-sdk v1.0.4

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

RouterSDK

constructor

Initializes the RouterSDK

constructor(signerOrProvider, optionalParams)
- signerOrProvider - JsonRpcSigner (userWallet) | JsonRpcProvider
- optionalParams:
    - routerABI: RouterContractABI 
    - erc20ABI: ERC20Permit 
    - routerAddress: address
    - validators: array
    - threshold: number 

setParams(optionalParams)

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

getRandomProperty(obj)

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

async send(targetChainId, tokenAddress, amount, receiver)

Locks the given amount of tokens or burns them Returns unsigned lock/burn transaction

- targetChainId: string - ID of the target chain  
- tokenAddress: string - Address of the deployed token
- amount: number - Amount of tokend to be send
- receiver - Recepient wallet addres 

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

Gets the hative token to the tokenAddress, then locks the amount and burns it Returns unsigned lockWithPermit/burnWithPermit transaction

- targetChainId: string - ID of the target chain  
- tokenAddress: string - Address of the deployed token
- amount: number - Amount of tokend to be send
- receiver - Recepient wallet addres 
- v: number
- r: any
- s: string
- deadline: number - Miliseconds

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 tokend with this tokenAddress of the user ({ balance, tokenDecimals })

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

async allowance(tokenAddress, userAddress)

Returns the maximum amount that can be burn Returns { unsigned transaction, decimals of the token }

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

async isTokenApproved(tokenAddress, userAddress, threshold)

Checks if the token has been approved Returns boolean

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

async approve(tokenAddress, amount)

Checks if the token has been approved Returns unsigned transaction

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

async approveMaxInt(tokenAddress)

Calls approve but for amount passes ethers.constants.MaxUint256 Returns unsigned transaction

- tokenAddress: string - Address of the deployed token

async getServiceFee()

Returns how much is the service fee

async getClaims(userAddress, targetChainId)

Returns all the transactions for this exact user held in the specified chain

- userAddress: string - User wallet addres
- targetChainId: string - ID of the target chain  

async getWrappedTokens(chainId)

Returns all the wrapped tokens from the specified chain

- chainId: string - ID of the chain  

async isClaimed(transfer)

Returns the passed transfer is already claimed

- transfer: info needed claim the transaction

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 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

fixSignatures(signatures)

Formats the given sifnatures and returns the fixed ones

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

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago