codeforcer / foundry-yul Goto Github PK
View Code? Open in Web Editor NEWFoundry + Yul template
Foundry + Yul template
If I clone the repo and run forge test -vvv
, I get the following error:
ERROR forge::runner: setUp failed reason="YulDeployer could not deploy contract" contract=0x7fa9385be102ac3eac297483dd6233d62b3e1496
Digging into it and attempting to log the compiled bytecode, it appears that the bytecode is correct (0x6009600b5f3960095ff3fe5f35608052366080f3), but the create function returns an error. I'm uncertain as to why that's the case.
Any insight would be helpful.
Hi,
First of all, thanks for the useful repo!
I am new to Yul and Yul testing and playing with your example code to understand how to test with Yul.
Getting the following error while I want to test an eternal function.
Compiler run failed
error[9582]: TypeError: Member "uri" not found or not visible after argument-dependent lookup in contract Example.
--> test/Example.t.sol:19:9:
|
19 | exampleContract.uri(1);
Probably it doesn't find uri
function but I don't know how to make the call uri
function.
Here are the code
// Example.yul
object "Example" {
code {
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
// Return the calldata
code {
mstore(0x80, calldataload(0))
return(0x80, calldatasize())
switch getSelector()
case 0x0e89341c /* uri(uint256 id) */ {
mstore(0, 0x0a)
return(0, 0x40)
}
function getSelector() -> selector {
selector := div(calldataload(0), 0x100000000000000000000000000000000000000000000000000000000)
}
}
}
}
And the test file (Check the testUri
)
// Example.t.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "forge-std/Test.sol";
import "./lib/YulDeployer.sol";
interface Example {}
contract ExampleTest is Test {
YulDeployer yulDeployer = new YulDeployer();
Example exampleContract;
function setUp() public {
exampleContract = Example(yulDeployer.deployContract("Example"));
}
function testUri() public {
exampleContract.uri(1);
}
}
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.