Skip to content

Commit

Permalink
update global params interface (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-babylonlabs authored Oct 29, 2024
1 parent d20b628 commit 153b996
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion internal/clients/bbnclient/bbnclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *BbnClient) GetCheckpointParams(ctx context.Context) (*CheckpointParams,
fmt.Sprintf("failed to validate checkpoint params: %s", err.Error()),
)
}
return &params.Params, nil
return FromBbnCheckpointParams(params.Params), nil
}

func (c *BbnClient) GetAllStakingParams(ctx context.Context) (map[uint32]*StakingParams, *types.Error) {
Expand Down
42 changes: 27 additions & 15 deletions internal/clients/bbnclient/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ import (
// StakingParams represents the staking parameters of the BBN chain
// Reference: https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/btcstaking/v1/params.proto
type StakingParams struct {
CovenantPks []string
CovenantQuorum uint32
MinStakingValueSat int64
MaxStakingValueSat int64
MinStakingTimeBlocks uint32
MaxStakingTimeBlocks uint32
SlashingPkScript string
MinSlashingTxFeeSat int64
SlashingRate string
MinUnbondingTimeBlocks uint32
UnbondingFeeSat int64
MinCommissionRate string
MaxActiveFinalityProviders uint32
DelegationCreationBaseGasFee uint64
CovenantPks []string `bson:"covenant_pks"`
CovenantQuorum uint32 `bson:"covenant_quorum"`
MinStakingValueSat int64 `bson:"min_staking_value_sat"`
MaxStakingValueSat int64 `bson:"max_staking_value_sat"`
MinStakingTimeBlocks uint32 `bson:"min_staking_time_blocks"`
MaxStakingTimeBlocks uint32 `bson:"max_staking_time_blocks"`
SlashingPkScript string `bson:"slashing_pk_script"`
MinSlashingTxFeeSat int64 `bson:"min_slashing_tx_fee_sat"`
SlashingRate string `bson:"slashing_rate"`
MinUnbondingTimeBlocks uint32 `bson:"min_unbonding_time_blocks"`
UnbondingFeeSat int64 `bson:"unbonding_fee_sat"`
MinCommissionRate string `bson:"min_commission_rate"`
MaxActiveFinalityProviders uint32 `bson:"max_active_finality_providers"`
DelegationCreationBaseGasFee uint64 `bson:"delegation_creation_base_gas_fee"`
}

type CheckpointParams struct {
BtcConfirmationDepth uint64 `bson:"btc_confirmation_depth"`
CheckpointFinalizationTimeout uint64 `bson:"checkpoint_finalization_timeout"`
CheckpointTag string `bson:"checkpoint_tag"`
}

func FromBbnStakingParams(params stakingtypes.Params) *StakingParams {
Expand All @@ -45,4 +51,10 @@ func FromBbnStakingParams(params stakingtypes.Params) *StakingParams {
}
}

type CheckpointParams = checkpointtypes.Params
func FromBbnCheckpointParams(params checkpointtypes.Params) *CheckpointParams {
return &CheckpointParams{
BtcConfirmationDepth: params.BtcConfirmationDepth,
CheckpointFinalizationTimeout: params.CheckpointFinalizationTimeout,
CheckpointTag: params.CheckpointTag,
}
}

0 comments on commit 153b996

Please sign in to comment.