-
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): mint photon message (#53)
Relates to #44 This PR adds a new message `MsgMintPhoton` inside a new `x/photon` module. List of changes: - `x/photon` queries : `params` & `conversion_rate` - `x/photon` transaction: `MsgMintPhoton` - app plumbing with the new module - Some relative changes were made to the e2e tests to remove anything related to the `stake` denom (use `uatone` instead), which had some impact on other tests that had to be fixed. - Makefile: - target `start-localnet-ci` use `uatone` denom instead of default `stake` - new target `mockgen` to generates the mocks from gov and photon expected keepers --------- Co-authored-by: Giuseppe Natale <[email protected]>
- Loading branch information
Showing
75 changed files
with
5,550 additions
and
180 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
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
Oops, something went wrong.