Skip to content

Commit

Permalink
Merge pull request #24 from treasure-chess/cleanup-for-prod
Browse files Browse the repository at this point in the history
v0.1.0
  • Loading branch information
pi0neerpat committed Feb 2, 2022
2 parents 772e252 + dde9a82 commit 7e75cc5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 111 deletions.
165 changes: 55 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
# @treasure-chess/contracts

<details open="open">
<summary><h2 style="display: inline-block">Table of Contents</h2></summary>
<ol>
<li>
<a href="#docs">Docs</a>
</li>
<li>
<a href="#about-the-project">About The Project</a>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgements">Acknowledgements</a></li>
</ol>
</details>

## 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
<h1 align="center">Welcome to @treasure-chess/treasure-contracts 👋</h1>
<p>
<a href="https://www.npmjs.com/package/@treasure-chess/treasure-contracts" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/@treasure-chess/treasure-contracts.svg">
</a>
<a href="#" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
</p>

> 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:

Expand All @@ -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.
Expand All @@ -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 <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

Expand All @@ -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 <NETWORK>`.

Example tests of GSN enabled contract: https://github.com/qbzzt/opengsn/blob/master/01_SimpleUse/test/testcontracts.js
Expand Down Expand Up @@ -174,41 +157,3 @@ const gsnContractCall = async () => {
console.log(`Mined in block: ${receipt.blockNumber}`);
};
```

<h1 align="center">Welcome to @treasure-chess/treasure-contracts 👋</h1>
<p>
<a href="https://www.npmjs.com/package/@treasure-chess/treasure-contracts" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/@treasure-chess/treasure-contracts.svg">
</a>
<a href="#" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
</p>

## 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...")
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treasure-chess/treasure-contracts",
"version": "0.0.4",
"version": "0.1.0",
"description": "Treasure Chess contracts",
"files": [
"artifacts/contracts/**/*"
Expand Down

0 comments on commit 7e75cc5

Please sign in to comment.