-
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: update scripts to set addresses in AddressesProvider contract in a
separate script
- Loading branch information
Showing
5 changed files
with
172 additions
and
81 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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import "forge-std/Script.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import {IAddressesProvider} from "src/interfaces/IAddressesProvider.sol"; | ||
import {BaseDeploymentConfig, DeploymentConfig} from "script/BaseConfig.sol"; | ||
|
||
contract SetAddressesProvider is Script, BaseDeploymentConfig { | ||
struct DeployedLibrary { | ||
address addr; | ||
string name; | ||
} | ||
|
||
// useful variables to set libraries addresses in AddressesProvider in batch | ||
address[] public contractAddresses; | ||
string[] public contractNames; | ||
|
||
function run() external { | ||
runFor(vm.envString("CHAIN_NAME")); | ||
} | ||
|
||
function runFor(string memory _chainName) public { | ||
console.log("Run for CHAIN_NAME:", _chainName); | ||
console.log("Sender:", msg.sender); | ||
|
||
vm.startBroadcast(); | ||
_setConfig({chainName: _chainName}); | ||
|
||
// associate libraries addresses to names | ||
DeployedLibrary[] memory deployedLibrariesArray = new DeployedLibrary[](4); | ||
deployedLibrariesArray[0] = DeployedLibrary({ | ||
addr: address(config.authRequestBuilder), | ||
name: "authRequestBuilder-v1.1" | ||
}); | ||
deployedLibrariesArray[1] = DeployedLibrary({ | ||
addr: address(config.claimRequestBuilder), | ||
name: "claimRequestBuilder-v1.1" | ||
}); | ||
deployedLibrariesArray[2] = DeployedLibrary({ | ||
addr: address(config.signatureBuilder), | ||
name: "signatureBuilder-v1.1" | ||
}); | ||
deployedLibrariesArray[3] = DeployedLibrary({ | ||
addr: address(config.requestBuilder), | ||
name: "requestBuilder-v1.1" | ||
}); | ||
|
||
// update addresses provider with deployed libraries addresses | ||
_setLibrariesAddresses(deployedLibrariesArray); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function _setLibrariesAddresses(DeployedLibrary[] memory deployedLibrariesArray) private { | ||
console.log("== Updating Addresses Provider =="); | ||
IAddressesProvider sismoAddressProvider = IAddressesProvider(SISMO_ADDRESSES_PROVIDER_V2); | ||
|
||
for (uint256 i = 0; i < deployedLibrariesArray.length; i++) { | ||
DeployedLibrary memory deployedLibrary = deployedLibrariesArray[i]; | ||
address currentContractAddress = sismoAddressProvider.get(deployedLibrary.name); | ||
|
||
if (currentContractAddress != deployedLibrary.addr) { | ||
console.log( | ||
"current contract address for", | ||
deployedLibrary.name, | ||
"is different. Updating address to", | ||
deployedLibrary.addr | ||
); | ||
// save address to update in batch after | ||
contractAddresses.push(deployedLibrary.addr); | ||
contractNames.push(deployedLibrary.name); | ||
} else { | ||
console.log( | ||
"current contract address for", | ||
deployedLibrary.name, | ||
"is already the expected one. skipping update" | ||
); | ||
} | ||
} | ||
|
||
if (contractAddresses.length > 0) { | ||
console.log("Updating Addresses Provider in batch..."); | ||
sismoAddressProvider.setBatch(contractAddresses, contractNames); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@solidity-parser/parser@^0.16.0": | ||
version "0.16.1" | ||
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.16.1.tgz#f7c8a686974e1536da0105466c4db6727311253c" | ||
integrity sha512-PdhRFNhbTtu3x8Axm0uYpqOy/lODYQK+MlYSgqIsq2L8SFYEHJPHNUiOTAJbDGzNjjr1/n9AcIayxafR/fWmYw== | ||
dependencies: | ||
antlr4ts "^0.5.0-alpha.4" | ||
|
||
antlr4ts@^0.5.0-alpha.4: | ||
version "0.5.0-alpha.4" | ||
resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" | ||
integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== | ||
|
||
lru-cache@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" | ||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== | ||
dependencies: | ||
yallist "^4.0.0" | ||
|
||
prettier-plugin-solidity@^1.0.0-beta.13: | ||
version "1.1.3" | ||
resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.3.tgz#9a35124f578404caf617634a8cab80862d726cba" | ||
integrity sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg== | ||
dependencies: | ||
"@solidity-parser/parser" "^0.16.0" | ||
semver "^7.3.8" | ||
solidity-comments-extractor "^0.0.7" | ||
|
||
prettier@^2.3.1: | ||
version "2.8.8" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" | ||
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== | ||
|
||
semver@^7.3.8: | ||
version "7.5.4" | ||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" | ||
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== | ||
dependencies: | ||
lru-cache "^6.0.0" | ||
|
||
solidity-comments-extractor@^0.0.7: | ||
version "0.0.7" | ||
resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" | ||
integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== | ||
|
||
yallist@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" | ||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== |