UNPKG

rubik-sdk

Version:
73 lines (72 loc) 3.09 kB
import BigNumber from 'bignumber.js'; import { TransactionConfig } from 'web3-core'; import { AbiItem } from 'web3-utils'; import { TransactionGasParams } from 'src/features/instant-trades/models/gas-params'; /** * Contains common methods, connected with web3, e.g. wei conversion, encoding data, etc. */ export declare class Web3Pure { static readonly ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; private static web3Eth; /** * Gets address of native coin {@link NATIVE_TOKEN_ADDRESS}. */ static get nativeTokenAddress(): string; static isZeroAddress(address: string): boolean; /** * Increases the gas limit value by the specified percentage and rounds to the nearest integer. * @param gasLimit Gas limit value to increase. * @param multiplier The multiplier by which the gas limit will be increased. */ static calculateGasMargin(gasLimit: BigNumber | string | number | undefined, multiplier: number): BigNumber; /** * Converts amount from Ether to Wei units. * @param amount Amount to convert. * @param decimals Token decimals. * @param roundingMode BigNumberRoundingMode. */ static toWei(amount: BigNumber | string | number, decimals?: number, roundingMode?: BigNumber.RoundingMode): string; /** * Converts amount from Wei to Ether units. * @param amountInWei Amount to convert. * @param decimals Token decimals. */ static fromWei(amountInWei: BigNumber | string | number, decimals?: number): BigNumber; /** * Converts address to bytes32 format. * @param address Address to convert. */ static addressToBytes32(address: string): string; /** * Converts address to checksum format. * @param address Address to convert. */ static toChecksumAddress(address: string): string; /** * Checks if a given address is a valid Ethereum address. * @param address The address to check validity of. */ static isAddressCorrect(address: string): boolean; /** * Checks if address is Ether native address. * @param address Address to check. */ static isNativeAddress: (address: string) => boolean; /** * Returns transaction config with encoded data. */ static encodeMethodCall(contractAddress: string, contractAbi: AbiItem[], method: string, parameters?: unknown[], value?: string, options?: TransactionGasParams): TransactionConfig; /** * Encodes a function call using its JSON interface object and given parameters. * @param contractAbi The JSON interface object of a function. * @param methodName Method name to encode. * @param methodArguments Parameters to encode. * @returns An ABI encoded function call. Means function signature + parameters. */ static encodeFunctionCall(contractAbi: AbiItem[], methodName: string, methodArguments: unknown[]): string; /** * Converts ascii address to bytes32 format. * @param address Address to convert. */ static asciiToBytes32(address: string): string; }