Skip to content

Commit

Permalink
update lint stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Mar 6, 2024
1 parent b3d00bd commit 9a0e9d0
Show file tree
Hide file tree
Showing 18 changed files with 1,201 additions and 962 deletions.
13 changes: 6 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaVersion: 2020,
sourceType: 'module',
},
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:prettier/recommended', // Enable
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', // Puts Prettier last to override other settings
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/no-non-null-assertion': 'off',
// other rules...
},
};
16 changes: 8 additions & 8 deletions abigen/code.go.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const fs = require('fs')
const fs = require('fs');

const [,,package,compiled,contract] = process.argv
const [, , package, compiled, contract] = process.argv;

const output = JSON.parse(fs.readFileSync(compiled))
const output = JSON.parse(fs.readFileSync(compiled));

function makeCodeFile(contract, path=`contracts/${contract}.sol`) {
const Contract = output.contracts[`${path}:${contract}`]
const binRuntime = Contract['bin-runtime']
function makeCodeFile(contract, path = `contracts/${contract}.sol`) {
const Contract = output.contracts[`${path}:${contract}`];
const binRuntime = Contract['bin-runtime'];

return ` // Copyright 2019 The Swarm Authors
// This file is part of the Swarm library.
Expand All @@ -29,7 +29,7 @@ function makeCodeFile(contract, path=`contracts/${contract}.sol`) {
package ${package}
// ${contract}DeployedCode is the bytecode ${contract} will have after deployment
const ${contract}DeployedCode = "0x${binRuntime}"`
const ${contract}DeployedCode = "0x${binRuntime}"`;
}

console.log(makeCodeFile(contract))
console.log(makeCodeFile(contract));
11 changes: 5 additions & 6 deletions deploy/local/000_deploy_factory.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { DeployFunction } from 'hardhat-deploy/types';

const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) {

const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const waitBlockConfirmations = network.name != "testnet" ? 1 : 6;
const waitBlockConfirmations = network.name != 'testnet' ? 1 : 6;

log("----------------------------------------------------");
log('----------------------------------------------------');

const token = await deploy("TestToken", {
const token = await deploy('TestToken', {
from: deployer,
log: true,
});

log(`Token deployed at address ${token.address}`);

const deployArgs: string[] = [token.address];
const factory = await deploy("SimpleSwapFactory", {
const factory = await deploy('SimpleSwapFactory', {
from: deployer,
args: deployArgs,
log: true,
Expand All @@ -27,4 +26,4 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, ne
};

export default func;
func.tags = ["factory"];
func.tags = ['factory'];
7 changes: 3 additions & 4 deletions deploy/local/001_deploy_oracle.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

import { DeployFunction } from 'hardhat-deploy/types';

const func: DeployFunction = async function ({ deployments, getNamedAccounts }) {
const func: DeployFunction = async function ({ deployments, getNamedAccounts }) {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const waitBlockConfirmations = 1;

log("----------------------------------------------------");
log('----------------------------------------------------');
const deployArgs: [number, number] = [100, 200];

// Deploy the PriceOracle contract
Expand All @@ -22,4 +21,4 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts })
};

export default func;
func.tags = ["factory"];
func.tags = ['factory'];
19 changes: 9 additions & 10 deletions deploy/local/002_deploy_env_variables.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import fs from "fs";
import path from "path";
import fs from 'fs';
import path from 'path';
import { DeployFunction } from 'hardhat-deploy/types';


const func: DeployFunction = async function ({ deployments, config }) {
const { get, log } = deployments;

const SimpleSwapFactory = await get("SimpleSwapFactory");
const PriceOracle = await get("PriceOracle");
const SimpleSwapFactory = await get('SimpleSwapFactory');
const PriceOracle = await get('PriceOracle');

// Generate content for the environment file
let content = "";
let content = '';

content += `echo "----- USE THE COMMANDS BELOW TO SETUP YOUR TERMINALS -----" >&2\n\n`;
content += `export BEE_SWAP_FACTORY_ADDRESS=${SimpleSwapFactory.address}\n`;
content += `export BEE_SWAP_LEGACY_FACTORY_ADDRESSES=${SimpleSwapFactory.address}\n`;
content += `export BEE_SWAP_PRICE_ORACLE_ADDRESS=${PriceOracle.address}\n`;
content += `export BEE_SWAP_ENDPOINT=${config.networks.localhost.url}\n`;

const envFilePath = path.join(__dirname, "../../deployedContracts.sh");
const envFilePath = path.join(__dirname, '../../deployedContracts.sh');

// Write the content to the file
fs.writeFileSync(envFilePath, content, { flag: "a" });
fs.writeFileSync(envFilePath, content, { flag: 'a' });
log(`Exported contract addresses to ${envFilePath}`);

log("----------------------------------------------------");
log('----------------------------------------------------');
};

export default func;
func.tags = ["variables"];
func.tags = ['variables'];
7 changes: 3 additions & 4 deletions deploy/main/000_deploy.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { DeployFunction } from 'hardhat-deploy/types';

const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) {

const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();

// This code is just used for Sepolia testnet deployment
const waitBlockConfirmations = network.name !== "mainnet" ? 1 : 6;
const waitBlockConfirmations = network.name !== 'mainnet' ? 1 : 6;

log("----------------------------------------------------");
log('----------------------------------------------------');
// sBZZ token address
// TODO this still needs to be done for the first time
};

func.tags = ["factory"];
func.tags = ['factory'];
export default func;
17 changes: 8 additions & 9 deletions deploy/test/000_deploy_factory.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

import { verify } from "../../utils/verify";
import { verify } from '../../utils/verify';
import { DeployFunction } from 'hardhat-deploy/types';

const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();

// This code is just used for Sepolia testnet deployment
const waitBlockConfirmations = network.name !== "testnet" ? 1 : 6;
const waitBlockConfirmations = network.name !== 'testnet' ? 1 : 6;

log("----------------------------------------------------");
const deployArgs: string[] = ["0x543ddb01ba47acb11de34891cd86b675f04840db"];
const factory = await deploy("SimpleSwapFactory", {
log('----------------------------------------------------');
const deployArgs: string[] = ['0x543ddb01ba47acb11de34891cd86b675f04840db'];
const factory = await deploy('SimpleSwapFactory', {
from: deployer,
args: deployArgs,
log: true,
Expand All @@ -21,11 +20,11 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, ne
log(`Factory deployed at address ${factory.address}`);

// Verify the deployment
if (network.name === "testnet" && process.env.TESTNET_ETHERSCAN_KEY) {
log("Verifying...");
if (network.name === 'testnet' && process.env.TESTNET_ETHERSCAN_KEY) {
log('Verifying...');
await verify(factory.address, arguments);
}
};

func.tags = ["factory"];
func.tags = ['factory'];
export default func;
11 changes: 5 additions & 6 deletions deploy/test/001_deploy_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import verify from '../../utils/verify';
import { DeployFunction } from 'hardhat-deploy/types';

const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) {

const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const args = [100000, 100];
Expand All @@ -16,14 +15,14 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, ne
});

// Log the address at which the Oracle is deployed
console.log('Oracle deployed at address ' + oracle.address)
console.log('Oracle deployed at address ' + oracle.address);

// Verify the deployment
if (network.name == "testnet" && process.env.TESTNET_ETHERSCAN_KEY) {
log("Verifying...");
if (network.name == 'testnet' && process.env.TESTNET_ETHERSCAN_KEY) {
log('Verifying...');
await verify(oracle.address, arguments);
}
};

func.tags = ["factory"];
export default func;
func.tags = ['factory'];
export default func;
6 changes: 6 additions & 0 deletions deployedContracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ export BEE_SWAP_FACTORY_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
export BEE_SWAP_LEGACY_FACTORY_ADDRESSES=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
export BEE_SWAP_PRICE_ORACLE_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
export BEE_SWAP_ENDPOINT=http://localhost:8545
echo "----- USE THE COMMANDS BELOW TO SETUP YOUR TERMINALS -----" >&2

export BEE_SWAP_FACTORY_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
export BEE_SWAP_LEGACY_FACTORY_ADDRESSES=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
export BEE_SWAP_PRICE_ORACLE_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
export BEE_SWAP_ENDPOINT=http://localhost:8545
54 changes: 26 additions & 28 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ import { HardhatUserConfig } from 'hardhat/types';
const PRIVATE_RPC_MAINNET: string | undefined = process.env.PRIVATE_RPC_MAINNET;
const PRIVATE_RPC_TESTNET: string | undefined = process.env.PRIVATE_RPC_TESTNET;

const walletSecret: string =
process.env.WALLET_SECRET === undefined
? "undefined"
: process.env.WALLET_SECRET;
const walletSecret: string = process.env.WALLET_SECRET === undefined ? 'undefined' : process.env.WALLET_SECRET;

if (walletSecret === "undefined") {
console.log("Please set your WALLET_SECRET in a .env file");
if (walletSecret === 'undefined') {
console.log('Please set your WALLET_SECRET in a .env file');
} else if (walletSecret.length !== 64) {
console.log("WALLET_SECRET must be 64 characters long.");
console.log('WALLET_SECRET must be 64 characters long.');
}

const mainnetEtherscanKey: string | undefined = process.env.MAINNET_ETHERSCAN_KEY;
const testnetEtherscanKey: string | undefined = process.env.TESTNET_ETHERSCAN_KEY;
const accounts: string[] | { mnemonic: string } = walletSecret.length === 64 ? [walletSecret] : { mnemonic: walletSecret };
const accounts: string[] | { mnemonic: string } =
walletSecret.length === 64 ? [walletSecret] : { mnemonic: walletSecret };

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
defaultNetwork: 'hardhat',
solidity: {
compilers: [
{
Expand All @@ -38,59 +36,59 @@ const config: HardhatUserConfig = {
},
},
{
version: "0.7.6",
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
}
]
},
],
},
networks: {
hardhat: {
deploy: ["deploy/local/"],
deploy: ['deploy/local/'],
},
localhost: {
url: "http://localhost:8545",
url: 'http://localhost:8545',
accounts,
chainId: 31337,
deploy: ["deploy/local/"],
deploy: ['deploy/local/'],
},
testnet: {
url: PRIVATE_RPC_TESTNET || "https://1rpc.io/sepolia",
url: PRIVATE_RPC_TESTNET || 'https://1rpc.io/sepolia',
accounts,
chainId: 11155111,
deploy: ["deploy/test/"],
deploy: ['deploy/test/'],
},
mainnet: {
url: PRIVATE_RPC_MAINNET || "https://rpc.gnosischain.com",
url: PRIVATE_RPC_MAINNET || 'https://rpc.gnosischain.com',
accounts,
chainId: 100,
deploy: ["deploy/main/"],
deploy: ['deploy/main/'],
},
},
etherscan: {
apiKey: {
mainnet: mainnetEtherscanKey || "",
testnet: testnetEtherscanKey || "",
mainnet: mainnetEtherscanKey || '',
testnet: testnetEtherscanKey || '',
},
customChains: [
{
network: "testnet",
network: 'testnet',
chainId: 11155111,
urls: {
apiURL: "https://api-sepolia.etherscan.io/api",
browserURL: "https://sepolia.etherscan.io/address/",
apiURL: 'https://api-sepolia.etherscan.io/api',
browserURL: 'https://sepolia.etherscan.io/address/',
},
},
{
network: "mainnet",
network: 'mainnet',
chainId: 100,
urls: {
apiURL: "https://api.gnosisscan.io/api",
browserURL: "https://gnosisscan.io/address/",
apiURL: 'https://api.gnosisscan.io/api',
browserURL: 'https://gnosisscan.io/address/',
},
},
],
Expand All @@ -103,7 +101,7 @@ const config: HardhatUserConfig = {
other: 4,
},
paths: {
sources: "contracts",
sources: 'contracts',
},
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"cross-env": "^7.0.2",
"dotenv": "^16.0.3",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"ethereum-waffle": "^4.0.10",
"ethereumjs-abi": "^0.6.8",
"ethers": "^5.7.0",
Expand Down
Loading

0 comments on commit 9a0e9d0

Please # to comment.