From f6c447ff8dbfa621caf33cbd57669fc53459f1cc Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 11 May 2022 12:54:05 +0530 Subject: [PATCH] raw loader --- apps/remix-ide/webpack.config.js | 2 + .../workspace/src/lib/actions/workspace.ts | 11 +++- libs/remix-ws-templates/.eslintrc | 12 ++++ libs/remix-ws-templates/README.md | 7 +++ libs/remix-ws-templates/erc20/index.js | 8 --- libs/remix-ws-templates/index.js | 3 - libs/remix-ws-templates/package.json | 20 +++---- libs/remix-ws-templates/src/index.ts | 3 + .../src/templates/blank/index.ts | 1 + .../erc20/contracts/SampleERC20.sol | 0 .../src/templates/erc20/index.ts | 18 ++++++ .../erc20/scripts/deploy_with_ethers.ts | 2 +- .../erc20/scripts/deploy_with_web3.ts | 2 +- .../templates}/erc20/scripts/ethers.ts | 9 ++- .../{ => src/templates}/erc20/scripts/web3.ts | 6 +- .../erc20/tests/SampleERC20_test.sol | 4 +- .../templates}/remixDefault/README.txt | 2 +- .../remixDefault/contracts/1_Storage.sol | 0 .../remixDefault/contracts/2_Owner.sol | 8 +-- .../remixDefault/contracts/3_Ballot.sol | 4 +- .../templates/remixDefault/index.ts} | 0 .../scripts/deploy_with_ethers.ts | 2 +- .../remixDefault/scripts/deploy_with_web3.ts | 2 +- .../templates}/remixDefault/scripts/ethers.ts | 4 +- .../templates}/remixDefault/scripts/web3.ts | 2 +- .../remixDefault/tests/Ballot_test.sol | 8 +-- .../remixDefault/tests/storage.test.js | 0 libs/remix-ws-templates/src/types/index.d.ts | 4 ++ libs/remix-ws-templates/tsconfig.json | 7 +++ libs/remix-ws-templates/tsconfig.lib.json | 15 +++++ nx.json | 5 +- tsconfig.base.json | 15 ++++- workspace.json | 57 ++++++++++++++----- 33 files changed, 175 insertions(+), 68 deletions(-) create mode 100644 libs/remix-ws-templates/.eslintrc create mode 100644 libs/remix-ws-templates/README.md delete mode 100644 libs/remix-ws-templates/erc20/index.js delete mode 100644 libs/remix-ws-templates/index.js create mode 100644 libs/remix-ws-templates/src/index.ts create mode 100644 libs/remix-ws-templates/src/templates/blank/index.ts rename libs/remix-ws-templates/{ => src/templates}/erc20/contracts/SampleERC20.sol (100%) create mode 100644 libs/remix-ws-templates/src/templates/erc20/index.ts rename libs/remix-ws-templates/{ => src/templates}/erc20/scripts/deploy_with_ethers.ts (82%) rename libs/remix-ws-templates/{ => src/templates}/erc20/scripts/deploy_with_web3.ts (83%) rename libs/remix-ws-templates/{ => src/templates}/erc20/scripts/ethers.ts (95%) rename libs/remix-ws-templates/{ => src/templates}/erc20/scripts/web3.ts (93%) rename libs/remix-ws-templates/{ => src/templates}/erc20/tests/SampleERC20_test.sol (97%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/README.txt (99%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/contracts/1_Storage.sol (100%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/contracts/2_Owner.sol (98%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/contracts/3_Ballot.sol (99%) rename libs/remix-ws-templates/{remixDefault/index.js => src/templates/remixDefault/index.ts} (100%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/scripts/deploy_with_ethers.ts (91%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/scripts/deploy_with_web3.ts (92%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/scripts/ethers.ts (94%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/scripts/web3.ts (99%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/tests/Ballot_test.sol (98%) rename libs/remix-ws-templates/{ => src/templates}/remixDefault/tests/storage.test.js (100%) create mode 100644 libs/remix-ws-templates/src/types/index.d.ts create mode 100644 libs/remix-ws-templates/tsconfig.json create mode 100644 libs/remix-ws-templates/tsconfig.lib.json diff --git a/apps/remix-ide/webpack.config.js b/apps/remix-ide/webpack.config.js index c1c806505d..38802e0380 100644 --- a/apps/remix-ide/webpack.config.js +++ b/apps/remix-ide/webpack.config.js @@ -18,7 +18,9 @@ module.exports = config => { nxWebpackConfig.module.rules.push({ test: /\.txt$/, use: 'raw-loader' }) nxWebpackConfig.module.rules.push({ test: /\.sol$/, use: 'raw-loader' }) + nxWebpackConfig.module.rules.push({ test: /\.test\.js$/, use: 'raw-loader' }) + nxWebpackConfig.module.rules.push({ test: /\web3.ts$/, use: 'raw-loader' }) nxWebpackConfig.module.rules.push({ test: /\ethers.ts$/, use: 'raw-loader' }) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 20b3ca8d02..2fd1f95fe8 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -6,6 +6,7 @@ import { checkSlash, checkSpecialChars } from '@remix-ui/helper' import { JSONStandardInput, WorkspaceTemplate } from '../types' import { QueryParams } from '@remix-project/remix-lib' +import * as templateWithContent from '@remix-project/remix-ws-templates' const LOCALHOST = ' - connect to localhost - ' @@ -151,13 +152,17 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe default: try { - // const templateWithContent = await import('../templates') - const templateWithContent = await import('remix-ws-templates') + console.log('templateWithContent--->', templateWithContent) const templateList = Object.keys(templateWithContent) if (!templateList.includes(template)) break - const files = templateWithContent[template] + console.log('templateWithContent--->', templateWithContent[template]) + // @ts-ignore + const files = await templateWithContent[template]() + console.log('files--->', files) for (const file in files) { try { + // const f2 = await import(files[file]) + // console.log('files-with await f2-->', f2) await workspaceProvider.set(file, files[file]) } catch (error) { console.error(error) diff --git a/libs/remix-ws-templates/.eslintrc b/libs/remix-ws-templates/.eslintrc new file mode 100644 index 0000000000..0a49d6ddc4 --- /dev/null +++ b/libs/remix-ws-templates/.eslintrc @@ -0,0 +1,12 @@ +{ + "extends": "../../.eslintrc", + "rules": { + }, + "env": { + "browser": true, + "amd": true, + "node": true, + "es6": true + }, + "ignorePatterns": ["!**/*"] +} \ No newline at end of file diff --git a/libs/remix-ws-templates/README.md b/libs/remix-ws-templates/README.md new file mode 100644 index 0000000000..a48800596f --- /dev/null +++ b/libs/remix-ws-templates/README.md @@ -0,0 +1,7 @@ +# remix-ws-templates + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ws-templates` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ws-templates/erc20/index.js b/libs/remix-ws-templates/erc20/index.js deleted file mode 100644 index e3a5cbf078..0000000000 --- a/libs/remix-ws-templates/erc20/index.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - 'contracts/SampleERC20.sol': require('./contracts/SampleERC20.sol').default, - 'scripts/deploy_with_ethers.ts': require('./scripts/deploy_with_ethers.ts').default, - 'scripts/deploy_with_web3.ts': require('./scripts/deploy_with_web3.ts').default, - 'scripts/ethers.ts': require('./scripts/ethers.ts').default, - 'scripts/web3.ts': require('./scripts/web3.ts').default, - 'tests/SampleERC20_test.sol': require('./tests/SampleERC20_test.sol').default -} \ No newline at end of file diff --git a/libs/remix-ws-templates/index.js b/libs/remix-ws-templates/index.js deleted file mode 100644 index a076cfa671..0000000000 --- a/libs/remix-ws-templates/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as remixDefault } from './remixDefault' -export { default as erc20 } from './erc20' -// export { default as blank } from './blank' diff --git a/libs/remix-ws-templates/package.json b/libs/remix-ws-templates/package.json index 559b906d74..2e99679b63 100644 --- a/libs/remix-ws-templates/package.json +++ b/libs/remix-ws-templates/package.json @@ -1,11 +1,11 @@ { - "name": "remix-ws-templates", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Aniket-Engg", - "license": "ISC" -} + "name": "@remix-project/remix-ws-templates", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Aniket-Engg", + "license": "ISC" + } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts new file mode 100644 index 0000000000..0b1893126b --- /dev/null +++ b/libs/remix-ws-templates/src/index.ts @@ -0,0 +1,3 @@ +export { default as remixDefault } from './templates/remixDefault' +export { default as erc20 } from './templates/erc20' +export { default as blank } from './templates/blank' \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/blank/index.ts b/libs/remix-ws-templates/src/templates/blank/index.ts new file mode 100644 index 0000000000..56004c9f9e --- /dev/null +++ b/libs/remix-ws-templates/src/templates/blank/index.ts @@ -0,0 +1 @@ +export default {} \ No newline at end of file diff --git a/libs/remix-ws-templates/erc20/contracts/SampleERC20.sol b/libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol similarity index 100% rename from libs/remix-ws-templates/erc20/contracts/SampleERC20.sol rename to libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol diff --git a/libs/remix-ws-templates/src/templates/erc20/index.ts b/libs/remix-ws-templates/src/templates/erc20/index.ts new file mode 100644 index 0000000000..3ee2d68ccd --- /dev/null +++ b/libs/remix-ws-templates/src/templates/erc20/index.ts @@ -0,0 +1,18 @@ +export default async () => { + // @ts-ignore + console.log('------>', await import('raw-loader!./contracts/SampleERC20.sol')) + 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/erc20/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts similarity index 82% rename from libs/remix-ws-templates/erc20/scripts/deploy_with_ethers.ts rename to libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts index dc2f5286c4..f863a6bcd5 100644 --- a/libs/remix-ws-templates/erc20/scripts/deploy_with_ethers.ts +++ b/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts @@ -1,4 +1,4 @@ -import { deploy } from './ethers.ts' +import { deploy } from './ethers' (async () => { try { diff --git a/libs/remix-ws-templates/erc20/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts similarity index 83% rename from libs/remix-ws-templates/erc20/scripts/deploy_with_web3.ts rename to libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts index e6dddf65f0..653b1f244e 100644 --- a/libs/remix-ws-templates/erc20/scripts/deploy_with_web3.ts +++ b/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts @@ -1,4 +1,4 @@ -import { deploy } from './web3.ts' +import { deploy } from './web3' (async () => { try { diff --git a/libs/remix-ws-templates/erc20/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts similarity index 95% rename from libs/remix-ws-templates/erc20/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts index 16fbd8c4d7..12f5b7354d 100644 --- a/libs/remix-ws-templates/erc20/scripts/ethers.ts +++ b/libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts @@ -1,5 +1,8 @@ -export const deploy = async (contractName: string, args: Array, from?: string) => { - + + + +export const deploy = async (contractName: string, args: Array, from?: string): Promise => { + 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 @@ -21,4 +24,4 @@ export const deploy = async (contractName: string, args: Array, from?: stri // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() return contract -}: Promise \ No newline at end of file +} \ No newline at end of file diff --git a/libs/remix-ws-templates/erc20/scripts/web3.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts similarity index 93% rename from libs/remix-ws-templates/erc20/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts index 6fc26b2030..62f43b6611 100644 --- a/libs/remix-ws-templates/erc20/scripts/web3.ts +++ b/libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts @@ -1,5 +1,5 @@ -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number) => { - +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + 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 @@ -21,4 +21,4 @@ export const deploy = async (contractName: string, args: Array, from?: stri gas: gas || 1500000 }) return newContractInstance.options -}: Promise \ No newline at end of file +} \ No newline at end of file diff --git a/libs/remix-ws-templates/erc20/tests/SampleERC20_test.sol b/libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol similarity index 97% rename from libs/remix-ws-templates/erc20/tests/SampleERC20_test.sol rename to libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol index 45087c816c..19eb11d97d 100644 --- a/libs/remix-ws-templates/erc20/tests/SampleERC20_test.sol +++ b/libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol @@ -5,12 +5,12 @@ 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"); diff --git a/libs/remix-ws-templates/remixDefault/README.txt b/libs/remix-ws-templates/src/templates/remixDefault/README.txt similarity index 99% rename from libs/remix-ws-templates/remixDefault/README.txt rename to libs/remix-ws-templates/src/templates/remixDefault/README.txt index a71c4dc2d0..5e243584b2 100644 --- a/libs/remix-ws-templates/remixDefault/README.txt +++ b/libs/remix-ws-templates/src/templates/remixDefault/README.txt @@ -23,4 +23,4 @@ Output from script will appear in remix terminal. Please note, 'require' statement is supported in a limited manner for Remix supported modules. For now, modules supported by Remix are ethers, web3, swarmgw, chai, remix and hardhat only for hardhat.ethers object/plugin. -For unsupported modules, an error like this will be thrown: ' module require is not supported by Remix IDE will be shown.' +For unsupported modules, an error like this will be thrown: ' module require is not supported by Remix IDE will be shown.' \ No newline at end of file diff --git a/libs/remix-ws-templates/remixDefault/contracts/1_Storage.sol b/libs/remix-ws-templates/src/templates/remixDefault/contracts/1_Storage.sol similarity index 100% rename from libs/remix-ws-templates/remixDefault/contracts/1_Storage.sol rename to libs/remix-ws-templates/src/templates/remixDefault/contracts/1_Storage.sol diff --git a/libs/remix-ws-templates/remixDefault/contracts/2_Owner.sol b/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol similarity index 98% rename from libs/remix-ws-templates/remixDefault/contracts/2_Owner.sol rename to libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol index e6bc652c0f..9949f8cdd6 100644 --- a/libs/remix-ws-templates/remixDefault/contracts/2_Owner.sol +++ b/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol @@ -11,10 +11,10 @@ import "hardhat/console.sol"; contract Owner { address private owner; - + // event for EVM logging event OwnerSet(address indexed oldOwner, address indexed newOwner); - + // modifier to check if caller is owner modifier isOwner() { // If the first argument of 'require' evaluates to 'false', execution terminates and all @@ -25,7 +25,7 @@ contract Owner { require(msg.sender == owner, "Caller is not owner"); _; } - + /** * @dev Set contract deployer as owner */ @@ -51,4 +51,4 @@ contract Owner { function getOwner() external view returns (address) { return owner; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/libs/remix-ws-templates/remixDefault/contracts/3_Ballot.sol b/libs/remix-ws-templates/src/templates/remixDefault/contracts/3_Ballot.sol similarity index 99% rename from libs/remix-ws-templates/remixDefault/contracts/3_Ballot.sol rename to libs/remix-ws-templates/src/templates/remixDefault/contracts/3_Ballot.sol index 09fab7bc15..ffcc6c3609 100644 --- a/libs/remix-ws-templates/remixDefault/contracts/3_Ballot.sol +++ b/libs/remix-ws-templates/src/templates/remixDefault/contracts/3_Ballot.sol @@ -7,7 +7,7 @@ pragma solidity >=0.7.0 <0.9.0; * @dev Implements voting process along with vote delegation */ contract Ballot { - + struct Voter { uint weight; // weight is accumulated by delegation bool voted; // if true, that person already voted @@ -46,7 +46,7 @@ contract Ballot { })); } } - + /** * @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. * @param voter address of voter diff --git a/libs/remix-ws-templates/remixDefault/index.js b/libs/remix-ws-templates/src/templates/remixDefault/index.ts similarity index 100% rename from libs/remix-ws-templates/remixDefault/index.js rename to libs/remix-ws-templates/src/templates/remixDefault/index.ts diff --git a/libs/remix-ws-templates/remixDefault/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts similarity index 91% rename from libs/remix-ws-templates/remixDefault/scripts/deploy_with_ethers.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts index 2166c05842..e5fbf05264 100644 --- a/libs/remix-ws-templates/remixDefault/scripts/deploy_with_ethers.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts @@ -2,7 +2,7 @@ // Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S -import { deploy } from './ethers.ts' +import { deploy } from './ethers' (async () => { try { diff --git a/libs/remix-ws-templates/remixDefault/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts similarity index 92% rename from libs/remix-ws-templates/remixDefault/scripts/deploy_with_web3.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts index d6fc672929..d2fe1ff4ff 100644 --- a/libs/remix-ws-templates/remixDefault/scripts/deploy_with_web3.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts @@ -2,7 +2,7 @@ // Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S -import { deploy } from './web3.ts' +import { deploy } from './web3' (async () => { try { diff --git a/libs/remix-ws-templates/remixDefault/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts similarity index 94% rename from libs/remix-ws-templates/remixDefault/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts index be75c474c3..dc236caefb 100644 --- a/libs/remix-ws-templates/remixDefault/scripts/ethers.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts @@ -1,5 +1,5 @@ export const deploy = async (contractName: string, args: Array, from?: string): Promise => { - + 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 @@ -15,7 +15,7 @@ export const deploy = async (contractName: string, args: Array, from?: stri if (from) { contract = await factory.connect(from).deploy(...args); } else { - contract = await factory.deploy(...arguments); + contract = await factory.deploy(...args); } // The contract is NOT deployed yet; we must wait until it is mined diff --git a/libs/remix-ws-templates/remixDefault/scripts/web3.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts similarity index 99% rename from libs/remix-ws-templates/remixDefault/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts index 7b9ee72236..975a7176b4 100644 --- a/libs/remix-ws-templates/remixDefault/scripts/web3.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts @@ -1,5 +1,5 @@ export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - + 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 diff --git a/libs/remix-ws-templates/remixDefault/tests/Ballot_test.sol b/libs/remix-ws-templates/src/templates/remixDefault/tests/Ballot_test.sol similarity index 98% rename from libs/remix-ws-templates/remixDefault/tests/Ballot_test.sol rename to libs/remix-ws-templates/src/templates/remixDefault/tests/Ballot_test.sol index f3b81075f2..49146e99fa 100644 --- a/libs/remix-ws-templates/remixDefault/tests/Ballot_test.sol +++ b/libs/remix-ws-templates/src/templates/remixDefault/tests/Ballot_test.sol @@ -6,22 +6,22 @@ import "hardhat/console.sol"; import "../contracts/3_Ballot.sol"; contract BallotTest { - + bytes32[] proposalNames; - + Ballot ballotToTest; function beforeAll () public { proposalNames.push(bytes32("candidate1")); ballotToTest = new Ballot(proposalNames); } - + function checkWinningProposal () public { console.log("Running checkWinningProposal"); ballotToTest.vote(0); Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name"); } - + function checkWinninProposalWithReturnValue () public view returns (bool) { return ballotToTest.winningProposal() == 0; } diff --git a/libs/remix-ws-templates/remixDefault/tests/storage.test.js b/libs/remix-ws-templates/src/templates/remixDefault/tests/storage.test.js similarity index 100% rename from libs/remix-ws-templates/remixDefault/tests/storage.test.js rename to libs/remix-ws-templates/src/templates/remixDefault/tests/storage.test.js diff --git a/libs/remix-ws-templates/src/types/index.d.ts b/libs/remix-ws-templates/src/types/index.d.ts new file mode 100644 index 0000000000..ad12deddd8 --- /dev/null +++ b/libs/remix-ws-templates/src/types/index.d.ts @@ -0,0 +1,4 @@ +declare var remix:any +declare var ethers:any +declare var web3:any +declare var web3Provider:any \ No newline at end of file diff --git a/libs/remix-ws-templates/tsconfig.json b/libs/remix-ws-templates/tsconfig.json new file mode 100644 index 0000000000..eb1415fa71 --- /dev/null +++ b/libs/remix-ws-templates/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "types": ["node"], + }, + "include": ["**/*.ts"] +} \ No newline at end of file diff --git a/libs/remix-ws-templates/tsconfig.lib.json b/libs/remix-ws-templates/tsconfig.lib.json new file mode 100644 index 0000000000..b5f51c0965 --- /dev/null +++ b/libs/remix-ws-templates/tsconfig.lib.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": [ + "**/*.spec.ts", + "tests/" + ], + "include": ["**/*.ts", "**/*.sol"] +} diff --git a/nx.json b/nx.json index bbf5b08f6f..dc7a59fd15 100644 --- a/nx.json +++ b/nx.json @@ -133,7 +133,7 @@ "remix-ui-app": { "tags": [] }, - "remix-ui-helper": { + "remix-ui-helper": { "tags": [] }, "remix-ui-vertical-icons-panel": { @@ -165,6 +165,9 @@ }, "remix-ui-permission-handler": { "tags": [] + }, + "remix-ws-templates": { + "tags": [] } }, "targetDependencies": { diff --git a/tsconfig.base.json b/tsconfig.base.json index d9e148acdb..fb649a61b5 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -75,10 +75,19 @@ ], "@remix-ui/theme-module": ["libs/remix-ui/theme-module/src/index.ts"], "@remix-ui/panel": ["libs/remix-ui/panel/src/index.ts"], - "@remix-ui/editor-context-view": ["libs/remix-ui/editor-context-view/src/index.ts"], - "@remix-ui/solidity-unit-testing": ["libs/remix-ui/solidity-unit-testing/src/index.ts"], + "@remix-ui/editor-context-view": [ + "libs/remix-ui/editor-context-view/src/index.ts" + ], + "@remix-ui/solidity-unit-testing": [ + "libs/remix-ui/solidity-unit-testing/src/index.ts" + ], "@remix-ui/run-tab": ["libs/remix-ui/run-tab/src/index.ts"], - "@remix-ui/permission-handler": ["libs/remix-ui/permission-handler/src/index.ts"] + "@remix-ui/permission-handler": [ + "libs/remix-ui/permission-handler/src/index.ts" + ], + "@remix-project/remix-ws-templates": [ + "libs/remix-ws-templates/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index 149905a868..7e8853adb6 100644 --- a/workspace.json +++ b/workspace.json @@ -1,4 +1,3 @@ - { "version": 1, "projects": { @@ -756,8 +755,8 @@ } }, "remix-ui-plugin-manager": { - "root": "libs/remix-ui/plugin-manager", - "sourceRoot": "libs/remix-ui/plugin-manager/src", + "root": "libs/remix-ui/plugin-manager", + "sourceRoot": "libs/remix-ui/plugin-manager/src", "projectType": "library", "schematics": {}, "architect": { @@ -1010,7 +1009,6 @@ "tsConfig": ["libs/remix-ui/home-tab/tsconfig.lib.json"], "exclude": ["**/node_modules/**", "!libs/remix-ui/home-tab/**/*"] } - } } }, @@ -1039,8 +1037,8 @@ "builder": "@nrwl/linter:lint", "options": { "linter": "eslint", - "tsConfig": ["libs/remix-ui/editor/tsconfig.lib.json"], - "exclude": ["**/node_modules/**", "!libs/remix-ui/editor/**/*"] + "tsConfig": ["libs/remix-ui/editor/tsconfig.lib.json"], + "exclude": ["**/node_modules/**", "!libs/remix-ui/editor/**/*"] } } } @@ -1101,8 +1099,13 @@ "builder": "@nrwl/linter:lint", "options": { "linter": "eslint", - "tsConfig": ["libs/remix-ui/vertical-icons-panel/tsconfig.lib.json"], - "exclude": ["**/node_modules/**", "!libs/remix-ui/vertical-icons-panel/**/*"] + "tsConfig": [ + "libs/remix-ui/vertical-icons-panel/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-ui/vertical-icons-panel/**/*" + ] } } } @@ -1136,17 +1139,19 @@ } } } - }, + }, "solidity-unit-testing": { "root": "libs/remix-ui/solidity-unit-testing", - "sourceRoot": "libs/remix-ui/solidity-unit-testing/src", + "sourceRoot": "libs/remix-ui/solidity-unit-testing/src", "projectType": "library", "architect": { "lint": { "builder": "@nrwl/linter:lint", "options": { "linter": "eslint", - "tsConfig": ["libs/remix-ui/solidity-unit-testing/tsconfig.lib.json"], + "tsConfig": [ + "libs/remix-ui/solidity-unit-testing/tsconfig.lib.json" + ], "exclude": [ "**/node_modules/**", "!libs/remix-ui/solidity-unit-testing/**/*" @@ -1165,7 +1170,10 @@ "options": { "linter": "eslint", "tsConfig": ["libs/remix-ui/editor-context-view/tsconfig.lib.json"], - "exclude": ["**/node_modules/**", "!libs/remix-ui/editor-context-view/**/*"] + "exclude": [ + "**/node_modules/**", + "!libs/remix-ui/editor-context-view/**/*" + ] } } } @@ -1180,7 +1188,11 @@ "options": { "linter": "eslint", "tsConfig": ["libs/remix-ui/run-tab/tsconfig.lib.json"], - "exclude": ["**/node_modules/**", "libs/remix-ui/run-tab/**/*.d.ts", "!libs/remix-ui/run-tab/**/*"] + "exclude": [ + "**/node_modules/**", + "libs/remix-ui/run-tab/**/*.d.ts", + "!libs/remix-ui/run-tab/**/*" + ] } } } @@ -1195,7 +1207,24 @@ "options": { "linter": "eslint", "tsConfig": ["libs/remix-ui/permission-handler/tsconfig.lib.json"], - "exclude": ["**/node_modules/**", "libs/remix-ui/permission-handler/**/*.d.ts", "!libs/remix-ui/permission-handler/**/*"] + "exclude": [ + "**/node_modules/**", + "libs/remix-ui/permission-handler/**/*.d.ts", + "!libs/remix-ui/permission-handler/**/*" + ] + } + } + } + }, + "remix-ws-templates": { + "root": "libs/remix-ws-templates", + "sourceRoot": "libs/remix-ws-templates/src", + "projectType": "library", + "architect": { + "lint": { + "builder": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["libs/remix-ws-templates/**/*.ts"] } } }