Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add genericscheme callData raw data to the proposal details view #2052

Merged
merged 3 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"Name": "Name",
"ETH Balance": "ETH Balance",
"Members": "Members",
"Plugin activation time": "The plugin will be activated at"
"Plugin activation time": "The plugin will be activated at",
"Raw call data": "Raw call data"
}
30 changes: 23 additions & 7 deletions src/components/Proposal/ProposalSummary/ProposalSummaryCO2ken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { IGenericPluginProposalState } from "@daostack/arc.js";
import BN = require("bn.js");
import classNames from "classnames";
import { GenericPluginInfo } from "genericPluginRegistry";
import { formatTokens } from "lib/util";
import { formatTokens, truncateWithEllipses } from "lib/util";
import * as React from "react";
import * as css from "./ProposalSummary.scss";
import CopyToClipboard from "components/Shared/CopyToClipboard";
import i18next from "i18next";

interface IProps {
genericPluginInfo: GenericPluginInfo;
Expand All @@ -16,6 +18,14 @@ interface IProps {

export default class ProposalSummaryCO2ken extends React.Component<IProps, null> {

private rawCallData(proposalState: IGenericPluginProposalState) {
return <>
<p>{i18next.t("Raw call data")}:</p>
<pre>
{truncateWithEllipses(proposalState.callData, 66)}<CopyToClipboard value={proposalState.callData} />
</pre>
</>;
}
public render(): RenderOutput {
const { proposalState, detailView, genericPluginInfo, transactionModal } = this.props;
let decodedCallData: any;
Expand Down Expand Up @@ -47,7 +57,7 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
<span className={css.summaryTitle}>
{action.label}
</span>
{ detailView ?
{detailView ?
<div className={css.summaryDetails}>
<div>
<p>
Expand All @@ -64,6 +74,7 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
<a href={`https://cloudflare-ipfs.com/ipfs/${ipfsHashValue}`} target="_blank" rel="noopener noreferrer">{ipfsHashValue}</a>
</pre>
</div>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -84,6 +95,7 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
<pre>{-1}</pre>
It allows the the CO2ken contract to move DAI held by the DAO. This way, the DAO can offset its emissions by calling:
<pre>offsetCarbon()</pre>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -100,6 +112,7 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
Executing this proposal will call the function
<pre>{action.id}()</pre>
It transfers all the DAI stored in the CO2ken contract to the DAO.
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -116,12 +129,13 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
</span>
{detailView ?
<div className={css.summaryDetails}>
Executing this proposal will call the function
Executing this proposal will call the function
<pre>{action.id}()</pre>
DAI are sent to the CO2ken contract to retire a respecive number of CO2kens. One CO2ken is equivalent to a ton of carbon emissions. The total amount of DAI which will be sent to the contract is:
DAI are sent to the CO2ken contract to retire a respecive number of CO2kens. One CO2ken is equivalent to a ton of carbon emissions. The total amount of DAI which will be sent to the contract is:
<pre>
{formatTokens(new BN(value), field.unit, field.decimals)}
</pre>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -139,13 +153,14 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
</span>
{detailView ?
<div className={css.summaryDetails}>
Executing this proposal will call the function
Executing this proposal will call the function
<pre>{action.id}()</pre>
with value
<pre>
{ field.label }: {formatTokens(new BN(value), field.unit, field.decimals)}
{field.label}: {formatTokens(new BN(value), field.unit, field.decimals)}
</pre>
The value describes the amount of carbon tons the DAO wants to offset.
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -161,10 +176,11 @@ export default class ProposalSummaryCO2ken extends React.Component<IProps, null>
</span>
{detailView ?
<div className={css.summaryDetails}>
Executing this proposal will call the function
Executing this proposal will call the function
<pre>{action.id}()</pre>
with the new owner‘s address being
<pre>{decodedCallData.values[0]}</pre>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand Down
38 changes: 27 additions & 11 deletions src/components/Proposal/ProposalSummary/ProposalSummaryDutchX.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { IGenericPluginProposalState } from "@daostack/arc.js";
import BN = require("bn.js");
import classNames from "classnames";
import { GenericPluginInfo } from "genericPluginRegistry";
import { formatTokens, linkToEtherScan } from "lib/util";
import { formatTokens, linkToEtherScan, truncateWithEllipses } from "lib/util";
import * as React from "react";
import * as css from "./ProposalSummary.scss";
import CopyToClipboard from "components/Shared/CopyToClipboard";
import i18next from "i18next";

interface IProps {
genericPluginInfo: GenericPluginInfo;
Expand All @@ -16,6 +18,15 @@ interface IProps {

export default class ProposalSummaryDutchX extends React.Component<IProps, null> {

private rawCallData(proposalState: IGenericPluginProposalState) {
return <>
<p>{i18next.t("Raw call data")}:</p>
<pre>
{truncateWithEllipses(proposalState.callData, 66)}<CopyToClipboard value={proposalState.callData} />
</pre>
</>;
}

public render(): RenderOutput {
const { proposalState, detailView, genericPluginInfo, transactionModal } = this.props;
let decodedCallData: any;
Expand Down Expand Up @@ -50,13 +61,14 @@ export default class ProposalSummaryDutchX extends React.Component<IProps, null>
return (
<div className={proposalSummaryClass}>
<span className={css.summaryTitle}>
<img src="/assets/images/Icon/edit-sm.svg"/>&nbsp;
<img src="/assets/images/Icon/edit-sm.svg" />&nbsp;
{action.label}
{renderValueHtml()}
</span>
{ detailView ?
{detailView ?
<div className={css.summaryDetails}>
<div>{ action.fields[0].label}: <a href={linkToEtherScan(decodedCallData.values[0])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[0]}</a></div>
<div>{action.fields[0].label}: <a href={linkToEtherScan(decodedCallData.values[0])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[0]}</a></div>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -66,13 +78,14 @@ export default class ProposalSummaryDutchX extends React.Component<IProps, null>
return (
<div className={proposalSummaryClass}>
<span className={css.summaryTitle}>
<img src="/assets/images/Icon/edit-sm.svg"/>&nbsp;
<img src="/assets/images/Icon/edit-sm.svg" />&nbsp;
{action.label}
{renderValueHtml()}
</span>
{ detailView ?
{detailView ?
<div className={css.summaryDetails}>
New oracle address: <a href={linkToEtherScan(decodedCallData.values[0])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[0]}</a>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -82,13 +95,14 @@ export default class ProposalSummaryDutchX extends React.Component<IProps, null>
return (
<div className={proposalSummaryClass}>
<span className={css.summaryTitle}>
<img src="/assets/images/Icon/edit-sm.svg"/>&nbsp;
<img src="/assets/images/Icon/edit-sm.svg" />&nbsp;
{action.label}
{renderValueHtml()}
</span>
{ detailView ?
{detailView ?
<div className={css.summaryDetails}>
New owner address: <a href={linkToEtherScan(decodedCallData.values[0])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[0]}</a>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -102,11 +116,12 @@ export default class ProposalSummaryDutchX extends React.Component<IProps, null>
{decodedCallData.values[1] ? "Whitelist" : "Delist"} {decodedCallData.values[0].length} token{decodedCallData.values[0].length !== 1 ? "s" : ""}
{renderValueHtml()}
</span>
{ detailView ?
{detailView ?
<div className={css.summaryDetails}>
<ul>
{decodedCallData.values[0].map((token: string) => <li key={token}><a href={linkToEtherScan(token)} target="_blank" rel="noopener noreferrer">{token}</a></li>)}
</ul>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand All @@ -120,12 +135,13 @@ export default class ProposalSummaryDutchX extends React.Component<IProps, null>
return (
<div className={proposalSummaryClass}>
<span className={css.summaryTitle}>
<img src="/assets/images/Icon/edit-sm.svg"/>&nbsp;
{ field.label }: {formatTokens(new BN(value), field.unit, field.decimals)}
<img src="/assets/images/Icon/edit-sm.svg" />&nbsp;
{field.label}: {formatTokens(new BN(value), field.unit, field.decimals)}
{renderValueHtml()}
</span>
{detailView ?
<div className={css.summaryDetails}>
{this.rawCallData(proposalState)}
</div>
: ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ProposalSummaryDutchX from "./ProposalSummaryDutchX";
import ProposalSummaryStandardBounties from "./ProposalSummaryStandardBounties";
import ProposalSummaryCO2ken from "./ProposalSummaryCO2ken";
import ProposalSummaryNFTManager from "./ProposalSummaryNFTManager";
import i18next from "i18next";

interface IExternalProps {
beneficiaryProfile?: IProfileState;
Expand All @@ -33,7 +34,7 @@ export default class ProposalSummary extends React.Component<IProps> {
return <div
className={isArrayItem ? css.arrayItem : ""}
key={value}
>{truncatedValue}<CopyToClipboard value={value}/>{isArrayItem ? "," : ""}
>{truncatedValue}<CopyToClipboard value={value} />{isArrayItem ? "," : ""}
</div>;

} else {
Expand Down Expand Up @@ -118,6 +119,11 @@ export default class ProposalSummary extends React.Component<IProps> {
<pre><a href={linkToEtherScan(proposalState.contractToCall)}>{proposalState.contractToCall}</a></pre>
sending to contract:
<pre className={sendsETH ? css.warning : ""}>{formatTokens(proposalState.value)} ETH</pre>

{i18next.t("Raw call data")}:
<pre>
{truncateWithEllipses(proposalState.callData, 66)}<CopyToClipboard value={proposalState.callData} />
</pre>
</div>
: ""
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { IGenericPluginProposalState, IDAOState } from "@daostack/arc.js";
import * as classNames from "classnames";
import { GenericPluginInfo } from "genericPluginRegistry";
import { linkToEtherScan } from "lib/util";
import { linkToEtherScan, truncateWithEllipses } from "lib/util";
import * as React from "react";
import * as css from "./ProposalSummary.scss";
import CopyToClipboard from "components/Shared/CopyToClipboard";
import i18next from "i18next";
const Web3 = require("web3");

interface IProps {
Expand Down Expand Up @@ -55,20 +57,24 @@ export default class ProposalSummaryNFTManager extends React.Component<IProps, n
{decodedCallData.values[0]}
</span>
}
{ detailView &&
{detailView &&
<div className={css.summaryDetails}>
<div>
<strong>Send NFT </strong>
<img className={css.iconPadding} src="/assets/images/Icon/Transfer.svg" />
<a href={linkToEtherScan(decodedCallData.values[0])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[0]}</a>
</div>
<br/>
<br />
<div>
<strong>NFT Contract:</strong> <a href={linkToEtherScan(decodedCallData.values[1])} target="_blank" rel="noopener noreferrer">{decodedCallData.values[1]}</a>
</div>
<div>
<strong>TokenID:</strong> {decodedCallData.values[2]}
</div>
<div>
<strong>{i18next.t("Raw call data")}:</strong>
{truncateWithEllipses(proposalState.callData, 66)}<CopyToClipboard value={proposalState.callData} />
</div>
</div>
}
</div>
Expand Down
Loading