Skip to content

feat: Requirement tests for Staking#3

Open
JamesEarle wants to merge 3 commits intodevelopmentfrom
feat/requirement-tests
Open

feat: Requirement tests for Staking#3
JamesEarle wants to merge 3 commits intodevelopmentfrom
feat/requirement-tests

Conversation

@JamesEarle
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@durienb durienb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments to try and assist and answer questions

id,
msg.sender,
block.number - wasStakedAt
// TODO param expects just `stakedAt[i]` not `block.number - stakedAt[i]`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes needs changed


contract ObjectRegistry is IObjectRegistry {
bytes32 internal constant OWNER = "Owner";
bytes32 internal constant OWNER = "Owner"; // maybe put all constants in a library?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that may be better. This way does show you exactly which ones are being used by a contract but that can still be accomplished.

string memory stakedTokenSymbol, ///symbol of tokens that this contract issues on stake of underlyingToken
IObjectRegistry registry,
bytes32 game
bytes32 game // TODO unused
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs removed

IXP(registry.addressOf(XP)).awardXP(
to,
STAKER_XP_REWARD * (block.number - stakedAt)
// TODO are `rewardsPerBlock` and `STAKER_XP_REWARD` expected to be the same?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no one is vault tokens one is XP

numBlocks = block.number - stakedAt;
}
claimedAt[id] = block.number;
// TODO should this include a zero check so we don't call unnecessarily?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but that also unnecessarily checks for 0 every time then, where it should usually not happen that the value is actually 0.
but, checking 0 is a common approach.

require(
// TODO This `ownerOf` call will be incorrect
// The owner of the NFT while it is staked is the game vault, not the user
underlyingToken.ownerOf(id) == msg.sender,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes needs fixed, it needs to call the token at the GameVault address, not the underlying token

Comment thread test/reqs.test.ts
const gameNameBytes = hre.ethers.utils.formatBytes32String(gameName);
await games.createGame(gameNameBytes, deployer.address, "a-staking-game");

// Registry for the StakingGame
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you successfully get the gameObjects here, which is the ObjectRegistry for the game you're in.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(worth pointing out as this is a complicated part of the system. it is one step removed from just inheriting the ObjectRegistry in Games.sol, the simplest and first way I did it)

Comment thread test/zXP.test.ts
await mockErc721.connect(deployer).mint(s1, s1nft);
});
it("Staker 1 stakes NFT", async () => {
// how does user get staked nft back? is it burned on unstake?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is burned on withdrawTo in ERC721Wrapper

Comment thread test/zXP.test.ts
});
it("Gets season registry", async () => {
// shouldnt I be able to get this info through the gameRegistry?
// why do we have another registry?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the ObjectRegistrys stored in the Seasons struct.
It is a separate set of contracts stored and managed separately from the gameRegistrys set of contracts.

We're able to make different rules on this set of contracts for how they can be updated and added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants