import { EthApi } from "@joincivil/ethapi"; import { NewsroomRoles } from "@joincivil/utils"; import { Observable } from "rxjs"; import { TransactionReceipt, TransactionConfig, Transaction } from "web3-core"; import { ContentProvider } from "../content/contentprovider"; import { BigNumber, ApprovedRevision, CharterContent, ContentId, EthAddress, EthContentHeader, Hex, NewsroomContent, NewsroomData, NewsroomWrapper, RevisionId, TxHash, Uri } from "@joincivil/typescript-types"; import { CivilTransactionReceipt, TwoStepEthTransaction } from "../types"; import { BaseWrapper } from "./basewrapper"; import { NewsroomContract } from "./generated/wrappers/newsroom"; import { MultisigProxyTransaction } from "./multisig/basemultisigproxy"; import { MultisigTransaction } from "./multisig/multisigtransaction"; /** * A Newsroom can be thought of an organizational unit with a sole goal of providing content * in an organized way. * * Newsroom is controlled by access-control pattern, with multiple roles (see [[NewsroomRoles]]) that allow governing * what get's published and what isn't. * * All of the logic exists on the Ethereum network, with the data of articles living outside. * The smart-contracts doesn't limit _where_ the articles lives, as it accepts an URI with a schema. * And so articles can live in IPFS, Filecoin, Whisper, or just a simple HTTP server. * Right now the only supported systems are HTTP and [[InMemoryProvider]] for debugging purpouses */ export declare class Newsroom extends BaseWrapper { static deployTrusted(ethApi: EthApi, contentProvider: ContentProvider, newsroomName: string, charterUri?: Uri, charterHash?: Hex): Promise>; static fromFactoryReceipt(factoryReceipt: TransactionReceipt, ethApi: EthApi, contentProvider: ContentProvider): Promise; static estimateDeployTrusted(ethApi: EthApi, newsroomName: string, charterUri?: string, charterHash?: string): Promise; static deployNonMultisigTrusted(ethApi: EthApi, contentProvider: ContentProvider, newsroomName: string, charterUri?: Uri, charterHash?: Hex): Promise>; static atUntrusted(ethApi: EthApi, contentProvider: ContentProvider, address: EthAddress): Promise; static recoverArchiveTx(tx: Transaction): Promise; private multisigProxy; private contentProvider; private constructor(); editors(): Observable; /** * An unending stream of all the content, both signed as well as unsigned. * @param fromBlock Starting block in history for events concerning content being proposed. * Set to "latest" for only new events * @returns Metadata about the content from Ethereum. Use [[resolveContent]] to get actual contents */ content(fromBlock?: number): Observable; /** * An unending stream of all revsions * @param contentId Optional parameter to get revisions of only specific content * @param fromBlock Starting block in history for events concerning content being proposed. * Set to "latest" for only new events * @returns Metadata about the content from Ethereum. Use [[resolveContent]] to get actual contents */ revisions(contentId?: number | BigNumber | undefined, fromBlock?: number): Observable; /** * An unending stream of all names this Newsroom had ever had. * @param fromBlock Starting block in history for events. * Set to "latest" to only listen for new events * @returns Name history of this Newsroom */ nameChanges(fromBlock?: number): Observable; /** * Returns NewsroomWrapper (address + data) for this newsroom */ getNewsroomWrapper(): Promise; /** * Returns NewsroomData for this newsroom */ getNewsroomData(): Promise; /** * Returns a list of Board of Directors with superuser powers over this * newsroom. */ owners(): Promise; addOwner(owner: EthAddress): Promise>; estimateAddOwner(owner: EthAddress): Promise; /** * Returns the address of the multisig that controls this newsroom if one is defined */ getMultisigAddress(): Promise; /** * Transfers ETH from multisig to a given address * @param eth Amount to transfer, in ether * @param to Address to transfer to */ transferEthFromMultisig(eth: string, to: EthAddress): Promise>; /** * Checks if the user is the owner of the newsroom * @param address Address for the ownership check, leave empty for current user * @throws {CivilErrors.NoUnlockedAccount} Requires the node to have at least one account if no address provided */ isOwner(address?: EthAddress): Promise; /** * Checks if the user can assign roles and approve/deny content * @param address Address for the role check, leave empty for current user * @throws {CivilErrors.NoUnlockedAccount} Requires the node to have at least one account if no address provided */ isEditor(address?: EthAddress): Promise; /** * Checks if the user can assign roles and approve/deny content * Also returns true if user has director super powers * @param address Address for the role check, leave empty for current user * @throws {CivilErrors.NoUnlockedAccount} Requires the node to have at least one account if no address provided */ hasEditorCapabilities(address?: EthAddress): Promise; getArticleHeader(articleId: BigNumber): Promise; getCharterHeader(): Promise; /** * Gets newsroom charter data. * @throws {CivilErrors.MalformedCharter} Charter data is malformed. */ getCharter(): Promise; /** * Loads everything concerning one article needed to read it fully. * Accesess both Ethereum network as well as the active ContentProvider * @param articleId Id of the article that you want to read */ loadArticle(articleId: BigNumber): Promise; /** * Converts metadata gathered from Ethereum network into a fully fledged Article all the * text needed for display * @param header Metadata you get from Ethereum */ resolveContent(header: EthContentHeader): Promise; /** * Accesses the Ethereum network and loads basic metatadata about the content * @param articleId Id of the article whose metadata you need */ loadContentHeader(contentId: BigNumber, revisionId?: number | BigNumber): Promise; getName(): Promise; /** * Sets an Access-Control-List role to a specified address * @param actor The address that shall be granted a role * @param role What privilige the address should be given * @throws {Civil.NoPrivileges} Requires editor privilege * @throws {CivilErrors.NoUnlockedAccount} Needs at least one account for editor role check */ addRole(actor: EthAddress, role: NewsroomRoles): Promise; /** * Removes an Access-Control-List role to a specified address * Silently succeeds if the role isn't set * @param actor The address that shall have the role removed * @param role What privilege will be removed * @throws {Civil.NoPrivileges} Requires editor privilege * @throws {CivilErrors.NoUnlockedAccount} Needs at least one account for editor role check */ removeRole(actor: EthAddress, role: NewsroomRoles): Promise; removeOwner(actor: EthAddress): Promise>; /** * Changes the name of the Newsroom. * The name can be any string, but when applying to a TCR, it must be unique in that TCR * @param newName The new name of this Newsroom * @throws {CivilErrors.NoPrivileges} Requires owner permission * @throws {CivilErrors.NoUnlockedAccount} Needs the unlocked to check privileges */ setName(newName: string): Promise; txArchiveForContentId(contentId: number, revisionId: number): Observable; estimatePublishURIAndHash(uriOrContent: any, hash: string, author?: string, signature?: string, archive?: boolean): Promise; estimateUpdateURIAndHash(contentId: number, uriOrContent: any, hash: string, signature?: string, archive?: boolean): Promise; estimateFromDataMultiSig(data: TransactionConfig, content?: any): Promise; estimateFromContent(content: any, dataLength: number): Promise; publishURIAndHash(uri: string, hash: string, author?: string, signature?: string): Promise>; updateRevisionURIAndHash(contentId: ContentId, uri: string, hash: string, signature?: string): Promise>; addArchiveToMultisig(data: TransactionConfig, hex: string, gas: number): Promise; publishWithArchive(content: any, hash: string, author?: string, signature?: string): Promise>; updateRevisionURIAndHashWithArchive(contentId: ContentId, content: any, hash: string, signature?: string): Promise>; contentIdFromTxHash(txHash: TxHash): Promise; /** * Allows editor to publish content on the ethereum storage and record it in the * Blockchain Newsroom. * The content can also be pre-approved by the author through their signature using their private key * @param content The content that should be put in the content provider * @param signedData An object representing author's approval concerning this content * @returns An id assigned on Ethereum to the uri, or a multig transaction if it requires more confirmations */ publishContent(content: string, signedData?: ApprovedRevision): Promise>; revisionFromTxHash(txHash: TxHash): Promise; /** * Allows editor to create a new revision to already existing content. * The revision can be unsigned. If the revision is signed, * the author has to match the author defined when publishing in the first place. * If there was no author during publishing [[signRevision]] can update them. * @param contentId The id of the already published content * @param content The data that should be stored in content storage * @param signedData Optional pre-approval from the author concerning this article */ updateRevision(contentId: ContentId, content: string, signedData?: ApprovedRevision): Promise>; /** * Allows editor to back-sign a revision which was previously unsigned. * Additionally if the content was published without the author, this function will allow to set the author. * If the author was set previously, the signature also needs to be from the same author. * @param contentId The id of already published content * @param revisionId The id of already published revision for that content * @param signedData Data needed to back-sign the revision */ signRevision(contentId: ContentId, revisionId: RevisionId, signedData: ApprovedRevision): Promise>; /** * Signs that specific content with the current private key of the user of this library with their approval * @param content Data to sign * @returns An object containing all information to represent what has the author approved */ approveByAuthor(content: string): Promise; approveByAuthorPersonalSign(contentHash: Hex): Promise; private requireEditor; private requireRole; private requireOwner; private verifyApprovedRevision; private uploadToStorage; /** * Used when the transaction might go through a multisig wallet * In that case, more confirmations might be needed from other owners */ private twoStepOrMulti; }