diff --git a/apps/api/.env.example b/apps/api/.env.example index 84bbf5f8..616f9534 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -23,10 +23,11 @@ TWITTER_REDIRECT_URI= TWITTER_CLIENT_ID= TWITTER_CLIENT_SECRET= -# The network name must be the same as the supportedNetworks in blockchain provider -# but with capital letters and an underscore instead of a space to separate words. - -BLOCKCHAIN_SEPOLIA_RPC_URL= -BLOCKCHAIN_POLYGON_MUMBAI_RPC_URL= -BLOCKCHAIN_OPTIMISM_SEPOLIA_RPC_URL= -BLOCKCHAIN_ARBITRUM_SEPOLIA_RPC_URL= +# The network name must be the same as the blockchainCredentialNetworks in `getSupportedNetworks` +# in the `@bandada/utils` package but with capital letters and an underscore instead of a space +# to separate words. + +SEPOLIA_RPC_URL= +POLYGON_MUMBAI_RPC_URL= +OPTIMISM_SEPOLIA_RPC_URL= +ARBITRUM_SEPOLIA_RPC_URL= diff --git a/apps/api/src/app/credentials/credentials.service.test.ts b/apps/api/src/app/credentials/credentials.service.test.ts index 57e9175c..b8439a24 100644 --- a/apps/api/src/app/credentials/credentials.service.test.ts +++ b/apps/api/src/app/credentials/credentials.service.test.ts @@ -18,7 +18,8 @@ jest.mock("@bandada/utils", () => ({ logs: ["1"] }), getGroups: () => [] - }) + }), + blockchainCredentialNetworks: ["Sepolia"] })) jest.mock("@bandada/credentials", () => ({ diff --git a/apps/api/src/app/credentials/credentials.service.ts b/apps/api/src/app/credentials/credentials.service.ts index 47d9c4f3..d9ffe496 100644 --- a/apps/api/src/app/credentials/credentials.service.ts +++ b/apps/api/src/app/credentials/credentials.service.ts @@ -7,6 +7,7 @@ import { Web2Context, BlockchainContext } from "@bandada/credentials" +import { blockchainCredentialNetworks } from "@bandada/utils" import { id } from "@ethersproject/hash" import { BadRequestException, @@ -106,14 +107,21 @@ export class CredentialsService { if (address) { const { network } = JSON.parse(group.credentials).criteria + + if ( + !blockchainCredentialNetworks.some( + (n) => n.toLowerCase() === network.toLowerCase() + ) + ) { + throw new BadRequestException(`The network is not supported`) + } + const networkEnvVariableName = (network as string) .split(" ") .join("_") .toUpperCase() const web3providerRpcURL = - process.env[ - `${providerName.toUpperCase()}_${networkEnvVariableName}_RPC_URL` - ] + process.env[`${networkEnvVariableName}_RPC_URL`] const jsonRpcProvider = await ( provider as BlockchainProvider diff --git a/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx b/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx index 13c2c311..5e9dcd6c 100644 --- a/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx +++ b/apps/dashboard/src/components/new-group-stepper/access-mode-step.tsx @@ -1,9 +1,5 @@ -import { - validators, - providers, - Provider, - BlockchainProvider -} from "@bandada/credentials" +import { validators } from "@bandada/credentials" +import { blockchainCredentialNetworks } from "@bandada/utils" import { Box, Button, @@ -248,13 +244,7 @@ export default function AccessModeStep({ }) } > - {( - providers.find( - (provider: Provider) => - provider.name === - "blockchain" - ) as BlockchainProvider - ).supportedNetworks.map( + {blockchainCredentialNetworks.map( (network: string) => (