-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(types): add MustAccAddressFromBech32 util func (#12201)
(cherry picked from commit 82e13b1) # Conflicts: # CHANGELOG.md # server/rosetta/converter.go # simapp/export.go # x/authz/keeper/genesis.go # x/feegrant/simulation/operations.go # x/gov/keeper/deposit.go # x/gov/keeper/msg_server.go # x/gov/keeper/tally.go # x/group/msgs.go # x/group/types.go # x/nft/keeper/genesis.go # x/staking/keeper/delegation.go # x/staking/keeper/genesis.go
- Loading branch information
1 parent
48c2f77
commit 70d04af
Showing
26 changed files
with
1,874 additions
and
124 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,46 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
) | ||
|
||
// InitGenesis new authz genesis | ||
func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) { | ||
now := ctx.BlockTime() | ||
for _, entry := range data.Authorization { | ||
// ignore expired authorizations | ||
if entry.Expiration != nil && entry.Expiration.Before(now) { | ||
continue | ||
} | ||
|
||
grantee := sdk.MustAccAddressFromBech32(entry.Grantee) | ||
granter := sdk.MustAccAddressFromBech32(entry.Granter) | ||
|
||
a, ok := entry.Authorization.GetCachedValue().(authz.Authorization) | ||
if !ok { | ||
panic("expected authorization") | ||
} | ||
|
||
err := k.SaveGrant(ctx, grantee, granter, a, entry.Expiration) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
|
||
// ExportGenesis returns a GenesisState for a given context. | ||
func (k Keeper) ExportGenesis(ctx sdk.Context) *authz.GenesisState { | ||
var entries []authz.GrantAuthorization | ||
k.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool { | ||
entries = append(entries, authz.GrantAuthorization{ | ||
Granter: granter.String(), | ||
Grantee: grantee.String(), | ||
Expiration: grant.Expiration, | ||
Authorization: grant.Authorization, | ||
}) | ||
return false | ||
}) | ||
|
||
return authz.NewGenesisState(entries) | ||
} |
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
Oops, something went wrong.