mirror of
https://github.com/FlipsideCrypto/badger.git
synced 2026-02-06 02:47:06 +00:00
fix: dockerize
This commit is contained in:
parent
d29d40a64a
commit
9c5860370e
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
214
README.md
214
README.md
@ -6,11 +6,213 @@
|
||||
- Should use Docker for database
|
||||
- Have to have pinata
|
||||
|
||||
## [[[Contracts]]](contracts/README.md)
|
||||
- run the local hardhat node
|
||||
- make sure that a local hardhat node is NOT running when you try and run the coverage tests otherwise ganache will not be able to spin up it's node
|
||||
- when running deploy script the deployed addresses should be added to the config file
|
||||
|
||||
## [[[Frontend]]](frontend/README.md)
|
||||
# [[[Frontend]]](frontend/README.md)
|
||||
- needs deployments
|
||||
- needs alchemy
|
||||
|
||||
# Badger Primitive & Protocol
|
||||
|
||||
In this repository is contained the base primitive of Badger (`BadgerOrganization.sol`) as well as the Badger protocol (`Badger.sol`) on top of it.
|
||||
|
||||
## Badger Primitive
|
||||
|
||||
The Badger primitive is a simple contract that allows for the creation of a collection of NFTs that are all owned by the same address. This is useful for organizations that want to issue NFTs to their members, but don't want to have to manage a collection of NFTs for each member.
|
||||
|
||||
With the unique model in place an on-chain Organization can generate the keys needed to access all of the existing Web3 gates and locks.
|
||||
|
||||
Built on the standard ERC-1155, Badges allow for top-down management of any on-chain organization.
|
||||
|
||||
* The tokens can be account bound, but they don't have to be.
|
||||
* There can be custom signers.
|
||||
* This unlocks first-party claim gates and external development under the control of the Organization owner.
|
||||
* The tokens can be minted and burned.
|
||||
* The tokens can operate with trie-like permissions.
|
||||
* Achieved without breaking the composability of any standard or any of the existing locks in the market. Anyone that conforms to already released standards will be able to use Badger as keys.
|
||||
* The tokens can be used as a way to bootstrap on-chain roles and token-gated areas for their members.
|
||||
|
||||
## Tests
|
||||
|
||||
```
|
||||
Version
|
||||
=======
|
||||
> solidity-coverage: v0.8.2
|
||||
|
||||
Instrumenting for coverage...
|
||||
=============================
|
||||
|
||||
> Badger\Badger.sol
|
||||
> Badger\BadgerVersions.sol
|
||||
> Badger\interfaces\BadgerInterface.sol
|
||||
> Badger\interfaces\BadgerVersionsInterface.sol
|
||||
> BadgerOrganization\BadgerOrganization.sol
|
||||
> BadgerOrganization\BadgerScout.sol
|
||||
> BadgerOrganization\interfaces\BadgerOrganizationInterface.sol
|
||||
> BadgerOrganization\interfaces\BadgerScoutInterface.sol
|
||||
> Mocks\MockERC1155.sol
|
||||
> Mocks\MockERC20.sol
|
||||
> Mocks\MockERC721.sol
|
||||
|
||||
Compilation:
|
||||
============
|
||||
|
||||
Compiled 50 Solidity files successfully
|
||||
> server: http://127.0.0.1:8545
|
||||
|
||||
Network Info
|
||||
============
|
||||
> port: localhost
|
||||
> network: v2.13.2
|
||||
|
||||
Compiled 50 Solidity files successfully
|
||||
|
||||
|
||||
Badger
|
||||
Badger: Badger.sol
|
||||
✔ Should deploy the Badger contract (136ms)
|
||||
✔ createOrganization() success (732ms)
|
||||
✔ createOrganization() success: payable (1653ms)
|
||||
✔ createOrganization() fail: insufficient funding (166ms)
|
||||
✔ onERC1155Received() fail: invalid payment token (993ms)
|
||||
Badger: BadgerVersions.sol
|
||||
✔ setVersion() success (353ms)
|
||||
✔ setVersion() success: exogenous (422ms)
|
||||
✔ setVersion() fail: not owner (222ms)
|
||||
✔ setVersion() fail: locked (557ms)
|
||||
✔ setVersion() fail: not allowed to set payment token (462ms)
|
||||
✔ getVersionKey() success (76ms)
|
||||
✔ getLicenseKey() success (130ms)
|
||||
✔ execTransaction() success (488ms)
|
||||
✔ execTransaction() fail: is not built (177ms)
|
||||
✔ execTranscation() fail: is not owner (171ms)
|
||||
✔ supportsInterface() success (349ms)
|
||||
Badger: BadgerScout.sol
|
||||
✔ initialize() fail: cannot call twice (132ms)
|
||||
✔ setOrganizationURI() success (265ms)
|
||||
✔ setOrganizationURI() fail: not owner (117ms)
|
||||
✔ setBadge() success (489ms)
|
||||
✔ setBadge() fail: not leader (130ms)
|
||||
✔ setBadge() fail: uri cannot be empty (123ms)
|
||||
✔ setBadge() success (496ms)
|
||||
✔ setClaimable() success (367ms)
|
||||
✔ setClaimable() fail: not real badge (133ms)
|
||||
✔ setClaimable() fail: not leader (93ms)
|
||||
✔ setAccountBound() success (803ms)
|
||||
✔ setAccountBound() fail: not real badge (129ms)
|
||||
✔ setAccountBound() fail: not leader (109ms)
|
||||
✔ setSigner() success (789ms)
|
||||
✔ setSigner() fail: not real badge (98ms)
|
||||
✔ setSigner() fail: not leader (142ms)
|
||||
✔ setBadgeURI() success (165ms)
|
||||
✔ setBadgeURI() fail: not real badge (129ms)
|
||||
✔ setBadgeURI() fail: not leader (139ms)
|
||||
✔ setBadgeURI() fail: uri cannot be empty (92ms)
|
||||
✔ setPaymentToken() success (231ms)
|
||||
✔ setPaymentToken() fail: not real badge (56ms)
|
||||
✔ setPaymentToken() fail: not leader (131ms)
|
||||
✔ setDelegates() success (806ms)
|
||||
✔ setDelegates() fail: not real badge (114ms)
|
||||
✔ setDelegates() fail: not leader (124ms)
|
||||
✔ setDelegates() fail: arrays not equal length (111ms)
|
||||
✔ setDelegatesBatch() success (334ms)
|
||||
✔ setDelegatesBatch() fail: not real badge (115ms)
|
||||
✔ setDelegatesBatch() fail: not leader (138ms)
|
||||
✔ setDelegatesBatch() fail: arrays not equal length (137ms)
|
||||
✔ execTransaction() success (497ms)
|
||||
✔ execTransaction() fail: is not built (141ms)
|
||||
✔ execTranscation() fail: is not owner (128ms)
|
||||
Badger: BadgerOrganization.sol
|
||||
✔ leaderMint() success (198ms)
|
||||
✔ leaderMint() fail: not real badge (113ms)
|
||||
✔ leaderMint() fail: not leader (93ms)
|
||||
✔ leaderMintBatch() success (246ms)
|
||||
✔ leaderMintBatch() fail: not real badge (146ms)
|
||||
✔ leaderMintBatch() fail: not leader (153ms)
|
||||
✔ leaderMintBatch() fail: arrays not equal length (173ms)
|
||||
✔ leaderMintFullBatch() success (210ms)
|
||||
✔ leaderMintFullBatch() success: delegate (409ms)
|
||||
✔ leaderMintFullBatch() fail: not real badge (127ms)
|
||||
✔ leaderMintFullBatch() fail: not leader (106ms)
|
||||
✔ leaderMintFullBatch() fail: arrays not equal length (123ms)
|
||||
✔ revoke() success (184ms)
|
||||
✔ revoke() fail: insufficient balance (113ms)
|
||||
✔ revoke() fail: not leader (123ms)
|
||||
✔ revokeBatch() (471ms)
|
||||
✔ revokeBatch() fail: not leader (123ms)
|
||||
✔ revokeBatch() fail: arrays not equal length (107ms)
|
||||
✔ revokeFullBatch() success (216ms)
|
||||
✔ revokeFullBatch() success: delegate (500ms)
|
||||
✔ revokeFullBatch() fail: insufficient balance (110ms)
|
||||
✔ revokeFullBatch() fail: not leader (108ms)
|
||||
✔ revokeFullBatch() fail: arrays not equal length (109ms)
|
||||
✔ forfeit() success (202ms)
|
||||
✔ forfeit() fail: insufficient balance (124ms)
|
||||
✔ safeTransferFrom() success (667ms)
|
||||
✔ safeTransferFrom() success: leader can transfer account bound (782ms)
|
||||
✔ safeTransferFrom() success: delegate can transfer account bound (1165ms)
|
||||
✔ safeTransferFrom() success: can transfer to contract (434ms)
|
||||
✔ safeTransferFrom() fail: transferring out of contract as user (114ms)
|
||||
✔ safeTransferFrom() fail: account bound (529ms)
|
||||
✔ safeBatchTransferFrom() success (748ms)
|
||||
✔ safeBatchTransferFrom() success: leader can transfer account bound (952ms)
|
||||
✔ safeBatchTransferFrom() success: delegate can transfer account bound (1106ms)
|
||||
✔ safeBatchTransferFrom() success: can transfer to contract (431ms)
|
||||
✔ safeBatchTransferFrom() fail: transferring out of contract as user (115ms)
|
||||
✔ safeBatchTransferFrom() fail: account bound (542ms)
|
||||
✔ depositETH() success (667ms)
|
||||
✔ depositETH() fail: not real badge (158ms)
|
||||
✔ depositETH() fail: not claimable (533ms)
|
||||
✔ depositETH() fail: invalid payment token (650ms)
|
||||
✔ depositERC20() success (1397ms)
|
||||
✔ depositERC20() fail: not real badge (128ms)
|
||||
✔ depositERC20() fail: not claimable (455ms)
|
||||
✔ depositERC20() fail: invalid payment token (571ms)
|
||||
✔ depositERC20() fail: not enough allowance (1067ms)
|
||||
✔ onERC1155Received() success (1135ms)
|
||||
✔ onERC1155Received() success: normal transfer (520ms)
|
||||
✔ onERC1155Received() fail: not real badge (200ms)
|
||||
✔ onERC1155Received() fail: not claimable (368ms)
|
||||
✔ onERC1155Received() fail: invalid payment token (673ms)
|
||||
✔ onERC1155Received() fail: not enough balance (668ms)
|
||||
✔ onERC721Received() success (3615ms)
|
||||
✔ onERC721Received() success: normal transfer (355ms)
|
||||
✔ onERC721Received() fail: not real badge (254ms)
|
||||
✔ onERC721Received() fail: not claimable (1001ms)
|
||||
✔ onERC721Received() fail: invalid payment token (768ms)
|
||||
✔ claimMint() success: signature (1817ms)
|
||||
✔ claimMint() success: claimable (1773ms)
|
||||
✔ claimMint() fail: invalid signature (1404ms)
|
||||
✔ claimMint() fail: not real badge (833ms)
|
||||
✔ claimMint() fail: not claimable (372ms)
|
||||
✔ claimMint() fail: amount is zero (108ms)
|
||||
✔ claimMint() fail: has not funded (391ms)
|
||||
✔ uri() success: has badge uri (86ms)
|
||||
✔ uri() success: no badge uri (138ms)
|
||||
✔ contractURI() success (155ms)
|
||||
✔ supportsInterface() success (654ms)
|
||||
|
||||
|
||||
118 passing (54s)
|
||||
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
BadgerOrganization\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganization.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerScout.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganization\interfaces\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganizationInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerScoutInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
Badger\ | 100 | 100 | 100 | 100 | |
|
||||
Badger.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerVersions.sol | 100 | 100 | 100 | 100 | |
|
||||
Badger\interfaces\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerVersionsInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
Mocks\ | 100 | 100 | 100 | 100 | |
|
||||
MockERC1155.sol | 100 | 100 | 100 | 100 | |
|
||||
MockERC20.sol | 100 | 100 | 100 | 100 | |
|
||||
MockERC721.sol | 100 | 100 | 100 | 100 | |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
All files | 100 | 100 | 100 | 100 | |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
```
|
||||
|
||||
10
api/.dockerignore
Normal file
10
api/.dockerignore
Normal file
@ -0,0 +1,10 @@
|
||||
# Ignore the following in Docker context transfer
|
||||
+**/.git
|
||||
+**/.gitignore
|
||||
+**/.gitmodules
|
||||
+**/.dockerignore
|
||||
+**/Dockerfile
|
||||
+**/README.md
|
||||
+**/LICENSE
|
||||
|
||||
***/database/
|
||||
@ -1,23 +0,0 @@
|
||||
## Badger API
|
||||
|
||||
The API serves and stores related ownership of Orgs and Badgers to users, as well as any custom tags applied to a user by the Owner of an Org.
|
||||
|
||||
Authentication is gated to a wallet address with the use of Sign In With Ethereum. In order for any access to data related to a User's Organizations or Badges, the front end client must have used SIWE to prove their ownership of that address. If ownership of an address is not confirmed, that client will have no access to any data stored in the database.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- fork the repo
|
||||
- terminal: `cd api`
|
||||
- install Docker
|
||||
|
||||
- terminaL `npm i`
|
||||
- setup your `.env` (in `~root/contracts/`) to reflect `example.env`
|
||||
|
||||
**Important:** If you do not set Pinata keys in your `.env`, you will not be able to upload images to IPFS which will currently cause the API to halt and fail.
|
||||
|
||||
#### Running the API
|
||||
|
||||
The development environment for the API is built using Docker to minimize the amount of pain experienced when getting things running. Docker is super confusing so if you know how to do this better, please submit a PR <3.
|
||||
|
||||
- `docker compose run web python manage.py migrate`
|
||||
- `docker compose up --build`
|
||||
@ -10,9 +10,9 @@ load_dotenv()
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
DEBUG = os.getenv('DEBUG', False)
|
||||
DEBUG = os.getenv('API_DEBUG', False)
|
||||
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "secret")
|
||||
SECRET_KEY = os.getenv("API_SECRET_KEY", "secret")
|
||||
|
||||
# Application definition
|
||||
INSTALLED_APPS = [
|
||||
@ -129,7 +129,7 @@ REST_FRAMEWORK = {
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
|
||||
# Web3 settings
|
||||
ALCHEMY_API_KEY = os.getenv("ALCHEMY_API_KEY")
|
||||
ALCHEMY_API_KEY = os.getenv("API_ALCHEMY_API_KEY")
|
||||
AUTHENTICATION_BACKENDS = ["siwe_auth.backend.SiweBackend"]
|
||||
|
||||
CREATE_GROUPS_ON_AUTHN = False
|
||||
@ -141,5 +141,5 @@ CUSTOM_GROUPS = [
|
||||
PROVIDER = os.getenv("PROVIDER", f"https://eth-mainnet.g.alchemy.com/v2/{ALCHEMY_API_KEY}")
|
||||
|
||||
# IPFS settings
|
||||
PINATA_API_KEY = os.getenv("PINATA_API_KEY")
|
||||
PINATA_API_SECRET_KEY = os.getenv("PINATA_API_SECRET_KEY")
|
||||
PINATA_API_KEY = os.getenv("API_PINATA_API_KEY")
|
||||
PINATA_API_SECRET_KEY = os.getenv("API_PINATA_API_SECRET_KEY")
|
||||
@ -1,3 +0,0 @@
|
||||
ALCHEMY_API_KEY=""
|
||||
PINATA_API_KEY=""
|
||||
PINATA_API_SECRET_KEY=""
|
||||
16
contracts/.dockerignore
Normal file
16
contracts/.dockerignore
Normal file
@ -0,0 +1,16 @@
|
||||
# Ignore the following in Docker context transfer
|
||||
+**/.git
|
||||
+**/.gitignore
|
||||
+**/.gitmodules
|
||||
+**/.dockerignore
|
||||
+**/Dockerfile
|
||||
+**/README.md
|
||||
+**/LICENSE
|
||||
|
||||
***/artifacts/
|
||||
***/cache/
|
||||
***/coverage/
|
||||
***/node_modules/
|
||||
|
||||
coverage.json
|
||||
|
||||
12
contracts/Dockerfile.dev.deploy
Normal file
12
contracts/Dockerfile.dev.deploy
Normal file
@ -0,0 +1,12 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
COPY package.json /code/package.json
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . /code/
|
||||
|
||||
# Deploy the contracts
|
||||
CMD ["npx", "hardhat", "deploy"]
|
||||
13
contracts/Dockerfile.dev.node
Normal file
13
contracts/Dockerfile.dev.node
Normal file
@ -0,0 +1,13 @@
|
||||
FROM node
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
COPY package.json /code/package.json
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . /code/
|
||||
|
||||
# Run the local node
|
||||
CMD ["npx", "hardhat", "node"]
|
||||
|
||||
@ -1,231 +0,0 @@
|
||||
# Badger Primitive & Protocol
|
||||
|
||||
In this repository is contained the base primitive of Badger (`BadgerOrganization.sol`) as well as the Badger protocol (`Badger.sol`) on top of it.
|
||||
|
||||
## Badger Primitive
|
||||
|
||||
The Badger primitive is a simple contract that allows for the creation of a collection of NFTs that are all owned by the same address. This is useful for organizations that want to issue NFTs to their members, but don't want to have to manage a collection of NFTs for each member.
|
||||
|
||||
With the unique model in place an on-chain Organization can generate the keys needed to access all of the existing Web3 gates and locks.
|
||||
|
||||
Built on the standard ERC-1155, Badges allow for top-down management of any on-chain organization.
|
||||
|
||||
* The tokens can be account bound, but they don't have to be.
|
||||
* There can be custom signers.
|
||||
* This unlocks first-party claim gates and external development under the control of the Organization owner.
|
||||
* The tokens can be minted and burned.
|
||||
* The tokens can operate with trie-like permissions.
|
||||
* Achieved without breaking the composability of any standard or any of the existing locks in the market. Anyone that conforms to already released standards will be able to use Badger as keys.
|
||||
* The tokens can be used as a way to bootstrap on-chain roles and token-gated areas for their members.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- fork the repo
|
||||
- terminal: `cd contracts`
|
||||
- terminaL `npm i`
|
||||
- setup your `.env` (in `~root/contracts/`) to reflect `example.env`
|
||||
|
||||
## Running The Tests
|
||||
|
||||
- terminal: `npx hardhat coverage --network localhost`
|
||||
|
||||
## Running Local Hardhat Node
|
||||
|
||||
Once your repository has been setup and you have run the tests you are now ready to use the pieces of the Badger Primitive.
|
||||
|
||||
- terminal: `npx hardhat node`
|
||||
|
||||
## Deploying To Local Hardhat Node
|
||||
|
||||
Now that we finally have everything running, you are almost done. The last step is to deploy the contracts to the local hardhat node so that the front-end can use them.
|
||||
|
||||
- terminal: `npx hardhat run scripts/deploy/deploy.js --network localhost`
|
||||
|
||||
**Important:** Please, make sure that you type in `localhost` here. Hardhat has a default network called `hardhat` that is used for testing. If you use that network you will not be able to use the front-end.
|
||||
|
||||
## Tests
|
||||
|
||||
```
|
||||
Version
|
||||
=======
|
||||
> solidity-coverage: v0.8.2
|
||||
|
||||
Instrumenting for coverage...
|
||||
=============================
|
||||
|
||||
> Badger\Badger.sol
|
||||
> Badger\BadgerVersions.sol
|
||||
> Badger\interfaces\BadgerInterface.sol
|
||||
> Badger\interfaces\BadgerVersionsInterface.sol
|
||||
> BadgerOrganization\BadgerOrganization.sol
|
||||
> BadgerOrganization\BadgerScout.sol
|
||||
> BadgerOrganization\interfaces\BadgerOrganizationInterface.sol
|
||||
> BadgerOrganization\interfaces\BadgerScoutInterface.sol
|
||||
> Mocks\MockERC1155.sol
|
||||
> Mocks\MockERC20.sol
|
||||
> Mocks\MockERC721.sol
|
||||
|
||||
Compilation:
|
||||
============
|
||||
|
||||
Compiled 50 Solidity files successfully
|
||||
> server: http://127.0.0.1:8545
|
||||
|
||||
Network Info
|
||||
============
|
||||
> port: localhost
|
||||
> network: v2.13.2
|
||||
|
||||
Compiled 50 Solidity files successfully
|
||||
|
||||
|
||||
Badger
|
||||
Badger: Badger.sol
|
||||
✔ Should deploy the Badger contract (136ms)
|
||||
✔ createOrganization() success (732ms)
|
||||
✔ createOrganization() success: payable (1653ms)
|
||||
✔ createOrganization() fail: insufficient funding (166ms)
|
||||
✔ onERC1155Received() fail: invalid payment token (993ms)
|
||||
Badger: BadgerVersions.sol
|
||||
✔ setVersion() success (353ms)
|
||||
✔ setVersion() success: exogenous (422ms)
|
||||
✔ setVersion() fail: not owner (222ms)
|
||||
✔ setVersion() fail: locked (557ms)
|
||||
✔ setVersion() fail: not allowed to set payment token (462ms)
|
||||
✔ getVersionKey() success (76ms)
|
||||
✔ getLicenseKey() success (130ms)
|
||||
✔ execTransaction() success (488ms)
|
||||
✔ execTransaction() fail: is not built (177ms)
|
||||
✔ execTranscation() fail: is not owner (171ms)
|
||||
✔ supportsInterface() success (349ms)
|
||||
Badger: BadgerScout.sol
|
||||
✔ initialize() fail: cannot call twice (132ms)
|
||||
✔ setOrganizationURI() success (265ms)
|
||||
✔ setOrganizationURI() fail: not owner (117ms)
|
||||
✔ setBadge() success (489ms)
|
||||
✔ setBadge() fail: not leader (130ms)
|
||||
✔ setBadge() fail: uri cannot be empty (123ms)
|
||||
✔ setBadge() success (496ms)
|
||||
✔ setClaimable() success (367ms)
|
||||
✔ setClaimable() fail: not real badge (133ms)
|
||||
✔ setClaimable() fail: not leader (93ms)
|
||||
✔ setAccountBound() success (803ms)
|
||||
✔ setAccountBound() fail: not real badge (129ms)
|
||||
✔ setAccountBound() fail: not leader (109ms)
|
||||
✔ setSigner() success (789ms)
|
||||
✔ setSigner() fail: not real badge (98ms)
|
||||
✔ setSigner() fail: not leader (142ms)
|
||||
✔ setBadgeURI() success (165ms)
|
||||
✔ setBadgeURI() fail: not real badge (129ms)
|
||||
✔ setBadgeURI() fail: not leader (139ms)
|
||||
✔ setBadgeURI() fail: uri cannot be empty (92ms)
|
||||
✔ setPaymentToken() success (231ms)
|
||||
✔ setPaymentToken() fail: not real badge (56ms)
|
||||
✔ setPaymentToken() fail: not leader (131ms)
|
||||
✔ setDelegates() success (806ms)
|
||||
✔ setDelegates() fail: not real badge (114ms)
|
||||
✔ setDelegates() fail: not leader (124ms)
|
||||
✔ setDelegates() fail: arrays not equal length (111ms)
|
||||
✔ setDelegatesBatch() success (334ms)
|
||||
✔ setDelegatesBatch() fail: not real badge (115ms)
|
||||
✔ setDelegatesBatch() fail: not leader (138ms)
|
||||
✔ setDelegatesBatch() fail: arrays not equal length (137ms)
|
||||
✔ execTransaction() success (497ms)
|
||||
✔ execTransaction() fail: is not built (141ms)
|
||||
✔ execTranscation() fail: is not owner (128ms)
|
||||
Badger: BadgerOrganization.sol
|
||||
✔ leaderMint() success (198ms)
|
||||
✔ leaderMint() fail: not real badge (113ms)
|
||||
✔ leaderMint() fail: not leader (93ms)
|
||||
✔ leaderMintBatch() success (246ms)
|
||||
✔ leaderMintBatch() fail: not real badge (146ms)
|
||||
✔ leaderMintBatch() fail: not leader (153ms)
|
||||
✔ leaderMintBatch() fail: arrays not equal length (173ms)
|
||||
✔ leaderMintFullBatch() success (210ms)
|
||||
✔ leaderMintFullBatch() success: delegate (409ms)
|
||||
✔ leaderMintFullBatch() fail: not real badge (127ms)
|
||||
✔ leaderMintFullBatch() fail: not leader (106ms)
|
||||
✔ leaderMintFullBatch() fail: arrays not equal length (123ms)
|
||||
✔ revoke() success (184ms)
|
||||
✔ revoke() fail: insufficient balance (113ms)
|
||||
✔ revoke() fail: not leader (123ms)
|
||||
✔ revokeBatch() (471ms)
|
||||
✔ revokeBatch() fail: not leader (123ms)
|
||||
✔ revokeBatch() fail: arrays not equal length (107ms)
|
||||
✔ revokeFullBatch() success (216ms)
|
||||
✔ revokeFullBatch() success: delegate (500ms)
|
||||
✔ revokeFullBatch() fail: insufficient balance (110ms)
|
||||
✔ revokeFullBatch() fail: not leader (108ms)
|
||||
✔ revokeFullBatch() fail: arrays not equal length (109ms)
|
||||
✔ forfeit() success (202ms)
|
||||
✔ forfeit() fail: insufficient balance (124ms)
|
||||
✔ safeTransferFrom() success (667ms)
|
||||
✔ safeTransferFrom() success: leader can transfer account bound (782ms)
|
||||
✔ safeTransferFrom() success: delegate can transfer account bound (1165ms)
|
||||
✔ safeTransferFrom() success: can transfer to contract (434ms)
|
||||
✔ safeTransferFrom() fail: transferring out of contract as user (114ms)
|
||||
✔ safeTransferFrom() fail: account bound (529ms)
|
||||
✔ safeBatchTransferFrom() success (748ms)
|
||||
✔ safeBatchTransferFrom() success: leader can transfer account bound (952ms)
|
||||
✔ safeBatchTransferFrom() success: delegate can transfer account bound (1106ms)
|
||||
✔ safeBatchTransferFrom() success: can transfer to contract (431ms)
|
||||
✔ safeBatchTransferFrom() fail: transferring out of contract as user (115ms)
|
||||
✔ safeBatchTransferFrom() fail: account bound (542ms)
|
||||
✔ depositETH() success (667ms)
|
||||
✔ depositETH() fail: not real badge (158ms)
|
||||
✔ depositETH() fail: not claimable (533ms)
|
||||
✔ depositETH() fail: invalid payment token (650ms)
|
||||
✔ depositERC20() success (1397ms)
|
||||
✔ depositERC20() fail: not real badge (128ms)
|
||||
✔ depositERC20() fail: not claimable (455ms)
|
||||
✔ depositERC20() fail: invalid payment token (571ms)
|
||||
✔ depositERC20() fail: not enough allowance (1067ms)
|
||||
✔ onERC1155Received() success (1135ms)
|
||||
✔ onERC1155Received() success: normal transfer (520ms)
|
||||
✔ onERC1155Received() fail: not real badge (200ms)
|
||||
✔ onERC1155Received() fail: not claimable (368ms)
|
||||
✔ onERC1155Received() fail: invalid payment token (673ms)
|
||||
✔ onERC1155Received() fail: not enough balance (668ms)
|
||||
✔ onERC721Received() success (3615ms)
|
||||
✔ onERC721Received() success: normal transfer (355ms)
|
||||
✔ onERC721Received() fail: not real badge (254ms)
|
||||
✔ onERC721Received() fail: not claimable (1001ms)
|
||||
✔ onERC721Received() fail: invalid payment token (768ms)
|
||||
✔ claimMint() success: signature (1817ms)
|
||||
✔ claimMint() success: claimable (1773ms)
|
||||
✔ claimMint() fail: invalid signature (1404ms)
|
||||
✔ claimMint() fail: not real badge (833ms)
|
||||
✔ claimMint() fail: not claimable (372ms)
|
||||
✔ claimMint() fail: amount is zero (108ms)
|
||||
✔ claimMint() fail: has not funded (391ms)
|
||||
✔ uri() success: has badge uri (86ms)
|
||||
✔ uri() success: no badge uri (138ms)
|
||||
✔ contractURI() success (155ms)
|
||||
✔ supportsInterface() success (654ms)
|
||||
|
||||
|
||||
118 passing (54s)
|
||||
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
BadgerOrganization\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganization.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerScout.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganization\interfaces\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerOrganizationInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerScoutInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
Badger\ | 100 | 100 | 100 | 100 | |
|
||||
Badger.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerVersions.sol | 100 | 100 | 100 | 100 | |
|
||||
Badger\interfaces\ | 100 | 100 | 100 | 100 | |
|
||||
BadgerInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
BadgerVersionsInterface.sol | 100 | 100 | 100 | 100 | |
|
||||
Mocks\ | 100 | 100 | 100 | 100 | |
|
||||
MockERC1155.sol | 100 | 100 | 100 | 100 | |
|
||||
MockERC20.sol | 100 | 100 | 100 | 100 | |
|
||||
MockERC721.sol | 100 | 100 | 100 | 100 | |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
All files | 100 | 100 | 100 | 100 | |
|
||||
----------------------------------|----------|----------|----------|----------|----------------|
|
||||
```
|
||||
@ -8,7 +8,6 @@ require("hardhat-docgen");
|
||||
require("@nomiclabs/hardhat-waffle");
|
||||
require("@nomiclabs/hardhat-etherscan");
|
||||
require('solidity-coverage');
|
||||
|
||||
require("dotenv").config();
|
||||
|
||||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
||||
@ -19,6 +18,66 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
||||
}
|
||||
});
|
||||
|
||||
task("deploy", "Deploys the protocol")
|
||||
.addFlag("verify", "Verify the deployed contracts on Etherscan")
|
||||
.setAction(async (taskArgs, hre) => {
|
||||
// Compiling all of the contracts again just in case
|
||||
await hre.run('compile');
|
||||
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log(`✅ Connected to ${deployer.address}`);
|
||||
|
||||
const chainId = await getChainId()
|
||||
|
||||
// Deploying the primitive master BadgerOrganization contract that is used for clones
|
||||
const BadgerOrganization = await ethers.getContractFactory("BadgerOrganization");
|
||||
organizationMaster = await BadgerOrganization.deploy();
|
||||
organizationMaster = await organizationMaster.deployed();
|
||||
console.log("✅ Organization Implementation Deployed.")
|
||||
|
||||
organizationDeployment = {
|
||||
"Chain ID": chainId,
|
||||
"Deployer": deployer.address,
|
||||
"Organization Implementation Address": organizationMaster.address,
|
||||
"Remaining ETH Balance": parseInt((await deployer.getBalance()).toString()) / 1000000000000000000,
|
||||
}
|
||||
console.table(organizationDeployment)
|
||||
|
||||
// Deploy the protocol
|
||||
const Badger = await ethers.getContractFactory("Badger");
|
||||
badger = await Badger.deploy(organizationMaster.address);
|
||||
badger = await badger.deployed();
|
||||
console.log("✅ Badger Deployed.")
|
||||
|
||||
badgerDeployment = {
|
||||
"Chain ID": chainId,
|
||||
"Deployer": deployer.address,
|
||||
"Badger Address": badger.address,
|
||||
"Remaining ETH Balance": parseInt((await deployer.getBalance()).toString()) / 1000000000000000000,
|
||||
}
|
||||
console.table(badgerDeployment)
|
||||
|
||||
// Verifying
|
||||
if (taskArgs.verify !== false && chainId != '31337') {
|
||||
|
||||
// Give time for etherscan to confirm the contract before verifying.
|
||||
await new Promise(r => setTimeout(r, 30000));
|
||||
await hre.run("verify:verify", {
|
||||
address: organizationMaster.address,
|
||||
constructorArguments: [],
|
||||
});
|
||||
console.log("✅ Organization Implementation Verified.")
|
||||
|
||||
await new Promise(r => setTimeout(r, 30000));
|
||||
await hre.run("verify:verify", {
|
||||
address: badger.address,
|
||||
constructorArguments: [badger.address],
|
||||
});
|
||||
console.log("✅ Badger Verified.")
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
solidity: {
|
||||
compilers: [
|
||||
@ -27,7 +86,7 @@ module.exports = {
|
||||
settings: {
|
||||
optimizer: { // Keeps the amount of gas used in check
|
||||
enabled: true,
|
||||
runs: 1000
|
||||
runs: 100000
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,8 +118,15 @@ module.exports = {
|
||||
format: "minimal"
|
||||
},
|
||||
etherscan: {
|
||||
apiKey: process.env.ETHERSCAN_API_KEY
|
||||
// apiKey: process.env.POLYGON_API_KEY
|
||||
apiKey: {
|
||||
mainnet: process.env.ETHERSCAN_API_KEY,
|
||||
rinkeby: process.env.ETHERSCAN_API_KEY,
|
||||
goerli: process.env.ETHERSCAN_API_KEY,
|
||||
kovan: process.env.ETHERSCAN_API_KEY,
|
||||
ropsten: process.env.ETHERSCAN_API_KEY,
|
||||
mumbai: process.env.POLYGONSCAN_API_KEY,
|
||||
matic: process.env.POLYGONSCAN_API_KEY,
|
||||
}
|
||||
},
|
||||
defaultNetwork: "hardhat",
|
||||
networks: {
|
||||
@ -77,24 +143,24 @@ module.exports = {
|
||||
},
|
||||
goerli: {
|
||||
url: `https://eth-goerli.g.alchemy.com/v2/${process.env.ETH_ALCHEMY_KEY}`,
|
||||
accounts: [`0x${process.env.PRIVATE_KEY}`],
|
||||
accounts: [`0x${process.env.ETHEREUM_PRIVATE_KEY}`],
|
||||
gasPrice: 5000000000, // 5 gwei
|
||||
},
|
||||
mumbai: {
|
||||
url: `https://polygon-mumbai.g.alchemy.com/v2/${process.env.POLYGON_ALCHEMY_KEY}`,
|
||||
accounts: [`0x${process.env.PRIVATE_KEY}`],
|
||||
url: `https://polygon-mumbai.g.alchemy.com/v2/${process.env.POLYGONSCAN_API_KEY}`,
|
||||
accounts: [`0x${process.env.POLYGON_PRIVATE_KEY}`],
|
||||
gas: 3000000,
|
||||
gasPrice: 100000000000 // 100 gwei
|
||||
},
|
||||
mainnet: {
|
||||
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ETH_ALCHEMY_KEY}`,
|
||||
accounts: [`0x${process.env.PRIVATE_KEY}`],
|
||||
accounts: [`0x${process.env.ETHEREUM_PRIVATE_KEY}`],
|
||||
gasPrice: 50000000000, // 50 gwei
|
||||
},
|
||||
polygon: {
|
||||
url: `https://polygon-mainnet.g.alchemy.com/v2/${process.env.POLYGON_ALCHEMY_KEY}`,
|
||||
accounts: [`0x${process.env.PRIVATE_KEY}`],
|
||||
url: `https://polygon-mainnet.g.alchemy.com/v2/${process.env.POLYGONSCAN_API_KEY}`,
|
||||
accounts: [`0x${process.env.PRIVATPOLYGON_PRIVATE_KEYE_KEY}`],
|
||||
gasPrice: 'auto'
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
@ -1,5 +1,23 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
# Run the hardhat node
|
||||
badger_local_hardhat_node:
|
||||
build:
|
||||
dockerfile: Dockerfile.dev.node
|
||||
context: ./contracts
|
||||
volumes:
|
||||
- .:/contracts/code
|
||||
ports:
|
||||
- "8545:8545"
|
||||
restart: unless-stopped
|
||||
# Deploy the contracts
|
||||
badger_local_hardhat_deploy:
|
||||
build:
|
||||
dockerfile: Dockerfile.dev.deploy
|
||||
context: ./contracts
|
||||
volumes:
|
||||
- .:/contracts/code
|
||||
restart: "no"
|
||||
# Run the postgres server
|
||||
badger_db:
|
||||
image: postgres:13.2
|
||||
@ -25,10 +43,33 @@ services:
|
||||
ports:
|
||||
- '8000:8000'
|
||||
env_file:
|
||||
- ./api/.env
|
||||
- ./.env
|
||||
volumes:
|
||||
- .:/api/code
|
||||
depends_on:
|
||||
- badger_db
|
||||
links:
|
||||
- badger_db
|
||||
- badger_db
|
||||
# Run the React frontend
|
||||
frontend:
|
||||
container_name: badger_frontend
|
||||
build:
|
||||
dockerfile: Dockerfile.dev
|
||||
context: ./frontend
|
||||
args:
|
||||
# use FONTAWSOME_TOKEN in .env to get access to private fontawesome packages
|
||||
FONTAWESOME_NPM_AUTH_TOKEN: ${FONTAWESOME_NPM_AUTH_TOKEN}
|
||||
command: npm start
|
||||
restart: always
|
||||
ports:
|
||||
- '3000:3000'
|
||||
volumes:
|
||||
- .:/frontend/code
|
||||
environment:
|
||||
- NODE_OPTIONS=--openssl-legacy-provider
|
||||
env_file:
|
||||
- ./.env
|
||||
depends_on:
|
||||
- web
|
||||
links:
|
||||
- web
|
||||
|
||||
34
example.env
Normal file
34
example.env
Normal file
@ -0,0 +1,34 @@
|
||||
# ========== CHOOSE NETWORK ==========
|
||||
ETHERSCAN_API_KEY = ""
|
||||
ETH_ALCHEMY_KEY = ""
|
||||
POLYGONSCAN_API_KEY = ""
|
||||
POLYGON_ALCHEMY_KEY = ""
|
||||
|
||||
ETHEREUM_PRIVATE_KEY = ""
|
||||
POLYGON_PRIVATE_KEY = ""
|
||||
# ========== CHOOSE NETWORK ==========
|
||||
|
||||
FONTAWESOME_NPM_AUTH_TOKEN=""
|
||||
|
||||
API_SECRET_KEY="secret"
|
||||
API_DEBUG="True"
|
||||
API_ALCHEMY_API_KEY=""
|
||||
API_PINATA_API_KEY=""
|
||||
API_PINATA_API_SECRET_KEY=""
|
||||
|
||||
REACT_APP_API_URL = "http://localhost:8000"
|
||||
REACT_APP_BADGER_ADDRESSES = {"Hardhat":"0x0165878A594ca255338adfa4d48449f69242Eb8F"}
|
||||
REACT_APP_BADGER_IMPLEMENTATION = "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"
|
||||
REACT_APP_ALCHEMY_API_KEY = ""
|
||||
REACT_APP_PRODUCTION_CHAIN = "Hardhat"
|
||||
|
||||
COINMARKETCAP_API_KEY = ""
|
||||
|
||||
# ========== DO NOT TOUCH ==========
|
||||
POSTGRES_DB="badger"
|
||||
POSTGRES_USER="badger"
|
||||
POSTGRES_PASSWORD="badger"
|
||||
POSTGRES_HOST="badger_db"
|
||||
POSTGRES_PORT="5432"
|
||||
# ========== DO NOT TOUCH ==========
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
@fortawesome:registry=https://npm.fontawesome.com/
|
||||
//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}
|
||||
20
frontend/Dockerfile.dev
Normal file
20
frontend/Dockerfile.dev
Normal file
@ -0,0 +1,20 @@
|
||||
# Use node image
|
||||
FROM node
|
||||
|
||||
ARG FONTAWESOME_NPM_AUTH_TOKEN
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /code
|
||||
|
||||
# Copy package.json
|
||||
COPY package.json /code/package.json
|
||||
|
||||
# Load FontAwesome registry
|
||||
RUN npm config set "@fortawesome:registry" https://npm.fontawesome.com/
|
||||
|
||||
# Set the auth token
|
||||
RUN echo "//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}" > /code/.npmrc && \
|
||||
npm install && \
|
||||
rm -f /code/.npmrc
|
||||
|
||||
COPY . /code/
|
||||
@ -1,27 +0,0 @@
|
||||
## Badger App
|
||||
|
||||
The Badger App serves as the interface for the Primitive contracts and self-indexing database.
|
||||
|
||||
## Running The Repository
|
||||
|
||||
**Important:** No matter how hard you try if you do not make sure the items below are completed before trying to run the front-end, things will not function properly. Yes, there are a lot of things you have to setup and configure to get a local version running. There are lots of moving pieces.
|
||||
|
||||
Getting the frontend can only be done after the contracts have been taken care of as well as the backend is running.
|
||||
|
||||
### Pre-requisites
|
||||
|
||||
- fork the repo
|
||||
|
||||
- [run local hardhat node](../contracts/README.md#running-local-hardhat-node)
|
||||
- [deploy contracts to local hardhat node](../contracts/README.md#deploying-to-local-hardhat-node)
|
||||
- [run local api](../api/README.md#running-the-api)
|
||||
|
||||
- terminal: `cd frontend`
|
||||
- terminal: `npm i`
|
||||
- setup your .env (in ~root/frontend/) to reflect example.env
|
||||
- setup your .envrc (in ~root/frontend/) to reflect example.envrc
|
||||
|
||||
**Important:** `.envrc` - Requires a Pro level API key for Font Awesome for icons used. Things will not work properly without a pro key.
|
||||
|
||||
### Running The App
|
||||
- `npm start`
|
||||
@ -1,5 +0,0 @@
|
||||
REACT_APP_API_URL = "http://localhost:8000"
|
||||
REACT_APP_BADGER_ADDRESSES = {"Hardhat":"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"}
|
||||
REACT_APP_BADGER_IMPLEMENTATION = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
|
||||
REACT_APP_ALCHEMY_API_KEY = ""
|
||||
REACT_APP_PRODUCTION_CHAIN = "Hardhat"
|
||||
@ -1 +0,0 @@
|
||||
FONTAWESOME_NPM_AUTH_TOKEN=""
|
||||
Loading…
Reference in New Issue
Block a user