UNPKG

@nexex/api

Version:
43 lines (42 loc) 2.27 kB
import { ECSignature, PlainDexOrder, PlainUnsignedOrder } from '@nexex/types'; import { Signer } from 'ethers'; import { Provider } from 'ethers/providers'; import 'reflect-metadata'; import { Exchange } from './contracts/Exchange'; import { Portal } from './contracts/Portal'; import { TokenHelper } from './contracts/TokenHelper'; import { TokenRegistry } from './contracts/TokenRegistry'; import { DexConfig } from './types'; export declare class Dex { static create(config: DexConfig): Promise<Dex>; /** * Generates a pseudo-random 256-bit salt. * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash * and will not collide with other outstanding orders that are identical in all other parameters. * @return A pseudo-random 256-bit number that can be used as a salt. */ static generatePseudoRandomSalt(): string; eth: Provider; signer: Signer; config: DexConfig; portal: Portal; exchange: Exchange; token: TokenHelper; tokenRegistry: TokenRegistry; protected constructor(config: DexConfig); signOrder(signer: Signer, order: PlainUnsignedOrder): Promise<PlainDexOrder>; /** * Signs an orderHash and returns it's elliptic curve signature. * This method currently supports TestRPC, Geth and Parity above and below V1.6.6 * @param orderHash Hex encoded orderHash to sign. * @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address * must be available via the Web3.Provider supplied to 0x.js. * @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message` * themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client * (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix * before sending the request. * @return An object containing the Elliptic curve signature parameters generated by signing the orderHash. */ signOrderHash(signer: Signer, orderHash: string, shouldAddPersonalMessagePrefix?: boolean): Promise<ECSignature>; protected init(): Promise<void>; }