Skip to content

Commit

Permalink
Merge pull request #951 from thesandboxgame/asset-l2-integration
Browse files Browse the repository at this point in the history
Add Asset package
  • Loading branch information
atkinsonholly authored Oct 4, 2023
2 parents 35036f0 + 48025e0 commit 2df5192
Show file tree
Hide file tree
Showing 216 changed files with 47,171 additions and 522 deletions.
9 changes: 0 additions & 9 deletions .env.example

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:

- name: Running tests
run: yarn test:ci
env:
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}

coverage:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -72,3 +74,4 @@ jobs:
run: yarn deploy:ci
env:
ETH_NODE_URI_GOERLI: ${{ secrets.ETH_NODE_URI_GOERLI }}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ node_modules/

# yarn 3
.yarn/*
!.yarn/cache
.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ yarn install
- 📦 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 |
| 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/dependency-metatx) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🌐 Dependency: ERC2771 handler |
| [`@sandbox-smart-contracts/packages/dependency-royalty-management`](./packages/dependency-royalty-management) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/dependency-royalty-management)](https://www.npmjs.com/package/@sandbox-smart-contracts/royalty-management) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🎨 Dependency: The Sandbox Royalty Implementation in partnership with [Manifold's royalty-registry](https://github.com/manifoldxyz/royalty-registry-solidity/tree/main) |
| [`@sandbox-smart-contracts/packages/dependency-operator-filter`](./packages/dependency-operator-filter) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/dependency-operator-filter)](https://www.npmjs.com/package/@sandbox-smart-contracts/operator-filter) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🤝 Dependency: The Sandbox's implementation for OpenSea's operator filter |
| [`@sandbox-smart-contracts/packages/asset`](./packages/asset) | [![npm](https://img.shields.io/npm/v/@sandbox-smart-contracts/asset)](https://www.npmjs.com/package/@sandbox-smart-contracts/asset) | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | 🚗 Asset contract upgrade for L2 deployment featuring tiers, abilities, operator-filter and creator royalties |

## Contributing

Expand Down
16 changes: 16 additions & 0 deletions packages/asset/.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/asset/.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/asset/.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
./artifacts
./cache
./typechain

deploy
deployments
16 changes: 16 additions & 0 deletions packages/asset/.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/asset/.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/asset/.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: ['/mock'],
};
15 changes: 15 additions & 0 deletions packages/asset/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"compiler-version": ["error", "^0.8.0"],
"custom-errors": "off",
"func-visibility": ["error", {"ignoreConstructors": true}]
}
}
1 change: 1 addition & 0 deletions packages/asset/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/mock
71 changes: 71 additions & 0 deletions packages/asset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# <PACKAGE>

The Sandbox Asset package for deploying on Polygon

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

1 comment on commit 2df5192

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage for this commit

96.15%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/asset/contracts
   Asset.sol94.53%89.58%96.43%98.08%115, 206, 308, 308–309, 75
   AssetCreate.sol94.51%83.33%100%100%138, 140, 173, 293, 72
   AssetReveal.sol94.35%86.21%96.55%98.89%143, 147, 181, 376, 416, 424, 441, 75, 98
   AuthSuperValidator.sol90%83.33%100%88.89%51–52
   Catalyst.sol95%91.94%95.45%98.21%124, 126, 139, 151, 223, 79
packages/asset/contracts/interfaces
   IAsset.sol100%100%100%100%
   IAssetCreate.sol100%100%100%100%
   IAssetReveal.sol100%100%100%100%
   ICatalyst.sol100%100%100%100%
   ITokenUtils.sol100%100%100%100%
packages/asset/contracts/libraries
   TokenIdUtils.sol100%100%100%100%
packages/dependency-metatx/contracts
   ERC2771Handler.sol100%100%100%100%
   ERC2771HandlerAbstract.sol100%100%100%100%
   ERC2771HandlerUpgradeable.sol95.45%83.33%100%100%45
packages/dependency-metatx/contracts/test
   ERC2771HandlerTest.sol100%100%100%100%
   ERC2771HandlerUpgradeableTest.sol100%100%100%100%
   MockTrustedForwarder.sol0%0%0%0%15, 18–19, 19, 19–20
packages/dependency-operator-filter/contracts
   OperatorFiltererUpgradeable.sol82.35%85%71.43%83.33%17, 51–52, 61–62, 71, 87
   OperatorFilterSubscription.sol60%50%100%50%19–20
packages/dependency-operator-filter/contracts/interfaces
   IOperatorFilterRegistry.sol100%100%100%100%
packages/dependency-royalty-management/contracts
   MultiRoyaltyDistributor.sol84.06%65%90%92.31%104, 144, 25, 41, 41, 41, 41, 60–61, 97
   RoyaltyDistributor.sol78.95%50%80%90%20, 50, 56
   RoyaltyManager.sol96.39%87.50%100%100%104, 47, 98
   RoyaltySplitter.sol92.08%75%92.31%97.06%116, 156, 184, 217, 64, 71, 82
packages/dependency-royalty-management/contracts/interfaces
   IERC20Approve.sol100%100%100%100%
   IMultiRoyaltyDistributor.sol100%100%100%100%
   IMultiRoyaltyRecipients.sol100%100%100%100%
   IRoyaltyManager.sol100%100%100%100%
   IRoyaltyUGC.sol100%100%100%100%

Please sign in to comment.