Skip to content

Commit

Permalink
[REFAC] Upgraded applyTojoin() to nominate()
Browse files Browse the repository at this point in the history
  • Loading branch information
toledoroy committed Jul 6, 2022
1 parent bc2a708 commit 060b36c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions contracts/CaseUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ contract CaseUpgradable is
return repo().addressGetOf(address(_HUB), "avatar");
}

/// Apply to join a jurisdiction
function applyTojoin(string memory uri_) external override {
/// Request to Join
function nominate(uint256 soulToken, string memory uri_) external override {
// uint256 soulToken = _getExtTokenId(_msgSender());
uint256 soulToken = _getExtTokenId(msg.sender); //May be a contract
emit Application(soulToken, _msgSender(), uri_);
// uint256 soulToken = _getExtTokenId(msg.sender); //May be a contract
emit Nominate(_msgSender(), soulToken, uri_);
}

/// Assign to a Role
Expand Down
8 changes: 4 additions & 4 deletions contracts/JurisdictionUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ contract JurisdictionUpgradable is
return _GUIDRemove(_msgSender(), _stringToBytes32("member"), 1);
}

/// Apply to join a jurisdiction
function applyTojoin(string memory uri_) external override {
uint256 soulToken = _getExtTokenId(_msgSender());
emit Application(soulToken, _msgSender(), uri_);
/// Request to Join
function nominate(uint256 soulToken, string memory uri_) external override {
// uint256 soulToken = _getExtTokenId(_msgSender());
emit Nominate(_msgSender(), soulToken, uri_);
}

/// Assign Someone Else to a Role
Expand Down
2 changes: 1 addition & 1 deletion contracts/abstract/CommonYJUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ abstract contract CommonYJUpgradable is
function repo() internal view returns (IOpenRepo) {
return IOpenRepo(repoAddr());
}

}
8 changes: 4 additions & 4 deletions contracts/interfaces/ICase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ interface ICase {
/// Set Contract URI
function setContractURI(string calldata contract_uri) external;

/// Apply to join a jurisdiction
function applyTojoin(string memory uri) external;
/// Request to Join
function nominate(uint256 soulToken, string memory uri) external;

/// Assign Someone to a Role
function roleAssign(address account, string calldata role) external;
Expand Down Expand Up @@ -65,7 +65,7 @@ interface ICase {
//Rule Denied (Changed from Confirmed)
// event RuleDenied(uint256 ruleId);

/// Applied to Join the Case
event Application(uint256 indexed id, address account, string uri);
/// Nominate
event Nominate(address account, uint256 indexed id, string uri);

}
8 changes: 4 additions & 4 deletions contracts/interfaces/IJurisdictionUp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ interface IJurisdiction {
/// Leave member role in current jurisdiction
function leave() external returns (uint256);

/// Apply to join a jurisdiction
function applyTojoin(string memory uri) external;
/// Request to Join
function nominate(uint256 soulToken, string memory uri) external;

/// Assign Someone to a Role
function roleAssign(address account, string calldata role) external;
Expand Down Expand Up @@ -97,7 +97,7 @@ interface IJurisdiction {
/// New Case Created
event CaseCreated(uint256 indexed id, address contractAddress);

/// Applied to Join Jurisdiction
event Application(uint256 indexed id, address account, string uri);
/// Nominate
event Nominate(address account, uint256 indexed id, string uri);

}
24 changes: 12 additions & 12 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,13 @@ describe("Protocol", function () {
});

it("Can Apply to Join", async function () {
//Apply to Join Jurisdiction
let tx = await this.jurisdictionContract.connect(tester).applyTojoin(test_uri);
await tx.wait();
//Get Tester's Avatar TokenID
let tokenId = await avatarContract.tokenByAddress(this.testerAddr);
//Apply to Join Jurisdiction
let tx = await this.jurisdictionContract.connect(tester).nominate(tokenId, test_uri);
await tx.wait();
//Expect Event
await expect(tx).to.emit(jurisdictionContract, 'Application').withArgs(tokenId, this.testerAddr, test_uri);
await expect(tx).to.emit(jurisdictionContract, 'Nominate').withArgs(this.testerAddr, tokenId, test_uri);
});

it("Can Re-Open Jurisdiction", async function () {
Expand Down Expand Up @@ -719,13 +719,13 @@ describe("Protocol", function () {
});

it("Users Can Apply to Join", async function () {
//Apply to Join Jurisdiction
let tx = await this.caseContract.connect(tester).applyTojoin(test_uri);
await tx.wait();
//Get Tester's Avatar TokenID
let tokenId = await avatarContract.tokenByAddress(this.testerAddr);
//Apply to Join Jurisdiction
let tx = await this.caseContract.connect(tester).nominate(tokenId, test_uri);
await tx.wait();
//Expect Event
await expect(tx).to.emit(this.caseContract, 'Application').withArgs(tokenId, this.testerAddr, test_uri);
await expect(tx).to.emit(this.caseContract, 'Nominate').withArgs(this.testerAddr, tokenId, test_uri);
});

it("Should Update", async function () {
Expand Down Expand Up @@ -837,13 +837,13 @@ describe("Protocol", function () {
});

it("Anyonw Can Apply to Join", async function () {
//Apply to Join Jurisdiction
let tx = await this.caseContract.connect(tester).applyTojoin(test_uri);
await tx.wait();
//Get Tester's Avatar TokenID
let tokenId = await avatarContract.tokenByAddress(this.testerAddr);
//Apply to Join Jurisdiction
let tx = await this.caseContract.connect(tester).nominate(tokenId, test_uri);
await tx.wait();
//Expect Event
await expect(tx).to.emit(this.caseContract, 'Application').withArgs(tokenId, this.testerAddr, test_uri);
await expect(tx).to.emit(this.caseContract, 'Nominate').withArgs(this.testerAddr, tokenId, test_uri);
});

it("Should Accept Verdict URI & Close Case", async function () {
Expand Down

0 comments on commit 060b36c

Please sign in to comment.