GithubHelp home page GithubHelp logo

paintswap / estfor-contracts Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 7.0 13.25 MB

Estfor Kingdom game smart contracts

Home Page: https://estfor.com

Solidity 26.51% TypeScript 73.48% Shell 0.01% JavaScript 0.01%
brush fantom gamefi solidity typescript

estfor-contracts's Introduction

Estfor Kingdom contracts

image

Continuous integration

All the smart contract code for the Estfor Kingdom RPG game on the Fantom Blockchain.

Make sure yarn is installed (or replace with equivalent npm instructions)

These contracts use hardhat and require solidity 0.8.20 at minimum.

Install dependencies:

yarn install

To compile:

yarn compile

To run the tests:

yarn test

To deploy the contracts:

yarn deploy

To verify the contracts on ftmscan:

yarn verifyContracts

To check storage slot packing of the test file:

yarn umlStorage

Fantom mainnet deployed contract addresses:

WorldLibrary 0xcba2273a46649cc0ce76e69eb0bb05d9b699ca38
World 0x28866bf156152966b5872bee39bc05b5b5eedb02
Shop 0x7fb574e4fbe876f751fec90e59686c2776df19f9
RoyaltyReceiver 0xc3d53b81042454aa5fcf5c4e95de3e796dddb28b
AdminAccess 0xe63b7195b301b9313c9e337df4aceac436c3751e
ItemNFTLibrary 0x8d61639c830aaf82c8549c36e65a9aeef9a73b45
ItemNFT 0x4b9c90ebb1fa98d9724db46c4689994b46706f5a
EstforLibrary 0x804a530f41ecf0c40cd4e312a72e033c78a2c1fa
PlayerNFT 0xb809ed839c691d465e2ec45e1bcb5e5aded50fb9
PromotionsLibrary 0x5494e6a699e8e59e9a6ec3031ab96e35f2476c95
Promotions 0x7d1c598266Dd6Bb0Ed7a76161c11e5073D8A71A4
Quests 0x17c59f0d2d4f80FD0F906Df53a28272736c7b455
Clans 0x334caa8907bdf49470f7b085380c25431ef96f6d
WishingWell 0x0a8d80ce4855666b7d7121d75f2a49aac434a918
Bank Beacon 0xe183a43881eac74808c55bdb2a073929602af4db

PlayersLibrary 0x0DAbE42562B15614887C68fe486E9B81CB5DDbE9
PlayersImplQueueActions 0xb86cadad55067e24540c6d781d16778f887bf62f
PlayersImplProcessActions 0xe2a9b8c9cee566ae94758510aeaca20476eff97f
PlayersImplRewards 0xfb2aa5afc0de399c76d570ac9bc446940367cfba
PlayersImplMisc 0xddf2bf45e270c1cd624a6ad479974dff24113500
PlayersImplMisc1 0xc62bdaebc179b3f9cc83ac978db834457aea893b
Players 0x058ec56aba13f7fee3ae9c9b91b3bb03bc336143

BankRegistry 0x55a1b0251e1375bd41dd9778c379322e3863a54e
BankFactory 0x4af59427b2aeb66e6f7dca98c366ec66cca4e8d4

InstantActions 0x7e89fe755b546b10ea8372b056ea0d7b26cf36fe
InstantVRFActions 0xfe2c07fd7751bba25164adbd96e09b382403f4d7
GenericInstantVRFActionStrategy 0x6270b82049724ff6d7a78b71f2273bba03bfcdfc
EggInstantVRFActionStrategy 0x7797fd3904fc399184d2a549dff025210d62e645
VRFRequestInfo 0x8c3dcf7b09ea620b265d9daab237f29f485f725b

LockedBankVaults 0x65e944795d00cc287bdace77d57571fc4deff3e0
LockedBankVaultsLibrary 0x31c248c2f2c867dfeaa8f03c50ddabc8f14d00c0
Territories 0x2cfd3b9f8b595200d6b4b7f667b2a1bcc6d0c170
CombatantsHelper 0x8fedf83c55012acff7115b8fa164095721953c39
DecoratorProvider 0xba2f8cff9ea18f3687eb685f0c1bcd509b539963

PetNFTLibrary 0xf842b81350e8ac973bf7c7f32183cc1e1545e76d
PetNFT 0x1681f593ac5cba407c2a190de0ca2beb4a69b5d3
PassiveActions 0xa3e3a69edaee89b8dbbd1ca37704cc574cb8e1d4

Oracle 0x28ade840602d0363a2ab675479f1b590b23b0490
VRF 0xeF5AC0489fc8ABC1085E8D1f5BEE85e74E6D2cC2
Bazaar 0x6996c519dA4ac7815bEFbd836cf0b78Aa62fdBcE

Fantom mainnet beta deployed contract addresses:

WorldLibrary 0x31edace030c71d33bd8b6e53c1df123c0404e5ca
World 0xe2f0b5cb118da85be68de1801d40726ce48009aa
Shop 0xc5e24fbaba1a945226ad2f882e14fc7b44dc1f30
RoyaltyReceiver 0xc5de7625e1b5cb91d92bc65fd4d787f01c43e38e
AdminAccess 0xa298f1636dacab0db352fec84d2079814e0ce778
ItemNFTLibrary 0x2d0b79a4d76d6fd86b8ba08acc68d3f35430aa7a
ItemNFT 0x1dae89b469d15b0ded980007dfdc8e68c363203d
EstforLibrary 0xAD4Fe5A1d43F986659F548Cc899dCD4045FA9974
PlayerNFT 0xde70e49756322afdf7714d3aca963abcb4547b8d
PromotionsLibrary 0x684c6e254df63b9d5a28b29b7e4d0850d158f9f9
Promotions 0xf28cab48e29be56fcc68574b5c147b780c35647c
Quests 0x96948a6df3a64cc2eb0a1825fccd26f0c93bfce9
Clans 0xd35410f526db135f09bb8e2bb066c8a63135d812
WishingWell 0xdd1131f57e5e416622fa2b61d4108822e8cc38dc
Bank Beacon 0x73d1b1420deaeb6474b8aafb1d8229d392d1a04e

PlayersLibrary 0x0abc509929f6bfc27938f3709caf333bbae716cf
PlayersImplQueueActions 0xbbe4d7d9027e22562386cb794c618cde55ef04be
PlayersImplProcessActions 0xb42935f9a62dc3c6f6898d54400b8c6b68a29f22
PlayersImplRewards 0x45cac1133b81181af3d0543c33a3e7c568579592
PlayersImplMisc 0x55919fc7193d8c5fa409a1d2437ecda0eb395f17
PlayersImplMisc1 0xae72aebfdd87f74aa9409ada0f64a6d9d41a2ec8
Players 0x0aac9c0966ad5ea59cd0a47a0d415a68126ab7be

BankRegistry 0xd5da02cee3d9ef0d63d1b79c659df16770c3c4e0
BankProxy 0xe1998e9bad94716ecf81f3a3bead5fed3fb023cb
BankFactory 0x7b8197e7d7352e8910a7af79a9184f50290403da

InstantActions 0xe9a1a09be4a64f806a26b33fbdf07a6f3e61af76
InstantVRFActions 0xbbcc13d2359ad6f2c02e172de46097a1c534ef89
GenericInstantVRFActionStrategy 0xc4c92d3987cc0bad3219e696653eb87eddda78c6
EggInstantVRFActionStrategy 0x941369948CC8a4b5b8eFb1F688Eddfe26A736039
VRFRequestInfo 0x9bcf94e6c067c575dd6a748e45330b4ae4dc0483

LockedBankVaultsLibrary 0xdac97bdf170929fbf2140ab63403cae49ada2bbc
LockedBankVaults 0x40567ad9cd25c56422807ed67f0e66f1825bdb91
Territories 0xf31517db9f0987002f3a0fb4f787dfb9e892f184
CombatantsHelper 0xe8231ac805a88b3c72e9602c2ae14a5d3421bc7c
DecoratorProvider 0xea8c4d188eb8d9704bc36931d89ba4f8e935cee2

PetNFTLibrary 0x7b84ff0313ef08ddee716cf3430b9ab1204d76bc
PetNFT 0xa6489181b24e966402891225c65f8e2d136ddd2e
PassiveActions 0x3df5b6cad0d2de6b71f2d5084e0b933dbcd395f6

Oracle 0x6f7911cbbd4b5a1d2bdaa817a76056e510d728e7
VRF 0x58E9fd2Fae18c861B9F564200510A88106C05756
Bazaar 0x082480aAAF1ac5bb0Db2c241eF8b4230Da85E191

Other addresses:

Brush 0x85dec8c4b2680793661bca91a8f129607571863d

estfor-contracts's People

Contributors

0xsamwitch avatar doublesharp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

estfor-contracts's Issues

Tasks for migration

  • Upgrade solidity version to 0.8.26
    Introduces a bunch of via-ir optimization improvements
    Allows writing require(bool, MyCustomError()

  • Upgrade to OZ V5 #12

  • Change approval structure (#76)

  • Update SWOB to V2

  • Remove all legacy event handling

  • Remove debug/console.sol and use hardhat/console.sol

  • For PlayerNFT use single per token ERC1155

  • For Players object add isActive (or pack it), can be useful inside _updateOwner

  • Upgrade evm version from Paris

  • [Passive|Instant|InstantVRF]Actions add isAvailable to the Inputs and events. Read it in _packAction()

  • Remove selling to shop, can remove on-chain totals for the items too

  • Remove all the .connect() for impersonation, can add hardhat accounts using .env

  • New init events, reserve names for 30 days?

Remaining tasks for Alpha

  • Hook in chainlink oracles properly
  • Replace all requires with revert and custom error
  • Change all mentions of tokenId in Players to playerId
  • Add boost vial test
  • Use defence combat skill
  • Test for health point
  • More combat tests
  • Add level up rewards to pending output.
  • When consuming actions, also retrieve any random rewards for previous actions.
  • Go through all integer casts and check if they are necessary
  • Rename rate in pending
  • Make sure there are never errors thrown when processing actions
  • Rename itemTokenIdRangeMin/Max to include hand
  • Deployment test script, add combat
  • Include updated total xp reward items
  • Check speed multiplier is working correctly with past random loot items
  • Is minSkillPoints used correctly in places where there are no minimum equipment items.
  • minSkillPoints test for consumeables, attire and left/right hand equipment. Actions and action choices too
  • Full equipment bonuses
  • Map skill points to level in uri.
  • Check for re-entrancies (especially when minting)
  • Go through all the comments and check if they are still relevant
  • Fix solidity compiler warnings
  • Reuse some code from pendingRewards and processActions
  • Check storage slots are actually packed as expected
  • Is equip position correct for attire?
  • Upgrade to solidity 0.8.19
  • Convert for loops to while or do-while with unchecked increments
  • Use unsafe array access
  • Use new combat system
  • Implement ERC2981 and buy brush on the backend and send to the pool
  • Update names of item/player NFTs when they are launched
  • Update alpha whitelist to 2 mints per account
  • Make alpha whitelist players non-transferable (Not done)
  • Add require around brush transfer (e.g in RoyaltyReceiver)
  • Add nft vault check in alpha whitelist
  • Add shield test and check it is only equippable in left hand (and others only in right hand)
  • Daily/Weekly rewards
  • Discount on xp boosts for the first X weeks
  • Use non-transferable SoulBound ERC? (No clue EIP to use)
  • Use revertedWithCustomError in all tests with the appropriate custom error message
  • Create some re-usable objects in Players.ts tests
  • May need to move all error inside PlayerBase.sol
  • Use new npm definition library
  • Cooking success rate
  • Thieving success rate
  • Add CI
  • Beardie holder discount (Not doing)
  • Add admin whitelist
  • Give some characters extra skills
  • Verify contracts in deployment script
  • ProcessActions should fail if there are no actions to do
  • Add alpha whitelist
  • Use names of NFTs with (ALPHA)
  • Update boots to feet
  • Enable full attire bonuses once all items are added
  • Change max food and scrolls that can be consumed to 65536?
  • Make sure unused dynamic actions are not available to be used
  • Minting a new active player while an existing one has actions queued is not working.
  • Check XP boosts can be liquidated.
  • A test when maxing out XP (overflowing)
  • Combine some world.*() functions together to reduce calls
  • Some tests fail if they cross a UTC midnight boundary
  • Add a test which maxes out food/scrolls (scrolls not needed)
  • Add all shop items
  • Implement gathering boost
  • Add name to Item events
  • Use whitelist .json files from estfor-definitions lib
  • (bug) Combat not always using up food against high level enemies
  • Gathering boost random reward tests

During alpha

  • Thieving full set should give +3% reward chance
  • Add overall level to "name" in player metadata
  • Add external_uri to player url
  • Update liquidating logic, each item BRUSH allocation should be defined daily
  • Give each player permanent bonuses for their starting skills, 10%? and 5% if shared
  • Add multiple queued action checks with new pendingQueuedActionState

During beta

  • Check comment // TODO Update later to pendingRandomReward.elapsedTime

Update start of scripts to be consistent

Most scripts begin with something like this:

const [owner] = await ethers.getSigners();
console.log(`Deploying upgradeable contracts with the account: ${owner.address}`);

const network = await ethers.provider.getNetwork();
console.log(`ChainId: ${network.chainId}`);

But we could console.log in one line with this:

const [owner] = await ethers.getSigners();
const network = await ethers.provider.getNetwork();
console.log(`Deploying instant actions using account: ${owner.address} on chain id ${network.chainId}`);

Edit: Actually this might work:

const [owner] = await ethers.getSigners();
console.log(`Deploying instant actions using account: ${owner.address} on chain id ${await owner.getChainId()}`);

When losing a locked vault attack, check if there is anything to lose before doing brush transfers

In LockedBankVaults.sol check if totalWon != 0 before trying all this.

    uint brushBurnt;
    if (!didAttackersWin) {
      // Lost so take a percentage from the loser's vaults
      uint amountToTreasure = totalWon / 2;
      uint amountToDao = totalWon / 4;
      brushBurnt = totalWon - (amountToTreasure + amountToDao);

      // Send to the treasure
      brush.transfer(pool, amountToTreasure);
      brush.transfer(dev, amountToDao);
      brush.burn(brushBurnt);
    }
    ```
Otherwise it can do 0 brush transfer which are not necessary, example:  https://ftmscan.com/tx/0xcdff939e3cac54bc7426ca8e62ea8398f03906fce09d62c56d80164d6b63b9bf

Change to use approvals instead of listing all addresses explictly

Like instead of

  modifier onlyBurner(address from) {
    if (
      _msgSender() != from &&
      !isApprovedForAll(from, _msgSender()) &&
      _msgSender() != _companyNFT &&
      _msgSender() != _playerNFT
    ) {
      revert NotBurner();
    }
    _;
  }

Write:

  modifier onlyBurner(address from) {
    if (
      _msgSender() != from &&
      !isApprovedForAll(from, _msgSender())
    ) {
      revert NotBurner();
    }

And add a new state variable to store approvals

  function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
   return super.isApprovedForAll(account, operator) || _approvals[operator];
 }

Add private key to hardhat accounts in config and remove all explicit .connects

When forking with npx hardhat node --fork https://.... it currently uses the default hardhat accounts, this causes problems if we want to impersonate the owner for upgrades. Current we use getImpersonatedSigner and then pass the owner signer in various places through .connect, but I don't think this is necessary. Can set hardhat to use the owner as the default.

hardhat.config.ts

const hardhatAccounts: HardhatNetworkAccountUserConfig[] = [
  {
    privateKey: process.env.PRIVATE_KEY as string,
    balance: ethers.parseEther("100000").toString(),
  },
];

Add accounts here:

    hardhat: {
      gasPrice: 0,
      initialBaseFeePerGas: 0,
      allowUnlimitedContractSize: true,
      accounts: hardhatAccounts,
    }

But thought needs to be put into running the tests and deployment on CI as it would then use them too, hmm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.