diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 41a616772b..2c39c99b99 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -181,7 +181,7 @@ export class Blockchain extends Plugin { return this.call('terminal', 'logHtml', log) } await this.saveDeployedContractStorageLayout(implementationContractObject, address, networkInfo) - this.events.emit('newProxyDeployment', address, new Date().toISOString()) + this.events.emit('newProxyDeployment', address, new Date().toISOString(), implementationContractObject.contractName) _paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment successful']) this.call('udapp', 'addInstance', addressToString(address), implementationContractObject.abi, implementationContractObject.name) } diff --git a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts index aaa0c4733a..b624785e49 100644 --- a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts +++ b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts @@ -129,8 +129,21 @@ export const addSlash = (file: string) => { return file } -export const shortenAddressAndDate = (address: string, date: string) => { +export const shortenProxyAddress = (address: string) => { const len = address.length - return address.slice(0, 5) + '...' + address.slice(len - 5, len) + ' (' + new Date(date).toISOString().split('T')[0] + ')' + return address.slice(0, 5) + '...' + address.slice(len - 5, len) +} + +export const shortenDate = (dateString: string) => { + const date = new Date(dateString) + const now = new Date() + const diff = now.getTime() - date.getTime() + const oneDay = 24 * 60 * 60 * 1000 + + if (diff < oneDay) { + return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }) + } else { + return date.toLocaleDateString(undefined, { month: "short", day: "numeric" }) + ', ' + date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }) + } } diff --git a/libs/remix-ui/run-tab/src/lib/actions/actions.ts b/libs/remix-ui/run-tab/src/lib/actions/actions.ts index 0d12cbb4e1..16f144560c 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/actions.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/actions.ts @@ -91,6 +91,6 @@ export const setSendTransactionValue = (dispatch: React.Dispatch, value: st dispatch(setSendValue(value)) } -export const addNewProxyDeployment = (dispatch: React.Dispatch, address: string, date: Date) => { - dispatch(newProxyDeployment({ address, date })) +export const addNewProxyDeployment = (dispatch: React.Dispatch, address: string, date: string, contractName: string) => { + dispatch(newProxyDeployment({ address, date, contractName })) } \ No newline at end of file diff --git a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts index f6f2f0278f..8dc80b3e80 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts @@ -353,7 +353,7 @@ export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.D for (const proxyAddress in Object.keys(parsedNetworkFile.deployments)) { const solcBuildExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`) - if (solcBuildExists) deployments.push({ address: proxyAddress, date: parsedNetworkFile.deployments[proxyAddress].date }) + if (solcBuildExists) deployments.push({ address: proxyAddress, date: parsedNetworkFile.deployments[proxyAddress].date, contractName: parsedNetworkFile.deployments[proxyAddress].contractName }) } dispatch(fetchProxyDeploymentsSuccess(deployments)) } else { diff --git a/libs/remix-ui/run-tab/src/lib/actions/events.ts b/libs/remix-ui/run-tab/src/lib/actions/events.ts index f33cb0ac67..2fa196485c 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -45,7 +45,7 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch) => { plugin.blockchain.event.register('removeProvider', name => removeExternalProvider(dispatch, name)) - plugin.blockchain.events.on('newProxyDeployment', (address, date) => addNewProxyDeployment(dispatch, address, date)) + plugin.blockchain.events.on('newProxyDeployment', (address, date, contractName) => addNewProxyDeployment(dispatch, address, date, contractName)) plugin.on('solidity', 'compilationFinished', (file, source, languageVersion, data, input, version) => broadcastCompilationResult('remix', plugin, dispatch, file, source, languageVersion, data, input)) diff --git a/libs/remix-ui/run-tab/src/lib/actions/payload.ts b/libs/remix-ui/run-tab/src/lib/actions/payload.ts index 44fba14c9c..98189d529a 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/payload.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/payload.ts @@ -308,14 +308,14 @@ export const setRemixDActivated = (activated: boolean) => { } } -export const fetchProxyDeploymentsSuccess = (deployments: { address: string, date: Date }[]) => { +export const fetchProxyDeploymentsSuccess = (deployments: { address: string, date: string, contractName: string }[]) => { return { type: FETCH_PROXY_DEPLOYMENTS, payload: deployments } } -export const newProxyDeployment = (deployment: { address: string, date: Date }) => { +export const newProxyDeployment = (deployment: { address: string, date: string, contractName: string }) => { return { type: NEW_PROXY_DEPLOYMENT, payload: deployment diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 3e4db1cb50..7dda23a8a8 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -4,7 +4,7 @@ import { FormattedMessage, useIntl } from 'react-intl' import * as remixLib from '@remix-project/remix-lib' import { ContractGUIProps } from '../types' import { CopyToClipboard } from '@remix-ui/clipboard' -import { CustomTooltip, ProxyAddressToggle, ProxyDropdownMenu, shortenAddressAndDate } from '@remix-ui/helper' +import { CustomTooltip, ProxyAddressToggle, ProxyDropdownMenu, shortenDate, shortenProxyAddress } from '@remix-ui/helper' import { Dropdown } from 'react-bootstrap' const txFormat = remixLib.execution.txFormat @@ -521,7 +521,7 @@ export function ContractGUI (props: ContractGUIProps) { { props.proxy.deployments.length > 0 && - + { props.proxy.deployments.map((deployment, index) => ( - { proxyAddress === deployment.address ? ✓ { shortenAddressAndDate(deployment.address, deployment.date) } : { shortenAddressAndDate(deployment.address, deployment.date) } } + { proxyAddress === deployment.address ? ✓ { deployment.contractName + ' ' + shortenProxyAddress(deployment.address) + ' (' + shortenDate(deployment.date) + ')' } : { deployment.contractName + ' ' + shortenProxyAddress(deployment.address) + ' (' + shortenDate(deployment.date) + ')' } } )) } diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts index 4cacd820b6..0495fc479e 100644 --- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts +++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts @@ -612,7 +612,7 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A } case FETCH_PROXY_DEPLOYMENTS: { - const payload: { address: string, date: string }[] = action.payload + const payload: { address: string, date: string, contractName: string }[] = action.payload return { ...state, @@ -624,7 +624,7 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A } case NEW_PROXY_DEPLOYMENT: { - const payload: { address: string, date: string } = action.payload + const payload: { address: string, date: string, contractName: string } = action.payload return { ...state, diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts index 72abd2f1f8..2d17006664 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -101,7 +101,7 @@ export interface RunTabState { } remixdActivated: boolean, proxy: { - deployments: { address: string, date: string }[] + deployments: { address: string, date: string, contractName: string }[] } } @@ -265,7 +265,7 @@ export interface ContractDropdownProps { remixdActivated: boolean, isValidProxyAddress?: (address: string) => Promise, isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput) => void, - proxy: { deployments: { address: string, date: string }[] } + proxy: { deployments: { address: string, date: string, contractName: string }[] } } export interface RecorderProps { @@ -360,7 +360,7 @@ export interface ContractGUIProps { isDeploy?: boolean, deployOption?: { title: DeployMode, active: boolean }[], initializerOptions?: DeployOption, - proxy?: { deployments: { address: string, date: string }[] }, + proxy?: { deployments: { address: string, date: string, contractName: string }[] }, isValidProxyAddress?: (address: string) => Promise, isValidProxyUpgrade?: (proxyAddress: string) => void }