This repository was archived by the owner on Sep 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
feat: bsn fp allowlist #1516
Merged
Merged
feat: bsn fp allowlist #1516
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71e82da
feat: bsn fp allowlist
jeremy-babylonlabs b854b89
fix: resolve comments
jeremy-babylonlabs 27e3810
fix: resolve comments
jeremy-babylonlabs 0d67286
fix: resolve comments
jeremy-babylonlabs 58e2599
fix: resolve comments
jeremy-babylonlabs f894a7e
fix: resolve comments
jeremy-babylonlabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,29 @@ | ||
| import { Bsn } from "../types/bsn"; | ||
| import { getBsnLogoUrl } from "../utils/bsnLogo"; | ||
| import { BsnType } from "../types/bsn"; | ||
|
|
||
| import { apiWrapper } from "./apiWrapper"; | ||
|
|
||
| interface BsnAPI { | ||
| export const BSN_TYPE_COSMOS: BsnType = "COSMOS"; | ||
| export const BSN_TYPE_ROLLUP: BsnType = "ROLLUP"; | ||
|
|
||
| export interface BsnAPI { | ||
| id: string; | ||
| name: string; | ||
| description: string; | ||
| active_tvl: number; | ||
| type: BsnType; | ||
| allowlist?: string[]; // BTC FP pubkeys (hex) | ||
| } | ||
|
|
||
| interface BsnDataResponse { | ||
| data: BsnAPI[]; | ||
| } | ||
|
|
||
| const createBSN = (bsn: BsnAPI): Bsn => ({ | ||
| id: bsn.id, | ||
| name: bsn.name, | ||
| description: bsn.description, | ||
| activeTvl: bsn.active_tvl, | ||
| logoUrl: getBsnLogoUrl(bsn.id), | ||
| }); | ||
|
|
||
| export const getBSNs = async (): Promise<Bsn[]> => { | ||
| export const getBsnAPI = async (): Promise<BsnAPI[]> => { | ||
| const response = await apiWrapper<BsnDataResponse>( | ||
| "GET", | ||
| "/v2/bsn", | ||
| "Error getting BSN list", | ||
| ); | ||
|
|
||
| const { data } = response.data; | ||
| return data.map(createBSN); | ||
| return response.data.data; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import logger from "@/infrastructure/logger"; | ||
| import { getNetworkConfigBBN } from "@/ui/common/config/network/bbn"; | ||
|
|
||
| import { Bsn, BsnType } from "../types/bsn"; | ||
| import { getBsnLogoUrl } from "../utils/bsnLogo"; | ||
|
|
||
| const { chainId: BBN_CHAIN_ID } = getNetworkConfigBBN(); | ||
|
|
||
| export interface BsnFilterOption { | ||
| value: string; | ||
| label: string; | ||
| } | ||
|
|
||
| export interface BsnConfig { | ||
| modalTitle: string; | ||
| filterOptions: BsnFilterOption[]; | ||
| } | ||
|
|
||
| export const BSN_CONFIGS: Record<string, BsnConfig> = { | ||
| // Babylon Genesis | ||
| [BBN_CHAIN_ID]: { | ||
| modalTitle: "Select Babylon Genesis Finality Provider", | ||
| filterOptions: [ | ||
| { value: "active", label: "Active" }, | ||
| { value: "inactive", label: "Inactive" }, | ||
| { value: "jailed", label: "Jailed" }, | ||
| { value: "slashed", label: "Slashed" }, | ||
| ], | ||
| }, | ||
| COSMOS: { | ||
| modalTitle: "Select Cosmos Finality Provider", | ||
| filterOptions: [ | ||
| { value: "registered", label: "Registered" }, | ||
| { value: "slashed", label: "Slashed" }, | ||
| ], | ||
| }, | ||
| // Roll-up BSN config | ||
| ROLLUP: { | ||
| modalTitle: "Select Roll Up Finality Provider", | ||
| filterOptions: [ | ||
| { value: "allowlisted", label: "Allow Listed" }, | ||
| { value: "non-allowlisted", label: "Non-Allow Listed" }, | ||
| { value: "slashed", label: "Slashed" }, | ||
| { value: "jailed", label: "Jailed" }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| /** | ||
| * Get BSN configuration based on BSN type | ||
| */ | ||
| export const getBsnConfig = (bsn?: Bsn): BsnConfig => { | ||
| if (!bsn) return BSN_CONFIGS[BBN_CHAIN_ID]; | ||
|
|
||
| // Check if it's Babylon Genesis first | ||
| if (bsn.id === BBN_CHAIN_ID) { | ||
| return BSN_CONFIGS[BBN_CHAIN_ID]; | ||
| } | ||
|
|
||
| // Use type-based config | ||
| const config = BSN_CONFIGS[bsn.type]; | ||
| if (!config) { | ||
| logger.error(new Error(`BSN config not found for type: ${bsn.type}`), { | ||
| tags: { service: "bsnService", function: "getBsnConfig" }, | ||
| data: { | ||
| bsnType: bsn.type, | ||
| bsnId: bsn.id, | ||
| fallback: "Babylon Genesis config", | ||
| }, | ||
| }); | ||
| return BSN_CONFIGS[BBN_CHAIN_ID]; | ||
| } | ||
| return config; | ||
| }; | ||
|
|
||
| export const createBSN = (bsn: { | ||
| id: string; | ||
| name: string; | ||
| description: string; | ||
| active_tvl: number; | ||
| type: BsnType; | ||
| allowlist?: string[]; | ||
| }): Bsn => ({ | ||
| id: bsn.id, | ||
| name: bsn.name, | ||
| description: bsn.description, | ||
| activeTvl: bsn.active_tvl, | ||
| logoUrl: getBsnLogoUrl(bsn.id), | ||
| type: bsn.type, | ||
| allowlist: bsn.allowlist, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.