Skip to content

Commit

Permalink
OCT-353 Reorganize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Mar 30, 2023
1 parent 28179cc commit e1d5b1b
Show file tree
Hide file tree
Showing 149 changed files with 9,735 additions and 13,263 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

32 changes: 1 addition & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
.env
.idea
**/.idea
.yarn
coverage
coverage.json
node_modules

# Hardhat files
.docs
artifacts
artifacts-zk
cache
cache-zk
deployments
typechain
typechain-types

# Client
dist
## rollup-plugin-visualizer result file
/client/bundleAnalysis.html

# Oracle
.pytest_cache
__pycache__
venv

# Subgraph
/subgraph/build
/subgraph/data
/subgraph/generated
/subgraph/networks.json
/subgraph/tests/.*

#logs
/oracle/api_mock/*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
50 changes: 28 additions & 22 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,30 @@ Build:
policy: pull-push
- key: $CI_COMMIT_REF_SLUG-contracts
paths:
- .yarn
- artifacts
- typechain-types
- contracts/.yarn
- contracts/artifacts
- contracts/typechain-types
- contracts/node_modules
policy: pull-push

- key: $CI_COMMIT_REF_SLUG-client-subgraph-fiatserver-yarn.lock
paths:
- client/node_modules
- crypto-server/node_modules
- coin-prices-server/node_modules
- subgraph/node_modules
policy: pull-push

script:
- apt-get update && apt-get install -y --no-install-recommends git --reinstall ca-certificates
- yarn install
- cd contracts
- yarn install --non-interactive --cache-folder .yarn
- yarn compile
- cd client
- cd ../client
- yarn install --non-interactive --cache-folder .yarn
- cd ../subgraph
- yarn install --non-interactive --cache-folder .yarn
- cd ../crypto-server
- cd ../coin-prices-server
- yarn install --non-interactive --cache-folder .yarn

Lint and typecheck:
Expand All @@ -52,22 +55,25 @@ Lint and typecheck:
policy: pull
- key: $CI_COMMIT_REF_SLUG-contracts
paths:
- .yarn
- artifacts
- typechain-types
- contracts/.yarn
- contracts/artifacts
- contracts/typechain-types
policy: pull
- key: $CI_COMMIT_REF_SLUG-client-subgraph-fiatserver-yarn.lock
paths:
- client/node_modules
policy: pull
script:
- yarn install
- cd contracts
- yarn install
- yarn eslint
- yarn type-check
- cd client
- cd ../client
- yarn install
- yarn eslint
- yarn type-check
- cd ../crypto-server
- cd ../coin-prices-server
- yarn install
- yarn eslint
- yarn type-check
Expand All @@ -78,17 +84,15 @@ Lint and typecheck:
Contracts unit tests:
stage: test
cache:
- key: $CI_COMMIT_REF_SLUG-yarn.lock
paths:
- node_modules
policy: pull
- key: $CI_COMMIT_REF_SLUG-contracts
paths:
- .yarn
- artifacts
- typechain-types
- contracts/node_modules
- contracts/.yarn
- contracts/artifacts
- contracts/typechain-types
policy: pull
script:
- cd contracts
- yarn test
- yarn docs

Expand Down Expand Up @@ -122,7 +126,7 @@ Client unit tests:
# cache:
# - key: $CI_COMMIT_REF_SLUG-contracts
# paths:
# - artifacts
# - contracts/artifacts
# script:
# - cd oracle
# - pip install -r requirements.txt
Expand All @@ -140,11 +144,12 @@ Contracts deploy:
policy: pull
- key: $CI_COMMIT_REF_SLUG-contracts
paths:
- .yarn
- artifacts
- typechain-types
- contracts/.yarn
- contracts/artifacts
- contracts/typechain-types
policy: pull
script:
- cd contracts
- yarn deploy:goerli

pages:
Expand All @@ -154,6 +159,7 @@ pages:
when: manual
script:
- apt-get update && apt-get install -y --no-install-recommends git --reinstall ca-certificates
- cd contracts
- yarn install --non-interactive --cache-folder .yarn
- yarn compile
- cd client
Expand Down
10 changes: 10 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd client
yarn install
cd ../contracts
yarn install
cd ../coin-prices-server
yarn install
cd ../subgraph
yarn install
cd ..

yarn lint-staged
9 changes: 9 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd client
yarn install
yarn type-check
cd ../contracts
yarn install
yarn type-check
cd ../coin-prices-server
yarn install

yarn type-check
80 changes: 3 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,85 +6,11 @@ Developed by the [Golem Foundation](https://golem.foundation/) to test various h

Documentation is available [here](https://docs.octant.app/).

## Configuration
---

Ensure that the `.env` file is present. See `.env.template`.
Documentation, configuration, deployment is available in directories of this repository. `contracts` should be an entry point.

## Clean
```bash
yarn clean
```

## Compile
```bash
yarn compile
```

## Test
```bash
yarn test
```

## Format and lint
```bash
yarn format
yarn lint
```

## Documentation
Generate contracts documentation:
```bash
yarn docs
```
Go to `.docs` and open the `index.html` file in your browser.

## Deployment

### Local
In one terminal:
```bash
yarn start-node
```
In second terminal:
```bash
yarn prepare-local-test-env
```
In order to generate reward budget:
```bash
yarn generate-reward
```
Please note that this needs to be run in each epoch you want to have reward budget.

### Goerli testnet
```bash
yarn deploy:goerli
yarn verify:goerli
```

## GLM Faucet (Goerli)
Update `.env` with your private key:
```bash
GOERLI_PRIVATE_KEY=<your private key>
```
Send Test GLM.
```bash
npx hardhat --network goerli send-glm --recipient <recipient address>
```

## Known technical problems
### root

Root `package.json` `yarn postinstall` command replaces `@nomiclabs/hardhat-ethers` with `hardhat-deploy-ethers`. This is due to the fact that the first package, although essential declares different methods for `ethers` than the latter package, causing unexpected type collision.

### client
Typechain combines responses from contracts so that an array and object are joined together, e.g.:
```
export type AllocationStructOutput = [BigNumber, BigNumber] & {
allocation: BigNumber;
proposalId: BigNumber;
};
```
The problem with this approach is that the `react-query` package used for fetching and managing data from contracts does drop the latter object part on all but first after rerender requests. Hence, the remapping of array elements to named variables is required during response parsing phase.
---

## Contributor Agreement

Expand Down
10 changes: 10 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dist
node_modules
typechain-types
## rollup-plugin-visualizer result file
/client/bundleAnalysis.html

#logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
10 changes: 10 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Known technical problems

Typechain combines responses from contracts so that an array and object are joined together, e.g.:
```
export type AllocationStructOutput = [BigNumber, BigNumber] & {
allocation: BigNumber;
proposalId: BigNumber;
};
```
The problem with this approach is that the `react-query` package used for fetching and managing data from contracts does drop the latter object part on all but first after rerender requests. Hence, the remapping of array elements to named variables is required during response parsing phase.
18 changes: 10 additions & 8 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
"scripts": {
"build": "vite build",
"build:staging": "vite build --mode staging",
"copy-typechain": "cp -r ../typechain-types ./src/typechain-types",
"dev": "yarn predev && vite",
"dev": "yarn install && vite",
"eslint": "eslint './**/*.{js,jsx,ts,tsx}'",
"eslint:fix": "yarn prettier && yarn eslint --fix",
"install-root-packages": "cd .. && yarn clean && yarn install && yarn compile && cd client",
"predev": "yarn install",
"preinstall": "yarn install-root-packages && yarn remove-typechain && yarn copy-typechain",
"install:rootpackages": "cd .. && yarn install && cd client",
"predev": "yarn install:rootpackages && yarn install",
"preinstall": "yarn install:rootpackages && yarn typechain:synchronize",
"prettier": "yarn prettier:js --loglevel silent && yarn prettier:ts --loglevel silent",
"prettier:js": "yarn prettier:js:pure './**/*.{js,jsx}'",
"prettier:js:pure": "prettier --write",
"prettier:ts": "yarn prettier:ts:pure './**/*.{ts,tsx}'",
"prettier:ts:pure": "prettier --parser typescript --write",
"preview": "vite preview",
"remove-typechain": "rm -rf ./src/typechain-types",
"test": "TZ=UTC jest",
"type-check": "tsc --noEmit true"
"type-check": "tsc --noEmit true",
"typechain:copy": "cp -r ../contracts/typechain-types ./src/typechain-types",
"typechain:install": "cd ../contracts && yarn clean && yarn compile && cd ../client",
"typechain:remove": "rm -rf ./src/typechain-types",
"typechain:synchronize": "yarn typechain:remove && yarn typechain:copy"
},
"dependencies": {
"@apollo/client": "^3.7.4",
Expand Down Expand Up @@ -79,7 +81,7 @@
"rollup-plugin-visualizer": "^5.9.0",
"sass": "^1.57.1",
"ts-jest": "^29.0.5",
"typescript": "^4.9.4",
"typescript": "^5.0.2",
"vite": "^4.0.4"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion client/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const env = {
},
cryptoValuesEndpoint:
// @ts-expect-error TS does not understand the way vite imports envs.
import.meta.VITE_CRYPTO_VALUES_ENDPOINT || 'https://crypto-server.octant.world/',
import.meta.env.VITE_CRYPTO_VALUES_ENDPOINT || 'https://crypto-server.octant.world/',
ipfsGateway:
// @ts-expect-error TS does not understand the way vite imports envs.
import.meta.env.IPFS_GATEWAY || 'https://octant.infura-ipfs.io/ipfs/',
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/queries/useUserAllocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useContractAllocationsStorage from 'hooks/contracts/useContractAllocation

import useCurrentEpoch from './useCurrentEpoch';

import { IAllocationsStorage } from '../../../../typechain-types';
import { IAllocationsStorage } from '../../typechain-types';

export type UserAllocation = { allocation: BigNumber; proposalAddress: string };

Expand Down
3 changes: 3 additions & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"strict": true,
"target": "es2022"
},
"exclude": [
"src/typechain-types/**/*",
],
"include": [
"src/**/*"
]
Expand Down
8 changes: 4 additions & 4 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7497,10 +7497,10 @@ [email protected]:
dependencies:
is-typedarray "^1.0.0"

typescript@^4.9.4:
version "4.9.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==
typescript@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.2.tgz#891e1a90c5189d8506af64b9ef929fca99ba1ee5"
integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==

uint8arrays@^3.0.0, uint8arrays@^3.1.0:
version "3.1.1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e1d5b1b

Please sign in to comment.