-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(x/photon): validate fee ante decorator (#54)
Relates to #44 This PR adds a `sdk.AnteDecorator` implementation in `x/photon/ante` and adds it to the list of the app ante decorators. This new ante decorator ensures that photon is the fee token or returns an error. Exceptions are possible like if the transaction's messages type URL are present in a new parameter of the photon module `txFeeExceptions`. Some significant changes have been made to the e2e tests to make them compatible with this conditions. `uatone` has also been put in a constant to avoid repetition (in `app/params` package)
- Loading branch information
Showing
32 changed files
with
822 additions
and
227 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,20 @@ | ||
package params | ||
|
||
const ( | ||
BondDenom = "uatone" | ||
|
||
Bech32PrefixAccAddr = "atone" | ||
) | ||
|
||
var ( | ||
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. | ||
Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" | ||
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. | ||
Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper" | ||
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. | ||
Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub" | ||
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. | ||
Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons" | ||
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. | ||
Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub" | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains 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,23 @@ | ||
package v2 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/atomone-hub/atomone/app/upgrades" | ||
photontypes "github.com/atomone-hub/atomone/x/photon/types" | ||
) | ||
|
||
const ( | ||
UpgradeName = "v2" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
// new module added in v2 | ||
photontypes.ModuleName, | ||
}, | ||
}, | ||
} |
This file contains 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,66 @@ | ||
package v2 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
"github.com/atomone-hub/atomone/app/keepers" | ||
) | ||
|
||
// CreateUpgradeHandler returns a upgrade handler for AtomOne v2 | ||
// which executes the following migrations: | ||
// - add new denom metadata for photon in the bank module store. | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("Starting module migrations...") | ||
// RunMigrations will detect the add of the photon module, will initiate | ||
// its genesis and will fill the versionMap with its consensus version. | ||
vm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return vm, err | ||
} | ||
// Add the photon denom metadata to the bank module store | ||
setPhotonDenomMetadata(ctx, keepers.BankKeeper) | ||
ctx.Logger().Info("Upgrade complete") | ||
return vm, nil | ||
} | ||
} | ||
|
||
func setPhotonDenomMetadata(ctx sdk.Context, bk bankkeeper.Keeper) { | ||
ctx.Logger().Info("Adding photon denom metadata...") | ||
bk.SetDenomMetaData(ctx, banktypes.Metadata{ | ||
Base: "uphoton", | ||
Display: "photon", | ||
Name: "AtomOne Photon", | ||
Symbol: "PHOTON", | ||
Description: "The fee token of AtomOne Hub", | ||
DenomUnits: []*banktypes.DenomUnit{ | ||
{ | ||
Denom: "uphoton", | ||
Exponent: 0, | ||
Aliases: []string{ | ||
"microphoton", | ||
}, | ||
}, | ||
{ | ||
Denom: "mphoton", | ||
Exponent: 3, | ||
Aliases: []string{ | ||
"milliphoton", | ||
}, | ||
}, | ||
{ | ||
Denom: "photon", | ||
Exponent: 6, | ||
}, | ||
}, | ||
}) | ||
ctx.Logger().Info("Photon denom metadata added") | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.