-
Notifications
You must be signed in to change notification settings - Fork 0
An brief description on how the project is configured and deployment works #30
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
base: v6
Are you sure you want to change the base?
Changes from all commits
56c4634
50f87dd
3c9c29d
3cf6539
e619dd0
a5c33c9
596d0b2
161eac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ __pycache__ | |
| artifacts | ||
| lib | ||
| typechain | ||
| subgraph.yaml | ||
|
|
||
| # dependencies | ||
| node_modules | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Brøk API | ||
| Creates a simplified interface for enterprise systems, so they can use BRØK without the need for any knowledge or system implementation of web3 technologies. | ||
|
|
||
| Built with Next.js framework. | ||
|
|
||
| Remember to complete the steps described [here](./../../README.md#development) before running this application the first time. | ||
|
|
||
| The chapter on .env describes how this application is configured to connect to other application. | ||
|
|
||
|
|
||
| ## Application endpoints overview | ||
|
|
||
| ``/api/health`` Checks the status for the external connection, and ethereum balance | ||
|
|
||
| ``/api/checkTransaction`` Checks the status of a transaction | ||
|
|
||
| ``/api/v1/company/`` Control the CapTable for a company | ||
|
|
||
| ``/api/v1/person/`` Get the ownership information for a person or company owning shares | ||
|
|
||
| For more explanation, check out the [swagger file](./../../docs/swagger.yaml) | ||
|
|
||
|
|
||
| ## External applications | ||
|
|
||
| This application depends on the following to work properly: | ||
| - an Ethereum network, either Hardhat network running locally, or Arbitrum Goerli/Sepolia/One | ||
| - The Graph subgraph for CapTableRegistry | ||
| - Navnetjener API | ||
|
|
||
| To start Hardhat network and The Graph services locally, run the vs code task `deploy-local` | ||
|
|
||
| To start Navnetjener, follow [these instructions](https://github.com/brreg/brok-navnetjener#development-setup) | ||
|
|
||
|
|
||
| ## .env | ||
| The .env files uses the following values: | ||
|
|
||
| | **Value** | **Description** | | ||
| |--|--| | ||
| | `PRIVATE_KEY` | The Private key for the wallet used by Brøk API, intended to be provided by Brønnøysundregistrene in the future | | ||
| | `RPC_LOCAL` | Network address to the Hardhat network | | ||
| | `RPC_SEPOLIA` | Network address to the Arbitrum Sepolia network | | ||
| | `RPC_GOERLI` | Network address to the Arbitrum Goerli network | | ||
| | `RPC_ONE` | Network address to the Arbitrum One network | | ||
| | `PORT` | Port for the API | | ||
| | `NAVNETJENER_URL` | URL to Navnetjener API | | ||
| | `BROK_ENV` | Selects Ethereum network, valid arguments: `localhost`, `brokStage` or `brokProd` | | ||
| | `DEBUG` | Select what part of the application you want to debug, default to `brok*` for the whole application | | ||
| | `THE_GRAPH_URL` | URL to The Graph subgraph | | ||
|
|
||
|
|
||
| # Development | ||
|
|
||
| Start dev server: `pnpm run dev` | ||
|
|
||
| Run all tests: `pnpm run test` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ SEED_PROD=test test test test test test test test test test test junk | |
| RPC_CONTAINER=http://host.docker.internal:8545 | ||
| RPC_LOCAL=http://127.0.0.1:8545 | ||
| RPC_TESTNET=http://127.0.0.1:8545 | ||
| RPC_STAGENET=http://127.0.0.1:8545 | ||
| RPC_MAINNET=http://127.0.0.1:8545 | ||
| REPORT_GAS=false | ||
| CAP_TABLE_REGISTRY_brokDev=0x8EF52e971B7Aa8f263A7C25b0F4e200709287A30 | ||
| DEV_ENTERPRISE_SYSTEM_ADDRESS=0x0a665B1Bc813cAE9fcDd2Eb7E25b8E55A5F35f23 | ||
| DEV_ENTERPRISE_SYSTEM_ADDRESS=0x4cCE8E0e2Ba902FE7D2D1fD894d85883E7cd720d | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Har du kjørt koden med disse endringene, slik at vi vet det fungerer? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,55 @@ | ||
| # Smart contracts for CapTable BRØK | ||
|
|
||
| NB! brokProd is still against Arbitrum Goerli | ||
| Smart contracts for CapTable and CapTableRegistry developed in [Solidity v0.8.0](https://docs.soliditylang.org/en/v0.8.0/) | ||
|
|
||
| Based on [ERC1400](https://consensys.io/staking/assets/universal-token), but intended to migrate to [ERC3643](https://www.erc3643.org/) in the future. | ||
|
|
||
| The contracts are built and tested with [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#overview) | ||
|
|
||
| Based on the generated contracts, [tsup](https://www.npmjs.com/package/tsup) is used to generate a TypeScript library, to be used by Brøk API and The Graph configuration. | ||
|
|
||
| ***Note: 'brokProd' is currently configured to run on the deprecated Arbitrum Goerli network. In future versions we might transition to Sepolia.*** | ||
|
|
||
| ## Project overview | ||
|
|
||
| | **Folder** | **Description** | | ||
| |--|--| | ||
| | `artifacts/` | Compiled artifacts generated by Hardhat compile (generated) | | ||
| | `cache/` | The directory used by Hardhat to cache its internal stuff (generated) | | ||
| | `contracts/` | CapTable and CapTableRegistry contracts in Solidity, with dependencies | | ||
| | `deployments/` | Our way to persist smart contract addresses deployed on Arbitrum, generated by [./tasks/generate-deployments.ts](./tasks/generate-deployments.ts) | | ||
| | `dist/` | Generated TypeScript library of CapTable and CapTableRegistry (generated) | | ||
| | `scripts/` | I dont know what this does | | ||
ohatland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | `tasks/` | Hardhat tasks to be run with ``hardhat <task name> --network <network name> --log`` | ||
| | `test/` | Tests for CapTable and CapTableRegistry | | ||
| | `typechain-types/` | Generated TypeScript bindings for smart contracts (generated) | | ||
|
|
||
|
|
||
| ### .env | ||
| | **Value** | **Description** | | ||
| |--|--| | ||
| | `ETHERSCAN_API_KEY` | Used for verifying that the contract's source code matches the executed bytecode onchain, makes the source code viewable on Etherscan and makes it possible to execute smart contract functions directly from Etherscan. | | ||
| | `SEED_DEV` | Mnemonic key for Brønnøysundregistrenes wallet used to deploy contracts in the dev environment | | ||
| | `SEED_STAGE` | Mnemonic key for Brønnøysundregistrenes wallet used to deploy contracts in the stage environment | | ||
| | `SEED_PROD` | Mnemonic key for Brønnøysundregistrenes wallet used to deploy contracts in the production environment **NB: contains real money** | | ||
| | `RPC_CONTAINER` | Network address to Hardhat network running with `docker-compose` | | ||
| | `RPC_LOCAL` | Network address to Hardhat network running local | | ||
| | `RPC_TESTNET` | Network address to the Arbitrum Goerli network | | ||
| | `RPC_STAGENET` | Network address to the Arbitrum One network | | ||
| | `RPC_MAINNET` | Network address to the Arbitrum One network | | ||
| | `CONTRACT_SIZER` | Boolean for turning on verbose compilation where contract sizes are being outputted when they are compiled. | | ||
| | `REPORT_GAS` | Same as `CONTRACT_SIZER` but with finer granularity output. This outputs gas used for each test and every smart contract method | | ||
| | `DEV_ENTERPRISE_SYSTEM_ADDRESS` | Give this wallet address the permission to publish CapTables to the CapTableRegistry | | ||
|
|
||
|
|
||
| ## Hardhat networks | ||
| There are several hardhat networks configured in [hardhat.config.ts](./hardhat.config.ts#L83). These networks are configured to use a url from the .env file `RPC_*` and mnemonic frases, `SEED_*`, to access the account on the network used to deploy the smart contracts. | ||
|
|
||
| **Be very careful about the `SEED_PROD` because this wallet holds real money, they will be quickly stolen if the key is leaked to the public!** | ||
|
|
||
| These networks are used in the Hardhat cli as `hardhat --network <network name>` e.g. `hardhat --network brokStage` | ||
|
|
||
| ## Deployment prosess | ||
| To deploy the smart contracts to production, run `pnpm hardhat-deploy-contracts-production`, | ||
|
|
||
| Again, make sure the `.env` file holds the correct values **before** running this command | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,28 @@ | ||
| # DEV | ||
| # Search indexing for CapTableRegistry BRØK | ||
|
|
||
| Make sure the correct CapTableRegistry is sert in config | ||
| The Graph is an indexing protocol for organizing blockchain data and making it easily accessible with GraphQL. | ||
|
|
||
| Create a subgraph at https://thegraph.com/legacy-explorer/ | ||
| The Graph makes it possible to query data that is difficult to query directly. | ||
|
|
||
| Change the NPM command to reflect new subgraph, then run `yarn run brokDev:deploy` | ||
| The Graph learns what and how to index Ethereum data based on subgraph descriptions, known as the subgraph manifest. The subgraph description defines the smart contracts of interest for a subgraph, the events in those contracts to pay attention to, and how to map event data to data that The Graph will store in its database. | ||
|
|
||
| Once you have written a `subgraph manifest`, you use the Graph CLI to store the definition in IPFS and tell the indexer to start indexing data for that subgraph. | ||
|
|
||
| This diagram gives more detail about the flow of data once a subgraph manifest has been deployed, dealing with Ethereum transactions: | ||
|
|
||
|
|
||
| ## Project overview | ||
|
|
||
| | **Folder** | **Description** | | ||
| |--|--| | ||
| | `abis/` | ABIS files for CapTable and CapTableRegistry, ***NB: These files are generated and copy manually*** | | ||
| | `build/` | Generated files from `graph codegen && graph build`, based on the content of `subgraph.yaml` | | ||
| | `docker-compose/` | Specs for running TheGraph locally with Docker compose | | ||
| | `generated/` | Some manually generated files @jon ? | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "build" folder contains compiled and ready-to-deploy files such as ABI files for smart contracts, necessary for deploying the subgraph. The "generated" folder includes TypeScript types and auxiliary files generated from the smart contracts' ABI, mainly used to ensure type safety and facilitate a smoother development experience when working with GraphQL queries or smart contract interactions. |
||
| | `podman-compose/` | Specs for running TheGraph locally with Podman compose | ||
| | `scripts/` | Takes constant variables from `packages/captable/deployment/` and creates `subgraph.yaml` | | ||
| | `src/` | Some more files copy @jon ? | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Contains TypeScript mapping scripts that handle blockchain events, updating the subgraph's state with entities like |
||
| | `tests/` | I dont know @jon ? | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used for tracking the version and timestamp of the latest test run, aiding in test management and version control. |
||
|
|
||
| ## Deployment prosess | ||
| To deploy subgraph to The Graph hosted services. update the deployment name in `package.json` and run one of the `deploy:*` commands | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Har du kjørt koden med disse endringene, slik at vi vet det fungerer?