-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nix flake to generate contract abi bindings
- Loading branch information
Showing
3 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
description = '' | ||
A Nix flake for compiling and extracting the fuel contract abi. | ||
''; | ||
|
||
inputs = { | ||
open-zeppelin = { | ||
url = "github:OpenZeppelin/openzeppelin-contracts"; | ||
flake = false; | ||
}; | ||
fuel-v1-contracts = { | ||
url = "github:FuelLabs/fuel-merkle-sol"; | ||
flake = false; | ||
}; | ||
fuel-v2-contracts.url = "git+ssh://git@github.com/fuellabs/fuel-v2-contracts/"; | ||
fuel-v2-contracts.flake = false; | ||
nixpkgs = { | ||
url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
}; | ||
dapptools = { | ||
url = "github:dapphub/dapptools/master"; | ||
flake = false; | ||
}; | ||
npm.url = "github:/serokell/nix-npm-buildpackage"; | ||
}; | ||
|
||
outputs = inputs: let | ||
system = "x86_64-darwin"; | ||
dapp = import inputs.dapptools {inherit system;}; | ||
solc = dapp.runCommand "solc" {} "mkdir -p $out/bin; ln -s ${dapp.solc-static-versions.solc_0_8_9}/bin/solc-0.8.9 $out/bin/solc"; | ||
overlays = [inputs.npm.overlays.default]; | ||
pkgs = import inputs.nixpkgs {inherit overlays system;}; | ||
in { | ||
packages."x86_64-darwin" = { | ||
add-folder = pkgs.linkFarm "contracts-with-layer" [ | ||
{ | ||
name = "merkle-sol"; | ||
path = inputs.fuel-v1-contracts; | ||
} | ||
]; | ||
build-abi-json = | ||
pkgs.runCommand | ||
"build-abi-json" | ||
{} | ||
'' | ||
${solc}/bin/solc --abi --pretty-json ${inputs.fuel-v2-contracts}/contracts/sidechain/FuelSidechain.sol @openzeppelin=${inputs.open-zeppelin} @fuel-contracts=${inputs.self.packages."${system}".add-folder} -o $out/build | ||
''; | ||
generate-abi-json = pkgs.writeShellApplication { | ||
name = "generate-abi-0json"; | ||
runtimeInputs = [solc pkgs.jq inputs.self.packages."${system}".build-abi-json]; | ||
text = '' | ||
if [[ -z $1 ]] | ||
then | ||
echo "Invalid input. Must provide output directoy" >&2; exit 1; | ||
fi | ||
declare -a arr=("FuelMessagePortal") | ||
for i in "''${arr[@]}" | ||
do | ||
(cat ${inputs.self.packages."${system}".build-abi-json}/build/"$i".abi) | jq '.' > "$1"/"$i".json | ||
done | ||
''; | ||
}; | ||
|
||
|
||
}; | ||
formatter.x86_64-darwin = pkgs.alejandra; | ||
}; | ||
} |