feat: support avalanche c chain in the blockchain credential

The blockchainCredentialSupportedNetworks variable type changed to make it easier to identify a
network and display its name.

re #451
This commit is contained in:
Vivian Plasencia
2024-03-27 17:29:28 +01:00
parent 0c1128c76c
commit 9e77800332
5 changed files with 44 additions and 22 deletions

View File

@@ -23,11 +23,11 @@ TWITTER_REDIRECT_URI=
TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=
# The network name must be the same as what appears in the `blockchainCredentialSupportedNetworks` list
# exported from the `@bandada/utils` package but with capital letters and an underscore
# instead of a space to separate words.
# The network name must be the same as the id that appears in the `blockchainCredentialSupportedNetworks` list
# exported from the `@bandada/utils` package but with capital letters. E.g. polygon_mumbai would be POLYGON_MUMBAI.
SEPOLIA_RPC_URL=
POLYGON_MUMBAI_RPC_URL=
OPTIMISM_SEPOLIA_RPC_URL=
ARBITRUM_SEPOLIA_RPC_URL=
AVALANCHE_C_CHAIN_FUJI_RPC_URL=

View File

@@ -108,18 +108,15 @@ export class CredentialsService {
if (address) {
const { network } = JSON.parse(group.credentials).criteria
if (
!blockchainCredentialSupportedNetworks.some(
(n) => n.toLowerCase() === network.toLowerCase()
)
) {
throw new BadRequestException(`The network is not supported`)
}
const supportedNetwork = blockchainCredentialSupportedNetworks.find(
(n) => n.name.toLowerCase() === network.toLowerCase()
)
if (supportedNetwork === undefined)
throw new BadRequestException(`The network is not supported`)
const networkEnvVariableName = supportedNetwork.id.toUpperCase()
const networkEnvVariableName = (network as string)
.split(" ")
.join("_")
.toUpperCase()
const web3providerRpcURL =
process.env[`${networkEnvVariableName}_RPC_URL`]

View File

@@ -245,9 +245,11 @@ export default function AccessModeStep({
}
>
{blockchainCredentialSupportedNetworks.map(
(network: string) => (
<option value={network}>
{network}
(network: any) => (
<option
value={network.name}
>
{network.name}
</option>
)
)}

View File

@@ -1,6 +1,24 @@
export const blockchainCredentialSupportedNetworks: string[] = [
"Sepolia",
"Polygon Mumbai",
"Optimism Sepolia",
"Arbitrum Sepolia"
import type { BlockchainNetwork } from "./types"
export const blockchainCredentialSupportedNetworks: BlockchainNetwork[] = [
{
id: "sepolia",
name: "Sepolia"
},
{
id: "polygon_mumbai",
name: "Polygon Mumbai"
},
{
id: "optimism_sepolia",
name: "Optimism Sepolia"
},
{
id: "arbitrum_sepolia",
name: "Arbitrum Sepolia"
},
{
id: "avalanche_c_chain_fuji",
name: "Avalanche C-Chain Fuji"
}
]

View File

@@ -7,3 +7,8 @@ export type OnchainBandadaGroup = {
id: BigInt
fingerprint: BigInt
}
export type BlockchainNetwork = {
id: string
name: string
}