From b8601a657ea4f3ee990066722e80138fc6b32495 Mon Sep 17 00:00:00 2001 From: amusingaxl <112016538+amusingaxl@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:57:10 -0300 Subject: [PATCH] feat: add deployment script --- .env.example | 2 ++ script/ProtegoDeploy.s.sol | 43 +++++++++++++++++++++++++ script/dependencies/ProtegoDeploy.sol | 30 +++++++++++++++++ script/dependencies/ProtegoInstance.sol | 21 ++++++++++++ script/input/1/README.md | 1 + script/output/1/README.md | 1 + 6 files changed, 98 insertions(+) create mode 100644 .env.example create mode 100644 script/ProtegoDeploy.s.sol create mode 100644 script/dependencies/ProtegoDeploy.sol create mode 100644 script/dependencies/ProtegoInstance.sol create mode 100644 script/input/1/README.md create mode 100644 script/output/1/README.md diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..29208fa --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +FOUNDRY_ROOT_CHAINID='number: the ID of the chain' +FOUNDRY_EXPORTS_OVERWRITE_LATEST='bool: whether to override the latest deployment or not' diff --git a/script/ProtegoDeploy.s.sol b/script/ProtegoDeploy.s.sol new file mode 100644 index 0000000..52c9723 --- /dev/null +++ b/script/ProtegoDeploy.s.sol @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: © 2023 Dai Foundation +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +pragma solidity ^0.8.16; + +import {Script} from "forge-std/Script.sol"; +import {MCD, DssInstance} from "dss-test/MCD.sol"; +import {ScriptTools} from "dss-test/ScriptTools.sol"; +import {ProtegoDeploy, ProtegoDeployParams} from "./dependencies/ProtegoDeploy.sol"; +import {ProtegoInstance} from "./dependencies/ProtegoInstance.sol"; + +contract ProtegoDeployScript is Script { + using ScriptTools for string; + + string constant NAME = "protego"; + + address constant CHAINLOG = 0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F; + DssInstance dss = MCD.loadFromChainlog(CHAINLOG); + address pause = dss.chainlog.getAddress("MCD_PAUSE"); + ProtegoInstance inst; + + function run() external { + vm.startBroadcast(); + + inst = ProtegoDeploy.deploy(ProtegoDeployParams({pause: pause})); + + vm.stopBroadcast(); + + ScriptTools.exportContract(NAME, "protego", inst.protego); + } +} diff --git a/script/dependencies/ProtegoDeploy.sol b/script/dependencies/ProtegoDeploy.sol new file mode 100644 index 0000000..c6dee70 --- /dev/null +++ b/script/dependencies/ProtegoDeploy.sol @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: © 2023 Dai Foundation +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +pragma solidity ^0.8.16; + +import {ScriptTools} from "dss-test/ScriptTools.sol"; +import {Protego} from "src/Protego.sol"; +import {ProtegoInstance} from "./ProtegoInstance.sol"; + +struct ProtegoDeployParams { + address pause; +} + +library ProtegoDeploy { + function deploy(ProtegoDeployParams memory p) internal returns (ProtegoInstance memory r) { + r.protego = address(new Protego(p.pause)); + } +} diff --git a/script/dependencies/ProtegoInstance.sol b/script/dependencies/ProtegoInstance.sol new file mode 100644 index 0000000..8606408 --- /dev/null +++ b/script/dependencies/ProtegoInstance.sol @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: © 2023 Dai Foundation +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +pragma solidity ^0.8.16; + +struct ProtegoInstance { + address protego; +} + diff --git a/script/input/1/README.md b/script/input/1/README.md new file mode 100644 index 0000000..9f32fb8 --- /dev/null +++ b/script/input/1/README.md @@ -0,0 +1 @@ +Inputs for Mainnet scripts. diff --git a/script/output/1/README.md b/script/output/1/README.md new file mode 100644 index 0000000..51a26d3 --- /dev/null +++ b/script/output/1/README.md @@ -0,0 +1 @@ +Outputs for Mainnet scripts.