Skip to content

Commit

Permalink
Merge pull request #748 from clrfund/chore/remove-brightid-sponsorshi…
Browse files Browse the repository at this point in the history
…p-p1

Remove BrightId sponsorship from the front end
  • Loading branch information
yuetloo authored May 8, 2024
2 parents 9ff8f87 + 6a84556 commit 65b4c96
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 573 deletions.
8 changes: 1 addition & 7 deletions contracts/deploy-config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
"OptimisticRecipientRegistry": {
"challengePeriodSeconds": 9007199254740990,
"deposit": "0.001"
},
"BrightIdUserRegistry": {
"deploy": false,
"context": "clrfund-arbitrum-goerli",
"verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c"
}
},
"arbitrum-sepolia": {
Expand All @@ -43,8 +38,7 @@
},
"BrightIdUserRegistry": {
"context": "clrfund-arbitrum-goerli",
"verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c",
"sponsor": "0xC7c81634Dac2de4E7f2Ba407B638ff003ce4534C"
"verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c"
}
}
}
62 changes: 0 additions & 62 deletions contracts/tasks/subtasks/user/03-brightidSponsor.ts

This file was deleted.

14 changes: 5 additions & 9 deletions contracts/tasks/subtasks/user/04-brightidUserRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { EContracts } from '../../../utils/types'
const subtask = Subtask.getInstance()
const storage = ContractStorage.getInstance()

// @TODO remove this on the next major release when the sponsor contract is removed
// Hardcode with a dummy address for now
const BRIGHTID_SPONSOR = '0xC7c81634Dac2de4E7f2Ba407B638ff003ce4534C'

/**
* Deploy step registration and task itself
*/
Expand Down Expand Up @@ -58,15 +62,7 @@ subtask
'verifier'
)

let sponsor = subtask.tryGetConfigField<string>(
EContracts.BrightIdUserRegistry,
'sponsor'
)
if (!sponsor) {
sponsor = storage.mustGetAddress(EContracts.BrightIdSponsor, network)
}

const args = [encodeBytes32String(context), verifier, sponsor]
const args = [encodeBytes32String(context), verifier, BRIGHTID_SPONSOR]
const brightidUserRegistryContract = await subtask.deployContract(
EContracts.BrightIdUserRegistry,
{ signer: deployer, args }
Expand Down
43 changes: 12 additions & 31 deletions docs/brightid.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ USER_REGISTRY_TYPE=brightid

Available envs:

| Network/Env | Context | Sponsor Contract |
| ----------- | ------- | ---------------- |
| arbitrum | clrfund-arbitrum |0x669A55Dd17a2f9F4dacC37C7eeB5Ed3e13f474f9|
| arbitrum rinkeby | clrfund-arbitrum-rinkeby | 0xC7c81634Dac2de4E7f2Ba407B638ff003ce4534C |
| arbitrum sepolia | clrfund-arbitrum-goerli | 0xF1ef516dEa7e6Dd334996726D58029Ee9bAD081D |
| goerli | clrfund-goerli | 0xF045234A776C87060DEEc5689056455A24a59c08 |
| xdai | clrfund-gnosischain |0x669A55Dd17a2f9F4dacC37C7eeB5Ed3e13f474f9|
| Network/Env | Context |
| ----------- | ------- |
| arbitrum | clrfund-arbitrum |
| arbitrum rinkeby | clrfund-arbitrum-rinkeby |
| arbitrum sepolia | clrfund-arbitrum-goerli |
| goerli | clrfund-goerli |
| xdai | clrfund-gnosischain |

```.sh
# /vue-app/.env
Expand All @@ -35,7 +35,6 @@ BRIGHTID_CONTEXT={CONTEXT}
```

Note: the BrightID context is specific to the BrightID network - it's independent from the Ethereum network you choose to run the app on. It refers to the BrightID app context where you want to burn sponsorship tokens.
The `Sponsor Contract` is the contract set up in the BrightID node to track the sponsorship event.

The BrightID context can be found here: https://apps.brightid.org/#nodes

Expand All @@ -55,38 +54,20 @@ BRIGHTID_VERIFIER_ADDR=0xdbf0b2ee9887fe11934789644096028ed3febe9c
By default, the clrfund app will connect to the BrightId node run by clrfund, https://brightid.clr.fund.


**#4 configure the BrightID sponsorship page**
By default, the clrfund app will sponsor the BrightId users using the smart contract event logging method. The `Sponsor` contract is listed in the step #2 above.

Alternatively, you can configure the clrfund app to use the BrightId sponsorship api to submit the sponsorship request directly by setting the following environment variables. Only one of VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY or VITE_BRIGHTID_SPONSOR_KEY needs to be set. If VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY is set, the clrfund app must be deployed to the netlify platform as it will use the netlify serverless function. The netlify option is used if you want to protect the BrightId sponsor key.

The BrightId sponsor key can be generated using the random Nacl keypair at [https://tweetnacl.js.org/#/sign](https://tweetnacl.js.org/#/sign). Give the public key part to the BrightId folks to setup the context and put the private key part in VITE_BRIGHTID_SPONSOR_KEY or VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY.

```.sh
# /vue-app/.env
VITE_BRIGHTID_SPONSOR_API_URL=https://brightid.clr.fund/brightid/v6/operations
VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY=
VITE_BRIGHTID_SPONSOR_KEY=
```

**#5 netlify function setup**
See the [deployment guide](./deploymnet.md) for special setup to use the sponsor netlify function.

## Troubleshooting linking failure
### Sponsorship timeout
1. check for sponsorship status https://app.brightid.org/node/v6/sponsorships/WALLET_ADDRESS
2. check for sponsorship status from clrfund's brightid node:
### General linking error
1. check for sponsorship status from clrfund's brightid node:
- https://brightid.clr.fund/brightid/v6/sponsorships/WALLET_ADDRESS
3. check the clrfund's brightid node docker logs
2. check the clrfund's brightid node docker logs
- look for sponsorship event listening error
```.sh
docker logs --since 1440m brightid-node-docker-db-1
```
4. check for sponsorship token balance
3. check for sponsorship token balance
- for clrfund-arbitrum context: https://brightid.clr.fund/brightid/v6/apps/clrfund-arbitrum
### Signature is not valid
1. Check that the verifier address is correct, it is the `ethSigningAddress` from https://brightid.clr.fund
2. You can update the verifier address using `sponsorContract.setSettings()`
2. You can update the verifier address using `BrightIdUserRegistryContract.setSettings()`
## Resources
Expand Down
13 changes: 0 additions & 13 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ Note: select the `hex address (ONLY)` option to identify users and the `meet` ve

Once the app is registered, you will get an appId which will be set to `BRIGHTID_CONTEXT` when deploying the contracts in later steps.

### Setup BrightID sponsorship keys

1. Generate sponsorship signing keys here: https://tweetnacl.js.org/#/sign
2. Provide the public key to BrightID support through their discord channel: https://discord.gg/QW7ThZ5K4V
3. Save the private key for setting up the clrfund user interface in environment variable: `VITE_BRIGHTID_SPONSOR_KEY`


## Deploy Contracts

Goto the `contracts` folder.
Expand Down Expand Up @@ -161,8 +154,6 @@ VITE_SUBGRAPH_URL=
VITE_CLRFUND_ADDRESS=
VITE_USER_REGISTRY_TYPE=
VITE_BRIGHTID_CONTEXT=
VITE_BRIGHTID_SPONSOR_KEY=
VITE_BRIGHTID_SPONSOR_API_URL=https://brightid.clr.fund/brightid/v6/operations
VITE_RECIPIENT_REGISTRY_TYPE=
# see google-sheets.md for instruction on how to set these
Expand All @@ -177,10 +168,6 @@ VITE_GOOGLE_SPREADSHEET_ID=

See [How to set netlify function directory](https://docs.netlify.com/functions/optional-configuration/?fn-language=ts)

2. Set environment variable: `AWS_LAMBDA_JS_RUNTIME=nodejs18.x`

This environment variable is needed for the `sponsor.js` function. If not set, it will throw error `fetch not found`.


#### Deploy on IPFS

Expand Down
12 changes: 0 additions & 12 deletions vue-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,11 @@ VITE_USER_REGISTRY_TYPE=simple
VITE_BRIGHTID_CONTEXT=clrfund-goerli


# These are for interacting with the BrightID api. When the SPONSOR_API_URL and one of the
# SPONSOR_KEY is set, a sponsor request will be sent to the BrightID node when the QR code
# to link users wallet address to BrightID is displayed. SPONSOR_KEY is used to sign the
# sponsor request. The SPONSOR_KEY_FOR_NETLIFY will trigger the netlify serverless function
# to send the sponsor request. The SPONSOR_KEY alone will send the request directly from
# the web app without using the netlify function.
# VITE_BRIGHTID_NODE_URL is the BrightID node used to query BrightID status. It needs to
# match the BRIGHTID_VERIFIER_ADDR defined in the contract .env file. This address is used
# to verify the signature returned from the BrightID verification status for user registration.
# The BRIGHTID_VERIFIER_ADDR value is the ethSigningAddress from the node url,
# e.g. https://brightid.clr.fund
#VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY=
#VITE_BRIGHTID_SPONSOR_KEY=
#VITE_BRIGHTID_SPONSOR_API_URL=https://brightid.clr.fund/brightid/v6/operations

# BrightId node one url, default to clrfund node at https://brightid.clr.fund/brightid/v6
#VITE_BRIGHTID_NODE_URL=https://app.brightid.org/node/v6
Expand Down Expand Up @@ -75,9 +66,6 @@ GOOGLE_SHEET_NAME=
# the number of record to export in a pending submissions JSON file. Default 60.
VITE_EXPORT_BATCH_SIZE=

# This is only used for netlify function, sponsor.js, to avoid getting the 'fetch not found' error
AWS_LAMBDA_JS_RUNTIME=nodejs18.x

# walletconnect project id
VITE_WALLET_CONNECT_PROJECT_ID=walletconnect_project_id

Expand Down
Loading

0 comments on commit 65b4c96

Please sign in to comment.