diff --git a/packages/hardhat/.prettierrc b/.prettierrc similarity index 100% rename from packages/hardhat/.prettierrc rename to .prettierrc diff --git a/package.json b/package.json index d92429b..1eb6fbb 100644 --- a/package.json +++ b/package.json @@ -1,75 +1,75 @@ { - "name": "@humbledao/rocket", - "version": "1.0.0", - "keywords": [ - "ethereum", - "vue", - "nuxt", - "uniswap", - "workspaces", - "yarn" + "name": "@humbledao/rocket", + "version": "1.0.0", + "keywords": [ + "ethereum", + "vue", + "nuxt", + "uniswap", + "workspaces", + "yarn" + ], + "private": true, + "scripts": { + "nuxt-app:build": "yarn workspace @humbledao/nuxt-app build --max-old-space-size=12288", + "nuxt-app:dev": "yarn workspace @humbledao/nuxt-app dev", + "nuxt-app:generate": "yarn workspace @humbledao/nuxt-app generate", + "nuxt-app:preview": "yarn workspace @humbledao/nuxt-app preview", + "nuxt-app:test": "yarn workspace @humbledao/nuxt-app test", + "build": "yarn workspace @humbledao/nuxt-app build --max-old-space-size=12288", + "prettier": "yarn workspace @humbledao/nuxt-app prettier --write && yarn workspace @humbledao/hardhat prettier --write", + "chain": "yarn workspace @humbledao/hardhat chain", + "fork": "yarn workspace @humbledao/hardhat fork", + "node": "yarn workspace @humbledao/hardhat chain", + "test": "yarn workspace @humbledao/hardhat test", + "dev": "yarn workspace @humbledao/nuxt-app dev", + "compile": "yarn workspace @humbledao/hardhat compile", + "deploy": "yarn workspace @humbledao/hardhat deploy", + "verify": "yarn workspace @humbledao/hardhat verify", + "watch": "yarn workspace @humbledao/hardhat watch", + "accounts": "yarn workspace @humbledao/hardhat accounts", + "balance": "yarn workspace @humbledao/hardhat balance", + "send": "yarn workspace @humbledao/hardhat send", + "ipfs": "yarn workspace @humbledao/nuxt-app ipfs", + "surge": "yarn workspace @humbledao/nuxt-app surge", + "s3": "yarn workspace @humbledao/nuxt-app s3", + "ship": "yarn workspace @humbledao/nuxt-app ship", + "generate": "yarn workspace @humbledao/hardhat generate", + "account": "yarn workspace @humbledao/hardhat account", + "mineContractAddress": "cd packages/hardhat && npx hardhat mineContractAddress", + "wallet": "cd packages/hardhat && npx hardhat wallet", + "fundedwallet": "cd packages/hardhat && npx hardhat fundedwallet", + "flatten": "cd packages/hardhat && npx hardhat flatten", + "clean": "cd packages/hardhat && npx hardhat clean", + "run-graph-node": "yarn workspace @humbledao/services run-graph-node", + "remove-graph-node": "yarn workspace @humbledao/services remove-graph-node", + "clean-graph-node": "yarn workspace @humbledao/services clean-graph-node", + "graph-codegen": "yarn workspace @humbledao/subgraph graph codegen", + "graph-build": "yarn workspace @humbledao/subgraph graph build", + "graph-create-local": "yarn workspace @humbledao/subgraph graph create --node http://localhost:8020/ rocket/your-contract", + "graph-remove-local": "yarn workspace @humbledao/subgraph graph remove --node http://localhost:8020/ rocket/your-contract", + "graph-deploy-local": "yarn workspace @humbledao/subgraph graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 rocket/your-contract", + "graph-ship-local": "yarn graph-codegen && yarn graph-build --network localhost && yarn graph-deploy-local", + "deploy-and-graph": "yarn deploy && yarn graph-ship-local", + "theme": "yarn workspace @humbledao/nuxt-app theme", + "watch-theme": "yarn workspace @humbledao/nuxt-app watch", + "postinstall": "husky install" + }, + "workspaces": { + "packages": [ + "packages/*" ], - "private": true, - "scripts": { - "nuxt-app:build": "yarn workspace @humbledao/nuxt-app build --max-old-space-size=12288", - "nuxt-app:dev": "yarn workspace @humbledao/nuxt-app dev", - "nuxt-app:generate": "yarn workspace @humbledao/nuxt-app generate", - "nuxt-app:preview": "yarn workspace @humbledao/nuxt-app preview", - "nuxt-app:test": "yarn workspace @humbledao/nuxt-app test", - "build": "yarn workspace @humbledao/nuxt-app build --max-old-space-size=12288", - "prettier": "yarn workspace @humbledao/nuxt-app prettier", - "chain": "yarn workspace @humbledao/hardhat chain", - "fork": "yarn workspace @humbledao/hardhat fork", - "node": "yarn workspace @humbledao/hardhat chain", - "test": "yarn workspace @humbledao/hardhat test", - "dev": "yarn workspace @humbledao/nuxt-app dev", - "compile": "yarn workspace @humbledao/hardhat compile", - "deploy": "yarn workspace @humbledao/hardhat deploy", - "verify": "yarn workspace @humbledao/hardhat verify", - "watch": "yarn workspace @humbledao/hardhat watch", - "accounts": "yarn workspace @humbledao/hardhat accounts", - "balance": "yarn workspace @humbledao/hardhat balance", - "send": "yarn workspace @humbledao/hardhat send", - "ipfs": "yarn workspace @humbledao/nuxt-app ipfs", - "surge": "yarn workspace @humbledao/nuxt-app surge", - "s3": "yarn workspace @humbledao/nuxt-app s3", - "ship": "yarn workspace @humbledao/nuxt-app ship", - "generate": "yarn workspace @humbledao/hardhat generate", - "account": "yarn workspace @humbledao/hardhat account", - "mineContractAddress": "cd packages/hardhat && npx hardhat mineContractAddress", - "wallet": "cd packages/hardhat && npx hardhat wallet", - "fundedwallet": "cd packages/hardhat && npx hardhat fundedwallet", - "flatten": "cd packages/hardhat && npx hardhat flatten", - "clean": "cd packages/hardhat && npx hardhat clean", - "run-graph-node": "yarn workspace @humbledao/services run-graph-node", - "remove-graph-node": "yarn workspace @humbledao/services remove-graph-node", - "clean-graph-node": "yarn workspace @humbledao/services clean-graph-node", - "graph-codegen": "yarn workspace @humbledao/subgraph graph codegen", - "graph-build": "yarn workspace @humbledao/subgraph graph build", - "graph-create-local": "yarn workspace @humbledao/subgraph graph create --node http://localhost:8020/ rocket/your-contract", - "graph-remove-local": "yarn workspace @humbledao/subgraph graph remove --node http://localhost:8020/ rocket/your-contract", - "graph-deploy-local": "yarn workspace @humbledao/subgraph graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 rocket/your-contract", - "graph-ship-local": "yarn graph-codegen && yarn graph-build --network localhost && yarn graph-deploy-local", - "deploy-and-graph": "yarn deploy && yarn graph-ship-local", - "theme": "yarn workspace @humbledao/nuxt-app theme", - "watch-theme": "yarn workspace @humbledao/nuxt-app watch", - "postinstall": "husky install" - }, - "workspaces": { - "packages": [ - "packages/*" - ], - "nohoist": [ - "**/@graphprotocol/graph-ts", - "**/@graphprotocol/graph-ts/**", - "**/hardhat", - "**/hardhat/**", - "**/hardhat-ts", - "**/hardhat-ts/**" - ] - }, - "dependencies": {}, - "devDependencies": { - "husky": "^7.0.2" - } + "nohoist": [ + "**/@graphprotocol/graph-ts", + "**/@graphprotocol/graph-ts/**", + "**/hardhat", + "**/hardhat/**", + "**/hardhat-ts", + "**/hardhat-ts/**" + ] + }, + "dependencies": {}, + "devDependencies": { + "husky": "^7.0.2" + } } diff --git a/packages/hardhat/.eslintrc.js b/packages/hardhat/.eslintrc.js index 094708d..047f39d 100644 --- a/packages/hardhat/.eslintrc.js +++ b/packages/hardhat/.eslintrc.js @@ -2,22 +2,22 @@ module.exports = { env: { mocha: true, }, - extends: ["airbnb", "plugin:prettier/recommended"], - plugins: ["babel"], + extends: ['airbnb', 'plugin:prettier/recommended'], + plugins: ['babel'], rules: { - "prettier/prettier": ["error"], - "import/extensions": [ - "error", - "ignorePackages", + 'prettier/prettier': ['error'], + 'import/extensions': [ + 'error', + 'ignorePackages', { - js: "never", - ts: "never", + js: 'never', + ts: 'never', }, ], - "import/prefer-default-export": "off", - "prefer-destructuring": "off", - "prefer-template": "off", - "no-console": "off", - "func-names": "off", + 'import/prefer-default-export': 'off', + 'prefer-destructuring': 'off', + 'prefer-template': 'off', + 'no-console': 'off', + 'func-names': 'off', }, -}; +} diff --git a/packages/hardhat/contracts/GoofyGoober.sol b/packages/hardhat/contracts/GoofyGoober.sol index a177faa..448b23c 100644 --- a/packages/hardhat/contracts/GoofyGoober.sol +++ b/packages/hardhat/contracts/GoofyGoober.sol @@ -1,12 +1,12 @@ //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; contract GoofyGoober is ERC20 { - uint256 constant _initial_supply = 100 * (10**18); + uint256 constant _initial_supply = 100 * (10**18); - constructor() ERC20("GoofyGoober", "GG") { - _mint(msg.sender, _initial_supply); - } + constructor() ERC20('GoofyGoober', 'GG') { + _mint(msg.sender, _initial_supply); + } } diff --git a/packages/hardhat/contracts/RocketFactory.sol b/packages/hardhat/contracts/RocketFactory.sol index 6c4a20b..ebaebf6 100644 --- a/packages/hardhat/contracts/RocketFactory.sol +++ b/packages/hardhat/contracts/RocketFactory.sol @@ -1,170 +1,163 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.9.0; pragma experimental ABIEncoderV2; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/utils/math/SafeMath.sol"; -import "@chainlink/contracts/src/v0.8/KeeperCompatible.sol"; -import "abdk-libraries-solidity/ABDKMath64x64.sol"; +import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; +import '@openzeppelin/contracts/utils/math/SafeMath.sol'; +import '@chainlink/contracts/src/v0.8/KeeperCompatible.sol'; +import 'abdk-libraries-solidity/ABDKMath64x64.sol'; contract RocketFactory is KeeperCompatibleInterface { - Transaction[] transactionsList; - using ABDKMath64x64 for int128; - using SafeMath for uint256; - using SafeMath for uint64; - using SafeMath for uint24; - using SafeMath for uint8; - //mapping for - - struct Transaction { - uint256 id; - address owner; - address receiver; - uint256 deadline; - address ERC20TokenAddress; - uint256 amount; - uint256 tip; - bool pending; - } - - //TODO fix this shit - //sends the tip amount to the treasury address - function claimTip( - address IERC20address, - address treasury, - uint256 amount, - uint256 tip - ) public returns (uint256 taxAmount) { - uint256 taxAmount = ABDKMath64x64.mulu(amount, tip); - transferFrom(address(this), treasury, taxAmount); - return taxAmount; - } - - //creates a new transaction for later scheduling - function createTransaction( - address receiver, - address ERC20TokenAddress, - uint256 amount, - uint256 deadline, - uint256 tip - ) public { - // Check if they have the ERC20Token amount in their wallet - uint256 dueBy = block.timestamp + deadline; //in seconds - IERC20 token = IERC20(ERC20TokenAddress); - require( - token.allowance(msg.sender, address(this)) >= amount, - "Not enough tokens to complete tx" - ); - - //Send that amount to the contract - bool sent = token.transferFrom(msg.sender, address(this), amount); - require(sent, "transfer fialed"); - - Transaction memory newTransaction = Transaction( - transactionsList.length, - msg.sender, - receiver, - dueBy, - ERC20TokenAddress, - amount, - tip, - true - ); - transactionsList.push(newTransaction); - } - - //TODO - // 1. send the money from the escrow account to the receiver - // 2. (later) add a modifier that only allows approved liquidators to execute transaction - //who can execute this transaction? only the liquidator bots - function executeTransaction(uint256 id) - public - returns (Transaction memory) - { - //ensure that the transaction is not pending - Transaction memory scheduledTx = getTransaction(id); - require(scheduledTx.pending == true, "Already executed"); - // require( block.timestamp >= scheduledTx.deadline,"Not ready to be executed"); - - //take the money from the lending pool and send it to the receiver - //do this later - - //send the tip reward to the treasury - address treasury = 0x54e51feF99fFcCDCE4a7391a7c81FB0087A376de; - uint256 taxAmount = claimTip( - scheduledTx.ERC20TokenAddress, - treasury, - scheduledTx.amount, - scheduledTx.tip - ); - uint256 actualAmount = scheduledTx.amount - taxAmount; - - //TODO ad logic that sends this to the tresury address - - // create a new struct and update the transactionsList - Transaction memory newTransaction = Transaction( - id, - scheduledTx.owner, - scheduledTx.receiver, - scheduledTx.deadline, - scheduledTx.ERC20TokenAddress, - scheduledTx.amount, - scheduledTx.tip, - false - ); - transactionsList[id] = newTransaction; - return newTransaction; - } - - //get the current transactions in the array - function getAllTransactions() public view returns (Transaction[] memory) { - return transactionsList; - } - - function getTransaction(uint256 id) - public - view - returns (Transaction memory) - { - require(id <= transactionsList.length); - return transactionsList[id]; - } - - // Called by ChainLink Keeper every block to see if condition is met - function checkUpkeep( - bytes calldata /* checkData */ + Transaction[] transactionsList; + using ABDKMath64x64 for int128; + using SafeMath for uint256; + using SafeMath for uint64; + using SafeMath for uint24; + using SafeMath for uint8; + //mapping for + + struct Transaction { + uint256 id; + address owner; + address receiver; + uint256 deadline; + address ERC20TokenAddress; + uint256 amount; + uint256 tip; + bool pending; + } + + //TODO fix this shit + //sends the tip amount to the treasury address + function claimTip( + address IERC20address, + address treasury, + uint256 amount, + uint256 tip + ) public returns (uint256 taxAmount) { + uint256 taxAmount = ABDKMath64x64.mulu(amount, tip); + transferFrom(address(this), treasury, taxAmount); + return taxAmount; + } + + //creates a new transaction for later scheduling + function createTransaction( + address receiver, + address ERC20TokenAddress, + uint256 amount, + uint256 deadline, + uint256 tip + ) public { + // Check if they have the ERC20Token amount in their wallet + uint256 dueBy = block.timestamp + deadline; //in seconds + IERC20 token = IERC20(ERC20TokenAddress); + require( + token.allowance(msg.sender, address(this)) >= amount, + 'Not enough tokens to complete tx' + ); + + //Send that amount to the contract + bool sent = token.transferFrom(msg.sender, address(this), amount); + require(sent, 'transfer fialed'); + + Transaction memory newTransaction = Transaction( + transactionsList.length, + msg.sender, + receiver, + dueBy, + ERC20TokenAddress, + amount, + tip, + true + ); + transactionsList.push(newTransaction); + } + + //TODO + // 1. send the money from the escrow account to the receiver + // 2. (later) add a modifier that only allows approved liquidators to execute transaction + //who can execute this transaction? only the liquidator bots + function executeTransaction(uint256 id) public returns (Transaction memory) { + //ensure that the transaction is not pending + Transaction memory scheduledTx = getTransaction(id); + require(scheduledTx.pending == true, 'Already executed'); + // require( block.timestamp >= scheduledTx.deadline,"Not ready to be executed"); + + //take the money from the lending pool and send it to the receiver + //do this later + + //send the tip reward to the treasury + address treasury = 0x54e51feF99fFcCDCE4a7391a7c81FB0087A376de; + uint256 taxAmount = claimTip( + scheduledTx.ERC20TokenAddress, + treasury, + scheduledTx.amount, + scheduledTx.tip + ); + uint256 actualAmount = scheduledTx.amount - taxAmount; + + //TODO ad logic that sends this to the tresury address + + // create a new struct and update the transactionsList + Transaction memory newTransaction = Transaction( + id, + scheduledTx.owner, + scheduledTx.receiver, + scheduledTx.deadline, + scheduledTx.ERC20TokenAddress, + scheduledTx.amount, + scheduledTx.tip, + false + ); + transactionsList[id] = newTransaction; + return newTransaction; + } + + //get the current transactions in the array + function getAllTransactions() public view returns (Transaction[] memory) { + return transactionsList; + } + + function getTransaction(uint256 id) public view returns (Transaction memory) { + require(id <= transactionsList.length); + return transactionsList[id]; + } + + // Called by ChainLink Keeper every block to see if condition is met + function checkUpkeep( + bytes calldata /* checkData */ + ) + external + view + override + returns ( + bool upkeepNeeded, + bytes memory /* performData */ ) - external - view - override - returns ( - bool upkeepNeeded, - bytes memory /* performData */ - ) - { - // Get Array of all Pending Transactions - Transaction[] memory allTxs = getAllTransactions(); - // Map thru all transaction to find where deadline < blocktime - for (uint256 index = 0; index < allTxs.length; index++) { - Transaction memory txn = allTxs[index]; - if (txn.deadline < block.timestamp) { - upkeepNeeded = true; - } - } + { + // Get Array of all Pending Transactions + Transaction[] memory allTxs = getAllTransactions(); + // Map thru all transaction to find where deadline < blocktime + for (uint256 index = 0; index < allTxs.length; index++) { + Transaction memory txn = allTxs[index]; + if (txn.deadline < block.timestamp) { + upkeepNeeded = true; + } } - - function performUpkeep( - bytes calldata /* performData */ - ) external override { - // We highly recommend re-validating the upkeep in the performUpkeep function - Transaction[] memory allTxs = getAllTransactions(); - // Map thru all transaction to find where deadline < blocktime - for (uint256 index = 0; index < allTxs.length; index++) { - Transaction memory txn = allTxs[index]; - if (txn.deadline < block.timestamp) { - executeTransaction(txn.id); - } - } - - // We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function + } + + function performUpkeep( + bytes calldata /* performData */ + ) external override { + // We highly recommend re-validating the upkeep in the performUpkeep function + Transaction[] memory allTxs = getAllTransactions(); + // Map thru all transaction to find where deadline < blocktime + for (uint256 index = 0; index < allTxs.length; index++) { + Transaction memory txn = allTxs[index]; + if (txn.deadline < block.timestamp) { + executeTransaction(txn.id); + } } + + // We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function + } } diff --git a/packages/hardhat/deploy/00_deploy_your_contract.js b/packages/hardhat/deploy/00_deploy_your_contract.js index 1c2489f..9c05203 100644 --- a/packages/hardhat/deploy/00_deploy_your_contract.js +++ b/packages/hardhat/deploy/00_deploy_your_contract.js @@ -1,8 +1,8 @@ // deploy/00_deploy_your_contract.js -const { ethers } = require("hardhat"); +const { ethers } = require('hardhat') -const localChainId = "31337"; +const localChainId = '31337' // const sleep = (ms) => // new Promise((r) => @@ -13,18 +13,17 @@ const localChainId = "31337"; // ); module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { - const { deploy } = deployments; - const { deployer } = await getNamedAccounts(); - const chainId = await getChainId(); + const { deploy } = deployments + const { deployer } = await getNamedAccounts() + const chainId = await getChainId() - await deploy("RocketFactory", { + await deploy('RocketFactory', { // Learn more about args here: https://www.npmjs.com/package/hardhat-deploy#deploymentsdeploy from: deployer, // args: [ "Hello", ethers.utils.parseEther("1.5") ], log: true, waitConfirmations: 5, - }); - + }) // Getting a previously deployed contract // const YourContract = await ethers.getContract("RocketFactory", deployer); @@ -76,5 +75,5 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { // } catch (error) { // console.error(error); // } -}; -module.exports.tags = ["RocketFactory"]; +} +module.exports.tags = ['RocketFactory'] diff --git a/packages/hardhat/deploy/01_deploy_token.js b/packages/hardhat/deploy/01_deploy_token.js index 01e9e00..abf5d1e 100644 --- a/packages/hardhat/deploy/01_deploy_token.js +++ b/packages/hardhat/deploy/01_deploy_token.js @@ -1,8 +1,8 @@ // deploy/00_deploy_your_contract.js -const { ethers } = require("hardhat"); +const { ethers } = require('hardhat') -const localChainId = "31337"; +const localChainId = '31337' // const sleep = (ms) => // new Promise((r) => @@ -13,17 +13,17 @@ const localChainId = "31337"; // ); module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { - const { deploy } = deployments; - const { deployer } = await getNamedAccounts(); - const chainId = await getChainId(); + const { deploy } = deployments + const { deployer } = await getNamedAccounts() + const chainId = await getChainId() - await deploy("GoofyGoober", { + await deploy('GoofyGoober', { // Learn more about args here: https://www.npmjs.com/package/hardhat-deploy#deploymentsdeploy from: deployer, // args: [ "Hello", ethers.utils.parseEther("1.5") ], log: true, waitConfirmations: 5, - }); + }) // Getting a previously deployed contract // const YourContract = await ethers.getContract("RocketFactory", deployer); @@ -75,6 +75,6 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { // } catch (error) { // console.error(error); // } -}; +} -module.exports.tags = ["RocketFactory"]; +module.exports.tags = ['RocketFactory'] diff --git a/packages/hardhat/hardhat.config.js b/packages/hardhat/hardhat.config.js index 200bad7..78a8d8a 100644 --- a/packages/hardhat/hardhat.config.js +++ b/packages/hardhat/hardhat.config.js @@ -1,19 +1,19 @@ -require("dotenv").config(); -const { utils } = require("ethers"); -const fs = require("fs"); -const chalk = require("chalk"); +require('dotenv').config() +const { utils } = require('ethers') +const fs = require('fs') +const chalk = require('chalk') -require("@nomiclabs/hardhat-waffle"); -require("@tenderly/hardhat-tenderly"); +require('@nomiclabs/hardhat-waffle') +require('@tenderly/hardhat-tenderly') -require("hardhat-deploy"); -require("hardhat-gas-reporter"); -require("hardhat-abi-exporter"); +require('hardhat-deploy') +require('hardhat-gas-reporter') +require('hardhat-abi-exporter') -require("@nomiclabs/hardhat-ethers"); -require("@nomiclabs/hardhat-etherscan"); +require('@nomiclabs/hardhat-ethers') +require('@nomiclabs/hardhat-etherscan') -const { isAddress, getAddress, formatUnits, parseUnits } = utils; +const { isAddress, getAddress, formatUnits, parseUnits } = utils /* Configure deploy configurations @@ -27,21 +27,21 @@ const { isAddress, getAddress, formatUnits, parseUnits } = utils; // // Select the network you want to deploy to here: // -const defaultNetwork = "localhost"; +const defaultNetwork = 'localhost' -const mainnetGwei = 21; +const mainnetGwei = 21 function mnemonic() { try { - return fs.readFileSync("./mnemonic.txt").toString().trim(); + return fs.readFileSync('./mnemonic.txt').toString().trim() } catch (e) { - if (defaultNetwork !== "localhost") { + if (defaultNetwork !== 'localhost') { console.log( - "☢️ WARNING: No mnemonic file created for a deploy account. Try `yarn run generate` and then `yarn run account`." - ); + '☢️ WARNING: No mnemonic file created for a deploy account. Try `yarn run generate` and then `yarn run account`.' + ) } } - return ""; + return '' } module.exports = { @@ -53,7 +53,7 @@ module.exports = { * More here: https://hardhat.org/plugins/hardhat-gas-reporter.html */ gasReporter: { - currency: "USD", + currency: 'USD', coinmarketcap: process.env.COINMARKETCAP || null, }, @@ -66,7 +66,7 @@ module.exports = { networks: { localhost: { - url: "http://localhost:8545", + url: 'http://localhost:8545', /* notice no mnemonic here? it will just use account 0 of the hardhat node to deploy (you can put in a mnemonic here to set the deployer locally) @@ -74,21 +74,21 @@ module.exports = { */ }, rinkeby: { - url: "https://rinkeby.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work) + url: 'https://rinkeby.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad', // <---- YOUR INFURA ID! (or it won't work) // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/eth/rinkeby", // <---- YOUR MORALIS ID! (not limited to infura) accounts: { mnemonic: mnemonic(), }, }, kovan: { - url: "https://kovan.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work) + url: 'https://kovan.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad', // <---- YOUR INFURA ID! (or it won't work) // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/eth/kovan", // <---- YOUR MORALIS ID! (not limited to infura) accounts: { mnemonic: mnemonic(), }, }, mainnet: { - url: "https://mainnet.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work) + url: 'https://mainnet.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad', // <---- YOUR INFURA ID! (or it won't work) // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/mainnet", // <---- YOUR MORALIS ID! (not limited to infura) gasPrice: mainnetGwei * 1000000000, accounts: { @@ -96,42 +96,42 @@ module.exports = { }, }, ropsten: { - url: "https://ropsten.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work) + url: 'https://ropsten.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad', // <---- YOUR INFURA ID! (or it won't work) // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/ropsten",// <---- YOUR MORALIS ID! (not limited to infura) accounts: { mnemonic: mnemonic(), }, }, goerli: { - url: "https://goerli.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad", // <---- YOUR INFURA ID! (or it won't work) + url: 'https://goerli.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad', // <---- YOUR INFURA ID! (or it won't work) // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXXXX/eth/goerli", // <---- YOUR MORALIS ID! (not limited to infura) accounts: { mnemonic: mnemonic(), }, }, xdai: { - url: "https://rpc.xdaichain.com/", + url: 'https://rpc.xdaichain.com/', gasPrice: 8000000000, accounts: { mnemonic: mnemonic(), }, }, fantom: { - url: "https://rpcapi.fantom.network", + url: 'https://rpcapi.fantom.network', gasPrice: 8000000000, accounts: { mnemonic: mnemonic(), }, }, testnetFantom: { - url: "https://rpc.testnet.fantom.network", + url: 'https://rpc.testnet.fantom.network', gasPrice: 8000000000, accounts: { mnemonic: mnemonic(), }, }, polygon: { - url: "https://polygon-rpc.com", + url: 'https://polygon-rpc.com', // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXx/polygon/mainnet", // <---- YOUR MORALIS ID! (not limited to infura) gasPrice: 3200000000, accounts: { @@ -139,7 +139,7 @@ module.exports = { }, }, mumbai: { - url: "https://polygon-mumbai.g.alchemy.com/v2/DXdnHGOivf3gq0iDz7N4vU12aMUu-ODV", + url: 'https://polygon-mumbai.g.alchemy.com/v2/DXdnHGOivf3gq0iDz7N4vU12aMUu-ODV', // url: "https://speedy-nodes-nyc.moralis.io/XXXXXXXXXXXXXXXXXXXXXXX/polygon/mumbai", // <---- YOUR MORALIS ID! (not limited to infura) gasPrice: 3200000000, accounts: { @@ -147,51 +147,51 @@ module.exports = { }, }, matic: { - url: "https://rpc-mainnet.maticvigil.com/", + url: 'https://rpc-mainnet.maticvigil.com/', gasPrice: 8000000000, accounts: { mnemonic: mnemonic(), }, }, optimism: { - url: "https://mainnet.optimism.io", + url: 'https://mainnet.optimism.io', accounts: { mnemonic: mnemonic(), }, companionNetworks: { - l1: "mainnet", + l1: 'mainnet', }, }, kovanOptimism: { - url: "https://kovan.optimism.io", + url: 'https://kovan.optimism.io', accounts: { mnemonic: mnemonic(), }, companionNetworks: { - l1: "kovan", + l1: 'kovan', }, }, localOptimism: { - url: "http://localhost:8545", + url: 'http://localhost:8545', accounts: { mnemonic: mnemonic(), }, companionNetworks: { - l1: "localOptimismL1", + l1: 'localOptimismL1', }, }, localOptimismL1: { - url: "http://localhost:9545", + url: 'http://localhost:9545', gasPrice: 0, accounts: { mnemonic: mnemonic(), }, companionNetworks: { - l2: "localOptimism", + l2: 'localOptimism', }, }, localAvalanche: { - url: "http://localhost:9650/ext/bc/C/rpc", + url: 'http://localhost:9650/ext/bc/C/rpc', gasPrice: 225000000000, chainId: 43112, accounts: { @@ -199,7 +199,7 @@ module.exports = { }, }, fujiAvalanche: { - url: "https://api.avax-test.network/ext/bc/C/rpc", + url: 'https://api.avax-test.network/ext/bc/C/rpc', gasPrice: 225000000000, chainId: 43113, accounts: { @@ -207,7 +207,7 @@ module.exports = { }, }, mainnetAvalanche: { - url: "https://api.avax.network/ext/bc/C/rpc", + url: 'https://api.avax.network/ext/bc/C/rpc', gasPrice: 225000000000, chainId: 43114, accounts: { @@ -215,7 +215,7 @@ module.exports = { }, }, testnetHarmony: { - url: "https://api.s0.b.hmny.io", + url: 'https://api.s0.b.hmny.io', gasPrice: 8000000000, chainId: 1666700000, accounts: { @@ -223,7 +223,7 @@ module.exports = { }, }, mainnetHarmony: { - url: "https://api.harmony.one", + url: 'https://api.harmony.one', gasPrice: 8000000000, chainId: 1666600000, accounts: { @@ -231,28 +231,28 @@ module.exports = { }, }, moonbeam: { - url: "https://rpc.api.moonbeam.network", + url: 'https://rpc.api.moonbeam.network', chainId: 1284, accounts: { mnemonic: mnemonic(), }, }, moonriver: { - url: "https://rpc.api.moonriver.moonbeam.network", + url: 'https://rpc.api.moonriver.moonbeam.network', chainId: 1285, accounts: { mnemonic: mnemonic(), }, }, moonbaseAlpha: { - url: "https://rpc.api.moonbase.moonbeam.network", + url: 'https://rpc.api.moonbase.moonbeam.network', chainId: 1287, accounts: { mnemonic: mnemonic(), }, }, moonbeamDevNode: { - url: "http://127.0.0.1:9933", + url: 'http://127.0.0.1:9933', chainId: 1281, accounts: { mnemonic: mnemonic(), @@ -262,7 +262,7 @@ module.exports = { solidity: { compilers: [ { - version: "0.8.4", + version: '0.8.4', settings: { optimizer: { enabled: true, @@ -271,7 +271,7 @@ module.exports = { }, }, { - version: "0.6.7", + version: '0.6.7', settings: { optimizer: { enabled: true, @@ -282,7 +282,7 @@ module.exports = { ], }, ovm: { - solcVersion: "0.7.6", + solcVersion: '0.7.6', }, namedAccounts: { deployer: { @@ -291,12 +291,12 @@ module.exports = { }, etherscan: { apiKey: { - mainnet: "DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW", + mainnet: 'DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW', // add other network's API key here }, }, abiExporter: { - path: "../nuxt-app/contracts/ABI", + path: '../nuxt-app/contracts/ABI', runOnCompile: true, clear: true, flat: true, @@ -304,313 +304,310 @@ module.exports = { spacing: 2, pretty: false, }, -}; +} -const DEBUG = false; +const DEBUG = false function debug(text) { if (DEBUG) { - console.log(text); + console.log(text) } } -task("wallet", "Create a wallet (pk) link", async (_, { ethers }) => { - const randomWallet = ethers.Wallet.createRandom(); - const privateKey = randomWallet._signingKey().privateKey; - console.log("🔐 WALLET Generated as " + randomWallet.address + ""); - console.log("🔗 http://localhost:3000/pk#" + privateKey); -}); +task('wallet', 'Create a wallet (pk) link', async (_, { ethers }) => { + const randomWallet = ethers.Wallet.createRandom() + const privateKey = randomWallet._signingKey().privateKey + console.log('🔐 WALLET Generated as ' + randomWallet.address + '') + console.log('🔗 http://localhost:3000/pk#' + privateKey) +}) -task("fundedwallet", "Create a wallet (pk) link and fund it with deployer?") +task('fundedwallet', 'Create a wallet (pk) link and fund it with deployer?') .addOptionalParam( - "amount", - "Amount of ETH to send to wallet after generating" + 'amount', + 'Amount of ETH to send to wallet after generating' ) - .addOptionalParam("url", "URL to add pk to") + .addOptionalParam('url', 'URL to add pk to') .setAction(async (taskArgs, { network, ethers }) => { - const randomWallet = ethers.Wallet.createRandom(); - const privateKey = randomWallet._signingKey().privateKey; - console.log("🔐 WALLET Generated as " + randomWallet.address + ""); - const url = taskArgs.url ? taskArgs.url : "http://localhost:3000"; + const randomWallet = ethers.Wallet.createRandom() + const privateKey = randomWallet._signingKey().privateKey + console.log('🔐 WALLET Generated as ' + randomWallet.address + '') + const url = taskArgs.url ? taskArgs.url : 'http://localhost:3000' - let localDeployerMnemonic; + let localDeployerMnemonic try { - localDeployerMnemonic = fs.readFileSync("./mnemonic.txt"); - localDeployerMnemonic = localDeployerMnemonic.toString().trim(); + localDeployerMnemonic = fs.readFileSync('./mnemonic.txt') + localDeployerMnemonic = localDeployerMnemonic.toString().trim() } catch (e) { /* do nothing - this file isn't always there */ } - const amount = taskArgs.amount ? taskArgs.amount : "0.01"; + const amount = taskArgs.amount ? taskArgs.amount : '0.01' const tx = { to: randomWallet.address, value: ethers.utils.parseEther(amount), - }; + } // SEND USING LOCAL DEPLOYER MNEMONIC IF THERE IS ONE // IF NOT SEND USING LOCAL HARDHAT NODE: if (localDeployerMnemonic) { - let deployerWallet = new ethers.Wallet.fromMnemonic( - localDeployerMnemonic - ); - deployerWallet = deployerWallet.connect(ethers.provider); + let deployerWallet = new ethers.Wallet.fromMnemonic(localDeployerMnemonic) + deployerWallet = deployerWallet.connect(ethers.provider) console.log( - "💵 Sending " + + '💵 Sending ' + amount + - " ETH to " + + ' ETH to ' + randomWallet.address + - " using deployer account" - ); - const sendresult = await deployerWallet.sendTransaction(tx); - console.log("\n" + url + "/pk#" + privateKey + "\n"); + ' using deployer account' + ) + const sendresult = await deployerWallet.sendTransaction(tx) + console.log('\n' + url + '/pk#' + privateKey + '\n') } else { console.log( - "💵 Sending " + + '💵 Sending ' + amount + - " ETH to " + + ' ETH to ' + randomWallet.address + - " using local node" - ); - console.log("\n" + url + "/pk#" + privateKey + "\n"); - return send(ethers.provider.getSigner(), tx); + ' using local node' + ) + console.log('\n' + url + '/pk#' + privateKey + '\n') + return send(ethers.provider.getSigner(), tx) } - }); + }) task( - "generate", - "Create a mnemonic for builder deploys", + 'generate', + 'Create a mnemonic for builder deploys', async (_, { ethers }) => { - const bip39 = require("bip39"); - const hdkey = require("ethereumjs-wallet/hdkey"); - const mnemonic = bip39.generateMnemonic(); - if (DEBUG) console.log("mnemonic", mnemonic); - const seed = await bip39.mnemonicToSeed(mnemonic); - if (DEBUG) console.log("seed", seed); - const hdwallet = hdkey.fromMasterSeed(seed); - const wallet_hdpath = "m/44'/60'/0'/0/"; - const account_index = 0; - const fullPath = wallet_hdpath + account_index; - if (DEBUG) console.log("fullPath", fullPath); - const wallet = hdwallet.derivePath(fullPath).getWallet(); - const privateKey = "0x" + wallet._privKey.toString("hex"); - if (DEBUG) console.log("privateKey", privateKey); - const EthUtil = require("ethereumjs-util"); + const bip39 = require('bip39') + const hdkey = require('ethereumjs-wallet/hdkey') + const mnemonic = bip39.generateMnemonic() + if (DEBUG) console.log('mnemonic', mnemonic) + const seed = await bip39.mnemonicToSeed(mnemonic) + if (DEBUG) console.log('seed', seed) + const hdwallet = hdkey.fromMasterSeed(seed) + const wallet_hdpath = "m/44'/60'/0'/0/" + const account_index = 0 + const fullPath = wallet_hdpath + account_index + if (DEBUG) console.log('fullPath', fullPath) + const wallet = hdwallet.derivePath(fullPath).getWallet() + const privateKey = '0x' + wallet._privKey.toString('hex') + if (DEBUG) console.log('privateKey', privateKey) + const EthUtil = require('ethereumjs-util') const address = - "0x" + EthUtil.privateToAddress(wallet._privKey).toString("hex"); + '0x' + EthUtil.privateToAddress(wallet._privKey).toString('hex') console.log( - "🔐 Account Generated as " + + '🔐 Account Generated as ' + address + - " and set as mnemonic in packages/hardhat" - ); + ' and set as mnemonic in packages/hardhat' + ) console.log( "💬 Use 'yarn run account' to get more information about the deployment account." - ); + ) - fs.writeFileSync("./" + address + ".txt", mnemonic.toString()); - fs.writeFileSync("./mnemonic.txt", mnemonic.toString()); + fs.writeFileSync('./' + address + '.txt', mnemonic.toString()) + fs.writeFileSync('./mnemonic.txt', mnemonic.toString()) } -); +) task( - "mineContractAddress", - "Looks for a deployer account that will give leading zeros" + 'mineContractAddress', + 'Looks for a deployer account that will give leading zeros' ) - .addParam("searchFor", "String to search for") + .addParam('searchFor', 'String to search for') .setAction(async (taskArgs, { network, ethers }) => { - let contract_address = ""; - let address; + let contract_address = '' + let address - const bip39 = require("bip39"); - const hdkey = require("ethereumjs-wallet/hdkey"); + const bip39 = require('bip39') + const hdkey = require('ethereumjs-wallet/hdkey') - let mnemonic = ""; + let mnemonic = '' while (contract_address.indexOf(taskArgs.searchFor) != 0) { - mnemonic = bip39.generateMnemonic(); - if (DEBUG) console.log("mnemonic", mnemonic); - const seed = await bip39.mnemonicToSeed(mnemonic); - if (DEBUG) console.log("seed", seed); - const hdwallet = hdkey.fromMasterSeed(seed); - const wallet_hdpath = "m/44'/60'/0'/0/"; - const account_index = 0; - const fullPath = wallet_hdpath + account_index; - if (DEBUG) console.log("fullPath", fullPath); - const wallet = hdwallet.derivePath(fullPath).getWallet(); - const privateKey = "0x" + wallet._privKey.toString("hex"); - if (DEBUG) console.log("privateKey", privateKey); - const EthUtil = require("ethereumjs-util"); - address = - "0x" + EthUtil.privateToAddress(wallet._privKey).toString("hex"); - - const rlp = require("rlp"); - const keccak = require("keccak"); - - const nonce = 0x00; // The nonce must be a hex literal! - const sender = address; - - const input_arr = [sender, nonce]; - const rlp_encoded = rlp.encode(input_arr); - - const contract_address_long = keccak("keccak256") + mnemonic = bip39.generateMnemonic() + if (DEBUG) console.log('mnemonic', mnemonic) + const seed = await bip39.mnemonicToSeed(mnemonic) + if (DEBUG) console.log('seed', seed) + const hdwallet = hdkey.fromMasterSeed(seed) + const wallet_hdpath = "m/44'/60'/0'/0/" + const account_index = 0 + const fullPath = wallet_hdpath + account_index + if (DEBUG) console.log('fullPath', fullPath) + const wallet = hdwallet.derivePath(fullPath).getWallet() + const privateKey = '0x' + wallet._privKey.toString('hex') + if (DEBUG) console.log('privateKey', privateKey) + const EthUtil = require('ethereumjs-util') + address = '0x' + EthUtil.privateToAddress(wallet._privKey).toString('hex') + + const rlp = require('rlp') + const keccak = require('keccak') + + const nonce = 0x00 // The nonce must be a hex literal! + const sender = address + + const input_arr = [sender, nonce] + const rlp_encoded = rlp.encode(input_arr) + + const contract_address_long = keccak('keccak256') .update(rlp_encoded) - .digest("hex"); + .digest('hex') - contract_address = contract_address_long.substring(24); // Trim the first 24 characters. + contract_address = contract_address_long.substring(24) // Trim the first 24 characters. } console.log( - "⛏ Account Mined as " + + '⛏ Account Mined as ' + address + - " and set as mnemonic in packages/hardhat" - ); + ' and set as mnemonic in packages/hardhat' + ) console.log( - "📜 This will create the first contract: " + - chalk.magenta("0x" + contract_address) - ); + '📜 This will create the first contract: ' + + chalk.magenta('0x' + contract_address) + ) console.log( "💬 Use 'yarn run account' to get more information about the deployment account." - ); + ) fs.writeFileSync( - "./" + address + "_produces" + contract_address + ".txt", + './' + address + '_produces' + contract_address + '.txt', mnemonic.toString() - ); - fs.writeFileSync("./mnemonic.txt", mnemonic.toString()); - }); + ) + fs.writeFileSync('./mnemonic.txt', mnemonic.toString()) + }) task( - "account", - "Get balance informations for the deployment account.", + 'account', + 'Get balance informations for the deployment account.', async (_, { ethers }) => { - const hdkey = require("ethereumjs-wallet/hdkey"); - const bip39 = require("bip39"); + const hdkey = require('ethereumjs-wallet/hdkey') + const bip39 = require('bip39') try { - const mnemonic = fs.readFileSync("./mnemonic.txt").toString().trim(); - if (DEBUG) console.log("mnemonic", mnemonic); - const seed = await bip39.mnemonicToSeed(mnemonic); - if (DEBUG) console.log("seed", seed); - const hdwallet = hdkey.fromMasterSeed(seed); - const wallet_hdpath = "m/44'/60'/0'/0/"; - const account_index = 0; - const fullPath = wallet_hdpath + account_index; - if (DEBUG) console.log("fullPath", fullPath); - const wallet = hdwallet.derivePath(fullPath).getWallet(); - const privateKey = "0x" + wallet._privKey.toString("hex"); - if (DEBUG) console.log("privateKey", privateKey); - const EthUtil = require("ethereumjs-util"); + const mnemonic = fs.readFileSync('./mnemonic.txt').toString().trim() + if (DEBUG) console.log('mnemonic', mnemonic) + const seed = await bip39.mnemonicToSeed(mnemonic) + if (DEBUG) console.log('seed', seed) + const hdwallet = hdkey.fromMasterSeed(seed) + const wallet_hdpath = "m/44'/60'/0'/0/" + const account_index = 0 + const fullPath = wallet_hdpath + account_index + if (DEBUG) console.log('fullPath', fullPath) + const wallet = hdwallet.derivePath(fullPath).getWallet() + const privateKey = '0x' + wallet._privKey.toString('hex') + if (DEBUG) console.log('privateKey', privateKey) + const EthUtil = require('ethereumjs-util') const address = - "0x" + EthUtil.privateToAddress(wallet._privKey).toString("hex"); + '0x' + EthUtil.privateToAddress(wallet._privKey).toString('hex') - const qrcode = require("qrcode-terminal"); - qrcode.generate(address); - console.log("‍📬 Deployer Account is " + address); + const qrcode = require('qrcode-terminal') + qrcode.generate(address) + console.log('‍📬 Deployer Account is ' + address) for (const n in config.networks) { // console.log(config.networks[n],n) try { const provider = new ethers.providers.JsonRpcProvider( config.networks[n].url - ); - const balance = await provider.getBalance(address); - console.log(" -- " + n + " -- -- -- 📡 "); - console.log(" balance: " + ethers.utils.formatEther(balance)); + ) + const balance = await provider.getBalance(address) + console.log(' -- ' + n + ' -- -- -- 📡 ') + console.log(' balance: ' + ethers.utils.formatEther(balance)) console.log( - " nonce: " + (await provider.getTransactionCount(address)) - ); + ' nonce: ' + (await provider.getTransactionCount(address)) + ) } catch (e) { if (DEBUG) { - console.log(e); + console.log(e) } } } } catch (err) { - console.log(`--- Looks like there is no mnemonic file created yet.`); + console.log(`--- Looks like there is no mnemonic file created yet.`) console.log( - `--- Please run ${chalk.greenBright("yarn generate")} to create one` - ); + `--- Please run ${chalk.greenBright('yarn generate')} to create one` + ) } } -); +) async function addr(ethers, addr) { if (isAddress(addr)) { - return getAddress(addr); + return getAddress(addr) } - const accounts = await ethers.provider.listAccounts(); + const accounts = await ethers.provider.listAccounts() if (accounts[addr] !== undefined) { - return accounts[addr]; + return accounts[addr] } - throw `Could not normalize address: ${addr}`; + throw `Could not normalize address: ${addr}` } -task("accounts", "Prints the list of accounts", async (_, { ethers }) => { - const accounts = await ethers.provider.listAccounts(); - accounts.forEach((account) => console.log(account)); -}); +task('accounts', 'Prints the list of accounts', async (_, { ethers }) => { + const accounts = await ethers.provider.listAccounts() + accounts.forEach((account) => console.log(account)) +}) -task("blockNumber", "Prints the block number", async (_, { ethers }) => { - const blockNumber = await ethers.provider.getBlockNumber(); - console.log(blockNumber); -}); +task('blockNumber', 'Prints the block number', async (_, { ethers }) => { + const blockNumber = await ethers.provider.getBlockNumber() + console.log(blockNumber) +}) -task("balance", "Prints an account's balance") - .addPositionalParam("account", "The account's address") +task('balance', "Prints an account's balance") + .addPositionalParam('account', "The account's address") .setAction(async (taskArgs, { ethers }) => { const balance = await ethers.provider.getBalance( await addr(ethers, taskArgs.account) - ); - console.log(formatUnits(balance, "ether"), "ETH"); - }); + ) + console.log(formatUnits(balance, 'ether'), 'ETH') + }) function send(signer, txparams) { return signer.sendTransaction(txparams, (error, transactionHash) => { if (error) { - debug(`Error: ${error}`); + debug(`Error: ${error}`) } - debug(`transactionHash: ${transactionHash}`); + debug(`transactionHash: ${transactionHash}`) // checkForReceipt(2, params, transactionHash, resolve) - }); + }) } -task("send", "Send ETH") - .addParam("from", "From address or account index") - .addOptionalParam("to", "To address or account index") - .addOptionalParam("amount", "Amount to send in ether") - .addOptionalParam("data", "Data included in transaction") - .addOptionalParam("gasPrice", "Price you are willing to pay in gwei") - .addOptionalParam("gasLimit", "Limit of how much gas to spend") +task('send', 'Send ETH') + .addParam('from', 'From address or account index') + .addOptionalParam('to', 'To address or account index') + .addOptionalParam('amount', 'Amount to send in ether') + .addOptionalParam('data', 'Data included in transaction') + .addOptionalParam('gasPrice', 'Price you are willing to pay in gwei') + .addOptionalParam('gasLimit', 'Limit of how much gas to spend') .setAction(async (taskArgs, { network, ethers }) => { - const from = await addr(ethers, taskArgs.from); - debug(`Normalized from address: ${from}`); - const fromSigner = await ethers.provider.getSigner(from); + const from = await addr(ethers, taskArgs.from) + debug(`Normalized from address: ${from}`) + const fromSigner = await ethers.provider.getSigner(from) - let to; + let to if (taskArgs.to) { - to = await addr(ethers, taskArgs.to); - debug(`Normalized to address: ${to}`); + to = await addr(ethers, taskArgs.to) + debug(`Normalized to address: ${to}`) } const txRequest = { from: await fromSigner.getAddress(), to, value: parseUnits( - taskArgs.amount ? taskArgs.amount : "0", - "ether" + taskArgs.amount ? taskArgs.amount : '0', + 'ether' ).toHexString(), nonce: await fromSigner.getTransactionCount(), gasPrice: parseUnits( - taskArgs.gasPrice ? taskArgs.gasPrice : "1.001", - "gwei" + taskArgs.gasPrice ? taskArgs.gasPrice : '1.001', + 'gwei' ).toHexString(), gasLimit: taskArgs.gasLimit ? taskArgs.gasLimit : 24000, chainId: network.config.chainId, - }; + } if (taskArgs.data !== undefined) { - txRequest.data = taskArgs.data; - debug(`Adding data to payload: ${txRequest.data}`); + txRequest.data = taskArgs.data + debug(`Adding data to payload: ${txRequest.data}`) } - debug(txRequest.gasPrice / 8000000000 + " gwei"); - debug(JSON.stringify(txRequest, null, 2)); + debug(txRequest.gasPrice / 8000000000 + ' gwei') + debug(JSON.stringify(txRequest, null, 2)) - return send(fromSigner, txRequest); - }); + return send(fromSigner, txRequest) + }) diff --git a/packages/hardhat/package.json b/packages/hardhat/package.json index 621b753..8ad4c4c 100644 --- a/packages/hardhat/package.json +++ b/packages/hardhat/package.json @@ -44,6 +44,7 @@ "send": "hardhat send", "generate": "hardhat generate", "account": "hardhat account", - "verify": "hardhat verify" + "verify": "hardhat verify", + "prettier": "npx prettier --write . '!(node_module|artifacts|cache|deployments)/**/*'" } } diff --git a/packages/hardhat/scripts/watch.js b/packages/hardhat/scripts/watch.js index 074715b..8a93f1a 100644 --- a/packages/hardhat/scripts/watch.js +++ b/packages/hardhat/scripts/watch.js @@ -1,19 +1,19 @@ -const watch = require("node-watch"); -const { exec } = require("child_process"); +const watch = require('node-watch') +const { exec } = require('child_process') const run = () => { - console.log("🛠 Compiling & Deploying..."); - exec("yarn deploy", function (error, stdout, stderr) { - console.log(stdout); - if (error) console.log(error); - if (stderr) console.log(stderr); - }); -}; + console.log('🛠 Compiling & Deploying...') + exec('yarn deploy', function (error, stdout, stderr) { + console.log(stdout) + if (error) console.log(error) + if (stderr) console.log(stderr) + }) +} -console.log("🔬 Watching Contracts..."); -watch("./contracts", { recursive: true }, function (evt, name) { - console.log("%s changed.", name); - run(); -}); +console.log('🔬 Watching Contracts...') +watch('./contracts', { recursive: true }, function (evt, name) { + console.log('%s changed.', name) + run() +}) -run(); +run() diff --git a/packages/hardhat/test/RocketFactory.test.js b/packages/hardhat/test/RocketFactory.test.js index 24956ac..8fe4449 100644 --- a/packages/hardhat/test/RocketFactory.test.js +++ b/packages/hardhat/test/RocketFactory.test.js @@ -17,28 +17,33 @@ describe('My Rocket Test', function () { const RocketFactory = await ethers.getContractFactory('RocketFactory') myContract = await RocketFactory.deploy() // console.log(myContract.address) - }) - - it("Should create a tx", async function () { + }) + + it('Should create a tx', async function () { const GoofyGoober = await ethers.getContractFactory('GoofyGoober') myToken = await GoofyGoober.deploy() address = myToken.address - let result = await myContract.createTransaction("0x976EA74026E726554dB657fA54763abd0C3a0aa9",address,0,1652078273,0) + let result = await myContract.createTransaction( + '0x976EA74026E726554dB657fA54763abd0C3a0aa9', + address, + 0, + 1652078273, + 0 + ) // console.log(result) }) - it("Should get all transactions", async function () { + it('Should get all transactions', async function () { let result = await myContract.getAllTransactions() // console.log(result) }) - it("Should get a specific transaction", async function () { + it('Should get a specific transaction', async function () { let result = await myContract.getTransaction(0) // console.log("transaction",result) }) - - it("Should execute a transaction and switch the pending flag to true", async function () { + it('Should execute a transaction and switch the pending flag to true', async function () { // const GoofyGoober = await ethers.getContractFactory('GoofyGoober') // myToken = await GoofyGoober.deploy() // address = myToken.address diff --git a/packages/nuxt-app/.prettierrc b/packages/nuxt-app/.prettierrc deleted file mode 100644 index fa51da2..0000000 --- a/packages/nuxt-app/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "trailingComma": "es5", - "tabWidth": 2, - "semi": false, - "singleQuote": true -}