Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
walfly committed Apr 23, 2018
1 parent 94df845 commit 89b437f
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 124,779 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/test/newsroom/newsroom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as chai from "chai";
import { configureChai } from "@joincivil/dev-utils";

import { events, NEWSROOM_ROLE_EDITOR, NEWSROOM_ROLE_REPORTER, REVERTED } from "../utils/constants";
import { findEvent, idFromEvent, is0x0Address, timestampFromTx } from "../utils/contractutils";
import { findEvent, idFromEvent } from "../utils/contractutils";

const Newsroom = artifacts.require("Newsroom");

Expand Down Expand Up @@ -52,7 +52,7 @@ contract("Newsroom", (accounts: string[]) => {
const tx = await newsroom.publishRevision(SOME_URI, SOME_HASH, { from: accounts[1] });
const id = idFromEvent(tx);

const [hash, uri, ...rest] = await newsroom.content(id);
const [hash, uri] = await newsroom.content(id);
expect(uri).to.be.equal(SOME_URI);
expect(hash).to.be.equal(`${SOME_HASH}`);
});
Expand Down
7 changes: 4 additions & 3 deletions packages/core/doc/examples/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as process from "process";

import { Civil } from "../../src";
import { NewsroomRoles } from "../../src/types";
import { InMemoryProvider } from "../../src/content/inmemoryprovider";

(async () => {
const civil = new Civil();
const civil = new Civil({ContentProvider: InMemoryProvider});

console.log("Deploying newsroom...");
const newsroom = await (await civil.newsroomDeployTrusted("My new newsroom")).awaitReceipt();
Expand All @@ -29,9 +30,9 @@ import { NewsroomRoles } from "../../src/types";
console.log("Am I the owner:", await newsroom.isOwner());

console.log("Setting myself to be reporter");
await (await newsroom.addRole(civil.userAccount!, NewsroomRoles.Reporter)).awaitReceipt();
await (await newsroom.addRole(civil.userAccount!, NewsroomRoles.Editor)).awaitReceipt();

console.log("Proposing a new article...");
console.log("publishing a new article...");
const id = await (await newsroom.publishRevision("This is example content that I want to post")).awaitReceipt();
console.log("Article proposed: ", id);

Expand Down
7 changes: 1 addition & 6 deletions packages/core/doc/examples/low-level/typed_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ const data: TxData = {

const subscription = newsroom.RevisionPublishedStream().subscribe(async event => {
console.log("Content proposed");
// console.log("\tAuthor: ", event.args.author);
console.log("\tContent id:", event.args.id.toString());
console.log(
"\tTimestamp for article id " + event.args.id.toString() + ": ",
// (await newsroom.timestamp.callAsync(event.args.id)).toString(),
);
console.log("\tGot an article, unsubscribing");
subscription.unsubscribe();
});

console.log("Publishing a revision");
const proposeOptions = await newsroom.publishRevision.getRaw("http://someuirhere.com", "0x01", data);
const proposeOptions = await newsroom.publishRevision.getRaw("http://someuirhere.com", "hash", data);
console.log("Propose options:", proposeOptions);
const proposeTxHash = await web3.sendTransaction(proposeOptions);
await web3.awaitReceipt(proposeTxHash);
Expand Down
33,618 changes: 9 additions & 33,609 deletions packages/core/src/artifacts/CivilTCR.json

Large diffs are not rendered by default.

5,760 changes: 6 additions & 5,754 deletions packages/core/src/artifacts/EIP20.json

Large diffs are not rendered by default.

24,678 changes: 6 additions & 24,672 deletions packages/core/src/artifacts/MultiSigWallet.json

Large diffs are not rendered by default.

4,276 changes: 6 additions & 4,270 deletions packages/core/src/artifacts/Newsroom.json

Large diffs are not rendered by default.

1,534 changes: 6 additions & 1,528 deletions packages/core/src/artifacts/NewsroomFactory.json

Large diffs are not rendered by default.

28,058 changes: 6 additions & 28,052 deletions packages/core/src/artifacts/PLCRVoting.json

Large diffs are not rendered by default.

26,848 changes: 6 additions & 26,842 deletions packages/core/src/artifacts/Parameterizer.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/core/src/civil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Debug from "debug";
import * as Web3 from "web3";

import { ContentProvider, ContentProviderCreator } from "./content/contentprovider";
import { InMemoryProvider } from "./content/inmemoryprovider";
import { Newsroom } from "./contracts/newsroom";
import { EthAddress, TxHash, CivilTransactionReceipt, TwoStepEthTransaction, Uri } from "./types";
import { CivilTCR } from "./contracts/tcr/civilTCR";
Expand All @@ -27,7 +26,7 @@ export interface CivilOptions {
*/
export class Civil {
private web3Wrapper: Web3Wrapper;
private contentProvider: ContentProvider | IPFSProvider;
private contentProvider: ContentProvider;

/**
* An optional object, conforming to Web3 provider interface can be provided.
Expand All @@ -52,7 +51,7 @@ export class Civil {

// TODO(ritave): Choose a better default provider
if (opts.ContentProvider) {
this.contentProvider = new opts.ContentProvider({web3Wrapper: this.web3Wrapper});
this.contentProvider = new opts.ContentProvider({ web3Wrapper: this.web3Wrapper });
} else {
this.contentProvider = new IPFSProvider();
}
Expand Down Expand Up @@ -160,6 +159,7 @@ export class Civil {
* @returns A URI that points to the content
*/
public async publishContent(content: string): Promise<Uri> {
return this.contentProvider.put(content);
const { uri } = await this.contentProvider.put(content);
return uri;
}
}
2 changes: 1 addition & 1 deletion packages/core/src/content/contentprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export interface ContentProviderOptions {
}

export interface ContentProviderCreator {
new(options: ContentProviderOptions): ContentProvider;
new (options: ContentProviderOptions): ContentProvider;
}
2 changes: 1 addition & 1 deletion packages/core/src/content/inmemoryprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export class InMemoryProvider implements ContentProvider {
const hash = this.web3Wrapper.web3.sha3(content);
const uri = this.scheme() + "://" + hash;
this.data.uri = content;
return {uri, hash};
return { uri, hash };
}
}
6 changes: 3 additions & 3 deletions packages/core/src/content/ipfsprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class IPFSProvider implements ContentProvider {
});
}

public async put(content: string): Promise<Uri> {
return new Promise<Uri>((resolve, reject) => {
public async put(content: string): Promise<ContentHeader> {
return new Promise<ContentHeader>((resolve, reject) => {
ipfs.add(Buffer.from(content), (err: any, ipfsHash: any) => {
resolve(this.scheme() + "://" + ipfsHash[0].path);
resolve({ uri: this.scheme() + "://" + ipfsHash[0].path, hash: ipfsHash[0].path });
});
});
}
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/contracts/newsroom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ContentHeader,
NewsroomContent,
} from "../types";
import { NewsroomContract, NewsroomEvents, RevisionPublishedArgs } from "./generated/newsroom";
import { NewsroomContract, NewsroomEvents, RevisionPublishedLog } from "./generated/newsroom";
import { createTwoStepTransaction, createTwoStepSimple, findEvents, findEventOrThrow } from "./utils/contracts";
import { NewsroomMultisigProxy } from "./generated/multisig/newsroom";
import { MultisigProxyTransaction } from "./multisig/basemultisigproxy";
Expand Down Expand Up @@ -295,7 +295,7 @@ export class Newsroom extends BaseWrapper<NewsroomContract> {
this.web3Wrapper,
await this.instance.publishRevision.sendTransactionAsync(contentHeader.uri, contentHeader.hash),
receipt => {
return findEventOrThrow<RevisionPublishedArgs>(receipt, NewsroomEvents.RevisionPublished).args.id.toNumber();
return findEventOrThrow<RevisionPublishedLog>(receipt, NewsroomEvents.RevisionPublished).args.id.toNumber();
},
);
}
Expand All @@ -322,10 +322,6 @@ export class Newsroom extends BaseWrapper<NewsroomContract> {
await this.requireRole(NewsroomRoles.Editor);
}

private async requireReporter(): Promise<void> {
await this.requireRole(NewsroomRoles.Reporter);
}

private async requireRole(role: NewsroomRoles): Promise<void> {
const account = requireAccount(this.web3Wrapper);
if ((await this.instance.owner.callAsync()) !== account) {
Expand Down
2 changes: 1 addition & 1 deletion packages/debug-ui/src/code/newsroomEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function setNewsroomListeners(): void {
console.log("Deploying newsroom");
const deployedNewsroom = await civil.newsroomAtUntrusted(address);
console.log("Proposing content");
const articleId = await deployedNewsroom.proposeContent(article);
const articleId = await deployedNewsroom.publishRevision(article);
console.log(`\tContent id: ${articleId}`);

console.log("Approving content");
Expand Down
58 changes: 33 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@
keccakjs "^0.2.1"
minimist "^1.2.0"

"@joincivil/utils@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@joincivil/utils/-/utils-1.1.4.tgz#85e0786e64c2e3e565b5e9f81561016f037d9619"
dependencies:
ethereumjs-abi "^0.6.5"
rxjs "^5.5.6"
"@joincivil/editor@1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@joincivil/editor/-/editor-1.1.3.tgz#8c9b152cbab99133abbd58e69a678fd7da292e07"
dependencies:
material-ui "^1.0.0-beta.38"
material-ui-icons "^1.0.0-beta.36"
react-material-icons "^1.0.3"
slate "^0.33.0"
slate-drop-or-paste-images "^0.8.0"
slate-edit-list "^0.11.2"
slate-react "^0.12.0"
slate-schema-violations "^0.1.4"
styled-components "^3.1.6"

"@sindresorhus/is@^0.7.0":
version "0.7.0"
Expand Down Expand Up @@ -10720,6 +10727,10 @@ react-inspector@^2.2.2:
babel-runtime "^6.26.0"
is-dom "^1.0.9"

react-is@^16.3.1:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.3.2.tgz#f4d3d0e2f5fbb6ac46450641eb2e25bf05d36b22"

react-jss@^8.1.0:
version "8.3.5"
resolved "https://registry.yarnpkg.com/react-jss/-/react-jss-8.3.5.tgz#963ed6677e8112820d0495853cd4c3d0fb1d05fd"
Expand Down Expand Up @@ -11870,10 +11881,6 @@ slate-schema-violations@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/slate-schema-violations/-/slate-schema-violations-0.1.4.tgz#f87ad4091f72c66edf32f418a33d80e5e87ad5e8"

slate-schema-violations@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/slate-schema-violations/-/slate-schema-violations-0.1.8.tgz#b6bfbcc4defaa4971a96bf2d324c5b67fb4a4e20"

slate@^0.33.0:
version "0.33.0"
resolved "http://registry.npmjs.org/slate/-/slate-0.33.0.tgz#6a4e084aa3a55dc5b09bce1b7037f284396b9160"
Expand All @@ -11888,20 +11895,6 @@ slate@^0.33.0:
slate-schema-violations "^0.1.4"
type-of "^2.0.1"

slate@^0.33.4:
version "0.33.4"
resolved "https://registry.yarnpkg.com/slate/-/slate-0.33.4.tgz#8f39000a7a0fb1ec04b211c3e264e45677dfd9d8"
dependencies:
debug "^2.3.2"
direction "^0.1.5"
esrever "^0.2.0"
is-empty "^1.0.0"
is-plain-object "^2.0.4"
lodash "^4.17.4"
slate-dev-logger "^0.1.39"
slate-schema-violations "^0.1.8"
type-of "^2.0.1"

slice-ansi@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35"
Expand Down Expand Up @@ -12478,7 +12471,22 @@ style-loader@^0.19.1:
loader-utils "^1.0.2"
schema-utils "^0.3.0"

styled-components@3.2.5, styled-components@^3.2.5:
styled-components@^3.1.6:
version "3.2.6"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-3.2.6.tgz#99e6e75a746bdedd295a17e03dd1493055a1cc3b"
dependencies:
buffer "^5.0.3"
css-to-react-native "^2.0.3"
fbjs "^0.8.16"
hoist-non-react-statics "^2.5.0"
is-plain-object "^2.0.1"
prop-types "^15.5.4"
react-is "^16.3.1"
stylis "^3.5.0"
stylis-rule-sheet "^0.0.10"
supports-color "^3.2.3"

styled-components@^3.2.5:
version "3.2.5"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-3.2.5.tgz#b5d5d7d618ab240ff10602b5ca5886b8db3d0a0d"
dependencies:
Expand Down

0 comments on commit 89b437f

Please sign in to comment.