Skip to content

Commit

Permalink
fix(taiko-client): fix GetBasefeeV2 usage (#18664)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Dec 27, 2024
1 parent 42cd90d commit 03537c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ func (c *Client) calculateBaseFeeOntake(
if strings.Contains(encoding.TryParsingCustomError(err).Error(), "L2_DEPRECATED_METHOD") {
baseFeeInfo, err := c.TaikoL2.GetBasefeeV2(
&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx},
0,
uint32(l2Head.GasUsed),
*baseFeeConfig,
)
if err != nil {
Expand All @@ -933,6 +933,19 @@ func (c *Client) calculateBaseFeeOntake(
uint32(l2Head.GasUsed),
)
if err != nil {
// If the `calculateBaseFee()` method is deprecated, we will use the new method `getBasefeeV2()`
// to calculate the base fee.
if strings.Contains(encoding.TryParsingCustomError(err).Error(), "L2_DEPRECATED_METHOD") {
baseFeeInfo, err := c.TaikoL2.GetBasefeeV2(
&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx},
uint32(l2Head.GasUsed),
*baseFeeConfig,
)
if err != nil {
return nil, fmt.Errorf("failed to calculate base fee by GetBasefeeV2: %w", err)
}
return baseFeeInfo.Basefee, nil
}
return nil, err
}

Expand Down

0 comments on commit 03537c7

Please sign in to comment.