Template error reporting

pull/5370/head
ioedeveloper 2 years ago committed by Aniket
parent e579a7baba
commit 5f4f87dc61
  1. 1
      libs/remix-core-plugin/src/types/contract.ts
  2. 7
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts
  3. 3
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  4. 43
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
  5. 6
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -10,7 +10,6 @@ export interface FuncABI {
export interface ContractData { export interface ContractData {
name: string, name: string,
contractName?: string,
contract: any, contract: any,
compiler: any, compiler: any,
abi: FuncABI[], abi: FuncABI[],

@ -381,15 +381,14 @@ export const isValidContractUpgrade = async (plugin: RunTab, dispatch: React.Dis
const newImpl = new UpgradeableContract(newContractName, solcInput, solcOutput, { kind: 'uups' }) const newImpl = new UpgradeableContract(newContractName, solcInput, solcOutput, { kind: 'uups' })
const report = oldImpl.getStorageUpgradeReport(newImpl, { kind: 'uups' }) const report = oldImpl.getStorageUpgradeReport(newImpl, { kind: 'uups' })
console.log('report: ', report)
return report return report
} else { } else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' } return { ok: false, pass: false, warning: 'Previous contract implementation not available for upgrade comparison.' }
} }
} else { } else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' } return { ok: false, pass: false, warning: 'Previous contract implementation not available for upgrade comparison.' }
} }
} else { } else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' } return { ok: false, pass: false, warning: 'Previous contract implementation not available for upgrade comparison.' }
} }
} }

@ -235,7 +235,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
} }
const isValidProxyUpgrade = (proxyAddress: string) => { const isValidProxyUpgrade = (proxyAddress: string) => {
props.isValidProxyUpgrade(proxyAddress, loadedContractData.contractName, loadedContractData.compiler.source, loadedContractData.compiler.data) return props.isValidProxyUpgrade(proxyAddress, loadedContractData.name, loadedContractData.compiler.source, loadedContractData.compiler.data)
} }
const checkSumWarning = () => { const checkSumWarning = () => {
@ -318,6 +318,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
proxy={props.proxy} proxy={props.proxy}
isValidProxyAddress={props.isValidProxyAddress} isValidProxyAddress={props.isValidProxyAddress}
isValidProxyUpgrade={isValidProxyUpgrade} isValidProxyUpgrade={isValidProxyUpgrade}
modal={props.modal}
/> />
<div className="d-flex py-1 align-items-center custom-control custom-checkbox"> <div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input <input

@ -178,14 +178,41 @@ export function ContractGUI (props: ContractGUIProps) {
} }
} }
const handleActionClick = () => { const handleActionClick = async () => {
if (deployState.deploy) { if (deployState.deploy) {
const proxyInitializeString = getMultiValsString(initializeFields.current) const proxyInitializeString = getMultiValsString(initializeFields.current)
props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy'])
} else if (deployState.upgrade) { } else if (deployState.upgrade) {
props.isValidProxyUpgrade(proxyAddress) if (proxyAddress === '') {
setProxyAddressError('proxy address cannot be empty')
} else {
const isValidProxyAddress = await props.isValidProxyAddress(proxyAddress)
if (isValidProxyAddress) {
setProxyAddressError('')
const upgradeReport: any = await props.isValidProxyUpgrade(proxyAddress)
if (upgradeReport.ok) {
!proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy'])
} else {
if (upgradeReport.warning) {
props.modal('Warning', upgradeReport.warning, 'Proceed', () => {
!proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy'])
}, 'Cancel', () => {})
} else {
props.modal('Proxy Upgrade Error', `New deployment storage layout is incompactible with previous deployment.\n
${upgradeReport.ops.map((failedCase) => `"${failedCase.kind}": ${failedCase.original.label}`).join('\n')}\n
Do you want to continue?`, 'Proceed', () => {
!proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy'])
}, 'Cancel', () => {})
}
// console.log('upgradeReport: ', upgradeReport)
}
} else {
setProxyAddressError('not a valid contract address')
}
}
} else { } else {
props.clickCallBack(props.funcABI.inputs, basicInput) props.clickCallBack(props.funcABI.inputs, basicInput)
} }
@ -233,18 +260,6 @@ export function ContractGUI (props: ContractGUIProps) {
setProxyAddress(address) setProxyAddress(address)
} }
const validateProxyAddress = async (address: string) => {
if (address === '') {
setProxyAddressError('proxy address cannot be empty')
} else {
if (await props.isValidProxyAddress(address)) {
setProxyAddressError('')
} else {
setProxyAddressError('not a valid contract address')
}
}
}
const toggleDropdown = (isOpen: boolean) => { const toggleDropdown = (isOpen: boolean) => {
setShowDropdown(isOpen) setShowDropdown(isOpen)
} }

@ -3,6 +3,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity'
import { ContractData, FuncABI } from '@remix-project/core-plugin' import { ContractData, FuncABI } from '@remix-project/core-plugin'
import { RunTab } from './run-tab' import { RunTab } from './run-tab'
import { SolcInput, SolcOutput } from '@openzeppelin/upgrades-core' import { SolcInput, SolcOutput } from '@openzeppelin/upgrades-core'
import { LayoutCompatibilityReport } from '@openzeppelin/upgrades-core/dist/storage/report'
export interface RunTabProps { export interface RunTabProps {
plugin: RunTab plugin: RunTab
} }
@ -264,7 +265,7 @@ export interface ContractDropdownProps {
setSelectedContract: (contractName: string) => void setSelectedContract: (contractName: string) => void
remixdActivated: boolean, remixdActivated: boolean,
isValidProxyAddress?: (address: string) => Promise<boolean>, isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput) => void, isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput) => Promise<LayoutCompatibilityReport | { ok: boolean, pass: boolean, warning: string }>,
proxy: { deployments: { address: string, date: string, contractName: string }[] } proxy: { deployments: { address: string, date: string, contractName: string }[] }
} }
@ -362,7 +363,8 @@ export interface ContractGUIProps {
initializerOptions?: DeployOption, initializerOptions?: DeployOption,
proxy?: { deployments: { address: string, date: string, contractName: string }[] }, proxy?: { deployments: { address: string, date: string, contractName: string }[] },
isValidProxyAddress?: (address: string) => Promise<boolean>, isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string) => void isValidProxyUpgrade?: (proxyAddress: string) => Promise<LayoutCompatibilityReport | { ok: boolean, pass: boolean, warning: string }>,
modal?: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void
} }
export interface MainnetProps { export interface MainnetProps {
network: Network, network: Network,

Loading…
Cancel
Save