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

[feature] Move avatar code to separate package #1195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
575b7ec
add: mumbai deployment
lionseal May 22, 2023
79d6b68
add: mainnet deployment
lionseal Jun 2, 2023
dd391ea
rebase: fetched changes for solc 0.5 and deployment scripts
capedcrusader21 Jun 2, 2023
6e28df7
rebase: fetched changes from solc_0.8 of land_tunnel_upgrade branch
capedcrusader21 Jun 2, 2023
5e39a34
rebase: fetched test changes from tunnel upgrade PR
capedcrusader21 Jun 3, 2023
a869d18
fix: imports and tests
capedcrusader21 Jun 4, 2023
d41005c
chore: prettier
adjisb Jun 4, 2023
7daa79a
test: make revertedWith match a regexp
adjisb Jun 5, 2023
869d55c
fix double ext
Jun 5, 2023
c383cc9
Land doc
Jun 5, 2023
c869531
fix tag in doc
Jun 5, 2023
5d2580f
Operator filter registry on testnets
Jun 6, 2023
5f425c7
Operator filter subscription testnets deployments
Jun 6, 2023
59c2178
LAND testnet deployments
Jun 6, 2023
07a1e1c
LAND tunnels deployment
Jun 6, 2023
6e0ffa3
fix: corrected path of scripts in migration md
capedcrusader21 Jun 8, 2023
a301945
refactor: added defender address as admin in migation contract deploy…
capedcrusader21 Jun 8, 2023
1b4ca62
refactor: modified fetching address of oz relayer in migration contra…
capedcrusader21 Jun 8, 2023
50f98e8
fix: fixed format
capedcrusader21 Jun 8, 2023
8a0bd54
feat: added migration contract deployments file
capedcrusader21 Jun 9, 2023
a1b8cec
refactor: resolved package conflict
capedcrusader21 Jun 9, 2023
862d962
fix: format
capedcrusader21 Jun 9, 2023
a14aa54
feat: add signed multigivaway package
adjisb Jun 1, 2023
51a8b08
feat: update solhint and prettier packages
adjisb Jun 2, 2023
d2b5afd
fix: simplify npm scripts for test and coverage
adjisb Jun 8, 2023
0419d7c
Merge pull request #1001 from thesandboxgame/feat/signedMultiGiveaway…
adjisb Jun 9, 2023
399bc13
feat: fix an error when there is no coverage report
adjisb Jun 9, 2023
406114d
Merge pull request #1002 from thesandboxgame/feat/monorepo_coverage_fix
adjisb Jun 9, 2023
789ef58
feat: deploy package
adjisb Jun 7, 2023
53ce0a4
revert: removed indexed from SuperOperator and Minter event
capedcrusader21 Jun 16, 2023
25a46b5
Merge pull request #998 from thesandboxgame/chore/deploy-landsale-48
atkinsonholly Jun 19, 2023
b693887
Merge pull request #1005 from thesandboxgame/refactor/revert-indexed-…
capedcrusader21 Jun 20, 2023
ddf2080
added deployment files for goerli
capedcrusader21 Jun 20, 2023
0cf372b
added deployment files for mumbai
capedcrusader21 Jun 20, 2023
66a978c
fix: updated numDeployments in deployment files
capedcrusader21 Jun 21, 2023
159712c
Merge pull request #1007 from thesandboxgame/deployments/upgrade-land…
capedcrusader21 Jun 22, 2023
6fe5965
bulk moved deployments
abarbatei Jun 22, 2023
c2cb916
Merge remote-tracking branch 'origin' into feature/move-avatar-to-sep…
abarbatei Jun 22, 2023
4a68144
fix: renumber the deploy scripts
Jun 26, 2023
a833081
Merge pull request #1000 from thesandboxgame/feat/signedMultiGiveaway…
adjisb Jun 26, 2023
4b983ff
feat: admin will be able to set the trusted forwarder
adjisb Jun 26, 2023
6bcd5f6
Merge pull request #1010 from thesandboxgame/feat/instant_giveaway_se…
adjisb Jun 26, 2023
a440c86
chore: update hardhat to 2.16.0
adjisb Jun 27, 2023
bae8415
Merge pull request #1013 from thesandboxgame/feat/deploy_update_hardhat
adjisb Jun 27, 2023
15747b3
chore: add prettir and lint for json files in deploy package
adjisb Jun 27, 2023
daf5a9d
Merge pull request #1014 from thesandboxgame/feat/deploy_lint_json
adjisb Jun 27, 2023
6655d4e
feat: add default proxy admin to deployments
adjisb Jun 27, 2023
750d39a
fix: prettier over deployment files
adjisb Jun 27, 2023
b9ea48c
Merge pull request #1012 from thesandboxgame/feat/deploy_add_default_…
adjisb Jun 27, 2023
ea3b713
fix: update solidity-coverage on core package
adjisb Jun 27, 2023
18ba46e
Merge pull request #1015 from thesandboxgame/fix/update_coverage_on_core
adjisb Jun 28, 2023
7120381
fix: fix some potential concurrency issues in tests
Jun 28, 2023
47ba255
Merge pull request #1017 from thesandboxgame/fix/potential_concurrenc…
adjisb Jun 28, 2023
9a7574a
Avatar contract v2 audit report
BenjaminCoste Jun 30, 2023
83a74e5
add: template package for hardhat
atkinsonholly Jun 29, 2023
f7ee3da
fix: rm forking and remove testnets from package config
atkinsonholly Jun 29, 2023
91bc8ac
feat: add linter, simplify configuration
adjisb Jun 29, 2023
76d8336
fix: add PR fixes, improve README and upgradable example
adjisb Jun 30, 2023
c049339
update: merge improvements and tidy readme
atkinsonholly Jul 3, 2023
a927ea0
update: pr template
atkinsonholly Jul 3, 2023
89a3bf3
fix: chai matchers version and filename format
atkinsonholly Jul 3, 2023
ba977c0
fix: yarn.lock
atkinsonholly Jul 3, 2023
065f385
fix: avoid chainging git worflow and .gitignore
adjisb Jul 3, 2023
377f5d7
fix: update the tools to latest version
adjisb Jul 3, 2023
5368c64
fix: rename .doc.exampel to doc.example
adjisb Jul 3, 2023
f7e2af3
fix: fix the name of a test suite
adjisb Jul 3, 2023
3932aaf
Merge pull request #1020 from thesandboxgame/packages-example
adjisb Jul 3, 2023
3f332c4
Revert "revert: removed indexed from SuperOperator and Minter event"
capedcrusader21 Jul 3, 2023
4872093
refactor: deployed Land and PolygonLand with indexed events
capedcrusader21 Jul 3, 2023
0a15c17
fix: add some missing await that give random errors
adjisb Jun 30, 2023
bd31368
fix: instant giveaway pre-audit fixes
adjisb Jul 4, 2023
a8d38da
chore: deploy mumbai
lionseal Jun 16, 2023
852d553
add: polygon landsale
lionseal Jul 10, 2023
42ffab4
you shall not pass!
Jul 3, 2023
0d50716
suggest updates
atkinsonholly Jul 4, 2023
b642d54
fix: audit fixes
Jul 19, 2023
2dbbbfe
merged origin/master
abarbatei Jul 24, 2023
9c54016
external domainSeparator
Jul 27, 2023
9a5f481
doc expiration
Jul 27, 2023
8bb7fb2
fix: fix L-03 correclty
adjisb Jul 31, 2023
903c27e
doc: natspec for events
adjisb Jul 31, 2023
0fde71e
doc: update the markdown doc after the fixes
adjisb Jul 31, 2023
4d8efbc
doc: add documentation for the data field
adjisb Jul 31, 2023
ef852ca
fix: run ci tasks sequentially.
adjisb Jul 31, 2023
a3c8b2b
chore/add-deployment-versions (#1016)
lionseal Aug 1, 2023
1c2352d
update: exclude minted function to log estate info
lionseal Aug 2, 2023
6a7c099
add: option to skip test deployments while forking
lionseal Aug 2, 2023
b6dcddd
fix: format
lionseal Aug 2, 2023
a59178f
Merge pull request #1067 from thesandboxgame/feat/instant_giveaway_au…
adjisb Aug 3, 2023
e1a8e0d
feat: add a reusable dependency metatx package
adjisb Aug 1, 2023
044d2bc
fix: fix hardhat version in core and deploy
adjisb Aug 1, 2023
1b327ce
fix: fix solidity-coverage version
Aug 1, 2023
360af8c
feat: add latest instant giveaway deployment
adjisb Aug 3, 2023
a5bbc51
Chore/land tunnel migration (#1073)
lionseal Aug 7, 2023
c4b8f3d
Add files via upload
BenjaminCoste Aug 7, 2023
5cf5daf
fix: add a missing await in core package
adjisb Aug 3, 2023
26d163e
fix: ignore docs so we don't run the ci
adjisb Aug 7, 2023
147b2c1
fix: rename deploymet to SignedMultiGiveaway
adjisb Aug 8, 2023
87998d2
update: new readme format
atkinsonholly Aug 9, 2023
1e884b3
fix: update readme typos and add example link
atkinsonholly Aug 9, 2023
5bc21b3
add: coverage badge added to readme
atkinsonholly Aug 9, 2023
d586d79
update: readme ref to audit best practices and logo
atkinsonholly Aug 9, 2023
38925f5
update: readme ref to audit best practices and logo
atkinsonholly Aug 9, 2023
b725aba
Merge pull request #1090 from thesandboxgame/docs/readme-updates
atkinsonholly Aug 9, 2023
8e18dcd
update: readme minor edits
atkinsonholly Aug 9, 2023
fccac70
Merge pull request #1091 from thesandboxgame/docs/readme-root-edits
atkinsonholly Aug 9, 2023
604c386
feat: fixes to use the new solhint version
adjisb Aug 11, 2023
c546d38
fix: disable custom errors check
adjisb Aug 23, 2023
b15dfeb
Merge pull request #1098 from thesandboxgame/feat/prepare_for_new_sol…
adjisb Aug 24, 2023
0174533
fix typo
omahs Aug 24, 2023
53e866a
fix typos
omahs Aug 24, 2023
798a577
fix typos
omahs Aug 24, 2023
ac602b6
fix typos
omahs Aug 24, 2023
b689638
fix typo
omahs Aug 24, 2023
0501f47
fix: skip coverage for test contracts in giveaway package
adjisb Aug 31, 2023
5430cc8
Merge pull request #1116 from thesandboxgame/fix/giveaway_skip_covera…
adjisb Aug 31, 2023
d99b4a2
Merge pull request #1081 from thesandboxgame/feat/instant_giveaway_de…
adjisb Sep 1, 2023
8e7de80
Chore/deploy land sale 50 (#1110)
lionseal Sep 5, 2023
ce86b22
refactor/script.js (#1144)
lionseal Sep 5, 2023
f0b742a
feat: use latest giveaway source package
adjisb Aug 25, 2023
4d2156d
feat: add release-it
adjisb Aug 24, 2023
0bfd228
chore: @sandbox-smart-contracts/giveaway release v0.0.2
adjisb Aug 24, 2023
1230ae7
fix: fix release-it hooks
adjisb Aug 24, 2023
e8f9ef8
fix: move OZ contract to dependencies
adjisb Aug 24, 2023
b57cd11
chore: @sandbox-smart-contracts/giveaway release v0.0.3
adjisb Aug 24, 2023
a5cf14a
chore: deploy instant giveaway polygon
lionseal Sep 12, 2023
208c42a
Merge branch 'chore/deploy-instant-giveaways' into feat/release_it
adjisb Sep 14, 2023
43e7326
chore: changelog
adjisb Sep 14, 2023
cc52771
chore: @sandbox-smart-contracts/giveaway release v1.0.0
adjisb Sep 14, 2023
aba07e9
chore: update yarn.lock
adjisb Sep 14, 2023
889a89d
Merge pull request #1099 from thesandboxgame/feat/release_it
adjisb Sep 18, 2023
25627aa
fix: use the right named address for giveaway test
adjisb Sep 19, 2023
c20cd5f
Merge pull request #1151 from thesandboxgame/fix/deploy-givaway-address
atkinsonholly Sep 19, 2023
aaaec46
Merge pull request #1100 from omahs/omahs-patch-1
atkinsonholly Sep 21, 2023
8bf904c
fix: use fqn for TrustedForwarderMock
adjisb Sep 26, 2023
bb2fab0
Merge pull request #1162 from thesandboxgame/fix/deploy-use-fqn
adjisb Sep 26, 2023
1b83633
add: mumbai deployment
lionseal Sep 5, 2023
35036f0
chore: deploy land sale 51 polygon
lionseal Sep 25, 2023
057bc63
updated avatar and factory tests to ethers v6 and separated them
abarbatei Sep 28, 2023
460ad27
modified old raffle tests to new structure for polygon collections
abarbatei Sep 28, 2023
7ae2af4
moved old raffle contrats (first versions)
abarbatei Sep 28, 2023
35f92bc
moved avatar contracts to avatar package
abarbatei Sep 28, 2023
1add64c
properly moved old raffle contrats (first versions)
abarbatei Sep 28, 2023
d29cccb
fixed migrated raffle tests
abarbatei Sep 28, 2023
b52b4e2
removed comment from old raffle, workaround by ignoring the warning
abarbatei Sep 28, 2023
d4f0d9f
major package cleanup; deployment related files moved; settings file …
abarbatei Sep 28, 2023
583d989
Merge remote-tracking branch 'origin/master' into feature/move-avatar…
abarbatei Sep 29, 2023
ddae02f
added raffle, avatar and collection factory deployment scripts
abarbatei Oct 3, 2023
3008f95
added raffle, avatar and collection factory deployment files
abarbatei Oct 3, 2023
3cd493c
added deployment script dependency from core project
abarbatei Oct 3, 2023
77bbd74
added fork:deploy:mumbai command to ./package.json
abarbatei Oct 3, 2023
59e6b08
added avatar package to importedPackages task in ./hardhat.config.ts
abarbatei Oct 3, 2023
3bfa535
removed old deployment files; they were moved to deploy module
abarbatei Oct 3, 2023
787c885
undo yarn.lock changes
abarbatei Oct 3, 2023
616abf0
undo yarn.lock changes x2
abarbatei Oct 3, 2023
205716d
updated ./yarn.lock
abarbatei Oct 6, 2023
6b59444
removed .sol from yarn pretier, files have been audited, unknown if w…
abarbatei Oct 6, 2023
e84fe20
format fix
abarbatei Oct 6, 2023
5f14155
partial lint/format fix
abarbatei Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package-lock.json
.env
yarn.error.log
yarn-error.log
Expand Down
4 changes: 4 additions & 0 deletions .nxignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ secret/
# We don't want the CI to run over all the packages, we decided to ignore it for now
yarn.lock
.yarn/*

# We don't do anything with docs right now, specifically we don't want to run over the core package.
/**/documentation
/**/docs
69 changes: 57 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,65 @@
# TSB contracts
<p align="center"><a href="https://sandbox.game"><img width="300" title="TSB" src='brand-assets/tsb_pride.png' /></a></p>

This workspace uses [Nx, a Smart, fast and extensible build system.](https://nx.dev)
<h1 align="center">The Sandbox Smart Contracts</h1>

## Understand this workspace
<a href="https://github.com/thesandboxgame/sandbox-smart-contracts/actions"><img alt="Build Status" src="https://github.com/thesandboxgame/sandbox-smart-contracts/actions/workflows/main.yml/badge.svg"/></a>
![Node Version](https://img.shields.io/badge/node-18.x-green)
[![Discord](https://img.shields.io/discord/497312527093334036.svg?label=Discord&logo=discord)](<https://discord.gg/vAe4zvY>)

[The Sandbox](https://sandbox.game) is a user-generated content (UGC) gaming platform, that will empower creators through digital ownership and monetization of 3D voxel creations made and shared by users around the world.

This mono-repo contains The Sandbox smart contracts, underpinning The Sandbox metaverse. Our key token contracts were conceived inside the core package. You can find out more about some of our early blockchain features in [this article](https://medium.com/sandbox-game/blockchain-features-in-the-sandbox-7db91fcc615c). Since core was created, we have added new contracts and updates via new packages - see the below Architecture Overview for more information.

## Learn more

- [Website](www.sandbox.game)
- [Discord](https://discordapp.com/invite/vAe4zvY)
- [Telegram](https://t.me/sandboxgame)
- [Medium](https://medium.com/sandbox-game)

## Prerequisites

- ⚙️ [NodeJS](https://nodejs.org/)
- 🧰 [Yarn](https://yarnpkg.com/)

## Tech stack and getting started

This workspace uses [Nx: a smart, fast and extensible build system.](https://nx.dev)
Run `nx graph` to see a diagram of the dependencies of the projects.

To add a package simply add it inside the packages directory, optionally every package can implement
the following targets that will be run by the root `package.json` scripts and on the CI:
To add a package simply add it inside the packages directory. Every package can implement the following targets that will be run by the root `package.json` scripts and on the CI:

- `test`: run unit tests inside your new package.
- `coverage`: run coverage. Note: CI expects to have at least 80% coverage.
- `lint`: lint your code.
- `format`: format the code with prettier.

See [`packages/example-hardhat`](./packages/example-hardhat) for an example template package for smart contract development with Hardhat.

Refer to each package's readme for more information about that package. Note that deployment for all new packages is carried out via `packages/deploy`.
Each package should follow the [audit best practices](./audit-best-practices.md) where applicable.

### Developer quickstart

```bash
yarn install
```

## Architecture Overview

- 📦 This mono-repository contains a suite of smart contract packages.
- ⚖️ The mono-repository is released under [MIT license](./LICENSE). Note, that the packages may contain their own licenses.

| Package | Version | License | Description |
|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|------------------------------------------|
| [`@sandbox-smart-contracts/packages/core`](./packages/core) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/core)](https://www.npmjs.com/package/@sandbox-smart-contracts/core) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🗝️ Core smart contracts (pre 2023) |
| [`@sandbox-smart-contracts/packages/deploy`](./packages/deploy) | N/A | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🚀 Deploy all packages (except core) |
| [`@sandbox-smart-contracts/packages/example-hardhat`](./packages/example-hardhat) | N/A | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 👷 Development template using Hardhat |
| [`@sandbox-smart-contracts/packages/giveaway`](./packages/giveaway) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/giveaway)](https://www.npmjs.com/package/@sandbox-smart-contracts/giveaway) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🎁 Instant Giveaway smart contract claims |
| [`@sandbox-smart-contracts/packages/dependency-metatx`](./packages/dependency-metatx) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/dependency-metatx)](https://www.npmjs.com/package/@sandbox-smart-contracts/giveaway) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🌐 Dependency: ERC2771 handler |

- test
- coverage: run coverate, CI expect to have at least 80% coverage on packages.
- lint
- format: format the code with prettier.
- deploy: to test hardhat deployments.
## Contributing

## Further help
### Bug bounties

Visit the [Nx Documentation](https://nx.dev) to learn more.
Submit a bug at [Immunefi](https://immunefi.com/bounty/thesandbox/) to help secure our smart contracts!
63 changes: 63 additions & 0 deletions audit-best-practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Audit best practices

Here a non-exhaustive list of best practices to check before sending a contract to an audit:

## Smart Contracts
- fixed pragma version on all smart contracts
- natspec at least on external functions, public functions, variables, beginning of contract
- linebreaks between code (imports, contract, within functions, etc) to improve readability
- consistent indentation
- contract size under 24kb
- check gas usage and optimise where it is sensible to do so
- generate a gas report
- events on every non view functions
- DRTW: use OZ when possible (Access Control)
- use constants instead of strings or duplicate numbers
- disable initializer in the constructor for upgradeable contracts
- when upgrading a contract, check for storage consistency
- check who's owning the contract, the deployer should not own the contract
- when using ERC2771, only use msgSender()
- avoid loops on arrays that are not limited in size
- check for centralization issues: changing variables, transfering assets from the contract, upgrades, forwarder, centralized metadata, etc
- use recent solidity version but a stable one
- logic issues: go back to the specs and compare
- avoid fake random
- use uint256 over any other uint
- check your inputs (address it no 0, size is correct, limit size of arrays)
- think about how the user/dApp will interact with your contract (am i missing a getter ?)
- think about how to make your contract as generic as possible, that helps us build an open protocol
- when using OZ upgradeable contracts, don't forget to call the init functions
- check if your `supportsInterface` matchs what your contract uses
- check for the usual attacks: reentrancy, front running, etc
- challenge your naming
- only use named imports
- order your code (variables, constructor, public, etc)
- @notice on every external / public function; @dev to help developers understand
- licence on every contract
- @author on every contract
- check for typographical Errors
- unused named variable
- when dealing with ERC20, keep in mind deflationary tokens
- one condition per require for readability
- check for duplicate code
- clean debug / TODO comments
- put constants in upper case
- consider to block renouncing ownership
- consider using immutable on variables

## Unit Tests
- 100% coverage
- fuzzy testing

## Reports
- generate documentation from natspec

## Deployment
- tests deploy the contracts inside the fixture; no deploy scripts in package
- verify your contract to improve trust
- open source your contracts
- integration tests

## Security
- run slither but be selective about the issues
- deploy on a testnet & test manually
Binary file added brand-assets/tsb_3d.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added brand-assets/tsb_main.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added brand-assets/tsb_pride.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"description": "The Sandbox smart contracts",
"scripts": {
"test": "nx run-many --target=test",
"coverage": "nx run-many --target=coverage && istanbul-combine -r lcov -r html packages/*/coverage.json",
"coverage": "nx run-many --target=coverage && istanbul-combine -r lcov -r html 'packages/*/coverage.json'",
"lint": "nx run-many --target=lint",
"format": "nx run-many --target=format",
"deploy": "nx run-many --target=deploy",
"all": "nx run-many --all --parallel --targets=lint,format,test,deploy && nx run-many --all --targets=coverage",
"test:ci": "nx affected --target=test",
"coverage:ci": "nx affected --target=coverage && istanbul-combine -r lcov -r html packages/*/coverage.json",
"test:ci": "nx affected --target=test --parallel=1",
"coverage:ci": "nx affected --target=coverage --parallel=1 && istanbul-combine -r lcov -r html 'packages/*/coverage.json'",
"lint:ci": "nx affected --target=lint",
"format:ci": "nx affected --target=format",
"deploy:ci": "nx affected --target=deploy",
"deploy:ci": "nx affected --target=deploy --parallel=1",
"clean": "rimraf coverage/* && nx run-many --target=clean"
},
"repository": "https://github.com/thesandboxgame/sandbox-smart-contracts",
Expand Down
16 changes: 16 additions & 0 deletions packages/avatar/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# generated docs
generated-markups

# editors
.idea
41 changes: 41 additions & 0 deletions packages/avatar/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const path = require('path');
const tsconfigPath = path.join(__dirname, 'tsconfig.json');
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:mocha/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2020,
},
plugins: ['mocha'],
env: {
commonjs: true,
node: true,
mocha: true,
},
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [tsconfigPath],
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: ['mocha', '@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:mocha/recommended',
'plugin:prettier/recommended',
],
rules: {
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-floating-promises': 'error',
},
},
],
};
16 changes: 16 additions & 0 deletions packages/avatar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# generated docs
generated-markups

# editors
.idea
16 changes: 16 additions & 0 deletions packages/avatar/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# generated docs
generated-markups

# editors
.idea
15 changes: 15 additions & 0 deletions packages/avatar/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
singleQuote: true,
bracketSpacing: false,
plugins: ['prettier-plugin-solidity'],
overrides: [
{
files: '*.sol',
options: {
printWidth: 120,
tabWidth: 4,
singleQuote: false,
},
},
],
};
7 changes: 7 additions & 0 deletions packages/avatar/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
mocha: {
grep: '@skip-on-coverage', // Find everything with this tag
invert: true, // Run the grep's inverse set.
},
skipFiles: ['/contracts/mock'],
};
21 changes: 21 additions & 0 deletions packages/avatar/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"code-complexity": ["error", 7],
"compiler-version": ["error", "^0.8.0"],
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", {"ignoreConstructors": true}],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"reason-string": ["warn", {"maxLength": 64}]
}
}
75 changes: 75 additions & 0 deletions packages/avatar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# <PACKAGE>

*Include a high level description of your package here*

This example project is based on the template generated by hardhat when run in an empty directory.

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a sample test fixture for that contract,
and tests.

## Creating a new package

You can copy-paste this example package: `cp -a packages/example-hardhat packages/<package>`

## Running the project locally

Install dependencies with `yarn`

Testing: Use `yarn test` inside `packages/<package>` to run tests locally inside this package

For testing from root (with workspace feature) use: `yarn workspace @sandbox-smart-contracts/<package> test`

Coverage: Run `yarn coverage`

Formatting: Run `yarn prettier` to check and `yarn prettier:fix` to fix formatting errors

Linting: Run `yarn lint` to check and `yarn lint:fix` to fix static analysis errors

## Package structure and minimum standards

#### A NOTE ON DEPENDENCIES

1. Add whatever dependencies you like inside your package; this template is for hardhat usage. OpenZeppelin contracts
are highly recommended and should be installed as a dev dependency
2. For most Pull Requests there should be minimum changes to `yarn.lock` at root level
3. Changes to root-level dependencies are permissible, however they should not be downgraded
4. Take care to run `yarn` before pushing your changes
5. You shouldn't need to install dotenv since you won't be deploying inside this package (see below)

#### UNIT TESTING

1. Unit tests are to be added in `packages/<package>/test`
2. Coverage must meet minimum requirements for CI to pass
3. `getSigners` return an array of addresses, the first one is the default `deployer` for contracts, under no
circumstances should tests be written as `deployer`
4. It's permissible to create mock contracts at `packages/<package>/contracts/mock` e.g. for third-party contracts
5. Tests must not rely on any deploy scripts from the `deploy` package; your contracts must be deployed inside the test
fixture. See `test/fixtures.ts`

# Deployment

Each package must unit-test the contracts by running everything inside the `hardhat node`. Deployment to "real"
networks, configuration of our environment and integration tests must be done inside the `deploy` package.

The `deploy` package only imports `.sol` files. The idea is to recompile everything inside it and manage the entire
deploy strategy from one place.

1. Your deploy scripts should not be included inside `packages/<package>`: deploy scripts live inside `packages/deploy/`
2. The `deploy` package doesn't use the hardhat config file from the specific package. Instead, it
uses `packages/deploy/hardhat.config.ts`
3. You will need to review `packages/deploy/hardhat.config.ts` and update it as needed for any new namedAccounts you
added to your package
4. When it comes to deploy time, it is preferred to include deploy scripts and end-to-end tests as a separate PR
5. The named accounts inside the `deploy` package must use the "real-life" values
6. Refer to the readme at `packages/deploy` to learn more about importing your package

#### INTEGRATION TESTING

1. End-to-end tests live at `packages/deploy/`
2. You must add end-to-end tests ahead of deploying your package. Importantly, these tests should verify deployment and
initialization configuration

# A NOTE ON MAKING PULL REQUESTS

1. Follow the PR template checklist
2. Your PR will not be approved if the above criteria are not met
Loading
Loading