From c97366c784a061036b85e6d9c493094665eb6cbb Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 1 Feb 2022 20:22:16 -0800 Subject: [PATCH 1/2] update readme --- README.md | 165 ++++++++++++++++++------------------------------------ 1 file changed, 55 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index 7a3c3c5..6fcfabe 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,47 @@ -# @treasure-chess/contracts - -
-

Table of Contents

-
    -
  1. - Docs -
  2. -
  3. - About The Project -
  4. -
  5. - Getting Started - -
  6. -
  7. Usage
  8. -
  9. Contributing
  10. -
  11. License
  12. -
  13. Contact
  14. -
  15. Acknowledgements
  16. -
-
- -## Docs - -## Recent Dev Deploy - -Mumbai: -Treasure Contract Address: 0x8C7243028492aEeB49c9306355DAa30B5632DE18 -Treasure Market Contract Address: 0x9Ebf0123d8bA676d29aEFa0A490629546cB6DbB3 - -### Treasure Tips, Tricks, and Design Decisions - -- No meta transactions on the main Treasure contract, since only the admin controlled accounts can call minting function , and we only need to make transfers free -- contract name will be changed at the end, since we want to reserve the url /TreasureChess on third party marketplaces and don't want it scrapped if we decide to test on polygon later. -- Overrided `approveForAll` check so that OpenSea and our marketplace do not require an approval transaction for use. -- Achievements are on-chain and also can be part of json URI so make it something that onchain governance can decide -- The `Owner` should be updated to a multisig wallet (gnosis safe) controlled by the dev team, possibly Victor/a lawyer + a DAO for tiebreakers, while `Admins` should be internal addresses controlled +

Welcome to @treasure-chess/treasure-contracts 👋

+

+ + Version + + + License: MIT + +

+ +> Smart Contracts and Subgraphs for Treasure Chess + +## Usage + +This package includes resources for interacting with the Treasure Chess contracts. We've provided the Application Binary Interface (ABI), which can be used as follows: + +Install the package + +```sh +yarn add @treasure-chess/treasure-contracts +``` + +Import the package, and use `ethers.js` to create the contract + +```js +import treasureArtifact from "@treasure-chess/treasure-contracts/artifacts/contracts/Treasure.sol/Treasure.json"; +import { Contract } from "@ethersproject/contracts"; +import { JsonRpcProvider } from "@ethersproject/providers"; + +const treasureAbi = treasureArtifact.abi; +const rpcProvider = new JsonRpcProvider(process.env.MATIC_RPC); + +const treasureContract = new Contract( + "0x...."; // See our docs for the address + treasureAbi, + rpcProvider +); + +const tx = await treasureContract.balanceOf("0x...") +``` ## About The Project -A simple hardhat template modeled off of running `npx hardhat init`. +A simple hardhat template created from `npx hardhat init`. This project includes: @@ -53,15 +52,6 @@ This project includes: - `npx hardhat coverage` - `@openzeppelin/hardhat-upgrades`: a plugin which is used in conjunction with hardhat to deploy upgradeable contracts and upgrade them later. The plugin by default prevents you from deploying/upgrading "dangerous" upgradeable contracts. -### Built With - -- [hardhat](https://hardhat.org) -- [hardhat-prettier](https://www.npmjs.com/package/hardhat-prettier) -- [hardhat-typechain](https://hardhat.org/plugins/hardhat-typechain.html) -- [solidity-coverage](https://hardhat.org/plugins/solidity-coverage.html) -- [OpenZeppelin Upgrades Plugin](https://docs.openzeppelin.com/upgrades-plugins/1.x/) -- [OpenZeppelin Upgradeable Contracts](https://www.npmjs.com/package/@openzeppelin/contracts-upgradeable) - ## Getting Started To get a local copy up and running follow these simple steps. @@ -70,46 +60,37 @@ To get a local copy up and running follow these simple steps. You also need a `.env` file with the following items: +> NOTE: This section needs updating. + - `ROPSTEN_PRIVATE_KEY`: A private key (account which will deploy) for testing. - `INFURA_API_KEY`: An infura api key which you can obtain from [infura](https://infura.io). - `FORWARDER_ADDRESS`: The [opengsn](https://docs.opengsn.org/contracts/addresses.html) forwarder address - this will vary based on which network you are deploying/testing on or if you want to deploy your own forwarder. -### Installation - -Clone the repo - -```sh -git clone https://github.com/pi0neerpat/treasure-chess.git -``` - -Move into this directory and install packages - -``` -cd contracts/ -yarn install -``` - ## Usage To run tests, first compile the project with `yarn compile` and then `yarn test`. To deploy the contracts, simply call `yarn deploy --network `. Keep in mind, you must add this network to the `hardhat.config.ts` file with the necessary information for this to work. -### public user functions +### Public user functions #### Market -```js -function listItem(uint \_id, uint price, uint duration) public +Interface for using a token + +```sol +function tokenListItem(uint tokenId, uint price, uint duration) public -function cancelSale(uint \_id) public +function tokenUnlistItem(uint tokenId) public -function instantBuy( uint \_id ) public // **payable** +function tokenInstantBuy(uint tokenId) public ``` #### Transfers -- function safeTransferFrom( address from, address to, uint256 tokenId) +```sol +function safeTransferFrom(address from, address to, uint256 tokenId) +``` #### Meta transactions @@ -118,7 +99,9 @@ Make meta transaction calls calling the functions normally, and getting end user GSN example: https://docs.opengsn.org/javascript-client/getting-started.html#adding-gsn-support-to-existing-app To test upgrading the contract, you first need to deploy the `Treasure` and `TreasureMarket` contracts and copy the addresses over to your `.env` file under `TREASURE_ADDRESS` and `TREASURE_MARKET_ADDRESS`. + The current setup upgrades the contract to `TreasureUpgraded.sol` and `TreasureMarketUpgraded.sol`, but you can modify the `upgradeContracts` function in `scripts/helpers.ts` to upgraded to any contract (change value passed to `getContractFactory`). + To upgrade the contracts, use `yarn upgrade-contracts --network `. Example tests of GSN enabled contract: https://github.com/qbzzt/opengsn/blob/master/01_SimpleUse/test/testcontracts.js @@ -174,41 +157,3 @@ const gsnContractCall = async () => { console.log(`Mined in block: ${receipt.blockNumber}`); }; ``` - -

Welcome to @treasure-chess/treasure-contracts 👋

-

- - Version - - - License: MIT - -

- -## Usage - -> Note: The final contracts will be added once they are published. Until then only the ABIs are available here. - -Install the package - -```sh -yarn add @treasure-chess/treasure-contracts -``` - -Example usage: -```js -import treasureArtifact from "@treasure-chess/treasure-contracts/artifacts/contracts/Treasure.sol/Treasure.json"; -import { Contract } from "@ethersproject/contracts"; -import { JsonRpcProvider } from "@ethersproject/providers"; - -const treasureAbi = treasureArtifact.abi; -const rpcProvider = new JsonRpcProvider(process.env.MATIC_RPC); - -const treasureContract = new Contract( - "0x...."; // See our docs for the address - treasureAbi, - rpcProvider -); - -const tx = await treasureContract.balanceOf("0x...") -``` From dde9a824e5132fd9d1e0aa99b8e1b6f8bb926706 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 1 Feb 2022 21:13:23 -0800 Subject: [PATCH 2/2] v0.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8376b1f..a1f0beb 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treasure-chess/treasure-contracts", - "version": "0.0.4", + "version": "0.1.0", "description": "Treasure Chess contracts", "files": [ "artifacts/contracts/**/*"