Skip to content

Commit 262f940

Browse files
committed
feat: allow jurorNft to be address(0) which disables gating
1 parent 63744e9 commit 262f940

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

contracts/src/arbitration/KlerosCoreNeo.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ contract KlerosCoreNeo is KlerosCoreBase {
109109
/// @param _newStake The new stake.
110110
/// Note that the existing delayed stake will be nullified as non-relevant.
111111
function setStake(uint96 _courtID, uint256 _newStake) external override whenNotPaused {
112-
if (jurorNft.balanceOf(msg.sender) == 0) revert NotEligibleForStaking();
112+
if (address(jurorNft) != address(0) && jurorNft.balanceOf(msg.sender) == 0) revert NotEligibleForStaking();
113113
super._setStake(msg.sender, _courtID, _newStake, false, OnError.Revert);
114114
}
115115

contracts/test/arbitration/staking-neo.ts

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,51 @@ describe("Staking", async () => {
175175
});
176176
});
177177

178-
describe("When juror has no NFT", async () => {
178+
describe("When juror NFT is not set", async () => {
179179
before("Setup", async () => {
180180
await deployUnhappy();
181+
await core.changeJurorNft(ethers.ZeroAddress);
181182
});
182183

183-
it("Should not be able to stake", async () => {
184-
await pnk.connect(juror).approve(core.target, PNK(1000));
185-
await expect(core.connect(juror).setStake(1, PNK(1000))).to.be.revertedWithCustomError(
186-
core,
187-
"NotEligibleForStaking"
188-
);
184+
describe("When juror has no NFT", async () => {
185+
it("Should be able to stake", async () => {
186+
await pnk.connect(juror).approve(core.target, PNK(1000));
187+
await expect(await core.connect(juror).setStake(1, PNK(1000)))
188+
.to.emit(sortition, "StakeSet")
189+
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
190+
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
191+
});
189192
});
190193
});
191194

192-
describe("When juror does have a NFT", async () => {
193-
before("Setup", async () => {
194-
await deployUnhappy();
195-
await nft.safeMint(juror.address);
195+
describe("When juror NFT is set", async () => {
196+
describe("When juror has no NFT", async () => {
197+
before("Setup", async () => {
198+
await deployUnhappy();
199+
});
200+
201+
it("Should not be able to stake", async () => {
202+
await pnk.connect(juror).approve(core.target, PNK(1000));
203+
await expect(core.connect(juror).setStake(1, PNK(1000))).to.be.revertedWithCustomError(
204+
core,
205+
"NotEligibleForStaking"
206+
);
207+
});
196208
});
197209

198-
it("Should be able to stake", async () => {
199-
await pnk.connect(juror).approve(core.target, PNK(1000));
200-
await expect(await core.connect(juror).setStake(1, PNK(1000)))
201-
.to.emit(sortition, "StakeSet")
202-
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
203-
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
210+
describe("When juror does have a NFT", async () => {
211+
before("Setup", async () => {
212+
await deployUnhappy();
213+
await nft.safeMint(juror.address);
214+
});
215+
216+
it("Should be able to stake", async () => {
217+
await pnk.connect(juror).approve(core.target, PNK(1000));
218+
await expect(await core.connect(juror).setStake(1, PNK(1000)))
219+
.to.emit(sortition, "StakeSet")
220+
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
221+
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
222+
});
204223
});
205224
});
206225

0 commit comments

Comments
 (0)