Retrieve error reports

pull/3390/head^2
ioedeveloper 2 years ago committed by Aniket
parent c282fd0f6f
commit fc865231e3
  1. 2
      apps/remix-ide/src/app/components/preload.tsx
  2. 1
      libs/remix-core-plugin/src/types/contract.ts
  3. 1
      libs/remix-ui/run-tab/src/lib/actions/actions.ts
  4. 19
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts
  5. 4
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  6. 5
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  7. 68
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
  8. 3
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  9. 5
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -35,7 +35,7 @@ export const Preload = () => {
})
}).catch(err => {
_paq.push(['trackEvent', 'Preload', 'error', err && err.message])
console.log('Error loading Remix:', err)
console.error('Error loading Remix:', err)
setError(true)
})
}

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

@ -92,6 +92,5 @@ export const setSendTransactionValue = (dispatch: React.Dispatch<any>, value: st
}
export const addNewProxyDeployment = (dispatch: React.Dispatch<any>, address: string, date: Date) => {
console.log('called deployement: ', address, date)
dispatch(newProxyDeployment({ address, date }))
}

@ -2,7 +2,9 @@ import { ContractData, FuncABI, NetworkDeploymentFile } from "@remix-project/cor
import { RunTab } from "../types/run-tab"
import { CompilerAbstract as CompilerAbstractType } from '@remix-project/remix-solidity'
import * as remixLib from '@remix-project/remix-lib'
import { UpgradeableContract } from '@openzeppelin/upgrades-core'
import { SolcInput, SolcOutput } from "@openzeppelin/upgrades-core"
// Used direct path to UpgradeableContract class to fix cyclic dependency error from @openzeppelin/upgrades-core library
import { UpgradeableContract } from '../../../../../../node_modules/@openzeppelin/upgrades-core/dist/standalone'
import { DeployMode, MainnetPrompt } from "../types"
import { displayNotification, displayPopUp, fetchProxyDeploymentsSuccess, setDecodedResponse } from "./payload"
import { addInstance } from "./actions"
@ -357,7 +359,7 @@ export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.D
}
}
export const isValidContractUpgrade = async (plugin: RunTab, dispatch: React.Dispatch<any>, proxyAddress: string) => {
export const isValidContractUpgrade = async (plugin: RunTab, dispatch: React.Dispatch<any>, proxyAddress: string, newContractName: string, solcInput: SolcInput, solcOutput: SolcOutput) => {
// build current contract first to get artefacts.
const network = plugin.blockchain.networkStatus.network
const identifier = network.name === 'custom' ? network.name + '-' + network.id : network.name
@ -368,9 +370,18 @@ export const isValidContractUpgrade = async (plugin: RunTab, dispatch: React.Dis
const parsedNetworkFile: NetworkDeploymentFile = JSON.parse(networkFile)
if (parsedNetworkFile.deployments[proxyAddress] && parsedNetworkFile.deployments[proxyAddress].solcInput) {
const oldImpl = new UpgradeableContract(parsedNetworkFile.deployments[proxyAddress].contractName, parsedNetworkFile.deployments[proxyAddress].solcInput, parsedNetworkFile.deployments[proxyAddress].solcOutput)
try {
const oldImpl = new UpgradeableContract(parsedNetworkFile.deployments[proxyAddress].contractName, parsedNetworkFile.deployments[proxyAddress].solcInput, parsedNetworkFile.deployments[proxyAddress].solcOutput, { kind: 'uups' })
const newImpl = new UpgradeableContract(newContractName, solcInput, solcOutput, { kind: 'uups' })
const report = oldImpl.getStorageUpgradeReport(newImpl, { kind: 'uups' })
console.log('report: ', report)
} catch (e) {
console.log('e: ', e)
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' }
}
console.log('oldImpl: ', oldImpl)
} else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' }
}

@ -6,11 +6,12 @@ import { createNewBlockchainAccount, fillAccountsList, setExecutionContext, sign
import { clearInstances, clearPopUp, removeInstance, setAccount, setGasFee, setMatchPassphrasePrompt,
setNetworkNameFromProvider, setPassphrasePrompt, setSelectedContract, setSendTransactionValue, setUnit,
updateBaseFeePerGas, updateConfirmSettings, updateGasPrice, updateGasPriceStatus, updateMaxFee, updateMaxPriorityFee, updateScenarioPath } from './actions'
import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions, updateInstanceBalance, syncContractsInternal, isValidContractAddress } from './deploy'
import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions, updateInstanceBalance, syncContractsInternal, isValidContractAddress, isValidContractUpgrade } from './deploy'
import { CompilerAbstract as CompilerAbstractType } from '@remix-project/remix-solidity'
import { ContractData, FuncABI } from "@remix-project/core-plugin"
import { DeployMode, MainnetPrompt } from '../types'
import { runCurrentScenario, storeScenario } from './recorder'
import { SolcInput, SolcOutput } from '@openzeppelin/upgrades-core'
declare global {
interface Window {
@ -63,3 +64,4 @@ export const setNetworkName = (networkName: string) => setNetworkNameFromProvide
export const updateSelectedContract = (contractName) => setSelectedContract(dispatch, contractName)
export const syncContracts = () => syncContractsInternal(plugin)
export const isValidProxyAddress = (address: string) => isValidContractAddress(plugin, address)
export const isValidProxyUpgrade = (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput) => isValidContractUpgrade(plugin, dispatch, proxyAddress, contractName, solcInput, solcOuput)

@ -234,6 +234,10 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
props.setSelectedContract(value)
}
const isValidProxyUpgrade = (proxyAddress: string) => {
props.isValidProxyUpgrade(proxyAddress, loadedContractData.contractName, loadedContractData.compiler.source, loadedContractData.compiler.data)
}
const checkSumWarning = () => {
return (
<span className="text-start">
@ -313,6 +317,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
lookupOnly={false}
proxy={props.proxy}
isValidProxyAddress={props.isValidProxyAddress}
isValidProxyUpgrade={isValidProxyUpgrade}
/>
<div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input

@ -21,9 +21,7 @@ export function ContractGUI (props: ContractGUIProps) {
const [toggleDeployProxy, setToggleDeployProxy] = useState<boolean>(false)
const [toggleUpgradeImp, setToggleUpgradeImp] = useState<boolean>(false)
const [deployState, setDeployState] = useState<{ deploy: boolean, upgrade: boolean }>({ deploy: false, upgrade: false })
const [useLastProxy, setUseLastProxy] = useState<boolean>(false)
const [proxyAddress, setProxyAddress] = useState<string>('')
const [selectedProxyAddress, setSelectedProxyAddress] = useState<string>('')
const [proxyAddressError, setProxyAddressError] = useState<string>('')
const multiFields = useRef<Array<HTMLInputElement | null>>([])
const initializeFields = useRef<Array<HTMLInputElement | null>>([])
@ -37,6 +35,12 @@ export function ContractGUI (props: ContractGUIProps) {
}
}, [props.deployOption])
useEffect(() => {
if (!proxyAddress && props.proxy && props.proxy.deployments.length > 0) {
setProxyAddress(props.proxy.deployments[0].address)
}
}, [proxyAddress, props.proxy])
useEffect(() => {
if (props.title) {
setTitle(props.title)
@ -178,6 +182,7 @@ export function ContractGUI (props: ContractGUIProps) {
props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy'])
} else if (deployState.upgrade) {
props.isValidProxyUpgrade(proxyAddress)
!proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy'])
} else {
props.clickCallBack(props.funcABI.inputs, basicInput)
@ -223,25 +228,8 @@ export function ContractGUI (props: ContractGUIProps) {
setDeployState({ deploy: false, upgrade: value })
}
const handleUseLastProxySelect = (e) => {
const value = e.target.checked
const address = '' /* props.savedProxyAddress */
if (value) {
if (address) {
setProxyAddress(address)
setProxyAddressError('')
} else {
setProxyAddressError('No proxy address available')
setProxyAddress('')
}
}
setUseLastProxy(value)
}
const handleSetProxyAddress = (e) => {
const handleSelectProxyAddress = (e) => {
const value = e.target.value
setProxyAddress(value)
}
@ -520,48 +508,14 @@ export function ContractGUI (props: ContractGUIProps) {
}`}
>
<div className={`flex-column 'd-flex'}`}>
<div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input
id="proxyAddress"
data-id="contractGUIProxyAddress"
className="form-check-input custom-control-input"
type="checkbox"
onChange={handleUseLastProxySelect}
checked={useLastProxy}
/>
<CustomTooltip
tooltipText={<FormattedMessage id='udapp.proxyAddressTooltip' />}
tooltipId="proxyAddressTooltip"
placement="auto"
tooltipClasses="text-wrap"
>
<label
htmlFor="proxyAddress"
data-id="contractGUIProxyAddressLabel"
className="m-0 form-check-label custom-control-label udapp_checkboxAlign"
style={{ fontSize: 12 }}
>
<FormattedMessage id='udapp.useLastDeployedERC1967Contract' />
</label>
</CustomTooltip>
</div>
{
!useLastProxy ?
<div className="mb-2">
<label className="mt-2 text-left d-block">
<FormattedMessage id='udapp.proxyAddressLabel' /> :
</label>
<CustomTooltip placement="right" tooltipText={<FormattedMessage id='udapp.proxyAddressInputTooltip' />}>
<input style={{ height: 32 }} className="form-control udapp_input" data-id="ERC1967AddressInput" placeholder={intl.formatMessage({ id: 'udapp.proxyAddressPlaceholder' })} onChange={handleSetProxyAddress} onBlur={() => validateProxyAddress(proxyAddress) } />
</CustomTooltip>
{ proxyAddressError && <span className='text-lowercase' data-id="errorMsgProxyAddress" style={{ fontSize: '.8em' }}>{ proxyAddressError }</span> }
</div> :
<select data-id="udappSelectProxyAddress" name="selectproxy" className="form-control udapp_select custom-select pr-4" value={selectedProxyAddress} onChange={(e) => { }}>
<select data-id="udappSelectProxyAddress" name="selectproxy" className="form-control udapp_select custom-select pr-4" value={proxyAddress} onChange={handleSelectProxyAddress}>
{
props.proxy.deployments.map((deployment, index) => <option value={deployment.address} key={index}>{ shortenDeploymentAddresses(deployment.address, deployment.date) }</option>)
}
</select>
}
{ proxyAddressError && <span className='text-lowercase' data-id="errorMsgProxyAddress" style={{ fontSize: '.8em' }}>{ proxyAddressError }</span> }
</div>
</div>
</div>
</>

@ -27,7 +27,7 @@ import {
storeNewScenario, runScenario,
setScenarioPath, getFuncABIValues,
setNetworkName, updateSelectedContract,
syncContracts, isValidProxyAddress
syncContracts, isValidProxyAddress, isValidProxyUpgrade
} from './actions'
import './css/run-tab.css'
import { PublishToStorage } from '@remix-ui/publish-to-storage'
@ -242,6 +242,7 @@ export function RunTabUI (props: RunTabProps) {
setSelectedContract={updateSelectedContract}
remixdActivated={runTab.remixdActivated}
isValidProxyAddress={isValidProxyAddress}
isValidProxyUpgrade={isValidProxyUpgrade}
proxy={runTab.proxy}
/>
<RecorderUI

@ -2,6 +2,7 @@ import { Ref } from 'react'
import { CompilerAbstract } from '@remix-project/remix-solidity'
import { ContractData, FuncABI } from '@remix-project/core-plugin'
import { RunTab } from './run-tab'
import { SolcInput, SolcOutput } from '@openzeppelin/upgrades-core'
export interface RunTabProps {
plugin: RunTab
}
@ -263,6 +264,7 @@ export interface ContractDropdownProps {
setSelectedContract: (contractName: string) => void
remixdActivated: boolean,
isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput) => void,
proxy: { deployments: { address: string, date: Date }[] }
}
@ -359,7 +361,8 @@ export interface ContractGUIProps {
deployOption?: { title: DeployMode, active: boolean }[],
initializerOptions?: DeployOption,
proxy?: { deployments: { address: string, date: Date }[] },
isValidProxyAddress?: (address: string) => Promise<boolean>
isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string) => void
}
export interface MainnetProps {
network: Network,

Loading…
Cancel
Save