import { BigNumber, EthAddress, EthSignedMessage, TxHash, ContentData, StorageHeader } from "@joincivil/typescript-types"; import { Observable } from "rxjs/Observable"; import { CivilTransactionReceipt, TwoStepEthTransaction } from "."; import { ContentProviderCreator } from "./content/contentprovider"; import { Newsroom } from "./contracts/newsroom"; import { CivilTCR } from "./contracts/tcr/civilTCR"; import { Council } from "./contracts/tcr/council"; import { CVLToken } from "./contracts/tcr/cvltoken"; import { provider as Provider } from "web3-core"; export interface CivilOptions { web3Provider?: Provider; ContentProvider?: ContentProviderCreator; debug?: true; } /** * Single entry-point to the civil.ts library * It abstracts most of the web3 and Ethereum communication. * Since all the calls to the Ethereum network take time, it is written using Promises, * and all of them can fail (for eg. when the connection to the node drops) */ export declare class Civil { private ethApi; private contentProvider; /** * An optional object, conforming to Web3 provider interface can be provided. * If no provider is given, civil.ts shall try to automagically infer which provider to use. * First by checking for any injected ones (such as Metamask) and in the last case defaulting * to default http on localhost. * @param web3Provider Explicitly provide an Ethereum Node connection provider */ constructor(options?: CivilOptions); toBigNumber(num: number | string | BigNumber): any; toWei(num: number): BigNumber; toChecksumAddress(address: string): any; signMessage(message: string, account?: EthAddress): Promise; currentProviderEnable(): Promise; /** * @returns Currently default user account used, undefined if none unlocked/found */ readonly accountStream: Observable; readonly networkStream: Observable; readonly networkNameStream: Observable; /** * Returns the current provider that is used by all things Civil in the Core */ /** * Changes the web3 provider that is used by the Civil library. * All existing smart-contract object will switch to the new library behind the scenes. * This may invalidate any Ethereum calls in transit or event listening * @param web3Provider The new provider that shall replace the old one */ currentProvider: Provider; /** * Create a new Newsroom owned by a multisig on the current Ethereum network with the * bytecode included in this library * The smart contract is trusted since it comes from a trusted source (us). * This call may require user input - such as approving a transaction in Metamask */ newsroomDeployTrusted(newsroomName: string, charterUri?: string, charterHash?: string): Promise>; estimateNewsroomDeployTrusted(newsroomName: string, charterUri: string, charterHash: string): Promise; /** * Create a new Newsroom which is not owned by a multisig on the current Ethereum network with the * bytecode included in this library * The smart contract is trusted since it comes from a trusted source (us). * This call may require user input - such as approving a transaction in Metamask */ newsroomDeployNonMultisigTrusted(newsroomName: string): Promise>; /** * Returns a Newsroom object, that was beforehand put into blockchain's mempool, * or already mined into a block. * If the Newsroom was already mined, returns it immediately, otherwise * waits until it's put onto blockchain. * @see {@link Civil.awaitReceipt} * @param transactionHash The transaction hash which creates the Newsroom * @param blockConfirmations How many blocks should be mined before the Newsroom is considered immutabely created * @throws {CivilErrors.MalformedParams} If the transaction is not a Newsroom creation transaction */ newsroomFromTxHashUntrusted(transactionHash: TxHash, blockConfirmations?: number): Promise; /** * Returns a Newsroom object, that was beforehand put into blockchain's mempool using the factory method, * or already mined into a block. * If the Newsroom was already mined, returns it immediately, otherwise * waits until it's put onto blockchain. * @see {@link Civil.awaitReceipt} * @param transactionHash The transaction hash which creates the Newsroom * @param blockConfirmations How many blocks should be mined before the Newsroom is considered immutabely created */ newsroomFromFactoryTxHashUntrusted(transactionHash: TxHash, blockConfirmations?: number): Promise; /** * Returns a Newsroom object, which is an abstraction layer to * the smart-contract located a Ethereum on `address` in the current network. * No sanity checks are done concerning that smart-contracts, and so the contract * might a bad actor or not implementing Newsroom ABIs at all. * @param address The address on current Ethereum network where the smart-contract is located */ newsroomAtUntrusted(address: EthAddress): Promise; /** * Only one TCR is needed for in each network, a singleton living at a specific * Ethereum address, used by everyone. * @returns A singleton instance of TCR living on the current network * @throws {CivilErrors.UnsupportedNetwork} In case we're trying to get a non-deployed singleton */ tcrSingletonTrusted(): Promise; councilSingletonTrusted(): Promise; cvlTokenSingletonTrusted(multisigAddress?: EthAddress): Promise; /** * Same as `tcrSingletonTrusted` but is async and supports (but does not require) a multisig proxy. This is a separate function because most TCR instances don't need multisig and can continue to use synchronous `tcrSingletonTrusted` function. * @param multisigAddress (optional) Multisig through which to proxy interactions with this TCR * @returns Promise containing singleton instance of TCR living on the current network * @throws {CivilErrors.UnsupportedNetwork} In case we're trying to get a non-deployed singleton */ tcrSingletonTrustedMultisigSupport(multisigAddress?: EthAddress): Promise; /** * Waits for the transaction located through the hash gets into the blockchain * and returns it's receipt after it gets in. * Optionally, since Blockchain can reorganize sometimes and transactions are revoked, * you can wait for some blocks, which exponentionally decreases reorg chances, until * the transaction is considered confirmed. * @param transactionHash The hash of transaction you wanna confirm got into blockchain * @param blockConfirmations How man blocks after the block with transaction should wait before confirming */ awaitReceipt(transactionHash: TxHash, blockConfirmations?: number): Promise; /** * Stores content on a content provider (defaults to IPFS) * @param content The the data that you want to store, in the future, probably a JSON * @param options Options to be passed to the provider * @returns StorageHeader with info about published content */ publishContent(content: string, options?: object): Promise; getContent(header: StorageHeader): Promise; getBareContent(uri: string): Promise; currentBlock(): Promise; networkName(): Promise; getGasPrice(): Promise; accountBalance(account: EthAddress): Promise; simplePayment(recipient: EthAddress, amountInETH: string): Promise; }