Skip to content

Commit e18a025

Browse files
yann300Aniket-Engg
authored andcommitted
display error msg
1 parent 7baf913 commit e18a025

File tree

1 file changed

+11
-7
lines changed
  • libs/remix-ui/run-tab/src/lib/actions

1 file changed

+11
-7
lines changed

libs/remix-ui/run-tab/src/lib/actions/events.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,23 @@ const loadPinnedContracts = async (plugin, dispatch, dirName) => {
183183
try {
184184
const list = await plugin.call('fileManager', 'readdir', `.deploys/pinned-contracts/${dirName}`)
185185
const filePaths = Object.keys(list)
186+
let codeError = false
186187
for (const file of filePaths) {
187188
const pinnedContract = await plugin.call('fileManager', 'readFile', file)
188189
const pinnedContractObj = JSON.parse(pinnedContract)
189190
const code = await plugin.call('blockchain', 'getCode', pinnedContractObj.address)
190191
if (code === '0x') {
191-
const msg = `Cannot load contract at ${pinnedContractObj.address} .
192-
Contract not found at that address. If you are using a forked environment, please make sure that this contract was originally deployed in this fork.
193-
`
194-
await plugin.call('terminal', 'terminal', { type: 'error', value: msg })
195-
return
192+
codeError = true
193+
const msg = `Cannot load pinned contract at ${pinnedContractObj.address}: Contract not found at that address.`
194+
await plugin.call('terminal', 'log', { type: 'error', value: msg })
195+
} else {
196+
pinnedContractObj.isPinned = true
197+
if (pinnedContractObj) addInstance(dispatch, pinnedContractObj)
196198
}
197-
pinnedContractObj.isPinned = true
198-
if (pinnedContractObj) addInstance(dispatch, pinnedContractObj)
199+
}
200+
if (codeError) {
201+
const msg = `Some pinned contracts cannot be loaded.\nCotracts deployed to a (Mainnet, Custom, Sepolia) fork are not persisted unless there were already on chain.\nDirectly forking one of these forks will enable you to use the pinned contracts feature.`
202+
await plugin.call('terminal', 'log', { type: 'log', value: msg })
199203
}
200204
} catch (err) {
201205
console.log(err)

0 commit comments

Comments
 (0)