chore: compile smart contracts and generate types

This commit is contained in:
Richard Ramos 2023-08-30 18:00:14 -04:00 committed by richΛrd
parent 30422114f6
commit ab3f21f209
11 changed files with 2079 additions and 782 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "waku/v2/protocol/rln/contracts/rln-contract"]
path = waku/v2/protocol/rln/contracts/rln-contract
url = git@github.com:vacp2p/rln-contract.git
[submodule "waku/v2/protocol/rln/contracts/waku-rln-contract"]
path = waku/v2/protocol/rln/contracts/waku-rln-contract
url = git@github.com:waku-org/waku-rln-contract.git

View File

@ -3,6 +3,7 @@
### Requirements:
- Node.js
- Go
- jq
- [solcjs 0.8.15](https://github.com/ethereum/solc-js)
- [abigen](https://github.com/ethereum/go-ethereum/tree/master/cmd/abigen)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,24 @@
#!/bin/sh
# Generate solc_output.json
cat import.json | solcjs --bin --standard-json --base-path . > solc_output.json
tail -n +2 solc_output.json > solc_output.tmp # Removes ">>> Cannot retry compilation with SMT because there are no SMT solvers available."
mv solc_output.tmp solc_output.json
# Generate abi and binary files for each smart contract
jq '.contracts."WakuRln.sol".WakuRln.abi' -r -c solc_output.json > WakuRln.abi
jq '.contracts."WakuRln.sol".WakuRln.evm.bytecode.object' -r -c solc_output.json > WakuRln.bin
jq '.contracts."WakuRlnRegistry.sol".WakuRlnRegistry.abi' -r -c solc_output.json > WakuRlnRegistry.abi
jq '.contracts."WakuRlnRegistry.sol".WakuRlnRegistry.evm.bytecode.object' -r -c solc_output.json > WakuRlnRegistry.bin
jq '.contracts."rln-contract/PoseidonHasher.sol".PoseidonHasher.abi' -r -c solc_output.json > PoseidonHasher.abi
jq '.contracts."rln-contract/PoseidonHasher.sol".PoseidonHasher.evm.bytecode.object' -r -c solc_output.json > PoseidonHasher.bin
# Generate golang types for each contract
abigen --abi ./WakuRln.abi --pkg contracts --type RLN --out ./rln.go --bin ./WakuRln.bin
abigen --abi ./WakuRlnRegistry.abi --pkg contracts --type RLNRegistry --out ./registry.go --bin ./WakuRlnRegistry.bin
abigen --abi ./PoseidonHasher.abi --pkg contracts --type PoseidonHasher --out ./poseidon.go --bin ./PoseidonHasher.bin
# Cleanup
rm *.bin
rm *.abi
rm solc_output.json

View File

@ -1,5 +1,3 @@
package contracts
//go:generate solcjs --abi --bin ./rln-contract/contracts/Rln.sol -o ./
//go:generate abigen --abi ./rln-contract_contracts_Rln_sol_RLN.abi --pkg contracts --type RLN --out ./RLN.go --bin ./rln-contract_contracts_Rln_sol_RLN.bin
//go:generate abigen --abi ./rln-contract_contracts_PoseidonHasher_sol_PoseidonHasher.abi --pkg contracts --type PoseidonHasher --out ./PoseidonHasher.go --bin ./rln-contract_contracts_PoseidonHasher_sol_PoseidonHasher.bin
//go:generate ./compile_contracts.sh

View File

@ -0,0 +1,31 @@
{
"language": "Solidity",
"sources": {
"WakuRln.sol": {
"urls": ["./waku-rln-contract/contracts/WakuRln.sol"]
},
"WakuRlnRegistry.sol": {
"urls": ["./waku-rln-contract/contracts/WakuRlnRegistry.sol"]
},
"rln-contract/PoseidonHasher.sol": {
"urls": [
"./waku-rln-contract/lib/rln-contract/contracts/PoseidonHasher.sol"
]
},
"rln-contract/RlnBase.sol": {
"urls": ["./waku-rln-contract/lib/rln-contract/contracts/RlnBase.sol"]
},
"rln-contract/IVerifier.sol": {
"urls": ["./waku-rln-contract/lib/rln-contract/contracts/IVerifier.sol"]
},
"openzeppelin-contracts/contracts/access/Ownable.sol": {
"urls": ["./waku-rln-contract/lib/openzeppelin-contracts/contracts/access/Ownable.sol"]
},
"openzeppelin-contracts/contracts/utils/Context.sol": {
"urls": ["./waku-rln-contract/lib/openzeppelin-contracts/contracts/utils/Context.sol"]
}
},
"settings": {
"outputSelection": { "*": { "*": ["abi", "evm.bytecode.object"] } }
}
}

File diff suppressed because one or more lines are too long

@ -1 +0,0 @@
Subproject commit f99eb2aa0d62bb27631f6ffb4c6161ceb334d2a3

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
Subproject commit 63a7856eb29f08644d1e963e3edfc2c182469257