From 947cc035f61bd967f9773cfdec44711c1317f17f Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 22 Feb 2024 19:58:11 +0530 Subject: [PATCH] show file path --- .../src/app/tabs/locales/en/udapp.json | 4 +--- apps/remix-ide/src/app/udapp/run-tab.js | 4 ++-- .../remix-ui/run-tab/src/lib/actions/actions.ts | 2 +- libs/remix-ui/run-tab/src/lib/actions/events.ts | 4 ++-- .../src/lib/components/instanceContainerUI.tsx | 2 +- .../src/lib/components/universalDappUI.tsx | 17 ++++++++++++++--- libs/remix-ui/run-tab/src/lib/types/index.ts | 6 ++++-- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/udapp.json b/apps/remix-ide/src/app/tabs/locales/en/udapp.json index 1c98641612..bf055160cf 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/udapp.json +++ b/apps/remix-ide/src/app/tabs/locales/en/udapp.json @@ -74,9 +74,7 @@ "udapp.NoSavedInstanceText": "Currently you have no saved contracts to interact with.", "udapp.tooltipTextUnsave": "Delete from saved list", "udapp.savedOn": "Saved On", - - - + "udapp.filePath": "File Path", "udapp._comment_recorderCardUI.tsx": "libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx", "udapp.transactionsRecorded": "Transactions recorded", diff --git a/apps/remix-ide/src/app/udapp/run-tab.js b/apps/remix-ide/src/app/udapp/run-tab.js index 3cd767a689..05f1a27cf6 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.js +++ b/apps/remix-ide/src/app/udapp/run-tab.js @@ -84,8 +84,8 @@ export class RunTab extends ViewPlugin { this.emit('addInstanceReducer', address, abi, name) } - addSavedInstance(address, abi, name, savedOn) { - this.emit('addSavedInstanceReducer', address, abi, name, savedOn) + addSavedInstance(address, abi, name, savedOn, filePath) { + this.emit('addSavedInstanceReducer', address, abi, name, savedOn, filePath) } createVMAccount(newAccount) { 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 a6806e02ce..8c5e78f766 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/actions.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/actions.ts @@ -70,7 +70,7 @@ export const addInstance = (dispatch: React.Dispatch, instance: { contractD dispatch(addNewInstance(instance)) } -export const addSavedInstance = (dispatch: React.Dispatch, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record, savedOn?: number }) => { +export const addSavedInstance = (dispatch: React.Dispatch, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record, savedOn?: number, filePath?: string }) => { instance.decodedResponse = {} dispatch(addNewSavedInstance(instance)) } 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 39904dd650..5e1ae99e3d 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -83,8 +83,8 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch) => { addInstance(dispatch, { abi, address, name }) }) - plugin.on('udapp', 'addSavedInstanceReducer', (address, abi, name, savedOn) => { - addSavedInstance(dispatch, { abi, address, name, savedOn }) + plugin.on('udapp', 'addSavedInstanceReducer', (address, abi, name, savedOn, filePath) => { + addSavedInstance(dispatch, { abi, address, name, savedOn, filePath}) }) plugin.on('filePanel', 'setWorkspace', () => { diff --git a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx index 3cfbd8f564..b96fef6645 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -20,7 +20,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) { if (savedContracts[env.current] && savedContracts[env.current][network.id]) { const instances = savedContracts[env.current][network.id] for (const inst of instances) - if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name, inst.savedOn) + if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name, inst.savedOn, inst.filePath) } } } diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 361af61a07..b728c18a6b 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -59,6 +59,7 @@ export function UniversalDappUI(props: UdappProps) { }, [props.instance.balance]) useEffect(() => { + console.log('props--->', props.instance) const getEnv = async () => { env.current = await props.plugin.call('blockchain', 'getProvider') } @@ -134,6 +135,8 @@ export function UniversalDappUI(props: UdappProps) { const saveContract = async() => { const env = await props.plugin.call('blockchain', 'getProvider') + const workspace = await props.plugin.call('filePanel', 'getCurrentWorkspace') + console.log('workspace--->', workspace) const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus') const savedContracts = localStorage.getItem('savedContracts') let objToSave @@ -151,10 +154,11 @@ export function UniversalDappUI(props: UdappProps) { } } props.instance.savedOn = Date.now() + props.instance.filePath = `${workspace.name}/${props.instance.contractData.contract.file}` objToSave[env][network.id].push(props.instance) localStorage.setItem('savedContracts', JSON.stringify(objToSave)) // Add contract to saved contracts list on UI - await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name, props.instance.savedOn) + await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name, props.instance.savedOn, props.instance.filePath) // Remove contract from deployed contracts list on UI props.removeInstance(props.index, false) } @@ -294,13 +298,20 @@ export function UniversalDappUI(props: UdappProps) {
{ props.isSavedContract && props.instance.savedOn ? (
+
+ ) : null } + { props.isSavedContract && props.instance.filePath ? ( +
+
) : null } 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 390c8bd676..e09d5bf191 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -315,7 +315,8 @@ export interface InstanceContainerProps { name: string, decodedResponse?: Record, abi?: any, - savedOn?: number + savedOn?: number, + filePath?: string }[], error: string }, @@ -422,7 +423,8 @@ export interface UdappProps { name: string, decodedResponse?: Record, abi?: any, - savedOn?: number + savedOn?: number, + filePath?: string }, context: 'memory' | 'blockchain', isSavedContract?: boolean