Skip to content

Kirill Review and some small fixes#1

Open
Whytecrowe wants to merge 1 commit intodevelopmentfrom
kirill-review-initial
Open

Kirill Review and some small fixes#1
Whytecrowe wants to merge 1 commit intodevelopmentfrom
kirill-review-initial

Conversation

@Whytecrowe
Copy link
Copy Markdown

No description provided.

@Whytecrowe Whytecrowe requested a review from durienb February 13, 2024 23:44
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.

Thanks Kirill!
There was one issue with a change that you made so if we can correct that then I'll merge it.

Comment thread contracts/zxp/Games.sol

function createGame(
bytes32 name,
// why is this not an msg.sender? to set someone else as an owner?
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, compatibility for contracts so they can run this and set someone as the owner

Comment thread contracts/zxp/Games.sol
import { ObjectRegistry } from "./ObjectRegistry.sol";


// why does this need to be ObjectRegistry? where is this functionality used?
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.

Inheritance of the ObjectRegistry and its use below are all remnants of a rework.
Fixed, and it will give me an opportunity to discuss why this change was made.

Comment thread contracts/zxp/Games.sol
contract Games is IGames, ObjectRegistry {
struct Game {
string metadata;
// this should be named better. it's confusing what this is
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.

Change to registeredObjects?

Comment thread contracts/zxp/Games.sol
address owner,
string calldata metadata,
// who deploys these contracts and who pays for each deployment of
// these sets of objects per EVERY game?
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.

Not us. Users, who want to launch game utility for an NFT collection. These are the "game creators"

Comment thread contracts/zxp/Games.sol
) external override {
// what is the difference between this ObjectRegistry and the one we inherited here, initialized in the constructor?
// also, does there HAVE to be a new registry for every game?
// what are the advantages of this?
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.

Inherited ObjectRegistry is removed.
It was changed to one registry per game because this allows the data association with the mapping -> struct to work generically with the ObjectRegistry, which wasn't it's own contract previously. Instead, code was repeated with very slight variation on the Games and the Seasons, in order to achieve the spec. However this is bad practice - this change consolidates the repeated code and makes the ObjectRegistry reusable.

string reveal;
}

// what is the reason there's no nonce counter on the contract?
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, could store it, just no good reason to on-contract since it is not getting used anywhere.
This does mean you have to store these offchain, but even if you had them on-chain you'd still have some work to do there managing these.
And I don't think we'd want to spend gas on making them like enumerable or something.

);
require(
// why is this necessary to hash these here and not just compare string directly?
// what do we miss when just comparing strings?
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.

Simple compare does not work due to differing data types storage vs mem

// he can locally keep hashing his guesses to get the same hash,
// once he gets the same hash he (and we) already know that his guess is correct,
// so we should be able to reward him at guess commit time and this whole reveal secret flow
// seems redundant
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.

Aw but then, only one person would be able to guess and then everybody else would know that it's the right answer
without having to do the quest.

Actually there is an issue with the contract related to this though. that is WIP. either salt is needed here, or the nonce needs to be abstracted in the guess. in order to prevent copying.

mapping(address awardee => uint amount) public rewards;
mapping(uint nft => uint block) public claimedAt;

// incorrect naming here. what is even registry in zXP? is it seasons? is it ObjectRegistry?
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 was incorrect, fixed

function onUnstake(
uint id,
address to,
// why don't we check this value against a mapping in GameVault ?
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.

because this is a Season object, it doesn't actually know about the game vault. it is not on the same registry as it.

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