Merge pull request #3785 from ethereum/move_script_template

Move scripts to ws-template
pull/3795/head
yann300 1 year ago committed by GitHub
commit ebd3ed7858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      apps/etherscan/src/app/views/VerifyView.tsx
  2. 8
      apps/etherscan/webpack.config.js
  3. 24
      apps/remix-ide/webpack.config.js
  4. 11
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  5. 7
      libs/remix-ui/workspace/src/lib/scripts/index.ts
  6. 3
      libs/remix-ws-templates/src/index.ts
  7. 0
      libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts
  8. 0
      libs/remix-ws-templates/src/script-templates/contract-deployer/create2-factory-deploy.ts
  9. 0
      libs/remix-ws-templates/src/script-templates/contract-deployer/index.ts
  10. 0
      libs/remix-ws-templates/src/script-templates/etherscan/index.ts
  11. 0
      libs/remix-ws-templates/src/script-templates/etherscan/receiptGuidScript.ts
  12. 0
      libs/remix-ws-templates/src/script-templates/etherscan/verifyScript.ts

@ -10,7 +10,7 @@ import { Formik, ErrorMessage, Field } from "formik"
import { SubmitButton } from "../components"
import { Receipt } from "../types"
import { verify } from "../utils/verify"
import { receiptGuidScript, verifyScript } from "../utils/scripts"
import { etherscanScripts } from "@remix-project/remix-ws-templates"
interface Props {
client: PluginClient
@ -270,19 +270,7 @@ export const VerifyView: React.FC<Props> = ({
style={{ padding: "0.25rem 0.4rem", marginRight: "0.5em", marginBottom: "0.5em"}}
className="btn btn-secondary btn-block"
onClick={async () => {
if (!await client.call('fileManager', 'exists' as any, 'scripts/etherscan/receiptStatus.ts')) {
await client.call('fileManager', 'writeFile', 'scripts/etherscan/receiptStatus.ts', receiptGuidScript)
await client.call('fileManager', 'open', 'scripts/etherscan/receiptStatus.ts')
} else {
client.call('notification' as any, 'toast', 'File receiptStatus.ts already exists')
}
if (!await client.call('fileManager', 'exists' as any, 'scripts/etherscan/verify.ts')) {
await client.call('fileManager', 'writeFile', 'scripts/etherscan/verify.ts', verifyScript)
await client.call('fileManager', 'open', 'scripts/etherscan/verify.ts')
} else {
client.call('notification' as any, 'toast', 'File verify.ts already exists')
}
etherscanScripts(client)
}}
>
Generate Verification Scripts

@ -3,6 +3,10 @@ const webpack = require('webpack')
const TerserPlugin = require("terser-webpack-plugin")
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")
const versionData = {
timestamp: Date.now(),
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development'
}
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Update the webpack config as needed here.
@ -30,7 +34,6 @@ module.exports = composePlugins(withNx(), (config) => {
"vm": require.resolve('vm-browserify'),
}
// add externals
config.externals = {
...config.externals,
@ -40,6 +43,9 @@ module.exports = composePlugins(withNx(), (config) => {
// add public path
config.output.publicPath = '/'
// set filename
config.output.filename = `[name].plugin-etherscan.${versionData.timestamp}.js`
config.output.chunkFilename = `[name].plugin-etherscan.${versionData.timestamp}.js`
// add copy & provide plugin

@ -83,6 +83,7 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
config.output.filename = `[name].${versionData.version}.${versionData.timestamp}.js`
config.output.chunkFilename = `[name].${versionData.version}.${versionData.timestamp}.js`
// add copy & provide plugin
config.plugins.push(
new CopyPlugin({
@ -91,6 +92,7 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
...copyPatterns
].filter(Boolean)
}),
new CopyFileAfterBuild(),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
url: ['url', 'URL'],
@ -131,4 +133,26 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
return config;
});
class CopyFileAfterBuild {
apply(compiler) {
const onEnd = async () => {
try {
console.log('runnning CopyFileAfterBuild')
// This copy the raw-loader files used by the etherscan plugin to the remix-ide root folder.
// This is needed because by default the etherscan resources are served from the /plugins/etherscan/ folder,
// but the raw-loader try to access the resources from the root folder.
const files = fs.readdirSync('./dist/apps/etherscan')
files.forEach(file => {
if (file.startsWith('node_modules_raw-loader_')) {
fs.copyFileSync('./dist/apps/etherscan/' + file, './dist/apps/remix-ide/' + file)
}
})
} catch (e) {
console.error('running CopyFileAfterBuild failed with error: ' + e.message)
}
}
compiler.hooks.afterEmit.tapPromise('FileManagerPlugin', onEnd);
}
}

@ -13,7 +13,7 @@ import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } from '../utils/consta
import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB'
import { getUncommittedFiles } from '../utils/gitStatusFilter'
import { AppModal, ModalTypes } from '@remix-ui/app'
import { scripts } from '../scripts'
import { contractDeployerScripts, etherscanScripts } from '@remix-project/remix-ws-templates'
declare global {
interface Window { remixFileSystemCallback: IndexedDBStorage; }
@ -678,9 +678,14 @@ export const createSlitherGithubAction = async () => {
plugin.call('fileManager', 'open', path)
}
const scriptsRef = {
'deployer': contractDeployerScripts,
'etherscan': etherscanScripts
}
export const createHelperScripts = async (script: string) => {
if (!scripts[script]) return
await scripts[script](plugin)
if (!scriptsRef[script]) return
await scriptsRef[script](plugin)
plugin.call('notification', 'toast', 'scripts added in the "scripts" folder')
}

@ -1,7 +0,0 @@
import { contractDeployerScripts } from '../scripts/contract-deployer'
import { etherscanScripts } from '../scripts/etherscan'
export const scripts = {
'etherscan': etherscanScripts,
'deployer': contractDeployerScripts
}

@ -6,3 +6,6 @@ export { default as ozerc1155 } from './templates/ozerc1155'
export { default as zeroxErc20 } from './templates/zeroxErc20'
export { default as gnosisSafeMultisig } from './templates/gnosisSafeMultisig'
export { contractDeployerScripts } from './script-templates/contract-deployer'
export { etherscanScripts } from './script-templates/etherscan'

Loading…
Cancel
Save