diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 4b14321d6f..3fff396f77 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -89,7 +89,7 @@ module.exports = { // eslint-disable-next-line dot-notation .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc20' }) .click('select[id="wstemplate"]') - .click('select[id="wstemplate"] option[value=erc20]') + .click('select[id="wstemplate"] option[value=ozerc20]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) .pause(1000) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 4ab6fb3000..70551c701f 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -119,16 +119,21 @@ export function Workspace () { } } + const updateWsName = () => { + // @ts-ignore + workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` + } + const createModalMessage = () => { return ( <> -
+
- - + ) diff --git a/libs/remix-ui/workspace/src/lib/templates/blank.ts b/libs/remix-ui/workspace/src/lib/templates/blank.ts deleted file mode 100644 index 56004c9f9e..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/blank.ts +++ /dev/null @@ -1 +0,0 @@ -export default {} \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/templates/erc20.ts b/libs/remix-ui/workspace/src/lib/templates/erc20.ts deleted file mode 100644 index 348f9dbc73..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/erc20.ts +++ /dev/null @@ -1,125 +0,0 @@ -'use strict' - -const erc20 = `// SPDX-License-Identifier: GPL-3.0 - -pragma solidity >=0.7.0 <0.9.0; - -/** - * @title SampleERC20 - * @dev Create a sample ERC20 standard token - */ - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - -contract SampleERC20 is ERC20 { - - constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {} -}` - -const erc20_test = `// SPDX-License-Identifier: GPL-3.0 - -pragma solidity >=0.7.0 <0.9.0; -import "remix_tests.sol"; -import "../contracts/SampleERC20.sol"; - -contract SampleERC20Test { - - SampleERC20 s; - function beforeAll () public { - s = new SampleERC20("TestToken", "TST"); - } - - function testTokenNameAndSymbol () public { - Assert.equal(s.name(), "TestToken", "token name did not match"); - Assert.equal(s.symbol(), "TST", "token symbol did not match"); - } -} -` - -/* eslint-disable no-useless-escape */ -const deployWithWeb3 = `import { deploy } from './web3.ts' - -(async () => { - try { - const result = await deploy('SampleERC20', ['testToken', 'TST']) - console.log(\`address: \${result.address\}\`) - } catch (e) { - console.log(e.message) - } -})()` - -const deployWithEthers = `import { deploy } from './ethers.ts' - -(async () => { - try { - const result = await deploy('SampleERC20', ['testToken', 'TST']) - console.log(\`address: \${result.address\}\`) - } catch (e) { - console.log(e.message) - } - })()` - -const libWeb3 = ` -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number) => { - - console.log(\`deploying \${contractName\}\`) - // Note that the script needs the ABI which is generated from the compilation artifact. - // Make sure contract is compiled and artifacts are generated - const artifactsPath = \`browser/contracts/artifacts/\${contractName\}.json\` - - const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) - - const accounts = await web3.eth.getAccounts() - - let contract = new web3.eth.Contract(metadata.abi) - - contract = contract.deploy({ - data: metadata.data.bytecode.object, - arguments: args - }) - - const newContractInstance = await contract.send({ - from: from || accounts[0], - gas: gas || 1500000 - }) - return newContractInstance.options -}: Promise` - -const libEthers = ` -export const deploy = async (contractName: string, args: Array, from?: string) => { - - console.log(\`deploying \${contractName\}\`) - // Note that the script needs the ABI which is generated from the compilation artifact. - // Make sure contract is compiled and artifacts are generated - const artifactsPath = \`browser/contracts/artifacts/\${contractName\}.json\` - - const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) - // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - - let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } - - // The contract is NOT deployed yet; we must wait until it is mined - await contract.deployed() - return contract -}: Promise` -/* eslint-enable no-useless-escape */ - - - - -export default { - erc20: { name: 'contracts/SampleERC20.sol', content: erc20 }, - erc20_test: { name: 'tests/SampleERC20_test.sol', content: erc20_test }, - deployWithWeb3: { name: 'scripts/deploy_with_web3.ts', content: deployWithWeb3 }, - deployWithEthers: { name: 'scripts/deploy_with_ethers.ts', content: deployWithEthers }, - web3: { name: 'scripts/web3.ts', content: libWeb3 }, - ethers: { name: 'scripts/ethers.ts', content: libEthers }, -} diff --git a/libs/remix-ui/workspace/src/lib/templates/index.ts b/libs/remix-ui/workspace/src/lib/templates/index.ts deleted file mode 100644 index 0fff14d78b..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as erc20 } from './erc20' -export { default as blank } from './blank' diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index 0b1893126b..bf130689f2 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,3 +1,3 @@ export { default as remixDefault } from './templates/remixDefault' -export { default as erc20 } from './templates/erc20' +export { default as ozerc20 } from './templates/ozerc20' export { default as blank } from './templates/blank' \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/index.ts b/libs/remix-ws-templates/src/templates/erc20/index.ts deleted file mode 100644 index cc1f087b55..0000000000 --- a/libs/remix-ws-templates/src/templates/erc20/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default async () => { - return { - // @ts-ignore - 'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.sol')).default, - // @ts-ignore - 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, - // @ts-ignore - 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, - // @ts-ignore - 'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, - // @ts-ignore - 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, - // @ts-ignore - 'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default - } -} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol b/libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol similarity index 99% rename from libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol rename to libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol index 23aa792466..c315908d18 100644 --- a/libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol +++ b/libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol @@ -2,13 +2,13 @@ pragma solidity >=0.7.0 <0.9.0; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + /** * @title SampleERC20 * @dev Create a sample ERC20 standard token */ -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - contract SampleERC20 is ERC20 { constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {} diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts new file mode 100644 index 0000000000..683bfdd530 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -0,0 +1,16 @@ +export default async () => { + return { + // @ts-ignore + 'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.sol')).default, + // @ts-ignore + 'scripts/deploy_with_ethers.ts': (await import('raw-loader!./scripts/deploy_with_ethers.ts')).default, + // @ts-ignore + 'scripts/deploy_with_web3.ts': (await import('raw-loader!./scripts/deploy_with_web3.ts')).default, + // @ts-ignore + 'scripts/ethers.ts': (await import('raw-loader!./scripts/ethers.ts')).default, + // @ts-ignore + 'scripts/web3.ts': (await import('raw-loader!./scripts/web3.ts')).default, + // @ts-ignore + 'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers.ts diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/web3.ts diff --git a/libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol b/libs/remix-ws-templates/src/templates/ozerc20/tests/SampleERC20_test.sol similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol rename to libs/remix-ws-templates/src/templates/ozerc20/tests/SampleERC20_test.sol diff --git a/libs/remix-ws-templates/src/templates/remixDefault/index.ts b/libs/remix-ws-templates/src/templates/remixDefault/index.ts index 683c616397..eb73dba979 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/index.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/index.ts @@ -7,17 +7,17 @@ export default async () => { // @ts-ignore 'contracts/3_Ballot.sol': (await import('raw-loader!./contracts/3_Ballot.sol')).default, // @ts-ignore - 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, + 'scripts/deploy_with_ethers.ts': (await import('raw-loader!./scripts/deploy_with_ethers.ts')).default, // @ts-ignore - 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, + 'scripts/deploy_with_web3.ts': (await import('raw-loader!./scripts/deploy_with_web3.ts')).default, // @ts-ignore - 'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, + 'scripts/ethers.ts': (await import('raw-loader!./scripts/ethers.ts')).default, // @ts-ignore - 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, + 'scripts/web3.ts': (await import('raw-loader!./scripts/web3.ts')).default, // @ts-ignore 'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default, // @ts-ignore - 'tests/storage.test.js': (await import('!!raw-loader!./tests/storage.test.js')).default, + 'tests/storage.test.js': (await import('raw-loader!./tests/storage.test.js')).default, // @ts-ignore 'README.txt': (await import('raw-loader!./README.txt')).default, }