Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/nlohmann_json
Submodule nlohmann_json updated 226 files
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
buildInputs = [
hspkgs.cabal-install
hspkgs.haskell-language-server
pkgs.boost
pkgs.cmake
pkgs.foundry-bin
pkgs.go-ethereum
pkgs.jq
Expand Down
52 changes: 52 additions & 0 deletions test/examples/dispatch/basic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"basic": {
"bytecode": "",
"contract": "C",
"tests": [
{
"input": {
"calldata": "",
"value": "0"
},
"kind": "constructor"
},
{
"input": {
"text-calldata": "nothing()",
"calldata": "448f30a3",
"value": "0"
},
"kind": "call",
"output": {
"returndata": "",
"status": "success"
}
},
{
"input": {
"text-calldata": "something()(uint256)",
"calldata": "a7a0d537",
"value": "0"
},
"kind": "call",
"output": {
"returndata": "0000000000000000000000000000000000000000000000000000000000000001",
"status": "success"
}
},
{
"input": {
"text-calldata": "add2(uint256,uint256)(uint256) 2 3",
"calldata": "0x29fcda3300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003",
"value": "0"
},
"kind": "call",
"output": {
"returndata": "0000000000000000000000000000000000000000000000000000000000000005",
"status": "success"
}
}

]
}
}
1 change: 1 addition & 0 deletions test/examples/dispatch/basic.solc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dispatch;

contract C {
constructor() {}
function nothing() -> () {}

function something() -> (uint256) {
Expand Down
43 changes: 43 additions & 0 deletions test/examples/dispatch/miniERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"miniERC20": {
"bytecode": "_CODE",
"contract": "MiniERC20",
"tests": [
{
"input": {
"comment": "'constructor(string,string,uint)' Argot ARG 1000",
"calldata": "000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000054172676f7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034152470000000000000000000000000000000000000000000000000000000000",
"value": "0"
},
"kind": "constructor"
},

{
"input": {
"comment": "transfer(address,uint)(bool) $ANVIL1 958",
"calldata": "a9059cbb00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c800000000000000000000000000000000000000000000000000000000000003be",
"value": "0"
},
"kind": "call",
"output": {
"returndata": "0000000000000000000000000000000000000000000000000000000000000001",
"status": "success"
}
},

{
"input": {
"comment": "getMyBalance()",
"calldata": "0x4c738909",
"value": "0"
},
"kind": "call",
"output": {
"returndata": "000000000000000000000000000000000000000000000000000000000000002a",
"status": "success"
}
}
]

}
}
46 changes: 40 additions & 6 deletions testsol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,40 @@ function hevmsol() {

}

function deploysol() {
function hevmsol() {

echo $*
file=$1
echo $file
local base=$(basename $1 .solc)
local core=output1.core
local hexfile=$base.hex
local yulfile=$base.yul
echo Hex: $hexfile
shift
cabal exec sol-core -- -f $file $* && \
cabal exec yule -- $core --nodeploy -O -o $yulfile && \
solc --strict-assembly --bin --optimize $yulfile | tail -1 > $hexfile && \
hevm exec --code $(cat $hexfile) | awk -f parse_hevm_output.awk

}

function solchex() {
local file=$1
shift
echo "Solc: $file"
local base=$(basename $file .solc)
local core=output1.core
echo "Sail: $core"
echo "Hull: $core"
local yulfile=$base.yul
echo "Yul: $yulfile"
rm -f -v $yulfile
cabal exec sol-core -- -f $file $* && \
cabal exec yule -- $core -o $yulfile
cabal exec yule -- $core --compress -o $yulfile
hex=$(solc --strict-assembly --bin --optimize --optimize-yul $yulfile | tail -1)
rawtx=$(cast mktx --private-key=$DEPLOYER_KEY --create $hex)
addr=$(cast publish $rawtx | jq .contractAddress | tr -d '"')
echo $addr
local hexfile=$base.hex
echo "Writing hex: $hexfile"
echo $hex > $hexfile
}

function deploycore() {
Expand Down Expand Up @@ -122,6 +140,22 @@ function deployyul() {
echo $contractAddress
}

function deployhex() {
local hexfile=$1
shift
local data=$(cast ae $* | cut -c 3-)
echo "Args: $*"
echo "ABI-enc: $data"
prog=$(cat $hexfile)
hex="$prog$data"
echo Hex: $hex
rawtx=$(cast mktx --private-key=$DEPLOYER_KEY --create $hex $*)
txoutput=$(cast publish $rawtx)
echo $txoutput | jq .
export contractAddress=$(echo $txoutput | jq .contractAddress | tr -d '"')
echo $contractAddress
}

# deploy contract with 1 uint arg
function deployyul1() {
local yulfile=$1
Expand Down