Skip to content

Commit

Permalink
Refactor (DimensionDev#18)
Browse files Browse the repository at this point in the history
* removed safemath, removed unused contracts

* refactoring test

* update dependencies, added missing dependencies

* implemented contract types

* fixed generate-readme

* added prettier settings for .sol, replaced getLogs with event queryFilter, added error messages, removed toString() on type string, removed redundant code

* implemented type checks for addTxParameters()

* optimized code, added error msg

Co-authored-by: Li-Qing Wang <[email protected]>
  • Loading branch information
liqingnz and Li-Qing Wang authored Jun 27, 2022
1 parent 9520efa commit afbc118
Show file tree
Hide file tree
Showing 55 changed files with 45,477 additions and 10,438 deletions.
12 changes: 7 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
root = true

[*]
indent_size = 2
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*]
tab_width = 4
insert_final_newline = true
indent_style = space

[*.md]
tab_width = 2

[*.sol]
indent_size = 4
89 changes: 89 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"$schema": "https://dimensiondev.github.io/eslint-plugin/src/schema.json",
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@dimensiondev", "@typescript-eslint"],
"rules": {
"eqeqeq": ["error", "smart"],
"no-unsafe-negation": "error",
"no-unsafe-optional-chaining": "error",
"no-irregular-whitespace": [
"warn",
{
"skipComments": true,
"skipRegExps": true
}
],
"@dimensiondev/array/no-implicit-sort": "error",
"@dimensiondev/array/no-unneeded-flat-map": "error",
"@dimensiondev/array/prefer-from": "error",
"@dimensiondev/string/no-interpolation": "error",
"@dimensiondev/string/no-locale-case": "error",
"@dimensiondev/string/no-simple-template-literal": "error",
"@dimensiondev/string/no-unneeded-to-string": "error",
"@dimensiondev/type/no-bigint": "off",
"@dimensiondev/type/no-const-enum": "off",
"@dimensiondev/type/no-force-cast-via-top-type": "error",
"unicorn/no-instanceof-array": "off",
"@dimensiondev/type/no-instanceof-wrapper": "error",
"@dimensiondev/type/no-number-constructor": "error",
"@dimensiondev/type/no-wrapper-type-reference": "error",
"@dimensiondev/type/prefer-return-type-annotation": "error",
"@dimensiondev/unicode/no-bidi": "off",
"@dimensiondev/unicode/no-invisible": "error",
"@dimensiondev/unicode/specific-set": "off",
"@dimensiondev/ban-eslint-disable": "error",
"@dimensiondev/no-builtin-base64": "error",
"@dimensiondev/no-default-error": "error",
"@dimensiondev/no-redundant-variable": "error",
"@dimensiondev/no-single-return": "error",
"@dimensiondev/no-then": "error",
"@dimensiondev/no-timer": "off",
"@dimensiondev/no-top-level": "off",
"@dimensiondev/no-unsafe-date": "error",
"@dimensiondev/prefer-default-export": "off",
"@dimensiondev/prefer-early-return": "error",
"@dimensiondev/prefer-fetch": "error",
"@dimensiondev/prefer-timer-id": "error",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"warn",
{
"default": "array",
"readonly": "array"
}
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksConditionals": true,
"checksVoidReturn": true
}
],
"@typescript-eslint/no-inferrable-types": [
"error",
{
"ignoreParameters": false,
"ignoreProperties": false
}
],
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": [
"warn",
{
"allowComparingNullableBooleansToTrue": true
}
],
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/restrict-plus-operands": "error"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ coverage.json
.coverage_artifacts
.coverage_contracts
.env
project.secret.js
project.secret*
#Hardhat files
cache
artifacts
deployments
.openzeppelin
.vscode
types/
29 changes: 24 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
.github/
package.json
package-lock.json
truffle-config.js
tsconfig.json
README.md
contracts/**
migrations/**

# VSCode personal settings
.vscode/launch.json
.vscode/tasks.json

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# dotenv environment variables file
.env
.env.test

# Generated files
artifacts/
cache/
SmartContractProjectConfig/
types/
.openzeppelin
39 changes: 25 additions & 14 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
{
"trailingComma": "all",
"printWidth": 120,
"semi": true,
"singleQuote": true,
"jsxBracketSameLine": true,
"tabWidth": 4,
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 2
}
}
]
"trailingComma": "all",
"printWidth": 120,
"semi": true,
"singleQuote": false,
"jsxBracketSameLine": true,
"tabWidth": 2,
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 2
}
},
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
}
]
}
2 changes: 1 addition & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
configureYulOptimizer: true,
configureYulOptimizer: true,
};
9 changes: 2 additions & 7 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
"excludedFiles": "ERC721A.sol",
"rules": {
"avoid-throw": false,
"compiler-version": [
"error",
"^0.8.0"
],
"compiler-version": ["error", "^0.8.0"],
"avoid-suicide": "error",
"avoid-sha3": "warn"
},
"plugins": [
"prettier"
]
"plugins": ["prettier"]
}
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To deploy the smart contract on Ethereum `rinkeby` testnet:
npm run deploy rinkeby
```

Using the [`helper.js`](helper.js) script to set up the deployed smart contracts.
Using the [`helper.ts`](helper.ts) script to set up the deployed smart contracts.

### Troubleshoot & Tips

Expand All @@ -56,29 +56,29 @@ Using the [`helper.js`](helper.js) script to set up the deployed smart contracts

| Chain | MysteryBox | MaskTestNFT |
| ------------------- | -------------------------------------- | --------------------------------------- |
| Mainnet | [`0x294428f0`][mb-mainnet] | [`0x56136E69`][nft-mainnet] |
| Ropsten | [`0xc7387b6A`][mb-ropsten] | [`0x4c73F4DC`][nft-ropsten] |
| Rinkeby | [`0xF8ED169B`][mb-rinkeby] | [`0x0c8FB5C9`][nft-rinkeby] |
| BSC | | [`0xa8518287`][nft-bsc] |
| Matic | [`0x02F98667`][mb-matic] | [`0x49C2a3D9`][nft-matic] |
| Goerli | [`0xd4ABB07c`][mb-goerli] | [`0xcdE281B3`][nft-goerli] |
| Fantom | [`0x19f179D7`][mb-fantom] | [`0x05ee315E`][nft-fantom] |
| Celo | [`0x578a7Fee`][mb-celo] | [`0x066804d9`][nft-celo] |
| Avalanche | [`0x05ee315E`][mb-avalanche] | [`0x81246335`][nft-avalanche] |
| Optimism_kovan | [`0x3eadcFB5`][mb-optimism_kovan] | [`0x7DBA5446`][nft-optimism_kovan] |
| Optimism | [`0xF9F7C149`][mb-optimism] | [`0x578a7Fee`][nft-optimism] |
| Aurora | [`0x5B966f3a`][mb-aurora] | [`0x54a0A221`][nft-aurora] |
| Fuse | [`0x5B966f3a`][mb-fuse] | [`0x54a0A221`][nft-fuse] |
| Boba | [`0x5B966f3a`][mb-boba] | |
| Moonriver | [`0x6cc1b105`][mb-moonriver] | |
| Conflux_espace_test | [`0x4c64b524`][mb-conflux_espace_test] | [`0xc29afd93`][nft-conflux_espace_test] |
| Conflux_espace | [`0x4c64b524`][mb-conflux_espace] | [`0xc29afd93`][nft-conflux_espace] |
| Harmony_test | [`0x4fda6d9b`][mb-harmony_test] | [`0xd48bc506`][nft-harmony_test] |
| Harmony | [`0xDc0905F2`][mb-harmony] | [`0x677f7bba`][nft-harmony] |
| Metis_test | [`0x5B966f3a`][mb-metis_test] | [`0x981be454`][nft-metis_test] |
| Metis | [`0x981be454`][mb-metis] | [`0x96c7D011`][nft-metis] |
| Kardia | [`0xbC7d9898`][mb-kardia] | [`0x8D03d9b4`][nft-kardia] |
| Astar | [`0x041Bdc5b`][mb-astar] | [`0x7E0aa694`][nft-astar] |
| mainnet | [`0x294428f0`][mb-mainnet] | [`0x56136E69`][nft-mainnet] |
| ropsten | [`0xc7387b6A`][mb-ropsten] | [`0x4c73F4DC`][nft-ropsten] |
| rinkeby | [`0xF8ED169B`][mb-rinkeby] | [`0x0c8FB5C9`][nft-rinkeby] |
| bsc | | [`0xa8518287`][nft-bsc] |
| matic | [`0x02F98667`][mb-matic] | [`0x49C2a3D9`][nft-matic] |
| goerli | [`0xd4ABB07c`][mb-goerli] | [`0xcdE281B3`][nft-goerli] |
| fantom | [`0x19f179D7`][mb-fantom] | [`0x05ee315E`][nft-fantom] |
| celo | [`0x578a7Fee`][mb-celo] | [`0x066804d9`][nft-celo] |
| avalanche | [`0x05ee315E`][mb-avalanche] | [`0x81246335`][nft-avalanche] |
| optimism_kovan | [`0x3eadcFB5`][mb-optimism_kovan] | [`0x7DBA5446`][nft-optimism_kovan] |
| optimism | [`0xF9F7C149`][mb-optimism] | [`0x578a7Fee`][nft-optimism] |
| aurora | [`0x5B966f3a`][mb-aurora] | [`0x54a0A221`][nft-aurora] |
| fuse | [`0x5B966f3a`][mb-fuse] | [`0x54a0A221`][nft-fuse] |
| boba | [`0x5B966f3a`][mb-boba] | |
| moonriver | [`0x6cc1b105`][mb-moonriver] | |
| conflux_espace_test | [`0x4c64b524`][mb-conflux_espace_test] | [`0xc29afd93`][nft-conflux_espace_test] |
| conflux_espace | [`0x4c64b524`][mb-conflux_espace] | [`0xc29afd93`][nft-conflux_espace] |
| harmony_test | [`0x4fda6d9b`][mb-harmony_test] | [`0xd48bc506`][nft-harmony_test] |
| harmony | [`0xDc0905F2`][mb-harmony] | [`0x677f7bba`][nft-harmony] |
| metis_test | [`0x5B966f3a`][mb-metis_test] | [`0x981be454`][nft-metis_test] |
| metis | [`0x981be454`][mb-metis] | [`0x96c7D011`][nft-metis] |
| kardia | [`0xbC7d9898`][mb-kardia] | [`0x8D03d9b4`][nft-kardia] |
| astar | [`0x041Bdc5b`][mb-astar] | [`0x7E0aa694`][nft-astar] |

[mb-mainnet]: https://etherscan.io/address/0x294428f04b0F9EbC49B7Ad61E2736ebD6808c145
[mb-ropsten]: https://ropsten.etherscan.io/address/0xc7387b6Ac310ae15576451d2d37058711331105c
Expand Down Expand Up @@ -130,13 +130,13 @@ Using the [`helper.js`](helper.js) script to set up the deployed smart contracts

<!-- begin Qualification -->

| Chain | WhitelistQlf | SigVerifyQlf | MaskHolderQlf | MerkleProofQlf |
| ------------------- | -------------------------- | -------------------------- | -------------------------- | -------------------------- |
| Ropsten | [`0x3011dF5b`][wl-ropsten] | | | |
| Rinkeby | [`0x50eCEebb`][wl-rinkeby] | [`0x9a656528`][sv-rinkeby] | [`0x26c3DE14`][mh-rinkeby] | [`0x450A1185`][mp-rinkeby] |
| Goerli | [`0xfE14631D`][wl-goerli] | | | |
| Aurora | [`0x83D6b366`][wl-aurora] | | | |
| Fuse | [`0x83D6b366`][wl-fuse] | | | |
| Chain | WhitelistQlf | SigVerifyQlf | MaskHolderQlf | MerkleProofQlf |
| ------- | -------------------------- | -------------------------- | -------------------------- | -------------------------- |
| ropsten | [`0x3011dF5b`][wl-ropsten] | | | |
| rinkeby | [`0x50eCEebb`][wl-rinkeby] | [`0x9a656528`][sv-rinkeby] | [`0x26c3DE14`][mh-rinkeby] | [`0x450A1185`][mp-rinkeby] |
| goerli | [`0xfE14631D`][wl-goerli] | | | |
| aurora | [`0x83D6b366`][wl-aurora] | | | |
| fuse | [`0x83D6b366`][wl-fuse] | | | |

[wl-ropsten]: https://ropsten.etherscan.io/address/0x3011dF5b0Be18A56693cC062Cb61a160dca571C3
[wl-rinkeby]: https://rinkeby.etherscan.io/address/0x50eCEebb7360Efb93094dDEA692e04274E548b1d
Expand Down
13 changes: 13 additions & 0 deletions abi/MaskEnumerableNFT.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
13 changes: 13 additions & 0 deletions abi/MaskHolderQlf.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
13 changes: 13 additions & 0 deletions abi/MaskNonEnumerableNFT.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
13 changes: 13 additions & 0 deletions abi/MysteryBox.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
"name": "CreationSuccess",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint8",
"name": "version",
"type": "uint8"
}
],
"name": "Initialized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
Loading

0 comments on commit afbc118

Please sign in to comment.