mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-09 19:38:07 -05:00
refactor: move the blockchain credential supported networks to the bandada utils package
Since the supported networks are attached to the infrastructure and not to the credential package, they have been to the bandada utils package. re #443
This commit is contained in:
@@ -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.
|
||||
# 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.
|
||||
|
||||
BLOCKCHAIN_SEPOLIA_RPC_URL=
|
||||
BLOCKCHAIN_POLYGON_MUMBAI_RPC_URL=
|
||||
BLOCKCHAIN_OPTIMISM_SEPOLIA_RPC_URL=
|
||||
BLOCKCHAIN_ARBITRUM_SEPOLIA_RPC_URL=
|
||||
SEPOLIA_RPC_URL=
|
||||
POLYGON_MUMBAI_RPC_URL=
|
||||
OPTIMISM_SEPOLIA_RPC_URL=
|
||||
ARBITRUM_SEPOLIA_RPC_URL=
|
||||
|
||||
@@ -18,7 +18,8 @@ jest.mock("@bandada/utils", () => ({
|
||||
logs: ["1"]
|
||||
}),
|
||||
getGroups: () => []
|
||||
})
|
||||
}),
|
||||
blockchainCredentialNetworks: ["Sepolia"]
|
||||
}))
|
||||
|
||||
jest.mock("@bandada/credentials", () => ({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) => (
|
||||
<option value={network}>
|
||||
{network}
|
||||
|
||||
@@ -18,14 +18,7 @@ const provider: BlockchainProvider = {
|
||||
const jsonRpcProvider = getJsonRpcProvider(url)
|
||||
|
||||
return jsonRpcProvider
|
||||
},
|
||||
|
||||
supportedNetworks: [
|
||||
"Sepolia",
|
||||
"Polygon Mumbai",
|
||||
"Optimism Sepolia",
|
||||
"Arbitrum Sepolia"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export default provider
|
||||
|
||||
@@ -57,7 +57,6 @@ export interface Web2Provider extends Provider {
|
||||
export interface BlockchainProvider extends Provider {
|
||||
getAddress: (message: string, signature: string) => Promise<BigNumberish>
|
||||
getJsonRpcProvider: (url: string) => Promise<any>
|
||||
supportedNetworks: string[]
|
||||
}
|
||||
|
||||
export interface EASProvider extends Provider {
|
||||
|
||||
6
libs/utils/src/getSupportedNetworks.ts
Normal file
6
libs/utils/src/getSupportedNetworks.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const blockchainCredentialNetworks: string[] = [
|
||||
"Sepolia",
|
||||
"Polygon Mumbai",
|
||||
"Optimism Sepolia",
|
||||
"Arbitrum Sepolia"
|
||||
]
|
||||
@@ -8,6 +8,7 @@ import getWallet from "./getWallet"
|
||||
import getBandadaContract, { BandadaContract } from "./getBandadaContract"
|
||||
import request from "./request"
|
||||
import shortenAddress from "./shortenAddress"
|
||||
import { blockchainCredentialNetworks } from "./getSupportedNetworks"
|
||||
|
||||
export * from "./types/index"
|
||||
export {
|
||||
@@ -23,5 +24,6 @@ export {
|
||||
CONTRACT_ADDRESSES,
|
||||
getContractAddresses,
|
||||
SemaphoreABI,
|
||||
BandadaABI
|
||||
BandadaABI,
|
||||
blockchainCredentialNetworks
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user