Skip to content

Instantly share code, notes, and snippets.

View Midvel's full-sized avatar

Pavlo Horbonos Midvel

View GitHub Profile
@Midvel
Midvel / docgen.js
Created July 25, 2021 19:57
docgen example
/// @notice Storage variable documentation example.
uint256 public storagevar;
/// @notice Mints desired amount of tokens for the recepient
/// @param _receiver Receiver of the tokens.
/// @param _amount Amount (in wei - smallest decimals)
function mintFor(address _receiver, uint256 _amount) external {
}
@Midvel
Midvel / husky.sh
Created July 25, 2021 19:55
Commitlint
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx commitlint --edit $1
@Midvel
Midvel / husky.sh
Created July 25, 2021 19:54
Pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run prettier:fix
npm run prettier:check
"dev:prettier": "npx prettier --write .",
"dev:prettier-check": "npx prettier --check .",
"dev:lint": "npx eslint . && npx solhint contracts/**/*.sol",
"dev:coverage": "npx truffle run coverage --network coverage --solcoverjs ./.solcover.js",
"dev:contract-size": "npx truffle run contract-size",
"dev:docgen": "npx solidity-docgen -i ./contracts -o ./docs -t docgen --solc-module solc -H docgen/helpers.js",
"dev:slither": "slither . --config-file slither-config.json",
"prettier:fix": "npx prettier --write \"contracts/**/*.sol\"",
"prettier:check": "npx prettier --check \"contracts/**/*.sol\"",
"postinstall": "npm run compile && npm run generate-abi",
"prepare": "husky install"
"compile": "npx truffle compile --all",
"ganache": "npx ganache-cli --gasLimit 6721975 --gasPrice 20000000000 -e 10000000 -p 8545 -a 20",
"test": "npx truffle test",
"generate-abi": "npx truffle-abi -o ./abi",
module.exports = {
// networks and other stuff
plugins: ["solidity-coverage", "truffle-contract-size"],
// Set default mocha options here, use special reporters etc.
mocha: {
timeout: 25000,
reporter: 'eth-gas-reporter'
},
require("dotenv").config();
const HDWalletProvider = require("@truffle/hdwallet-provider");
module.exports = {
networks: {
main: {
provider: () =>
new HDWalletProvider(
process.env.MAINNET_PRIVATE_KEY,
`https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`
// CODE FROM web3-eth-accounts/lib/index.js
// NATIVE WEB3 LIBRARY CODE
Accounts.prototype.hashMessage = function hashMessage(data) {
var messageHex = utils.isHexStrict(data) ? data : utils.utf8ToHex(data);
var messageBytes = utils.hexToBytes(messageHex);
var messageBuffer = Buffer.from(messageBytes);
// MANDATORY HASHING
var preamble = '\x19Ethereum Signed Message:\n' + messageBytes.length;
var preambleBuffer = Buffer.from(preamble);
var ethMessage = Buffer.concat([preambleBuffer, messageBuffer]);
//Create new account
refUser = await web3.eth.accounts.create();
let mesGenerated = ... //from previous gist
let mesSigned = refUser.sign(mesGenerated)