Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Solidity usability #277

Merged
merged 24 commits into from
Jan 9, 2024
Merged

Improve Solidity usability #277

merged 24 commits into from
Jan 9, 2024

Conversation

SebastienGllmt
Copy link
Contributor

@SebastienGllmt SebastienGllmt commented Jan 9, 2024

Right now deploying and interacting with the Solidity contracts for Paima is a pain. The old setup was like this:

  1. Manually extract the contracts from Paima using the ./paima-engine contracts CLI
  2. Modify the contracts as needed
  3. Setup your own tool to deploy them (or use a custom CLI we provided that was extremely buggy)

The new option is like this:

  1. Improve any contract you need from NPM directly into your game (only overriding things if necessary)
  2. Run a simple deploy command to deploy the contracts to a custom chain or production
  3. Interact with these contracts using hardhat (either hardhat-interact or custom Paima tasks)

Some tasks off the top of my head that still need to be done

  • properly bundle the Solidity contracts with the Paima executable for the paima contracts command
  • decide if/how we want to include typechain-types in the NPM package
  • fix prettier complaining about the evm-contracts folder (I don't know why it doesn't like this despite being fine with the old code)
  • port any tests we want to keep from the old folders to the new evm-contracts folder
  • improve documentation of the contracts (that is to say, inline docs inside the .sol files
  • review the contracts (they were written quite a while ago, so probably best to review them to make sure they still follow best practices for Solidity)
  • delete the old paima-l2-contract and nft folders
  • publish the evm-contracts package to NPM

Related PRs that are ongoing

  • update the Paima docs to explain the new process
  • update Paima game templates to the new process

Comment on lines 38 to 39
uint256 indexed oldMaxSupply,
uint256 indexed newMaxSupply
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these indexed? I don't think you need filtered search on these parameters, henceforth this only adds unnecessary gas cost.


event RemoveMinter(address indexed oldMinter);

event SetBaseURI(string indexed oldUri, string indexed newUri);
Copy link
Contributor

Choose a reason for hiding this comment

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

indexed here doesn't make much sense as well.

  1. You don't need to filter events for specific uri values.
  2. Since they are strings, not the string value but its hash will be stored, so you wouldn't be able to retrieve the values from the event log.

Comment on lines 23 to 20
event RemoveWhiteListedToken(address indexed token);

event WhiteListTokens(address[] indexed token);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since whitelist is one word, it shouldn't be WhiteList but Whitelist


/// @title Proxy
/// @dev Proxy contract mostly based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol
contract NativeProxy is ERC1967 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a proxy for NativeNftSale contract right? I would propose changing the name to NativeNftSaleProxy, so it's more explanatory and consistent with the Proxy naming


/// @title Proxy
/// @dev Proxy contract mostly based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol
contract Proxy is ERC1967 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a proxy for Erc20NftSale contract right? I would propose changing the name to Erc20NftSaleProxy, so it's more explanatory and consistent with the Proxy naming

// Array of deposited currencies
ERC20[] public depositedCurrencies;

// mapping from token address to amount
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not true, it's a mapping from token address to boolean representing if this token has been deposited

// mapping from token address to amount
mapping(ERC20 => bool) public depositedCurrenciesMap;

// Array of supported currencies
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments like these feel really unnecessary 😅

@SebastienGllmt SebastienGllmt merged commit 8cd7b58 into master Jan 9, 2024
@SebastienGllmt SebastienGllmt deleted the improve-script-types branch January 9, 2024 17:47
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