From f67b8ccc3b265cdda01ae22ec6ff174d0aa5f7b0 Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Mon, 24 Apr 2023 16:56:20 +0200 Subject: [PATCH] yarn lint --- .../contracts/Casino.sol | 8 ++-- .../contracts/Killable.sol | 2 +- examples/metacoin/contracts/ConvertLib.sol | 13 +++--- examples/metacoin/contracts/MetaCoin.sol | 44 +++++++++---------- .../metacoin/contracts/WrappedMetaCoin.sol | 28 ++++++------ .../contracts/SimpleProxyAdmin.sol | 3 +- .../contracts/SimpleToken.sol | 9 ++-- .../contracts/SimpleTokenUpgradeable.sol | 4 +- .../contracts/SimpleTokenUpgradeable2.sol | 4 +- src/types.ts | 2 +- src/util.ts | 1 - src/verifier/SourcifyVerifier.ts | 6 +-- src/verifier/Verifier.ts | 1 - src/verify.ts | 2 +- 14 files changed, 61 insertions(+), 66 deletions(-) diff --git a/docs/kalis-me-tutorial-code/contracts/Casino.sol b/docs/kalis-me-tutorial-code/contracts/Casino.sol index 463ffda..7116288 100644 --- a/docs/kalis-me-tutorial-code/contracts/Casino.sol +++ b/docs/kalis-me-tutorial-code/contracts/Casino.sol @@ -1,6 +1,6 @@ pragma solidity ^0.5.8; -import "./Killable.sol"; +import './Killable.sol'; contract Casino is Killable { event Play(address payable indexed player, uint256 betSize, uint8 betNumber, uint8 winningNumber); @@ -9,8 +9,8 @@ contract Casino is Killable { function fund() external payable {} function bet(uint8 number) external payable { - require(msg.value <= getMaxBet(), "Bet amount can not exceed max bet size"); - require(msg.value > 0, "A bet should be placed"); + require(msg.value <= getMaxBet(), 'Bet amount can not exceed max bet size'); + require(msg.value > 0, 'A bet should be placed'); uint8 winningNumber = generateWinningNumber(); emit Play(msg.sender, msg.value, number, winningNumber); @@ -25,7 +25,7 @@ contract Casino is Killable { } function generateWinningNumber() internal view returns (uint8) { - return uint8(block.number % 10 + 1); // Don't do this in production + return uint8((block.number % 10) + 1); // Don't do this in production } function payout(address payable winner, uint256 amount) internal { diff --git a/docs/kalis-me-tutorial-code/contracts/Killable.sol b/docs/kalis-me-tutorial-code/contracts/Killable.sol index 468995d..4636f2e 100644 --- a/docs/kalis-me-tutorial-code/contracts/Killable.sol +++ b/docs/kalis-me-tutorial-code/contracts/Killable.sol @@ -8,7 +8,7 @@ contract Killable { } function kill() external { - require(msg.sender == owner, "Only the owner can kill this contract"); + require(msg.sender == owner, 'Only the owner can kill this contract'); selfdestruct(owner); } } diff --git a/examples/metacoin/contracts/ConvertLib.sol b/examples/metacoin/contracts/ConvertLib.sol index c16bdb1..5ce0403 100644 --- a/examples/metacoin/contracts/ConvertLib.sol +++ b/examples/metacoin/contracts/ConvertLib.sol @@ -2,12 +2,11 @@ pragma solidity >=0.4.25 <0.9.0; library ConvertLib { - struct TestStruct { - uint256 name; - } + struct TestStruct { + uint256 name; + } - function convert(uint amount,uint conversionRate) public pure returns (uint convertedAmount) - { - return amount * conversionRate; - } + function convert(uint amount, uint conversionRate) public pure returns (uint convertedAmount) { + return amount * conversionRate; + } } diff --git a/examples/metacoin/contracts/MetaCoin.sol b/examples/metacoin/contracts/MetaCoin.sol index 0e388ba..c3cd73b 100644 --- a/examples/metacoin/contracts/MetaCoin.sol +++ b/examples/metacoin/contracts/MetaCoin.sol @@ -2,7 +2,7 @@ pragma experimental ABIEncoderV2; pragma solidity >=0.4.25 <0.9.0; -import "./ConvertLib.sol"; +import './ConvertLib.sol'; // This is just a simple example of a coin-like contract. // It is not standards compatible and cannot be expected to talk to other @@ -10,31 +10,31 @@ import "./ConvertLib.sol"; // token, see: https://github.com/ConsenSys/Tokens. Cheers! contract MetaCoin { - mapping (address => uint) balances; + mapping(address => uint) balances; - event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Transfer(address indexed _from, address indexed _to, uint256 _value); - constructor() public { - balances[tx.origin] = 10000; - } + constructor() public { + balances[tx.origin] = 10000; + } - function sendCoin(address receiver, uint amount) public returns(bool sufficient) { - if (balances[msg.sender] < amount) return false; - balances[msg.sender] -= amount; - balances[receiver] += amount; - emit Transfer(msg.sender, receiver, amount); - return true; - } + function sendCoin(address receiver, uint amount) public returns (bool sufficient) { + if (balances[msg.sender] < amount) return false; + balances[msg.sender] -= amount; + balances[receiver] += amount; + emit Transfer(msg.sender, receiver, amount); + return true; + } - function getBalanceInEth(address addr) public view returns(uint){ - return ConvertLib.convert(getBalance(addr),2); - } + function getBalanceInEth(address addr) public view returns (uint) { + return ConvertLib.convert(getBalance(addr), 2); + } - function getBalance(address addr) public view returns(uint) { - return balances[addr]; - } + function getBalance(address addr) public view returns (uint) { + return balances[addr]; + } - function test(ConvertLib.TestStruct memory testObj) public pure { - require(testObj.name > 10); - } + function test(ConvertLib.TestStruct memory testObj) public pure { + require(testObj.name > 10); + } } diff --git a/examples/metacoin/contracts/WrappedMetaCoin.sol b/examples/metacoin/contracts/WrappedMetaCoin.sol index e831d37..02e619b 100644 --- a/examples/metacoin/contracts/WrappedMetaCoin.sol +++ b/examples/metacoin/contracts/WrappedMetaCoin.sol @@ -1,24 +1,24 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.4.25 <0.9.0; -import { MetaCoin as Coin } from "./MetaCoin.sol"; +import {MetaCoin as Coin} from './MetaCoin.sol'; contract WrappedMetaCoin { - Coin public underlying; + Coin public underlying; - constructor(Coin _underlying) public { - underlying = _underlying; - } + constructor(Coin _underlying) public { + underlying = _underlying; + } - function sendCoin(address receiver, uint amount) public returns(bool sufficient) { - return underlying.sendCoin(receiver, amount); - } + function sendCoin(address receiver, uint amount) public returns (bool sufficient) { + return underlying.sendCoin(receiver, amount); + } - function getBalanceInEth(address addr) public view returns(uint){ - return underlying.getBalanceInEth(addr); - } + function getBalanceInEth(address addr) public view returns (uint) { + return underlying.getBalanceInEth(addr); + } - function getBalance(address addr) public view returns(uint) { - return underlying.getBalance(addr); - } + function getBalance(address addr) public view returns (uint) { + return underlying.getBalance(addr); + } } diff --git a/examples/openzeppelin-token/contracts/SimpleProxyAdmin.sol b/examples/openzeppelin-token/contracts/SimpleProxyAdmin.sol index ff73f97..0cb6f8f 100644 --- a/examples/openzeppelin-token/contracts/SimpleProxyAdmin.sol +++ b/examples/openzeppelin-token/contracts/SimpleProxyAdmin.sol @@ -4,5 +4,4 @@ pragma solidity 0.8.9; import '@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol'; -contract SimpleProxyAdmin is ProxyAdmin{} - +contract SimpleProxyAdmin is ProxyAdmin {} diff --git a/examples/openzeppelin-token/contracts/SimpleToken.sol b/examples/openzeppelin-token/contracts/SimpleToken.sol index e12a5cd..6963fec 100644 --- a/examples/openzeppelin-token/contracts/SimpleToken.sol +++ b/examples/openzeppelin-token/contracts/SimpleToken.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "truffle/console.sol"; +import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; +import 'truffle/console.sol'; /** * @title SimpleToken @@ -11,12 +11,11 @@ import "truffle/console.sol"; * `ERC20` functions. */ contract SimpleToken is ERC20 { - /** * @dev Constructor that gives msg.sender all of existing tokens. */ - constructor () ERC20("Simple Token", "SIM") { + constructor() ERC20('Simple Token', 'SIM') { _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); - console.log("Deployer address is %s", msg.sender); + console.log('Deployer address is %s', msg.sender); } } diff --git a/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable.sol b/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable.sol index 39a32f1..a37aeee 100644 --- a/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable.sol +++ b/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; +import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; contract SimpleTokenUpgradeable is ERC20Upgradeable { function __SimpleToken_init() external initializer { - __ERC20_init("Simple Token", "SIM"); + __ERC20_init('Simple Token', 'SIM'); _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); } } diff --git a/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable2.sol b/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable2.sol index 392f087..de0973f 100644 --- a/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable2.sol +++ b/examples/openzeppelin-token/contracts/SimpleTokenUpgradeable2.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; +import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; contract SimpleTokenUpgradeable2 is ERC20Upgradeable { function __SimpleToken_init() external initializer { - __ERC20_init("Simple Token", "SIM"); + __ERC20_init('Simple Token', 'SIM'); _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); } } diff --git a/src/types.ts b/src/types.ts index 73fbfb4..25cd5ab 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import type TruffleResolver from "@truffle/resolver"; +import type TruffleResolver from '@truffle/resolver'; export interface Logger extends Console { level(level: string): void; diff --git a/src/util.ts b/src/util.ts index 7cacc1b..c0186cb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,3 @@ -import fs from 'fs'; import path from 'path'; import { promisify } from 'util'; import { INDENT, NULL_ADDRESS, StorageSlot } from './constants'; diff --git a/src/verifier/SourcifyVerifier.ts b/src/verifier/SourcifyVerifier.ts index 130e9d7..2a582a3 100644 --- a/src/verifier/SourcifyVerifier.ts +++ b/src/verifier/SourcifyVerifier.ts @@ -58,17 +58,17 @@ export class SourcifyVerifier extends AbstractVerifier implements Verifier { if (result.storageTimestamp) return VerificationStatus.ALREADY_VERIFIED; if (result.status === 'partial') return VerificationStatus.PARTIAL; if (result.status === 'perfect') return VerificationStatus.SUCCESS; - return `${VerificationStatus.FAILED}: ${result?.message}` + return `${VerificationStatus.FAILED}: ${result?.message}`; } catch (error: any) { const errorResponse = error?.response?.data; const errorResponseMessage = errorResponse?.message ?? errorResponse?.error; this.logger.debug(`Error: ${error?.message}`); - logObject(this.logger, 'debug', error?.response?.data, 2) + logObject(this.logger, 'debug', error?.response?.data, 2); // If an error message is present in the checked response, this likely indicates a failed verification if (errorResponseMessage) { - return `${VerificationStatus.FAILED}: ${errorResponseMessage}` + return `${VerificationStatus.FAILED}: ${errorResponseMessage}`; } // If no message was passed in the response, this likely indicates a failed connection diff --git a/src/verifier/Verifier.ts b/src/verifier/Verifier.ts index c194414..872d86b 100644 --- a/src/verifier/Verifier.ts +++ b/src/verifier/Verifier.ts @@ -1,4 +1,3 @@ -import { VerificationStatus } from '../constants'; import { Artifact, Options } from '../types'; export interface Verifier { diff --git a/src/verify.ts b/src/verify.ts index 6885757..2c50d4a 100644 --- a/src/verify.ts +++ b/src/verify.ts @@ -1,6 +1,6 @@ +import TruffleResolver from '@truffle/resolver'; import axios from 'axios'; import tunnel from 'tunnel'; -import TruffleResolver from "@truffle/resolver"; import { API_URLS, EXPLORER_URLS, INDENT, SUPPORTED_VERIFIERS, VERSION } from './constants'; import { Logger, Options, TruffleConfig } from './types'; import { enforce, getApiKey, getNetwork } from './util';