Skip to content

Commit

Permalink
Merge branch 'master' into dave/accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Aug 1, 2022
2 parents 525d8bb + 1c49105 commit c4f4e7a
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 141 deletions.
14 changes: 11 additions & 3 deletions contracts/ToucanRegenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@openzeppelin/contracts/access/Ownable.sol";

import "./interfaces/IContractRegistry.sol";
import "./interfaces/ITCO2.sol";
import "./interfaces/INCTPool.sol";

/**
* @dev Implementation of the smart contract for Regen Ledger self custody bridge.
Expand All @@ -26,6 +27,9 @@ contract ToucanRegenBridge is Ownable, Pausable {
/// @notice address of the bridge wallet authorized to issue TCO2 tokens.
address public bridgeController;

/// @notice address of the NCT pool to be able to check TCO2 eligibility
INCTPool public immutable nctPool;

// ----------------------------------------
// Events
// ----------------------------------------
Expand Down Expand Up @@ -55,11 +59,14 @@ contract ToucanRegenBridge is Ownable, Pausable {
/**
* @dev Sets the values for {bridgeController} and {toucanContractRegistry}.
*/
constructor(address bridgeController_, IContractRegistry toucanContractRegistry_)
Ownable()
{
constructor(
address bridgeController_,
IContractRegistry toucanContractRegistry_,
INCTPool nctPool_
) Ownable() {
bridgeController = bridgeController_;
toucanContractRegistry = toucanContractRegistry_;
nctPool = nctPool_;
}

// ----------------------------------------
Expand Down Expand Up @@ -88,6 +95,7 @@ contract ToucanRegenBridge is Ownable, Pausable {
) external whenNotPaused isRegenAddress(bytes(recipient)) {
require(amount > 0, "amount must be positive");
require(toucanContractRegistry.checkERC20(tco2), "not a TCO2");
require(nctPool.checkEligible(tco2), "TCO2 not eligible for NCT pool");

totalTransferred += amount;
tco2Limits[tco2] += amount;
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/INCTPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.4;

interface INCTPool {
function checkEligible(address erc20Addr) external view returns (bool);
}
6 changes: 2 additions & 4 deletions lib/bridge.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const { ethers } = require("hardhat");

async function deployBridge(regenBridge, toucanRegistry) {
async function deployBridge(regenBridge, toucanRegistry, nctPool) {
const Bridge = await ethers.getContractFactory("ToucanRegenBridge");
const bridge = await Bridge.deploy(regenBridge, toucanRegistry);
const bridge = await Bridge.deploy(regenBridge, toucanRegistry, nctPool);

await bridge.deployed();
console.log("Bridge deployed to %s", bridge.address);

return bridge;
}

Expand Down
70 changes: 70 additions & 0 deletions lib/toucan-genesis-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[
{
"ProjectId": "projectId1",
"Standard": "standard1",
"Methodology": "methodology1",
"Region": "region1",
"StorageMethod": "storageMethod1",
"Method": "method1",
"EmissionType": "emissionType1",
"Category": "category1",
"IsNCTEligible": true,
"Uri": "uri1",
"Vintages": [
{
"UniqueId": "vintage1",
"Name": "vintage1Name",
"StartTime": "2017-01-01T00:00:00Z",
"EndTime": "2017-12-31T00:00:00Z",
"TotalVintageQuantity": 3000,
"IsCorsiaCompliant": true,
"IsCCPcompliant": true,
"CoBenefits": "",
"CorrespAdjustment": "",
"AdditionalCertification": "",
"Uri": "",
"Batches": [
{
"SerialNumber": "serialNumber1",
"Quantity": 2000,
"Uri": "uri1"
}
]
}
]
},
{
"ProjectId": "projectId2",
"Standard": "standard2",
"Methodology": "methodology2",
"Region": "region2",
"StorageMethod": "storageMethod2",
"Method": "method2",
"EmissionType": "emissionType2",
"Category": "category2",
"IsNCTEligible": false,
"Uri": "uri2",
"Vintages": [
{
"UniqueId": "vintage2",
"Name": "vintage2Name",
"StartTime": "2007-01-01T00:00:00Z",
"EndTime": "2007-12-31T00:00:00Z",
"TotalVintageQuantity": 3000,
"IsCorsiaCompliant": false,
"IsCCPcompliant": true,
"CoBenefits": "",
"CorrespAdjustment": "",
"AdditionalCertification": "",
"Uri": "",
"Batches": [
{
"SerialNumber": "serialNumber2",
"Quantity": 1000,
"Uri": "uri2"
}
]
}
]
}
]
35 changes: 0 additions & 35 deletions lib/toucan-genisis-data.json

This file was deleted.

Loading

0 comments on commit c4f4e7a

Please sign in to comment.