-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove
onchain-verifier
dependency + add hardhat configuratio…
…n + add libraries deployment logic (#3)
- Loading branch information
Showing
38 changed files
with
2,130 additions
and
665 deletions.
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
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
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts |
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,69 @@ | ||
<br /> | ||
<div align="center"> | ||
<img src="https://static.sismo.io/readme/top-main.png" alt="Logo" width="150" height="150" style="borderRadius: 20px"> | ||
|
||
<h3 align="center"> | ||
Sismo Connect Solidity | ||
</h3> | ||
|
||
<p align="center"> | ||
Made by <a href="https://docs.sismo.io/" target="_blank">Sismo</a> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://twitter.com/sismo_eth" target="_blank"> | ||
<img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white"/> | ||
</a> | ||
<a href="https://discord.gg/sismo" target="_blank"> | ||
<img src="https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white"/> | ||
</a> | ||
<a href="https://builders.sismo.io" target="_blank"> | ||
<img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"/> | ||
</a> | ||
</p> | ||
</div> | ||
|
||
|
||
Sismo Connect Solidity is a Solidity library that allows you to verify the zk-proofs of your Sismo Connect Application onchain and simplify the use of the [sismo-connect-onchain-verifier](https://github.com/sismo-core/sismo-connect-onchain-verifier). | ||
|
||
Here is the link to the full documentation of the library: [Sismo Connect Solidity Library](https://docs.sismo.io/build-with-sismo-connect/technical-documentation/solidity) | ||
|
||
You can learn more on Sismo Connect [here](https://docs.sismo.io/sismo-docs/build-with-sismo-connect/getting-started). | ||
|
||
### Prerequisites | ||
|
||
- [Node.js](https://nodejs.org/en/download/) >= 18.15.0 (Latest LTS version) | ||
- [Yarn](https://classic.yarnpkg.com/en/docs/install) | ||
|
||
## Usage | ||
|
||
### Installation | ||
|
||
```bash | ||
# install the package | ||
yarn add @sismo-core/sismo-connect-solidity | ||
``` | ||
|
||
### Import the library | ||
In your solidity file: | ||
|
||
```solidity | ||
import {SismoConnect} from "@sismo-core/sismo-connect-solidity/contracts/SismoConnectLib.sol"; | ||
``` | ||
|
||
You will find here how to use the library: [Sismo Connect Solidity Library](https://docs.sismo.io/build-with-sismo-connect/technical-documentation/solidity) | ||
|
||
## License | ||
|
||
Distributed under the MIT License. | ||
|
||
## Contribute | ||
|
||
Please, feel free to open issues, PRs or simply provide feedback! | ||
|
||
## Contact | ||
|
||
Send us a message in [Telegram](https://builders.sismo.io/) or [Discord](https://discord.gg/sismo) | ||
|
||
<br/> | ||
<img src="https://static.sismo.io/readme/bottom-main.png" alt="bottom" width="100%" > |
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,25 @@ | ||
{ | ||
"name": "@sismo-core/sismo-connect-solidity", | ||
"description": "Sismo Connect Library", | ||
"version": "0.0.21", | ||
"scripts": { | ||
"prepare": "mkdir -p contracts; cp -r ../src/* contracts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sismo-core/sismo-connect-solidity.git" | ||
}, | ||
"keywords": [ | ||
"solidity", | ||
"ethereum", | ||
"smart", | ||
"contracts" | ||
], | ||
"author": "Sismo <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sismo-core/sismo-connect-solidity/issues" | ||
}, | ||
"homepage": "https://github.com/sismo-core/sismo-connect-solidity#readme", | ||
"main": "index.js" | ||
} |
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,6 @@ | ||
{ | ||
"authRequestBuilder": "0xD4339e6d873b584FFfeACceE4CcB8Bf31Cd96ebb", | ||
"claimRequestBuilder": "0xF03dA119efEc165DbDc15D593aB455810C7fEd74", | ||
"requestBuilder": "0x0bB5c193aa815F7815aB8e854A87E041519CD2ad", | ||
"signatureBuilder": "0xc8F165a3B4CfB7CD2Ae92A582F17b0d7EB3BcE11" | ||
} |
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,6 @@ | ||
{ | ||
"authRequestBuilder": "0x8D090172DA53A21D27E7B651ab6E7D9334Ea0783", | ||
"claimRequestBuilder": "0x1B05f16686396398F16f8916A032D738005126b7", | ||
"requestBuilder": "0x40e208f4815Ce25b32BeEEC7415C6CA9424a898F", | ||
"signatureBuilder": "0x1e7a99e06Ca2C1A63330eC2df8D4fC15EfDa4C55" | ||
} |
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
Submodule openzeppelin-contracts
added at
d00ace
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
forge-std/=lib/forge-std/src/ | ||
forge-std/=lib/forge-std/src/ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ |
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,119 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import "forge-std/console.sol"; | ||
import "@openzeppelin/contracts/utils/Strings.sol"; | ||
|
||
struct DeploymentConfig { | ||
address authRequestBuilder; | ||
address claimRequestBuilder; | ||
address requestBuilder; | ||
address signatureBuilder; | ||
} | ||
|
||
contract BaseDeploymentConfig is Script { | ||
DeploymentConfig public config; | ||
|
||
string public _chainName; | ||
bool public _checkIfEmpty; | ||
|
||
address immutable SISMO_ADDRESSES_PROVIDER_V2 = 0x3Cd5334eB64ebBd4003b72022CC25465f1BFcEe6; | ||
address immutable ZERO_ADDRESS = 0x0000000000000000000000000000000000000000; | ||
|
||
error ChainNameNotFound(string chainName); | ||
|
||
function _setConfig(string memory chainName) internal { | ||
if ( | ||
_compareStrings(chainName, "mainnet") || | ||
_compareStrings(chainName, "gnosis") || | ||
_compareStrings(chainName, "polygon") || | ||
_compareStrings(chainName, "optimism") || | ||
_compareStrings(chainName, "arbitrum-one") || | ||
_compareStrings(chainName, "base") || | ||
_compareStrings(chainName, "testnet-goerli") || | ||
_compareStrings(chainName, "testnet-sepolia") || | ||
_compareStrings(chainName, "testnet-mumbai") || | ||
_compareStrings(chainName, "optimism-goerli") || | ||
_compareStrings(chainName, "arbitrum-goerli") || | ||
_compareStrings(chainName, "base-goerli") || | ||
_compareStrings(chainName, "scroll-testnet-goerli") || | ||
_compareStrings(chainName, "staging-goerli") || | ||
_compareStrings(chainName, "staging-mumbai") || | ||
_compareStrings(chainName, "test") | ||
) { | ||
config = _readDeploymentConfig( | ||
string.concat(vm.projectRoot(), "/deployments/", chainName, ".json") | ||
); | ||
} else { | ||
revert ChainNameNotFound(chainName); | ||
} | ||
} | ||
|
||
function _readDeploymentConfig( | ||
string memory filePath | ||
) internal view returns (DeploymentConfig memory) { | ||
string memory file = _tryReadingFile(filePath); | ||
return | ||
DeploymentConfig({ | ||
authRequestBuilder: _tryReadingAddressFromFileAtKey(file, ".authRequestBuilder"), | ||
claimRequestBuilder: _tryReadingAddressFromFileAtKey(file, ".claimRequestBuilder"), | ||
requestBuilder: _tryReadingAddressFromFileAtKey(file, ".requestBuilder"), | ||
signatureBuilder: _tryReadingAddressFromFileAtKey(file, ".signatureBuilder") | ||
}); | ||
} | ||
|
||
function _tryReadingFile(string memory filePath) internal view returns (string memory) { | ||
try vm.readFile(filePath) returns (string memory file) { | ||
return file; | ||
} catch { | ||
return ""; | ||
} | ||
} | ||
|
||
function _tryReadingAddressFromFileAtKey( | ||
string memory file, | ||
string memory key | ||
) internal view returns (address) { | ||
try vm.parseJson(file, key) returns (bytes memory encodedAddress) { | ||
return | ||
keccak256(encodedAddress) == keccak256(abi.encodePacked((""))) | ||
? address(0) | ||
: abi.decode(encodedAddress, (address)); | ||
} catch { | ||
return ZERO_ADDRESS; | ||
} | ||
} | ||
|
||
function _saveDeploymentConfig(string memory chainName) internal { | ||
_createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments")); | ||
_createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments/tmp")); | ||
_createFolderIfItDoesNotExists(string.concat(vm.projectRoot(), "/deployments/tmp/", chainName)); | ||
|
||
vm.serializeAddress(chainName, "authRequestBuilder", address(config.authRequestBuilder)); | ||
vm.serializeAddress(chainName, "claimRequestBuilder", address(config.claimRequestBuilder)); | ||
vm.serializeAddress(chainName, "requestBuilder", address(config.requestBuilder)); | ||
string memory finalJson = vm.serializeAddress( | ||
chainName, | ||
"signatureBuilder", | ||
address(config.signatureBuilder) | ||
); | ||
|
||
vm.writeJson( | ||
finalJson, | ||
string.concat(vm.projectRoot(), "/deployments/tmp/", chainName, "/run-latest.json") | ||
); | ||
} | ||
|
||
function _createFolderIfItDoesNotExists(string memory folderPath) internal { | ||
string[] memory inputs = new string[](3); | ||
inputs[0] = "mkdir"; | ||
inputs[1] = "-p"; | ||
inputs[2] = folderPath; | ||
vm.ffi(inputs); | ||
} | ||
|
||
function _compareStrings(string memory a, string memory b) internal pure returns (bool) { | ||
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b)))); | ||
} | ||
} |
Oops, something went wrong.