Skip to content

Commit 81dbf70

Browse files
author
ci-bot
committed
Fixed deployed contracts state
1 parent 10001ec commit 81dbf70

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

libs/remix-ui/run-tab-deployed-contracts/src/lib/deployed-contracts.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,15 @@ function DeployedContractsWidget({ plugin }: DeployedContractsWidgetProps) {
6262
}
6363
})
6464

65-
plugin.on('filePanel', 'setWorkspace', async () => {
66-
const network = await plugin.call('udappEnv', 'getNetwork')
67-
const chainId = network?.chainId
68-
const providerName = network?.name === 'VM' ? await plugin.call('udappEnv', 'getSelectedProvider') : chainId
69-
70-
await loadPinnedContracts(plugin, dispatch, providerName)
65+
plugin.on('filePanel', 'setWorkspace', async (workspace) => {
66+
if (workspace.name && widgetState.lastLoadedWorkspace !== workspace.name) {
67+
const network = await plugin.call('udappEnv', 'getNetwork')
68+
const chainId = network?.chainId
69+
const providerName = network?.name === 'VM' ? await plugin.call('udappEnv', 'getSelectedProvider') : chainId
70+
71+
dispatch({ type: 'SET_LAST_LOADED_WORKSPACE', payload: workspace.name })
72+
await loadPinnedContracts(plugin, dispatch, providerName)
73+
}
7174
})
7275

7376
plugin.on('blockchain', 'transactionExecuted', async (error, _, to, __, ___, txResult) => {

libs/remix-ui/run-tab-deployed-contracts/src/lib/reducers/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const deployedContractsInitialState: DeployedContractsWidgetState = {
88
showClearAllDialog: false,
99
loadType: 'other',
1010
currentFile: '',
11-
lastLoadedChainId: null
11+
lastLoadedChainId: null,
12+
lastLoadedWorkspace: null
1213
}
1314

1415
export const deployedContractsReducer = (state: DeployedContractsWidgetState, action: Actions): DeployedContractsWidgetState => {
@@ -122,6 +123,12 @@ export const deployedContractsReducer = (state: DeployedContractsWidgetState, ac
122123
lastLoadedChainId: action.payload
123124
}
124125

126+
case 'SET_LAST_LOADED_WORKSPACE':
127+
return {
128+
...state,
129+
lastLoadedWorkspace: action.payload
130+
}
131+
125132
default:
126133
return state
127134
}

libs/remix-ui/run-tab-deployed-contracts/src/lib/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface DeployedContractsWidgetState {
2626
loadType: 'abi' | 'sol' | 'vyper' | 'lexon' | 'contract' | 'other',
2727
currentFile: string
2828
lastLoadedChainId: string | null
29+
lastLoadedWorkspace: string | null
2930
}
3031

3132
export interface DeployedContractsAppContextType {
@@ -51,3 +52,4 @@ export type Actions =
5152
| { type: 'SET_DECODED_RESPONSE'; payload: { instanceIndex: number; funcIndex: number; response: any } }
5253
| { type: 'UPDATE_CONTRACT_BALANCE'; payload: { address: string; balance: string } }
5354
| { type: 'SET_LAST_LOADED_CHAIN_ID'; payload: string | null }
55+
| { type: 'SET_LAST_LOADED_WORKSPACE'; payload: string | null }

0 commit comments

Comments
 (0)