# QF Tech 會議記錄
## 220719
### New Try
接續著[上禮拜的進度](#220711)。關於 `@graphprotocol/graph-ts` 路徑的類似問題有被發成 [issues](https://github.com/graphprotocol/graph-ts/issues/113) 過。現在的問題很像是 0.5 以下的 SubGraph 在 `@graphprotocol` 的最新版不適用,而舊版的 `@graphprotocol` 雖然支援當前 SubGraph(0.2),但卻會有 path 錯誤的問題。
9. Keep going on...
```
$ yarn codegen
$ yarn build
```
> New problem appears, so I re-push the issues [**here**](https://github.com/clrfund/monorepo/issues/512#issuecomment-1181089849). The problem may be caused from the [`@graphprotocol/graph-ts`](https://www.npmjs.com/package/@graphprotocol/graph-ts) version.
10. **Try to solve the problems**
* My Linux flavor is `Ubuntu, 20.04.4, amd64` ( Oracle VM VirtualBox) on Windows 11 Pro.
* Delete the top-level `node_modules` and the `subgraph/node_modules`
* Change the `@graphprotocol/graph-ts` version to 0.20.0
* Change the `@graphprotocol/graph-cli` version to 0.21.0
11. Future
```
$ graph auth --product hosted-service 35b6af8330584ac6ab0cfaaad4cf6832
$ npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ chihaolu/monorepo-goerli
```
12. Revise `vue-app/.env`
```
VUE_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/chihaolu/monorepo-goerli
# Comma-separated list of URLs
VUE_APP_GUN_PEERS=http://localhost:8765/gun
VUE_APP_CLRFUND_FACTORY_ADDRESS=0xe815Dfdc91160E4781FD720509Ad89C59bf5FBe7
# Supported values: simple, brightid
VUE_APP_USER_REGISTRY_TYPE=brightid
# clr.fund (prod) or CLRFundTest (testing)
# Learn more about BrightID and context in /docs/brightid.md
VUE_APP_BRIGHTID_CONTEXT=clr.fund
# Supported values: simple, optimistic, kleros
VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic
VUE_APP_RECIPIENT_REGISTRY_POLICY=QmYmiHfAh7mGMFxRpP1pTNLv1pjuYNW8nmxsCAJU2XoAKF
# Comma-separated list of IPFS hashes
VUE_APP_EXTRA_ROUNDS=
# Operator of clr.fund instance
VUE_APP_OPERATOR=
# Google Service Account credentials in JSON format
GOOGLE_APPLICATION_CREDENTIALS=
# Spreadsheet ID to send recipients data
VUE_APP_GOOGLE_SPREADSHEET_ID=
```
---
## 220711
### New Try
他們把版本改成 georli,然後有重新大改文件,[**連結**](https://github.com/clrfund/monorepo/blob/develop/docs/admin.md)。
1. With new argument in `contracts/.env`
```
# Recipient registry type for local deployment: simple, optimistic
RECIPIENT_REGISTRY_TYPE=simple
# Supported values: simple, brightid
USER_REGISTRY_TYPE=brightid
# clr.fund (prod) or CLRFundTest (testing)
BRIGHTID_CONTEXT=CLRFundTest
# BrightId node addr that signs verifications. Node One uses this one
BRIGHTID_VERIFIER_ADDR=0xb1d71F62bEe34E9Fc349234C201090c33BCdF6DB
# JSON-RPC endpoint to the selected network
JSONRPC_HTTP_URL=https://goerli.infura.io/v3/4521b5a40d0d45428de0b40fca371a2b
# One of the two options
WALLET_MNEMONIC=attract clay ... hover
WALLET_PRIVATE_KEY=
# Token address for funding round .setToken
NATIVE_TOKEN_ADDRESS=0x4f38007de2adba1ba6467d4b82e8de59c2298a3e
```
2. Deploy new round
```
cd contracts
$ npx hardhat run --network goerli scripts/deployRound.ts
>
*******************
Deploying a new clr.fund instance of contracts!
*******************
deployer.address: 0xB42faBF7BCAE8bc5E368716B568a6f8Fdf3F84ec
maciFactory.address: 0xC904c79AF32eEDd3b4d6E88A0f18CCe3f28837B9
fundingRoundFactory.address: 0xe815Dfdc91160E4781FD720509Ad89C59bf5FBe7
userRegistry.address: 0xE55A76C1C74cFafF38eE203F938b069a9FF9B86B
recipientRegistry.address: 0x1BDBEE580ED778F997555dc2b1084f386453DB34
serializedCoordinatorPrivKey: macisk.27755bad803b533b2be88770a09ef22c15853653b58dd83b95b0544f4b5170b3
serializedCoordinatorPubKey: macipk.84b8232800c83fcdd0e4ff95a7ee542c52c91c957a919a8b04852f9796113381
```
3. With new arguments in `contracts/.env`:
```
# Required to use in the tally and finalize scripts
FACTORY_ADDRESS=0xC904c79AF32eEDd3b4d6E88A0f18CCe3f28837B9
ROUND_ADDRESS=0xe815Dfdc91160E4781FD720509Ad89C59bf5FBe7
COORDINATOR_PK=macisk.27755bad803b533b2be88770a09ef22c15853653b58dd83b95b0544f4b5170b3
COORDINATOR_ETH_PK=macipk.84b8232800c83fcdd0e4ff95a7ee542c52c91c957a919a8b04852f9796113381
```
4. Revise subgraph/config/goerli.json
```
{
"network": "goerli",
"address": "0xe815Dfdc91160E4781FD720509Ad89C59bf5FBe7",
"factoryStartBlock": 7109979,
"recipientRegistryStartBlock": 7109979
}
```
5. Use subgraph, [My subgraph](https://thegraph.com/hosted-service/subgraph/chihaolu/monorepo-goerli):
```
$ cd subgraph
$ rm -rf build generated node_modules
$ yarn
$ npx mustache config/goerli.json subgraph.template.yaml > subgraph.yaml
$ yarn codegen
```
> 我有照著做沒有使用 `init` 也確定重做一次是在 goerli 且前面的步驟都沒問題是乾淨的,然後有把快取還有 generated 檔案們都刪掉,但這邊還是出現一樣的問題,error 我回報到[**上次那個 issue 的最下面**](https://github.com/clrfund/monorepo/issues/512#issuecomment-1180130698)了。
> * 順便貼 Os 的 Debug.log 給他們,也許是因為 graph 的版本問題,但我更新到最新版或者降回前一個版本問題都一樣
> * 也有可能是 OS 的問題,我是用 windows 他們是用 LInux,不知道在編碼上是不是方法不同導致 yaml 會出現錯誤字元,但我用 validator 也是合法的沒錯
6. **Solve the above problem by move to Linux**
7. The another problem appears:
```
chihaolu@chihaolu-VirtualBox:~/blockchain/monorepo/subgraph$ yarn codegen
yarn run v1.22.19
$ graph codegen
The current version of graph-cli can't be used with mappings on apiVersion less than '0.0.5'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
8. **Solve it by downgrade the `@graphprotocol/graph-cli` to 0.21.0**
---
## 220704
### New Try
- [How to deploy to The Decentralized Graph](https://soliditydeveloper.com/thedecentralizedgraph?fbclid=IwAR0zZW4x9UUNaSOOqprKelauVbbfNPNud7HpnJLVD5XFAuDH1IVicfgH7K8)
## 220627
### New Try
1. With new argument in `contracts/.env`
```
USER_REGISTRY_TYPE=brightid
BRIGHTID_CONTEXT=CLRFundTest
```
2. Deploy new round
```
$ cd monorepo/contract
$ npx hardhat run --network rinkeby scripts/deployRound.ts
·--------------------------------------|-------------·
| Contract Name · Size (Kb) │
·······································|··············
| Address · 0.08 │
·······································|··············
│ ... · │
·······································|··············
| VerifyTally · 2.33 │
·--------------------------------------|-------------·
*******************
Deploying a new clr.fund instance of contracts!
*******************
deployer.address: 0xB42faBF7BCAE8bc5E368716B568a6f8Fdf3F84ec
maciFactory.address: 0xe5208b357307092A501C428cd0aD1Dde1583ea5E
fundingRoundFactory.address: 0xaD841958a0B80105661A0E2Bf78D97190A45e820
userRegistry.address: 0x384d46B0604dd9Ea881AE034f4fc3895117812dc
recipientRegistry.address: 0xed97ccD94C05555A42c42160CAfC82bC635e73BA
serializedCoordinatorPrivKey: macisk.294313a792989e2f8dfe93e3694c011195d36b308294c22a563bcd34e694d7c
serializedCoordinatorPubKey: macipk.63652f6ad4ac46a3880db128dc38b938be5f6db9473c7f9fb37871e21cef2990
```
3. With new arguments in `contracts/.env`:
```
# Required to use in the tally and finalize scripts
FACTORY_ADDRESS=0x806EE0951A74E4A3DA61AEfb3600a9e54286A4B8
ROUND_ADDRESS=0xaD841958a0B80105661A0E2Bf78D97190A45e820
COORDINATOR_PK=macisk.294313a792989e2f8dfe93e3694c011195d36b308294c22a563bcd34e694d7c
COORDINATOR_ETH_PK=macipk.63652f6ad4ac46a3880db128dc38b938be5f6db9473c7f9fb37871e21cef2990
```
4. Install subgraph:
- [My subgraph](https://thegraph.com/hosted-service/subgraph/chihaolu/qf)
```
$ npm install -g @graphprotocol/graph-cli
$ graph
> Welcome to graph CLI version 0.31.0!
Type graph --help to view common commands.
```
5. Init subgraph:
```
$ cd monorepo/subgraph
$ graph init --product hosted-service chihaolu/qf
>
√ Protocol · ethereum
√ Subgraph name · chihaolu/qf
√ Directory to create the subgraph in · qf
? Ethereum network ...
? Ethereum network ...
? Ethereum network ...
√ Ethereum network · rinkeby
√ Contract address · 0xaD841958a0B80105661A0E2Bf78D97190A45e820
× Failed to fetch ABI from Etherscan: ABI not found, try loading it from a local file
√ ABI file (path) · C:\Users\qazws\Desktop\Blockchain\clf\monorepo\subgraph\abis\FundingRoundFactory.json
√ Contract Name · FundingRoundFactory
———
Generate subgraph
Write subgraph to directory
√ Create subgraph scaffold
√ Initialize networks config
√ Initialize subgraph repository
√ Install dependencies with yarn
√ Generate ABI and schema types with yarn codegen
√ Add another contract? (y/N) · false
Subgraph chihaolu/qf created in qf
Next steps:
1. Run `graph auth` to authenticate with your deploy key.
2. Type `cd qf` to enter the subgraph.
3. Run `yarn deploy` to deploy the subgraph.
Make sure to visit the documentation on https://thegraph.com/docs/ for further information.
```
6. Create `subgraph/config/rinkeby.json`
- [Etherscan](https://rinkeby.etherscan.io/address/0xaD841958a0B80105661A0E2Bf78D97190A45e820)
```
{
"network": "rinkeby",
"address": "0xaD841958a0B80105661A0E2Bf78D97190A45e820",
"factoryStartBlock": 10924092,
"recipientRegistryStartBlock": 10924096
}
```
7. Revise `subgraph/subgraph.yaml` and deploy to IPFS:
```
$ npx mustache config/rinkeby.json subgraph.template.yaml > subgraph.yaml
$ cd qf
$ npm run codegen
$ npm run build
$ npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ chihaolu/qf
>
√ Upload subgraph to IPFS
Build completed: QmYmiHfAh7mGMFxRpP1pTNLv1pjuYNW8nmxsCAJU2XoAKF
Deployed to https://thegraph.com/explorer/subgraph/chihaolu/qf
Subgraph endpoints:
Queries (HTTP): https://api.thegraph.com/subgraphs/name/chihaolu/qf
```
8. Deploy Subgraph(in subgraph/qf)
```
$ graph auth --product hosted-service 35b6af8330584ac6ab0cfaaad4cf6832
> Deploy key set for https://api.thegraph.com/deploy/
$ cd subgraph
$ graph deploy --product hosted-service chihaolu/qf
```
9. Revise `vue-app/.env`
```
VUE_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/chihaolu/qf
# Comma-separated list of URLs
VUE_APP_GUN_PEERS=http://localhost:8765/gun
VUE_APP_CLRFUND_FACTORY_ADDRESS=0xaD841958a0B80105661A0E2Bf78D97190A45e820
# Supported values: simple, brightid
VUE_APP_USER_REGISTRY_TYPE=simple
# clr.fund (prod) or CLRFundTest (testing)
# Learn more about BrightID and context in /docs/brightid.md
VUE_APP_BRIGHTID_CONTEXT=clr.fund
# Supported values: simple, optimistic, kleros
VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic
VUE_APP_RECIPIENT_REGISTRY_POLICY=QmYmiHfAh7mGMFxRpP1pTNLv1pjuYNW8nmxsCAJU2XoAKF
# Comma-separated list of IPFS hashes
VUE_APP_EXTRA_ROUNDS=
# Operator of clr.fund instance
VUE_APP_OPERATOR=
# Google Service Account credentials in JSON format
GOOGLE_APPLICATION_CREDENTIALS=
# Spreadsheet ID to send recipients data
VUE_APP_GOOGLE_SPREADSHEET_ID=
```
10. Build & Deploy Vue-App(UI)
```
$ cd vue-app
$ yarn build
$ ipfs add -r vue-app/dist/
$ yarn start:web
```
### New Problems
1. **[SOLVED, These problem has been sent to the new issues by me [here](https://github.com/clrfund/monorepo/issues/512#issuecomment-1167106700).]** In the step.7, the command `$ npm run codegen` returns the error:
```
yarn run v1.22.18
$ graph codegen
Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 (graph-ts dependency not installed yet)
Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 (graph-ts dependency not installed yet)
Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 (graph-ts dependency not installed yet)
× Failed to apply migrations: end of the stream or a document separator is expected at line 1, column 4:
��s
^
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
2. **[SOLVED]** 一樣是 summit project 的最後一步卡住,這一步是忘記把 `vue-app/.env` 的 `daodesigner/clrfund` 改成 `chihaolu/qf` 的 API RPC URL --> https://api.thegraph.com/subgraphs/name/chihaolu/qf

3. **[UnSOLVED, These problem has been sent to the new issues by me [here](https://github.com/clrfund/monorepo/issues/512#issuecomment-1168173725)]** 一樣是 summit project 的最後一步卡住,貌似是[**我的 subgraph**](https://thegraph.com/hosted-service/subgraph/chihaolu/qf) 沒有正常的 fetch 到 scheme 或者 interface 的樣子。
> `fundingRoundAddress: 0x4377660ed8fb7ab84c0f88dd06f583be8ccff292` 貌似錯了。


---
## 220621
### Next Target
1. Run the deployed vue.app: check the Node_API_Key -> 應該沒問題
2. Verify in etherscan to operates the contract by owner
### New Problems
Deploy 前端和合約成功了,但不知道怎麼 donate to the pool、投票、Create Project、結算等等操作 -> 貌似是直接送交易到合約裡面即可
> 現在出現的 Create New Project 的 Submit 問題應該是 subgraph 或其他設定合約的部分,[**我有把問題 issue 到他們的 github repo 上**](https://github.com/clrfund/monorepo/issues/512),這個部分我不太懂怎麼操作也不知道每個參數的意義,希望會有人回應

---
## 220617
### Next Target
1. Vue.app 佈署到 firebase 可以玩的狀態:[***Link***](https://qf-tw-alpha1.web.app/#/)
2. Contract 佈署到 Layer 1 某個測試鏈,原版是 Arbitrum
```
$ cd contract
$ npx hardhat run --network rinkeby scripts/deployRound.ts
·--------------------------------------|-------------·
| Contract Name · Size (Kb) │
·······································|··············
| Address · 0.08 │
·······································|··············
│ ... · │
·······································|··············
| VerifyTally · 2.33 │
·--------------------------------------|-------------·
*******************
Deploying a new clr.fund instance of contracts!
*******************
deployer.address: 0xB42faBF7BCAE8bc5E368716B568a6f8Fdf3F84ec
maciFactory.address: 0x806EE0951A74E4A3DA61AEfb3600a9e54286A4B8
fundingRoundFactory.address: 0x82BA798f523fF464D8397493Ff97672416ED3A98
userRegistry.address: 0x7340E74cF375B9bDA775eCE372b1C8981164840a
recipientRegistry.address: 0x11Ef1898448376EEC4eE33Bbd83FA775271a4F08
serializedCoordinatorPrivKey: macisk.236bf3b50b07b2444d5f946e8a88d1b8d7e4ac3f49f4d091152d8aaa4dcdc3c7
serializedCoordinatorPubKey: macipk.bed1ddab4f3c710eee1fb561b617b16d75ba27967441b977a00ccfeef544c30a
```
3. Fron-End 做:
* 一個 dev mode:擁有原始 repo 的預設專案
* 一個 client-mode:可以新增專案、官方可開啟結束該輪 Funding 並進行正確結算
5. 有機會的話請教一下 Johnson、Nic、智程老師
6. 搞清楚開發端的流程
### Error De-Problems List
1. 遇到 `clean` command 時如果是 Windows 環境要把 -rm rf 改成 rimraf
2. 遇到 block tag 問題時要把 docker cache(該專案) 刪掉重新啟動便可以重新開始部屬
3. 遇到 docker: find no provider 時是 `docker-compose.yml` 裡面沒有設定好 ethereum: mainnet -> hardhat,這個部分要看目標網域在哪決定