diff --git a/src/containers/actionBuilder/scc/index.tsx b/src/containers/actionBuilder/scc/index.tsx index 26e64a8f8..a4cfdb2ea 100644 --- a/src/containers/actionBuilder/scc/index.tsx +++ b/src/containers/actionBuilder/scc/index.tsx @@ -28,10 +28,9 @@ const SCCAction: React.FC = ({ useEffect(() => { const validateAction = async () => { - const isValid = await validateSCCAction(actionData, network); + const isValid = await validateSCCAction(actionData); setIsValid(isValid); }; - validateAction(); }, [actionData, network]); diff --git a/src/containers/proposalStepper/index.tsx b/src/containers/proposalStepper/index.tsx index 8ef6cfc31..2815e71e7 100644 --- a/src/containers/proposalStepper/index.tsx +++ b/src/containers/proposalStepper/index.tsx @@ -81,12 +81,7 @@ const ProposalStepper: React.FC = () => { *************************************************/ useEffect(() => { const validateActions = async () => { - const isValid = await actionsAreValid( - formActions, - actions, - errors, - network - ); + const isValid = await actionsAreValid(formActions, actions, errors); setAreActionsValid(isValid); }; diff --git a/src/containers/smartContractComposer/components/inputForm.tsx b/src/containers/smartContractComposer/components/inputForm.tsx index bb26050fc..6ef768a6b 100644 --- a/src/containers/smartContractComposer/components/inputForm.tsx +++ b/src/containers/smartContractComposer/components/inputForm.tsx @@ -97,6 +97,7 @@ const InputForm: React.FC = ({ setValue(`actions.${actionIndex}.contractName`, selectedSC.name); setValue(`actions.${actionIndex}.functionName`, selectedAction.name); setValue(`actions.${actionIndex}.notice`, selectedAction.notice); + setValue(`actions.${actionIndex}.actions`, selectedSC.actions); // loop through all the inputs so we pick up the payable one as well // and keep it on the form @@ -153,6 +154,7 @@ const InputForm: React.FC = ({ sccActions, selectedAction.name, selectedAction.notice, + selectedSC.actions, selectedSC.address, selectedSC.name, setValue, diff --git a/src/containers/withdrawStepper/index.tsx b/src/containers/withdrawStepper/index.tsx index 586096a43..810c9e0a7 100644 --- a/src/containers/withdrawStepper/index.tsx +++ b/src/containers/withdrawStepper/index.tsx @@ -82,8 +82,7 @@ const WithdrawStepper: React.FC = ({ wizardTitle={t('newWithdraw.configureWithdraw.title')} wizardDescription={t('newWithdraw.configureWithdraw.subtitle')} isNextButtonDisabled={ - !actions.length || - !actionsAreValid(formActions, actions, errors, network) + !actions.length || !actionsAreValid(formActions, actions, errors) } onNextButtonClicked={next => { trackEvent('newWithdraw_continueBtn_clicked', { diff --git a/src/utils/types.ts b/src/utils/types.ts index 270ca10ca..4c1ef444e 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -390,6 +390,7 @@ export type ActionSCC = { functionName: string; inputs?: Array; value?: string; + actions?: Array; }; // Alias diff --git a/src/utils/validators.ts b/src/utils/validators.ts index 8dc25191e..138c69357 100644 --- a/src/utils/validators.ts +++ b/src/utils/validators.ts @@ -7,7 +7,7 @@ import {TFunction} from 'i18next'; import {TokenVotingClient} from '@aragon/sdk-client'; import {i18n} from '../../i18n.config'; -import {ALPHA_NUMERIC_PATTERN, SupportedNetworks} from './constants'; +import {ALPHA_NUMERIC_PATTERN} from './constants'; import { Web3Address, getDefaultPayableAmountInputName, @@ -24,7 +24,6 @@ import { ActionWithdraw, Nullable, } from './types'; -import {getEtherscanVerifiedContract} from 'services/etherscanAPI'; import {ensRegistryABI} from 'abis/ensRegistryABI'; export type TokenType = @@ -198,8 +197,7 @@ export const alphaNumericValidator = ( export async function actionsAreValid( formActions: Nullable, contextActions: ActionItem[], - errors: FieldErrors, - network: SupportedNetworks + errors: FieldErrors ) { // proposals can go through without any actions if (contextActions?.length === 0) return true; @@ -245,7 +243,7 @@ export async function actionsAreValid( ); case 'external_contract_action': { const SCCAction = formActions?.[index] as ActionSCC; - const result = await validateSCCAction(SCCAction, network); + const result = await validateSCCAction(SCCAction); return result; } default: @@ -263,22 +261,13 @@ export async function actionsAreValid( return isValid; } -export async function validateSCCAction( - SCCAction: ActionSCC, - network: SupportedNetworks -) { - const etherscanData = await getEtherscanVerifiedContract( - SCCAction.contractAddress, - network - ); +export async function validateSCCAction(SCCAction: ActionSCC) { + // looping through selectedAction.inputs instead of the actionInputs + // will allow us to ignore the payable input so that encoding using + // The ABI is coming from the selected action distinguishing between + // proxy or implementation ABI - if ( - etherscanData.status === '1' && - etherscanData.result[0].ABI !== 'Contract source code not verified' - ) { - // looping through selectedAction.inputs instead of the actionInputs - // will allow us to ignore the payable input so that encoding using - // the ABI does not complain + if (SCCAction?.actions) { const functionParams = SCCAction.inputs ?.filter(input => input.name !== getDefaultPayableAmountInputName(i18n.t)) .map(input => { @@ -290,7 +279,7 @@ export async function validateSCCAction( return param; }); - const iface = new ethers.utils.Interface(etherscanData.result[0].ABI); + const iface = new ethers.utils.Interface(SCCAction.actions); try { iface.encodeFunctionData(SCCAction.functionName, functionParams); @@ -299,6 +288,7 @@ export async function validateSCCAction( return false; } } + return false; }