Skip to content

Commit

Permalink
Add upgrade script and correct issue on not incrementing project reti…
Browse files Browse the repository at this point in the history
…rement totals (KlimaDAO#35)
  • Loading branch information
cujowolf authored Feb 17, 2023
1 parent e4c4789 commit bf399fc
Show file tree
Hide file tree
Showing 11 changed files with 634 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract RetireC3C3TFacet is ReentrancyGuard {
* @param fromMode From Mode for transfering tokens
* @return retirementIndex The latest retirement index for the beneficiary address
*/
function c3_retireExactC3T(
function c3RetireExactC3T(
address carbonToken,
uint256 amount,
address beneficiaryAddress,
Expand Down Expand Up @@ -73,7 +73,7 @@ contract RetireC3C3TFacet is ReentrancyGuard {
* @param fromMode From Mode for transfering tokens
* @return retirementIndex The latest retirement index for the beneficiary address
*/
function c3_retireExactC3TWithEntity(
function c3RetireExactC3TWithEntity(
address carbonToken,
uint256 amount,
string memory retiringEntityString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract RetireToucanTCO2Facet is ReentrancyGuard {
* @param fromMode From Mode for transfering tokens
* @return retirementIndex The latest retirement index for the beneficiary address
*/
function toucan_retireExactTCO2(
function toucanRetireExactTCO2(
address carbonToken,
uint256 amount,
address beneficiaryAddress,
Expand Down Expand Up @@ -73,7 +73,7 @@ contract RetireToucanTCO2Facet is ReentrancyGuard {
* @param fromMode From Mode for transfering tokens
* @return retirementIndex The latest retirement index for the beneficiary address
*/
function toucan_retireExactTCO2WithEntity(
function toucanRetireExactTCO2WithEntity(
address carbonToken,
uint256 amount,
string memory retiringEntityString,
Expand Down
19 changes: 19 additions & 0 deletions contracts/infinity/diamond/init/InitProjectTotals.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../AppStorage.sol";

contract InitProjectTotals {

AppStorage internal s;

function init() external {
// Update the project amounts retired for transactions sent through V2 thus far

s.a[0x20A580444DD4A90Cc8990DA7B480C5E3d605a26f].totalProjectRetired[0xb139C4cC9D20A3618E9a2268D73Eff18C496B991] += uint(1000000000000000);
s.a[0x808b891a69f2cF52f84228DA61f2F4F5b08297DE].totalProjectRetired[0xb139C4cC9D20A3618E9a2268D73Eff18C496B991] += uint(956844938827);
s.a[0x808b891a69f2cF52f84228DA61f2F4F5b08297DE].totalProjectRetired[0xb139C4cC9D20A3618E9a2268D73Eff18C496B991] += uint(956844938829);
s.a[0xDdfF75A29EB4BFEcF65380de9a75ad08C140eA49].totalProjectRetired[0xb139C4cC9D20A3618E9a2268D73Eff18C496B991] += uint(966561401954341706);
s.a[0x6F9F81eb4f54512Be8c91833783ee0074328E062].totalProjectRetired[0xb139C4cC9D20A3618E9a2268D73Eff18C496B991] += uint(1000000000000000);
}
}
8 changes: 8 additions & 0 deletions contracts/infinity/diamond/init/_EmptyInit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract _EmptyInit {

function init() external {
}
}
1 change: 1 addition & 0 deletions contracts/infinity/libraries/LibRetire.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ library LibRetire {

// Save the details of the retirement
s.a[beneficiaryAddress].retirements[currentRetirementIndex].projectTokenAddress = projectToken;
s.a[beneficiaryAddress].totalProjectRetired[projectToken] += amount;
}

/* ========== Account Getters ========== */
Expand Down
19 changes: 19 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { utils } = require("ethers");
const fs = require("fs");
const chalk = require("chalk");
const { daoFeeUpgrade } = require("./scripts/infinity/deploy_dao_fee_split");

require("@nomiclabs/hardhat-etherscan");
require("@tenderly/hardhat-tenderly");
Expand All @@ -12,6 +13,7 @@ require("@openzeppelin/hardhat-upgrades");
require("dotenv").config();

require("@nomiclabs/hardhat-etherscan");
require("hardhat-contract-sizer")
require("hardhat-gas-reporter");
require("solidity-coverage");

Expand All @@ -31,6 +33,11 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
}
});

task("upgrade", async () => {
account = await ethers.getSigner()
await daoFeeUpgrade(true, account)
})

task('diamondABI', 'Generates ABI file for diamond, includes all ABIs of facets and subdirectories', async () => {
var walk = function (dir) {
var results = [];
Expand Down Expand Up @@ -183,13 +190,25 @@ module.exports = {
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
polygon: {
url: process.env.POLYGON_URL || "",
gasPrice: 150e9,
timeout: 100000,
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: [],
},
polygonscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: [],
},
};

Expand Down
Loading

0 comments on commit bf399fc

Please sign in to comment.