Skip to content

Commit

Permalink
HUB: Jurisdiction Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
toledoroy committed May 7, 2022
1 parent 01e072e commit 79f7833
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
16 changes: 8 additions & 8 deletions contracts/Hub.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

// import "hardhat/console.sol";
import "hardhat/console.sol";

import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
Expand Down Expand Up @@ -121,9 +121,11 @@ contract Hub is IHub, Ownable {
//Validate
// require(beaconJurisdiction != address(0), "Jurisdiction Beacon Missing"); //Redundant

console.log("Deploy J", beaconJurisdiction);

//Deploy
BeaconProxy newJurisdictionProxy = new BeaconProxy(
beaconCase,
beaconJurisdiction,
abi.encodeWithSelector(
IJurisdiction( payable(address(0)) ).initialize.selector,
address(this), //Hub
Expand All @@ -134,7 +136,8 @@ contract Hub is IHub, Ownable {
// _msgSender() //Birth Parent (Container)
)
);

//Event
emit ContractCreated("jurisdiction", address(newJurisdictionProxy));
//Remember
_jurisdictions[address(newJurisdictionProxy)] = true;
//Return
Expand All @@ -149,8 +152,6 @@ contract Hub is IHub, Ownable {
) external override returns (address) {
//TODO: Validate Caller Permissions (A Jurisdiction)

//Rules

//Assign Case ID
// _caseIds.increment(); //Start with 1
// uint256 caseId = _caseIds.current();
Expand All @@ -170,11 +171,10 @@ contract Hub is IHub, Ownable {
_msgSender() //Birth Parent (Container)
)
);

//Event
emit ContractCreated("case", address(newCaseProxy));
//Remember
// _active[msg.sender][address(newCaseProxy)] = true;
_cases[address(newCaseProxy)] = msg.sender;

//Return
return address(newCaseProxy);
}
Expand Down
12 changes: 7 additions & 5 deletions contracts/JurisdictionUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ contract JurisdictionUpgradable is
__CommonYJ_init(hub);

//Fetch & Set Current History Contract
address actionRepo = _HUB.getAssoc("history");
console.log("Init WJ W/History:", actionRepo);
_setActionsContract(actionRepo);
// _setActionsContract(_HUB.getAssoc("history"));
// address actionRepo = _HUB.getAssoc("history");
// console.log("Init WJ W/History:", actionRepo);
// _setActionsContract(actionRepo);
_setActionsContract(_HUB.getAssoc("history")); //TODO: Hot History?

//TODO: Set Contract URI
//Set Contract URI
_contract_uri = uri_;

//Identifiers
Expand All @@ -106,8 +106,10 @@ contract JurisdictionUpgradable is
_roleCreate("admin");
_roleCreate("member");
_roleCreate("judge");

//Assign Creator as First Admin
_roleAssign(tx.origin, "admin");

}

//** Case Functions
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ interface IHub {

event UpdatedImplementation(string name, address implementation);

/// New Contract Created
event ContractCreated(string name, address contractAddress);
}
15 changes: 15 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@ describe("Protocol", function () {
jurisdictionContract = await ethers.getContractFactory("Jurisdiction").then(res => res.deploy(hubContract.address, actionContract.address));
this.jurisdictionContract = jurisdictionContract;


//Simulate to Get New Jurisdiction Address
// let JAddr = await hubContract.callStatic.jurisdictionMake("Test Jurisdiction", test_uri);
// let JAddr = await hubContract.connect(admin).callStatic.jurisdictionMake("Test Jurisdiction", test_uri);

//Create New Jurisdiction
let tx = await hubContract.jurisdictionMake("Test Jurisdiction", test_uri);

//Expect Valid Address
// expect(JAddr).to.be.properAddress;
//Expect Case Created Event
// await expect(tx).to.emit(hubContract, 'ContractCreated').withArgs("jurisdiction", JAddr);
//Init Jurisdiction Contract Object
// this.jurisdictionContract = await ethers.getContractFactory("JurisdictionUp").then(res => res.attach(JAddr));

});

it("Users can join as a member", async function () {
Expand Down

0 comments on commit 79f7833

Please sign in to comment.