Skip to content

Commit

Permalink
nominatedWearer now a single address to match business logic
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Oct 29, 2024
1 parent 3d771f4 commit 4a93ed0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
16 changes: 7 additions & 9 deletions contracts/DecentHats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract DecentHats {

struct TermedParam {
uint128 termEndDateTs;
address[] nominatedWearers;
address nominatedWearer;
}

struct Hat {
Expand Down Expand Up @@ -127,7 +127,7 @@ contract DecentHats {

for (uint256 i = 0; i < params.hats.length; ) {
// {assuption} if 0 nominatedWearers, then it is not a termed role
if (params.hats[i].termedParam.nominatedWearers.length > 0) {
if (params.hats[i].termedParam.nominatedWearer != address(0)) {
// Create election module and set as eligiblity
_createTermedHatAndAccountAndMintAndStreams(
params.hatsProtocol,
Expand Down Expand Up @@ -358,10 +358,6 @@ contract DecentHats {
uint256 adminHatId,
Hat calldata hat
) internal {
require(
hat.termedParam.nominatedWearers.length == 1,
"DecentHats: nominatedWearers length must be 1"
);
uint256 hatId = _createHat(
hatsProtocol,
adminHatId,
Expand All @@ -370,17 +366,19 @@ contract DecentHats {
eligibilityAddress
);

address[] memory nominatedWearers = new address[](1);
nominatedWearers[0] = hat.termedParam.nominatedWearer;
IHatsElectionEligibility(eligibilityAddress).elect(
hat.termedParam.termEndDateTs,
hat.termedParam.nominatedWearers
nominatedWearers
);

hatsProtocol.mintHat(hatId, hat.termedParam.nominatedWearers[0]);
hatsProtocol.mintHat(hatId, hat.termedParam.nominatedWearer);

for (uint256 i = 0; i < hat.sablierParams.length; ) {
_createSablierStream(
hat.sablierParams[i],
hat.termedParam.nominatedWearers[0]
hat.termedParam.nominatedWearer
);
unchecked {
++i;
Expand Down
32 changes: 16 additions & 16 deletions test/DecentHats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hats: [
Expand All @@ -199,7 +199,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
{
Expand All @@ -211,7 +211,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
],
Expand Down Expand Up @@ -271,7 +271,7 @@ describe('DecentHats', () => {

termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hats: [],
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hats: [
Expand All @@ -359,7 +359,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: BigInt(Date.now() + 100000),
nominatedWearers: ['0x14dC79964da2C08b23698B3D3cc7Ca32193d9955'],
nominatedWearer: '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955',
},
},
{
Expand All @@ -371,7 +371,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: BigInt(Date.now() + 100000),
nominatedWearers: ['0x14dC79964da2C08b23698B3D3cc7Ca32193d9955'],
nominatedWearer: '0x14dC79964da2C08b23698B3D3cc7Ca32193d9955',
},
},
],
Expand Down Expand Up @@ -433,7 +433,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hats: [
Expand Down Expand Up @@ -461,7 +461,7 @@ describe('DecentHats', () => {
],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
{
Expand All @@ -473,7 +473,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
],
Expand Down Expand Up @@ -566,7 +566,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hats: [
Expand Down Expand Up @@ -608,7 +608,7 @@ describe('DecentHats', () => {
],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
],
Expand Down Expand Up @@ -698,7 +698,7 @@ describe('DecentHats', () => {
sablierParams: [],
termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hatsModuleFactory: mockHatsModuleFactoryAddress,
Expand Down Expand Up @@ -740,7 +740,7 @@ describe('DecentHats', () => {

termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
sablierParams: [
{
Expand Down Expand Up @@ -840,7 +840,7 @@ describe('DecentHats', () => {

termedParam: {
termEndDateTs: 0,
nominatedWearers: [],
nominatedWearer: ethers.ZeroAddress,
},
},
hatsModuleFactory: mockHatsModuleFactoryAddress,
Expand Down Expand Up @@ -884,7 +884,7 @@ describe('DecentHats', () => {
wearer: '0xdce7ca0555101f97451926944f5ae3b7adb2f5ae',
termedParam: {
termEndDateTs: BigInt(Date.now() + 100000),
nominatedWearers: ['0xdce7ca0555101f97451926944f5ae3b7adb2f5ae'],
nominatedWearer: '0xdce7ca0555101f97451926944f5ae3b7adb2f5ae',
},
sablierParams: [
{
Expand Down

0 comments on commit 4a93ed0

Please sign in to comment.