Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update gnosis safe scripts #518

Merged
merged 4 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@nomiclabs/hardhat-waffle": "2.0.5",
"@typechain/ethers-v5": "10.2.0",
"@typechain/hardhat": "^6.1.5",
"@types/inquirer": "^8.2.0",
"@types/node": "^17.0.23",
"@types/pino": "^7.0.5",
"@typescript-eslint/eslint-plugin": "^5.16.0",
Expand Down Expand Up @@ -88,8 +87,8 @@
"@uniswap/sdk": "^3.0.3",
"chalk": "4.1.2",
"defender-relay-client": "^1.26.0",
"enquirer": "^2.4.1",
"hardhat-ethers": "^1.0.1",
"inquirer": "^8.2.1",
"light-spinner": "^1.0.4",
"notify-send": "^0.1.2",
"pino": "^7.9.2",
Expand Down
8 changes: 5 additions & 3 deletions script/deploy/deployUpgradesToSAFE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ deployUpgradesToSAFE() {
source script/config.sh
source script/helperFunctions.sh

ENVIRONMENT="production"
ENVIRONMENT=$1
FILE_SUFFIX=$(getFileSuffix $ENVIRONMENT)
NETWORK=$(getUserSelectedNetwork)
DIAMOND_CONTRACT_NAME=$(userDialogSelectDiamondType)
if [ "$DIAMOND_CONTRACT_NAME" == "LiFiDiamond" ]; then
Expand All @@ -24,8 +25,9 @@ deployUpgradesToSAFE() {
declare -a CUTS
for script in $SCRIPTS; do
UPDATE_SCRIPT=$(echo "$DEPLOY_SCRIPT_DIRECTORY"Update"$script".s.sol)
PRIVATE_KEY=$(getPrivateKey $NETWORK $ENVIRONMENT)
echo "Calculating facet cuts for $script..."
RAW_RETURN_DATA=$(NO_BROADCAST=true NETWORK=$NETWORK FILE_SUFFIX=$FILE_SUFFIX USE_DEF_DIAMOND=$USE_MUTABLE_DIAMOND PRIVATE_KEY=$(getPrivateKey "$ENVIRONMENT") forge script "$UPDATE_SCRIPT" -f $NETWORK -vvvv --json --silent --skip-simulation --legacy)
RAW_RETURN_DATA=$(NO_BROADCAST=true NETWORK=$NETWORK FILE_SUFFIX=$FILE_SUFFIX USE_DEF_DIAMOND=$USE_MUTABLE_DIAMOND PRIVATE_KEY=$PRIVATE_KEY forge script "$UPDATE_SCRIPT" -f $NETWORK -vvvv --json --silent --skip-simulation --legacy)
CLEAN_RETURN_DATA=$(echo $RAW_RETURN_DATA | sed 's/^.*{\"logs/{\"logs/')
FACET_CUT=$(echo $CLEAN_RETURN_DATA | jq -r '.returns.cutData.value')
if [ "$FACET_CUT" != "0x" ]; then
Expand All @@ -45,7 +47,7 @@ deployUpgradesToSAFE() {
DIAMOND_ADDRESS=$(getContractAddressFromDeploymentLogs "$NETWORK" "$ENVIRONMENT" "$DIAMOND_CONTRACT_NAME")

# Call the proposeTx script ts-node proposeTx.ts diamondAddress cuts network rpcUrl
ts-node script/deploy/gnosisSAFE/proposeTx.ts "$DIAMOND_ADDRESS" "$CUTS_JSON" "$NETWORK" $(getRPCUrl $NETWORK)
ts-node script/deploy/gnosisSAFE/proposeTx.ts "$DIAMOND_ADDRESS" "$CUTS_JSON" "$NETWORK" $(getRPCUrl $NETWORK) "$PRIVATE_KEY"
exit 0
}

Expand Down
28 changes: 1 addition & 27 deletions script/deploy/facets/UpdateCalldataVerificationFacet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,6 @@ contract DeployScript is UpdateScriptBase {
public
returns (address[] memory facets, bytes memory cutData)
{
address facet = json.readAddress(".CalldataVerificationFacet");

// CalldataVerificationFacet
bytes4[] memory exclude;
buildDiamondCut(
getSelectors("CalldataVerificationFacet", exclude),
facet
);
if (noBroadcast) {
if (cut.length > 0) {
cutData = abi.encodeWithSelector(
DiamondCutFacet.diamondCut.selector,
cut,
address(0),
""
);
}
return (facets, cutData);
}

vm.startBroadcast(deployerPrivateKey);
if (cut.length > 0) {
cutter.diamondCut(cut, address(0), "");
}
facets = loupe.facetAddresses();

vm.stopBroadcast();
return update("CalldataVerificationFacet");
}
}
25 changes: 1 addition & 24 deletions script/deploy/facets/UpdateStandardizedCallFacet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ contract DeployScript is UpdateScriptBase {
public
returns (address[] memory facets, bytes memory cutData)
{
address facet = json.readAddress(".StandardizedCallFacet");

// StandardizedCallFacet
bytes4[] memory exclude;
buildDiamondCut(getSelectors("StandardizedCallFacet", exclude), facet);
if (noBroadcast) {
if (cut.length > 0) {
cutData = abi.encodeWithSelector(
DiamondCutFacet.diamondCut.selector,
cut,
address(0),
""
);
}
return (facets, cutData);
}

vm.startBroadcast(deployerPrivateKey);
if (cut.length > 0) {
cutter.diamondCut(cut, address(0), "");
}
facets = loupe.facetAddresses();

vm.stopBroadcast();
return update("StandardizedCallFacet");
}
}
25 changes: 16 additions & 9 deletions script/deploy/gnosisSAFE/proposeTx.ts
ezynda3 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import SafeApiKit, {
OwnerResponse,
ProposeTransactionProps,
} from '@safe-global/api-kit'
import dotenv from 'dotenv'
import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types'
import { safeApiUrls } from './config'
import { exit } from 'process'
dotenv.config()
import { argv, exit } from 'process'
import enquirer from 'enquirer'

const [, , diamondAddress, rawCuts, network, rpcUrl] = process.argv
const [, , diamondAddress, rawCuts, network, rpcUrl, privateKey] = argv

let safeOwner = new ethers.Wallet(process.env.PRIVATE_KEY_PRODUCTION as string)
let safeOwner = new ethers.Wallet(privateKey as string)
const provider = new ethers.providers.JsonRpcProvider(rpcUrl)
safeOwner = safeOwner.connect(provider)

Expand All @@ -32,8 +31,16 @@ const main = async () => {
const res: OwnerResponse = await safeService.getSafesByOwner(
await safeOwner.getAddress()
)
const safeAddress = res.safes[0]
console.info('SAFE Address: ', res.safes[0])

const choice = await enquirer.prompt({
type: 'select',
name: 'safeAddress',
message: 'Choose the SAFE address you would like to use.',
choices: res.safes,
})

const safeAddress = (<{ safeAddress: string }>choice).safeAddress
console.info('SAFE Address: ', safeAddress)
console.info('Diamond Address: ', diamondAddress)

const safeSdk: Safe = await Safe.create({
Expand All @@ -47,7 +54,7 @@ const main = async () => {
let i = 1
for (const cut of cuts) {
const safeTransactionData: SafeTransactionDataPartial = {
to: '0x9FcB9Aaa138DBb2Cbf484Ba43285ca4b60b56D09',
to: diamondAddress,
value: '0',
data: cut,
nonce,
Expand All @@ -63,7 +70,7 @@ const main = async () => {
senderSignature: txHashSignature.data,
}
console.info(`Sending proposal [${i}]...`)
// await safeService.proposeTransaction(proposal)
await safeService.proposeTransaction(proposal)
nonce++
i++
}
Expand Down
3 changes: 2 additions & 1 deletion script/scriptMaster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scriptMaster() {
source script/deploy/deployFacetAndAddToDiamond.sh
source script/deploy/deployPeripheryContracts.sh
source script/config.sh
source script/deploy/deployUpgradesToSAFE.sh
for script in script/tasks/*.sh; do [ -f "$script" ] && source "$script"; done # sources all script in folder script/tasks/

# make sure that all compiled artifacts are current
Expand Down Expand Up @@ -488,7 +489,7 @@ scriptMaster() {
#---------------------------------------------------------------------------------------------------------------------
# use case 11: Propose upgrade TX to Gnosis SAFE
elif [[ "$SELECTION" == "11)"* ]]; then
deployUpgradesToSAFE
deployUpgradesToSAFE $ENVIRONMENT
else
error "invalid use case selected ('$SELECTION') - exiting script"
cleanup
Expand Down
17 changes: 9 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1249,13 +1249,6 @@
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812"
integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==

"@types/inquirer@^8.2.0":
version "8.2.5"
resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-8.2.5.tgz#c508423bcc11126db278170ab07347783ac2300c"
integrity sha512-QXlzybid60YtAwfgG3cpykptRYUx2KomzNutMlWsQC64J/WG/gQSl+P4w7A21sGN0VIxRVava4rgnT7FQmFCdg==
dependencies:
"@types/through" "*"

"@types/inquirer@^8.2.1":
version "8.2.6"
resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-8.2.6.tgz#abd41a5fb689c7f1acb12933d787d4262a02a0ab"
Expand Down Expand Up @@ -3296,6 +3289,14 @@ enquirer@^2.3.0, enquirer@^2.3.6:
dependencies:
ansi-colors "^4.1.1"

enquirer@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.1.tgz#93334b3fbd74fc7097b224ab4a8fb7e40bf4ae56"
integrity sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==
dependencies:
ansi-colors "^4.1.1"
strip-ansi "^6.0.1"

env-paths@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
Expand Down Expand Up @@ -5158,7 +5159,7 @@ inquirer@^6.2.2:
strip-ansi "^5.1.0"
through "^2.3.6"

inquirer@^8.2.1, inquirer@^8.2.2:
inquirer@^8.2.2:
version "8.2.5"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.2.5.tgz#d8654a7542c35a9b9e069d27e2df4858784d54f8"
integrity sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==
Expand Down