UNPKG

@dappykit/sdk

Version:

Web3 SDK for DApps

48 lines (47 loc) 1.93 kB
import { Bytes } from './bytes'; export declare const ETH_SIGNATURE_0X_HEX_LENGTH = 132; export type EthAddress = Bytes<20>; export declare const ETH_ADDR_HEX_LENGTH = 40; export declare const ETH_ADDR_0X_HEX_LENGTH = 42; /** * Creates Ethereum address from the given value. * @param address Value to convert */ export declare function makeEthAddress(address: EthAddress | Uint8Array | string | unknown): EthAddress; /** * Checks if the given value is a valid Ethereum address without 0x. * @param value Value to check */ export declare function isEthAddress(value: unknown): value is EthAddress; /** * Checks if the given value is a valid Ethereum address with 0x prefix. * @param value Value to check */ export declare function is0xEthAddress(value: unknown): value is string; /** * Asserts that the given value is a valid Ethereum address without 0x. * @param value Value to check */ export declare function assertHexEthAddress(value: unknown): asserts value is EthAddress; /** * Asserts that the given value is a valid Ethereum address with 0x prefix. * @param value Value to check */ export declare function assert0xEthAddress(value: unknown): asserts value is string; /** * Prepares the Ethereum address by removing the 0x prefix and converting it to lowercase. * @param address Ethereum address */ export declare function prepareEthAddress(address: string): string; export declare function prepareEthSignature(signature: string): string; /** * Checks if the given value is a valid Ethereum signature with 0x prefix. * @param value Value to check */ export declare function is0xEthSignature(value: unknown): value is string; /** * Extract the signer address from the data and signature * @param data Data to extract the signer address from * @param signature Signature to extract the signer address from */ export declare function extractSignerAddress(data: string, signature: string): Promise<string>;