-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(x/minfee): extract go module #4003
Changes from all commits
e2ab361
67a5e07
f4b9a38
51bd8b2
121c91b
af02319
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package minfee | ||
|
||
import sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
const ( | ||
// DefaultNetworkMinGasPrice is used by x/minfee to prevent transactions from being | ||
// included in a block if they specify a gas price lower than this. | ||
// Only applies to app version >= 2 | ||
DefaultNetworkMinGasPrice = 0.000001 // utia | ||
) | ||
|
||
var ( | ||
defaultNetworkMinGasPriceAsDec = sdk.NewDecWithPrec(1, 6) | ||
) | ||
|
||
func DefaultNetworkMinGasPriceAsDec() sdk.Dec { | ||
return defaultNetworkMinGasPriceAsDec | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package minfee | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDefaultNetworkMinGasPriceAsDec(t *testing.T) { | ||
want, err := sdk.NewDecFromStr("0.000001") | ||
assert.NoError(t, err) | ||
|
||
got := DefaultNetworkMinGasPriceAsDec() | ||
assert.Equal(t, want, got) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import ( | |
// DefaultGenesis returns the default genesis state. | ||
func DefaultGenesis() *GenesisState { | ||
return &GenesisState{ | ||
NetworkMinGasPrice: DefaultNetworkMinGasPrice, | ||
NetworkMinGasPrice: DefaultNetworkMinGasPriceAsDec(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Duplicate constant definition and inconsistent type usage needs attention The verification reveals several issues that need to be addressed:
Recommendations:
🔗 Analysis chainLGTM! Improved type safety in genesis state initialization. The change to use Let's verify the consistent usage of this new function across the codebase: Inconsistent usage of DefaultNetworkMinGasPrice detected across the codebase The verification reveals mixed usage of both the old constant 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for any remaining usage of the old DefaultNetworkMinGasPrice
# and verify the new function is used consistently
# Search for any remaining direct usage of DefaultNetworkMinGasPrice
rg "DefaultNetworkMinGasPrice[^A]"
# Search for usage of the new function
rg "DefaultNetworkMinGasPriceAsDec"
Length of output: 1550 Script: #!/bin/bash
# Check the implementation and relationship between both versions
ast-grep --pattern 'func DefaultNetworkMinGasPriceAsDec'
# Check the constant declaration
rg "DefaultNetworkMinGasPrice = " -A 2
Length of output: 362 Script: #!/bin/bash
# Let's check the implementation of DefaultNetworkMinGasPriceAsDec
cat x/minfee/constants.go
# Check if there are any imports of the old constant from pkg/appconsts
rg -p "appconsts.*DefaultNetworkMinGasPrice"
Length of output: 544 |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using a valid semantic version for x/minfee
The dependency version
v0.0.0
might cause issues with Go module resolution. Consider using a proper semantic version (e.g.,v0.1.0
) for the initial release.📝 Committable suggestion