From e8d8ae7f588ac5156a9b23f6c1ee69089bd47e27 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 May 2022 13:00:52 +0200 Subject: [PATCH] remove default --- .../src/templates/erc20/index.ts | 16 ----------- .../src/templates/erc20/scripts/ethers-lib.ts | 26 ------------------ .../src/templates/erc20/scripts/web3-lib.ts | 27 ------------------- 3 files changed, 69 deletions(-) delete mode 100644 libs/remix-ws-templates/src/templates/erc20/index.ts delete mode 100644 libs/remix-ws-templates/src/templates/erc20/scripts/ethers-lib.ts delete mode 100644 libs/remix-ws-templates/src/templates/erc20/scripts/web3-lib.ts 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 48ffb45341..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-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, - // @ts-ignore - 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.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/ethers-lib.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/ethers-lib.ts deleted file mode 100644 index 1c5f4c6548..0000000000 --- a/libs/remix-ws-templates/src/templates/erc20/scripts/ethers-lib.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ethers } from 'ethers' - -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 - 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() - - const 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 -} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/erc20/scripts/web3-lib.ts deleted file mode 100644 index 37ff2be99b..0000000000 --- a/libs/remix-ws-templates/src/templates/erc20/scripts/web3-lib.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Web3 from 'web3' - -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - - const web3 = new Web3(window.web3Provider) - 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 -} \ No newline at end of file