primitivefinance / hardhat-marmite Goto Github PK
View Code? Open in Web Editor NEW๐ฅ Hassle-free Hardhat plugin to compare gas cost among different Solidity code snippets.
License: MIT License
๐ฅ Hassle-free Hardhat plugin to compare gas cost among different Solidity code snippets.
License: MIT License
My script:
import hre from 'hardhat';
import marmite from '@primitivefi/hardhat-marmite';
async function main() {
await marmite(hre, async (flag) => {
const Complex = await hre.ethers.getContractFactory('Complex');
const complex = await Complex.deploy(1);
const tx = await complex.set(42);
await flag('Set function', tx);
});
}
main();
contract:
// SPDX-License-Identifier: WTFPL
pragma solidity 0.8.9;
contract Complex {
uint256 public bar;
constructor(uint256 initBar) {
bar = initBar;
}
function set(uint256 newBar) external {
@start<test1>
if (newBar > 0) {
bar = newBar;
}
@end
@start<test2>
if (newBar != 0) {
bar = newBar;
}
@end
}
}
executing: npx hardhat golf:script ./scripts/marmite.ts
returns:
Greater-than โ Different-from are from another contract in the same folder than Complex
I would expect return only from the contract I am running in the script
This is probably due to my lack of understanding of bash and/or zsh.
npx hardhat golf:contract --contract Foo --func mintManyToSender --params ("value"),1,"0x0"
// returns
zsh: no matches found: (value),1,0x0
this fails because ("value") gets interpreted as a string. This doesn't even compile
If I set a reference above it doesn't pass the reference:
array=(value)
npx hardhat golf:contract --contract Foo --func mintManyToSender --params array,1,"0x0"
This compiles BUT errors out with this:
reason: 'invalid value for array',
code: 'INVALID_ARGUMENT',
argument: 'value',
value: 'array'
Any ideas? I'm sure this will be an issue with others as well but again don't think it's necessarily related to this package just understanding of bash ๐
hardhat compile behaviour does not resemble the usual node_modules precedence rules. The compilation of contracts in the .gas directory seem to import from node_modules in root directory instead, therefore not removing the tags and leading to compilation error.
Import path resolution of the hardhat compile task needs to be manipulated to import from root/.gs/node_modules instead of root/node_modules
Hey guys, I'm currently trying to use the hardhat-marmite plugin. https://github.com/primitivefinance/hardhat-marmite
However, when I include a tag, ie @start in solidity, I get a ParserError: Invalid token. when running npx hardhat golf:script . This makes sense, as @start is not a valid token in solidity.
Do you guys have any ideas how to fix this error?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.