Skip to content

Commit be22b23

Browse files
yann300Aniket-Engg
authored andcommitted
forbid pinning if no persisted state
1 parent e18a025 commit be22b23

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

apps/remix-ide/src/blockchain/blockchain.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const profile = {
2525
name: 'blockchain',
2626
displayName: 'Blockchain',
2727
description: 'Blockchain - Logic',
28-
methods: ['getCode', 'getTransactionReceipt', 'addProvider', 'removeProvider', 'getCurrentFork', 'getAccounts', 'web3VM', 'web3', 'getProvider', 'getCurrentProvider', 'getCurrentNetworkStatus', 'getAllProviders', 'getPinnedProviders', 'changeExecutionContext'],
28+
methods: ['getCode', 'getTransactionReceipt', 'addProvider', 'removeProvider', 'getCurrentFork', 'getAccounts', 'web3VM', 'web3', 'getProvider', 'getCurrentProvider', 'getCurrentNetworkStatus', 'getAllProviders', 'getPinnedProviders', 'changeExecutionContext', 'getProviderObject'],
2929
version: packageJson.version
3030
}
3131

@@ -569,6 +569,10 @@ export class Blockchain extends Plugin {
569569
return allProviders[name]
570570
}
571571

572+
getProviderObject() {
573+
return this.executionContext.getProviderObject()
574+
}
575+
572576
getInjectedWeb3Address() {
573577
return this.executionContext.getSelectedAddress()
574578
}

libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ export function UniversalDappUI(props: UdappProps) {
129129
}
130130

131131
const pinContract = async() => {
132+
const provider = await props.plugin.call('blockchain', 'getProviderObject')
133+
if (!provider.config.statePath && provider.config.isRpcForkedState) {
134+
// we can't pin a contract in the following case:
135+
// - state is not persisted
136+
// - future state is browser stored (e.g it's not just a simple RPC provider)
137+
props.plugin.call('notification', 'toast', 'Cannot pin this contract in the current context: state is not persisted. Please fork this provider to start pinning a contract to it.')
138+
return
139+
}
132140
const workspace = await props.plugin.call('filePanel', 'getCurrentWorkspace')
133141
const objToSave = {
134142
name: props.instance.name,

0 commit comments

Comments
 (0)