Skip to content

Commit

Permalink
Different message when no write methods found in ABI (#2184)
Browse files Browse the repository at this point in the history
* different message when no write methods found in ABI

* updated message
  • Loading branch information
roienatan committed Oct 11, 2020
1 parent 9dd9c3c commit 9b9a53d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"Validate Digits" : "Must contain only digits",
"Call to Contract": "This proposal will call the following ",
"No ABI": "No ABI found for target contract, please verify the ",
"No Write Methods": "No write methods found for target ",
"contract": "contract",
"Add Params": "Add Params",
"Remove Params": "Remove Params"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ interface IDispatchProps {

interface IStateProps {
loading: boolean
tags: Array<string>;
abiMethods: any
tags: Array<string>
abiData: Array<any>
abiMethods: Array<any>
abiInputs: IABIField[]
callData: string
}
Expand Down Expand Up @@ -75,12 +76,13 @@ const defaultValues: IFormValues = Object.freeze({

interface INoABIProps {
contractToCall: string
abiData: Array<any>
}

const NoABI = (props: INoABIProps) => {
return (
<div className={css.noABIWrapper}>
{i18next.t("No ABI")}
{props.abiData.length === 0 ? i18next.t("No ABI") : i18next.t("No Write Methods")}
<a href={linkToEtherScan(props.contractToCall)} target="_blank" rel="noopener noreferrer">{i18next.t("contract")}</a>
</div>
);
Expand All @@ -93,7 +95,7 @@ class CreateGenericPlugin extends React.Component<IProps, IStateProps> {

constructor(props: IProps) {
super(props);
this.state = { loading: true, tags: [], abiMethods: [], abiInputs: [], callData: "" };
this.state = { loading: true, tags: [], abiData: [], abiMethods: [], abiInputs: [], callData: "" };

this.handleSubmit = this.handleSubmit.bind(this);
this.formModalService = CreateFormModalService(
Expand All @@ -116,7 +118,7 @@ class CreateGenericPlugin extends React.Component<IProps, IStateProps> {
const contractToCall = (this.props.pluginState as IGenericPluginState).pluginParams.contractToCall;
const abiData = await getABIByContract(contractToCall);
const abiMethods = extractABIMethods(abiData);
this.setState({ abiMethods: abiMethods, loading: false });
this.setState({ abiData: abiData, abiMethods: abiMethods, loading: false });
}

componentWillUnmount() {
Expand Down Expand Up @@ -417,7 +419,7 @@ class CreateGenericPlugin extends React.Component<IProps, IStateProps> {
</Form>
}
/>
</React.Fragment> : <NoABI contractToCall={contractToCall} />}
</React.Fragment> : <NoABI contractToCall={contractToCall} abiData={this.state.abiData} />}
</React.Fragment>}
</div>
);
Expand Down

0 comments on commit 9b9a53d

Please sign in to comment.