diff --git a/contracts/deploy-config-example.json b/contracts/deploy-config-example.json index 77032cfed..4fbcc8441 100644 --- a/contracts/deploy-config-example.json +++ b/contracts/deploy-config-example.json @@ -16,11 +16,6 @@ "OptimisticRecipientRegistry": { "challengePeriodSeconds": 9007199254740990, "deposit": "0.001" - }, - "BrightIdUserRegistry": { - "deploy": false, - "context": "clrfund-arbitrum-goerli", - "verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c" } }, "arbitrum-sepolia": { @@ -43,8 +38,7 @@ }, "BrightIdUserRegistry": { "context": "clrfund-arbitrum-goerli", - "verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c", - "sponsor": "0xC7c81634Dac2de4E7f2Ba407B638ff003ce4534C" + "verifier": "0xdbf0b2ee9887fe11934789644096028ed3febe9c" } } } diff --git a/contracts/tasks/subtasks/user/03-brightidSponsor.ts b/contracts/tasks/subtasks/user/03-brightidSponsor.ts deleted file mode 100644 index 9482a449e..000000000 --- a/contracts/tasks/subtasks/user/03-brightidSponsor.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Deploy an instance of the BrightID sponsor contract - * - */ -import { ContractStorage } from '../../helpers/ContractStorage' -import { Subtask } from '../../helpers/Subtask' -import { EContracts } from '../../../utils/types' - -const subtask = Subtask.getInstance() -const storage = ContractStorage.getInstance() - -/** - * Deploy step registration and task itself - */ -subtask - .addTask('user:deploy-brightid-sponsor', 'Deploy BrightID sponsor contract') - .setAction(async (_, hre) => { - subtask.setHre(hre) - const deployer = await subtask.getDeployer() - - const userRegistryName = subtask.getConfigField( - EContracts.ClrFund, - 'userRegistry' - ) - - if (userRegistryName !== EContracts.BrightIdUserRegistry) { - return - } - - let brightidSponsorContractAddress = subtask.tryGetConfigField( - EContracts.BrightIdUserRegistry, - 'sponsor' - ) - - if (brightidSponsorContractAddress) { - console.log( - `Skip BrightIdSponsor deployment, use ${brightidSponsorContractAddress}` - ) - return - } - - brightidSponsorContractAddress = storage.getAddress( - EContracts.BrightIdSponsor, - hre.network.name - ) - - if (brightidSponsorContractAddress) { - return - } - - const BrightIdSponsorContract = await subtask.deployContract( - EContracts.BrightIdSponsor, - { signer: deployer } - ) - - await storage.register({ - id: EContracts.BrightIdSponsor, - contract: BrightIdSponsorContract, - args: [], - network: hre.network.name, - }) - }) diff --git a/contracts/tasks/subtasks/user/04-brightidUserRegistry.ts b/contracts/tasks/subtasks/user/04-brightidUserRegistry.ts index 6db98dc2c..73f1ce259 100644 --- a/contracts/tasks/subtasks/user/04-brightidUserRegistry.ts +++ b/contracts/tasks/subtasks/user/04-brightidUserRegistry.ts @@ -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 */ @@ -58,15 +62,7 @@ subtask 'verifier' ) - let sponsor = subtask.tryGetConfigField( - 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 } diff --git a/docs/brightid.md b/docs/brightid.md index efd01636d..5c84d799e 100644 --- a/docs/brightid.md +++ b/docs/brightid.md @@ -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 @@ -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 @@ -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 diff --git a/docs/deployment.md b/docs/deployment.md index 4ddb0ccc1..284076f84 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -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. @@ -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 @@ -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 diff --git a/vue-app/.env.example b/vue-app/.env.example index 26689edf3..a1da8a51b 100644 --- a/vue-app/.env.example +++ b/vue-app/.env.example @@ -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 @@ -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 diff --git a/vue-app/src/api/bright-id.ts b/vue-app/src/api/bright-id.ts index 0aba9a8ad..10330c6fe 100644 --- a/vue-app/src/api/bright-id.ts +++ b/vue-app/src/api/bright-id.ts @@ -2,7 +2,7 @@ import { Contract, encodeBytes32String, toUtf8Bytes, decodeBase64, encodeBase64 import type { TransactionResponse, Signer } from 'ethers' import { BrightIdUserRegistry } from './abi' -import { brightIdSponsorKey, brightIdNodeUrl } from './core' +import { brightIdNodeUrl } from './core' import nacl from 'tweetnacl' const BRIGHTID_APP_URL = 'https://app.brightid.org' @@ -44,55 +44,6 @@ export interface Verification { app: string } -export interface Sponsorship { - timestamp: number - app: string - appHasAuthorized: boolean - spendRequested: boolean -} - -type AppData = { - id: string - name: string - context?: string - verification: string - verifications?: string[] - verificationsUrl: string - logo?: string - url?: string - assignedSponsorships?: number - unusedSponsorships?: number - testing?: boolean - idAsHex?: boolean - usingBlindSig?: boolean - verificationExpirationLength?: number - sponsorPublicKey?: string - nodeUrl?: string - soulbound: boolean - callbackUrl?: string -} - -type SponsorOperation = { - name: string - app: string - appUserId: string - timestamp: number - v: number - sig?: string -} - -type SponsorData = { - hash?: string - error?: string -} - -export async function selfSponsor(registryAddress: string, signer: Signer): Promise { - const registry = new Contract(registryAddress, BrightIdUserRegistry, signer) - const userAddress = await signer.getAddress() - const transaction = await registry.sponsor(userAddress) - return transaction -} - // This link is for generating QR code export function getBrightIdLink(userAddress: string): string { const deepLink = `brightid://link-verification/${CONTEXT}/${userAddress}` @@ -166,129 +117,3 @@ export async function getBrightId(contextId: string): Promise { } return brightId } - -/** - * Get the unused sponsorship amount - * @param context - the context to retrieve unused sponsorships for - * - * @returns Returns the number of sponsorships available to the specified `context` - */ -async function unusedSponsorships(context: string): Promise { - const endpoint = `${NODE_URL}/apps/${context}` - const response = await fetch(endpoint) - const json = await response.json() - - if (json['errorMessage']) { - throw new Error(JSON.stringify(json)) - } - - const data = json['data'] as AppData - return data.unusedSponsorships || 0 -} - -/** - * Call the BrightID sponsor operation endpoint to put a sponsorship request for the user - * @param userAddress user wallet address - * @returns sponsporship result or error - */ -export async function brightIdSponsor(userAddress: string): Promise { - const endpoint = `${NODE_URL}/operations` - - if (!brightIdSponsorKey) { - return { error: 'BrightId sponsor key not set' } - } - - const sponsorships = await unusedSponsorships(CONTEXT) - if (typeof sponsorships === 'number' && sponsorships < 1) { - return { error: 'BrightID sponsorships not available' } - } - - if (typeof sponsorships !== 'number') { - return { error: 'Invalid BrightID sponsorship' } - } - - const timestamp = Date.now() - - // these fields must be in alphabetical because - // BrightID nodes use 'fast-json-stable-stringify' that sorts fields - const op: SponsorOperation = { - app: CONTEXT, - appUserId: userAddress, - name: 'Sponsor', - timestamp, - v: 6, - } - - const message = JSON.stringify(op) - const arrayedMessage = toUtf8Bytes(message) - const arrayedKey = decodeBase64(brightIdSponsorKey) - const signature = nacl.sign.detached(arrayedMessage, arrayedKey) - op.sig = encodeBase64(signature) - - const res = await fetch(endpoint, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(op), - }) - const json = await res.json() - - if (json['error']) { - if (canIgnoreError(json.errorNum)) { - // sponsorship already sent recently, ignore this error - return { hash: '0x0' } - } - return { error: json['errorMessage'] } - } else { - return json['data'] - } -} - -/** - * Call the netlify function to invoke the BrightId sponsor api - * @param userAddress user wallet address - * @returns sponsorship data or error - */ -async function netlifySponsor(userAddress: string): Promise { - const res = await fetch('/.netlify/functions/sponsor', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ userAddress }), - }) - - const json = await res.json() - if (res.status === 200) { - return json - } - - if (res.status === 400 && canIgnoreError(json.errorNum)) { - return { hash: '0x0' } - } - - // return the error - return json -} - -/** - * Sponsor a BrightID user using the sponsorship api - * @param userAddress user wallet address - * @returns sponsporship result or error - */ -export async function sponsorUser(userAddress: string): Promise { - if (brightIdSponsorKey) { - return brightIdSponsor(userAddress) - } - - try { - return await netlifySponsor(userAddress) - } catch (err) { - if (err instanceof Error) { - return { error: (err as Error).message } - } else { - return { error: 'Unknown sponsorhip error' } - } - } -} diff --git a/vue-app/src/api/core.ts b/vue-app/src/api/core.ts index 6d79b2785..4b5073c10 100644 --- a/vue-app/src/api/core.ts +++ b/vue-app/src/api/core.ts @@ -73,10 +73,8 @@ export const maxDecimals = Number(import.meta.env.VUE_APP_MAX_DECIMAL || 1) // the number of records per batch in the `pending submissions` export file export const exportBatchSize = Number(import.meta.env.VITE_EXPORT_BATCH_SIZE) || 60 -// BrightId sponsorhip stuff, set these parameters to automatically sponsor user using the brightId URL -export const brightIdSponsorKey = import.meta.env.VITE_BRIGHTID_SPONSOR_KEY +// BrightId url for querying user verification export const brightIdNodeUrl = import.meta.env.VITE_BRIGHTID_NODE_URL || 'https://brightid.clr.fund/brightid/v6' -export const brightIdSponsorUrl = import.meta.env.VITE_BRIGHTID_SPONSOR_API_URL // wait for data to sync with the subgraph export const MAX_WAIT_DEPTH = Number(import.meta.env.VITE_MAX_WAIT_DEPTH) || 15 diff --git a/vue-app/src/lambda/sponsor.mts b/vue-app/src/lambda/sponsor.mts deleted file mode 100644 index 5d460e17a..000000000 --- a/vue-app/src/lambda/sponsor.mts +++ /dev/null @@ -1,137 +0,0 @@ -import { decodeBase64, encodeBase64, toUtf8Bytes } from 'ethers' -import nacl from 'tweetnacl' -import type { Handler } from '@netlify/functions' - -const NODE_URL = process.env.VITE_BRIGHTID_NODE_URL || 'https://app.brightid.org/node/v6' - -// these fields must be in alphabetical because -// BrightID nodes use 'fast-json-stable-stringify' that sorts fields -type BrightIDMessage = { - app: string - appUserId: string - name: string - sig?: string - timestamp: number - v: number -} - -/** - * Returns an error object - * @param errorMessage error message - * @returns error object - */ -function makeError(errorMessage: string, errorNum: number) { - const body = JSON.stringify({ error: errorMessage, errorNum }) - return { statusCode: 400, body } -} - -/** - * Returns the result with statusCode and body - * @param result the result - * @returns result object - */ -function makeResult(result: any) { - const body = JSON.stringify(result) - return { statusCode: 200, body } -} - -/** - * Get the unused sponsorship amount - * @param context - the context to retrieve unused sponsorships for - * - * @returns the number of sponsorships available to the specified `context` - */ -async function unusedSponsorships(context: string) { - const endpoint = `${NODE_URL}/apps/${context}` - const response = await fetch(endpoint) - const json = await response.json() - - if (json['errorMessage']) { - throw new Error(JSON.stringify(json)) - } - - const data = json['data'] - return data.unusedSponsorships || 0 -} - -async function handleSponsorRequest(userAddress: string) { - const endpoint = process.env.VITE_BRIGHTID_SPONSOR_API_URL - if (!endpoint) { - throw new Error('Environment variable VITE_BRIGHTID_SPONSOR_API_URL not set') - } - - const brightIdSponsorKey = process.env.VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY - if (!brightIdSponsorKey) { - throw new Error('Environment variable VITE_BRIGHTID_SPONSOR_KEY_FOR_NETLIFY not set') - } - - const CONTEXT = process.env.VITE_BRIGHTID_CONTEXT - if (!CONTEXT) { - throw new Error('Environment variable VITE_BRIGHTID_CONTEXT not set') - } - - const sponsorships = await unusedSponsorships(CONTEXT) - if (typeof sponsorships === 'number' && sponsorships < 1) { - throw new Error('BrightID sponsorships not available') - } - if (typeof sponsorships !== 'number') { - throw new Error('Invalid BrightID sponsorship') - } - - const timestamp = Date.now() - - const op: BrightIDMessage = { - app: CONTEXT, - appUserId: userAddress, - name: 'Sponsor', - timestamp, - v: 6, - } - - const message = JSON.stringify(op) - const arrayedMessage = toUtf8Bytes(message) - const arrayedKey = decodeBase64(brightIdSponsorKey) - const signature = nacl.sign.detached(arrayedMessage, arrayedKey) - op.sig = encodeBase64(signature) - - const res = await fetch(endpoint, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(op), - }) - const json = await res.json() - - if (json.error) { - return makeError(json.errorMessage, json.errorNum) - } - - if (json.data) { - return makeResult({ hash: json.data.hash }) - } - - return makeError('Unexpected result from the BrightID sponsorship API.', 500) -} - -/** - * Submit a sponsorship request using the BrightID api - * @param event contains user address to sponsor - * @returns sponsor data or error - */ -export const handler: Handler = async event => { - if (!event.body) { - return makeError('Missing request body', 400) - } - - try { - const jsonBody = JSON.parse(event.body) - if (!jsonBody.userAddress) { - return makeError('Missing userAddress in request body: ' + event.body, 400) - } - - return await handleSponsorRequest(jsonBody.userAddress) - } catch (err) { - return makeError(err.message, 500) - } -} diff --git a/vue-app/src/locales/cn.json b/vue-app/src/locales/cn.json index dbc945f34..63d63539e 100644 --- a/vue-app/src/locales/cn.json +++ b/vue-app/src/locales/cn.json @@ -803,15 +803,10 @@ "p7": "为了防止受贿和欺诈,您需要将您的钱包地址添加到智能合约注册表中。完成后,您就可以参加筹款活动了!", "btn": " 成为捐赠者", "next": "下一步", - "previous": "前一步", "copy_link": "复制", "verification_status": "您的钱包地址没有连接到 BrightID 的户口。 这可能需要几分钟的时间,稍等候后点击按钮再试。", "getting_proof": "正在获取验证证明...", - "not_authorized": "您没有权限注册", - "skip_sponsorship": "跳过", - "get_sponsored_header": "赞助", - "get_sponsored_text": "您需要一个赞助令牌才能为 BrightID 认证。这有助于支持 BrightID 作为去中心化平台。您只需这样做一次, 就可以应用任何 BrightID APPS。检查 BrightID 移动应用程序,看看您是否受到赞助。如果没有,请点击按钮提交赞助请求。如果您已受到赞助,您可跳过这一步。", - "get_sponsored_cta": "赞助" + "not_authorized": "您没有权限注册" }, "verifyLanding": { "h1": "证明您只使用一个帐户", diff --git a/vue-app/src/locales/en.json b/vue-app/src/locales/en.json index 3811acfbc..8462655d5 100644 --- a/vue-app/src/locales/en.json +++ b/vue-app/src/locales/en.json @@ -803,15 +803,10 @@ "p7": "To protect the round from bribery and fraud, you need to add your wallet address to a smart contract registry. Once you’re done, you can join the funding round!", "btn": " Become a contributor", "next": "Next", - "previous": "Previous", "copy_link": "Copy Link", "verification_status": "Your wallet address is not linked with BrightID. It may take a few minutes to verify the connection, please wait and click the button later to check the status.", "getting_proof": "Retrieving the verification proof...", - "not_authorized": "You are not authorized to register", - "skip_sponsorship": "Skip", - "get_sponsored_header": "Get sponsored", - "get_sponsored_text": "You need a sponsorship token to connect your wallet address with BrightID. This helps support BrightID as a decentralized platform. You’ll only ever need to do this once and it covers you for any other app that works with BrightID. Check the BrightID mobile app to see if you're sponsored. Get sponsored by submitting a sponsorship transaction or skip to the next step.", - "get_sponsored_cta": "Get Sponsored" + "not_authorized": "You are not authorized to register" }, "verifyLanding": { "h1": "Prove you’re only using one account", diff --git a/vue-app/src/locales/es.json b/vue-app/src/locales/es.json index ae103f13e..d76cba03a 100644 --- a/vue-app/src/locales/es.json +++ b/vue-app/src/locales/es.json @@ -803,15 +803,10 @@ "p7": "Para proteger la ronda de sobornos y fraudes, debes agregar la dirección de tu billetera a un registro de contrato inteligente. ¡Una vez que hayas terminado, puedes unirte a la ronda de financiamiento!", "btn": "Conviértete en colaborador", "next": "Siguiente", - "previous": "Anterior", "copy_link": "Copiar Enlace", "verification_status": "Tu dirección de billetera no está vinculada con BrightID. Puede tomar unos minutos verificar la conexión, por favor espera y haz clic en el botón más tarde para verificar el estado.", "getting_proof": "Recuperando la prueba de verificación...", - "not_authorized": "No está autorizado/a para registrarse", - "skip_sponsorship": "Saltar", - "get_sponsored_header": "Obtén un patrocinio", - "get_sponsored_text": "Necesitas un token de patrocinio para conectar tu dirección de billetera con BrightID. Esto ayuda a apoyar a BrightID como una plataforma descentralizada. Solo necesitarás hacer esto una vez y te cubrirá para cualquier otra aplicación que funcione con BrightID. Verifica en la aplicación móvil de BrightID si estás patrocinado. Obtén patrocinio al enviar una transacción de patrocinio o salta al siguiente paso.", - "get_sponsored_cta": "Obtener Patrocinio" + "not_authorized": "No está autorizado/a para registrarse" }, "verifyLanding": { "h1": "Demuestra que solo usas una cuenta", diff --git a/vue-app/src/views/Verify.vue b/vue-app/src/views/Verify.vue index c3ea80179..9fa25f2f6 100644 --- a/vue-app/src/views/Verify.vue +++ b/vue-app/src/views/Verify.vue @@ -56,30 +56,6 @@
-
-

{{ $t('verify.get_sponsored_header') }}

-

- {{ $t('verify.get_sponsored_text') }} -

-
-
-
- - -
-
{{ sponsorTxError }}
-
-
-

{{ $t('verify.h2_1') }}

@@ -88,16 +64,8 @@

{{ $t('verify.click_next') }}

- -
- +

{{ $t('verify.p4') }} @@ -124,14 +92,6 @@

- @@ -176,7 +136,7 @@ import { ref, computed, onMounted, watch } from 'vue' import ProgressBar from '@/components/ProgressBar.vue' import QRCode from 'qrcode' -import { getBrightIdLink, getBrightIdUniversalLink, registerUser, selfSponsor, sponsorUser } from '@/api/bright-id' +import { getBrightIdLink, getBrightIdUniversalLink, registerUser } from '@/api/bright-id' import { getProofSnapshot, getProofMerkle, registerUserSnapshot, registerUserMerkle } from '@/api/user' import Transaction from '@/components/Transaction.vue' import Loader from '@/components/Loader.vue' @@ -185,19 +145,17 @@ import { waitForTransaction } from '@/utils/contracts' import { useAppStore, useUserStore } from '@/stores' import { storeToRefs } from 'pinia' import { useRouter } from 'vue-router' -import { UserRegistryType, isBrightIdRequired, brightIdSponsorUrl, userRegistryType } from '@/api/core' +import { UserRegistryType, isBrightIdRequired, userRegistryType } from '@/api/core' import { assert } from '@/utils/assert' interface VerificationStep { - page: 'connect' | 'registration' | 'sponsorship' + page: 'connect' | 'registration' } function getVerificationSteps(): Array { switch (userRegistryType) { case UserRegistryType.BRIGHT_ID: - return brightIdSponsorUrl - ? [{ page: 'connect' }, { page: 'registration' }] - : [{ page: 'sponsorship' }, { page: 'connect' }, { page: 'registration' }] + return [{ page: 'connect' }, { page: 'registration' }] default: return [{ page: 'registration' }] } @@ -224,11 +182,7 @@ const registrationTxError = ref('') const notAuthorized = ref(false) const loadingTx = ref(false) const gettingProof = ref(false) -const isSponsoring = ref(!brightIdSponsorUrl) const showVerificationStatus = ref(false) -const autoSponsorError = ref('') -const sponsorTxError = ref('') -const selfSponsorTxHash = ref('') const brightId = computed(() => currentUser.value?.brightId) @@ -237,9 +191,6 @@ const currentStep = computed(() => { if (!brightId.value) { return 0 } - if (isSponsoring.value) { - return stepNumbers['sponsorship'] - } if (!brightId.value.isVerified) { return stepNumbers['connect'] } @@ -255,19 +206,6 @@ const currentPage = computed(() => { return steps[currentStep.value].page }) -// if the sponsor url is not defined, we are doing self sponsorship, show the button -// to allow users to go back to that page -const showBackToSponsorshipButton = !brightIdSponsorUrl - -function backToSponsorship() { - isSponsoring.value = true - showVerificationStatus.value = false -} - -function skipSponsorship() { - isSponsoring.value = false -} - async function checkVerificationStatus() { showVerificationStatus.value = false await userStore.loadBrightID() @@ -295,24 +233,8 @@ onMounted(async () => { // mounted if (isBrightIdRequired && currentUser.value && !brightId.value?.isVerified) { const walletAddress = currentUser.value.walletAddress - // send sponsorship request if automatic sponsoring is enabled - if (brightIdSponsorUrl) { - try { - const res = await sponsorUser(walletAddress) - if (!res.hash) { - autoSponsorError.value = res.error ? res.error : JSON.stringify(res) - return - } - } catch (err) { - const errorMessage = (err as Error).message - autoSponsorError.value = - 'Unable to sponsor user. Make sure the brightId node is setup correctly.' + errorMessage - return - } - } // Present app link and QR code - appLink.value = getBrightIdUniversalLink(walletAddress) const qrcodeLink = getBrightIdLink(walletAddress) QRCode.toDataURL(qrcodeLink, (error, url: string) => { @@ -329,26 +251,6 @@ watch(currentUser, () => { } }) -async function selfSponsorAndWait() { - if (!userRegistryAddress.value) { - sponsorTxError.value = 'Missing the user registry address' - return - } - - const signer = await userStore.getSigner() - loadingTx.value = true - sponsorTxError.value = '' - - try { - await waitForTransaction(selfSponsor(userRegistryAddress.value, signer), hash => (selfSponsorTxHash.value = hash)) - isSponsoring.value = false - } catch (error) { - sponsorTxError.value = (error as Error).message - } finally { - loadingTx.value = false - } -} - async function register() { const signer = await userStore.getSigner() @@ -418,8 +320,6 @@ function isStepUnlocked(step: number): boolean { const stepName = steps[step].page switch (stepName) { - case 'sponsorship': - return !isSponsoring.value case 'connect': return !!currentUser.value?.brightId?.isVerified case 'registration':