-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add deploy and verify contract #6394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b466ae3
2e6306d
7cc59ee
5cac7aa
04ba18b
1ab13fc
7be76eb
ea3b96a
d753a8f
03f53b0
fd89f8b
a030af0
d01568e
3e11d81
8eb4b36
c9e757b
3e61f03
1e8b2ca
37817d8
c4e1ad9
a97b17a
c61dd05
6a9f89e
07a3278
0a3dad1
73b0d35
9694dae
cb610dd
ea96642
2c034cf
faaf384
74f3812
4dbdbbe
833e44f
07a64a9
f70f839
7c7e2b3
6535bf8
838dca0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict' | ||
import { NightwatchBrowser } from 'nightwatch' | ||
import init from '../helpers/init' | ||
|
||
declare global { | ||
interface Window { testplugin: { name: string, url: string }; } | ||
} | ||
|
||
module.exports = { | ||
'@disabled': true, | ||
before: function (browser: NightwatchBrowser, done: VoidFunction) { | ||
init(browser, done, null) | ||
}, | ||
|
||
'Should show warning for unsupported network when deploying with "Verify" on Remix VM #group1': function (browser: NightwatchBrowser) { | ||
browser | ||
.waitForElementVisible('*[data-id="remixIdeSidePanel"]') | ||
.clickLaunchIcon('filePanel') | ||
.click('*[data-id="treeViewLitreeViewItemcontracts"]') | ||
.openFile('contracts/1_Storage.sol') | ||
.clickLaunchIcon('udapp') | ||
.waitForElementVisible('*[data-id="Deploy - transact (not payable)"]') | ||
.waitForElementVisible('#deployAndRunVerifyContract') | ||
.click('#deployAndRunVerifyContract') | ||
.click('*[data-id="Deploy - transact (not payable)"]') | ||
.waitForElementVisible({ | ||
selector: "//*[contains(text(),'is not supported for verification via this plugin')]", | ||
locateStrategy: 'xpath', | ||
timeout: 10000 | ||
}) | ||
.end() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,8 @@ export const createInstance = async ( | |
mainnetPrompt: MainnetPrompt, | ||
isOverSizePrompt: (values: OverSizeLimit) => JSX.Element, | ||
args, | ||
deployMode: DeployMode[]) => { | ||
deployMode: DeployMode[], | ||
isVerifyChecked: boolean) => { | ||
const isProxyDeployment = (deployMode || []).find(mode => mode === 'Deploy with Proxy') | ||
const isContractUpgrade = (deployMode || []).find(mode => mode === 'Upgrade with Proxy') | ||
const statusCb = (msg: string) => { | ||
|
@@ -173,22 +174,71 @@ export const createInstance = async ( | |
const finalCb = async (error, contractObject, address) => { | ||
if (error) { | ||
const log = logBuilder(error) | ||
|
||
return terminalLogger(plugin, log) | ||
} | ||
|
||
addInstance(dispatch, { contractData: contractObject, address, name: contractObject.name }) | ||
const data = await plugin.compilersArtefacts.getCompilerAbstract(contractObject.contract.file) | ||
|
||
plugin.compilersArtefacts.addResolvedContract(addressToString(address), data) | ||
if (plugin.REACT_API.ipfsChecked) { | ||
_paq.push(['trackEvent', 'udapp', 'DeployAndPublish', plugin.REACT_API.networkName]) | ||
publishToStorage('ipfs', selectedContract) | ||
|
||
if (isVerifyChecked) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the UI, that should be checked by default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But probably the setting should be remenbered when the page is loaded. |
||
_paq.push(['trackEvent', 'udapp', 'DeployAndVerify', plugin.REACT_API.networkName]) | ||
|
||
try { | ||
await publishToStorage('ipfs', selectedContract) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we keeping this in order to make sure sourcify verifies it? If we can use the sourcify api to verify it that would be better, we won't have to rely on a IPFS endpoint. |
||
} catch (e) { | ||
const errorMsg = `Could not publish contract metadata to IPFS. Continuing with verification... (Error: ${e.message})` | ||
const errorLog = logBuilder(errorMsg) | ||
terminalLogger(plugin, errorLog) | ||
} | ||
|
||
try { | ||
const status = plugin.blockchain.getCurrentNetworkStatus() | ||
if (status.error || !status.network) { | ||
throw new Error(`Could not get network status: ${status.error || 'Unknown error'}`) | ||
} | ||
const currentChainId = parseInt(status.network.id) | ||
|
||
const response = await fetch('https://chainid.network/chains.json') | ||
if (!response.ok) throw new Error('Could not fetch chains list from chainid.network.') | ||
const allChains = await response.json() | ||
const currentChain = allChains.find(chain => chain.chainId === currentChainId) | ||
|
||
if (!currentChain) { | ||
const errorMsg = `The current network (Chain ID: ${currentChainId}) is not supported for verification via this plugin. Please switch to a supported network like Sepolia or Mainnet.` | ||
const errorLog = logBuilder(errorMsg) | ||
terminalLogger(plugin, errorLog) | ||
return | ||
} | ||
|
||
const etherscanApiKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') | ||
|
||
const verificationData = { | ||
chainId: currentChainId.toString(), | ||
currentChain: currentChain, | ||
contractAddress: addressToString(address), | ||
contractName: selectedContract.name, | ||
compilationResult: await plugin.compilersArtefacts.getCompilerAbstract(selectedContract.contract.file), | ||
constructorArgs: args, | ||
etherscanApiKey: etherscanApiKey | ||
} | ||
|
||
setTimeout(async () => { | ||
await plugin.call('contract-verification', 'verifyOnDeploy', verificationData) | ||
}, 1000) | ||
|
||
} catch (e) { | ||
const errorMsg = `Verification setup failed: ${e.message}` | ||
const errorLog = logBuilder(errorMsg) | ||
terminalLogger(plugin, errorLog) | ||
} | ||
|
||
} else { | ||
_paq.push(['trackEvent', 'udapp', 'DeployOnly', plugin.REACT_API.networkName]) | ||
} | ||
|
||
if (isProxyDeployment) { | ||
const initABI = contractObject.abi.find(abi => abi.name === 'initialize') | ||
|
||
plugin.call('openzeppelin-proxy', 'executeUUPSProxy', addressToString(address), args, initABI, contractObject) | ||
} else if (isContractUpgrade) { | ||
plugin.call('openzeppelin-proxy', 'executeUUPSContractUpgrade', args, addressToString(address), contractObject) | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have receipts for submittedContract and store it in local storage, such that it also shows up in the plugin's UI. See the
VerifyView
for reference.I also thought of refactoring the
VerifyView
once, since a lot of the logic from there could actually be reused for this feature.Anyway, very nice that you tackled this feature!