cosmos-sdk/x/auth/context.go
Ethan Buchman a9b2636439 Coin (#312)
* wip: tests and fixes for kvstore iteration
* update for latest tmlibs
* types compiles
* x/coin almost compiles
* x/coin: move things out of the way so it builds
* rebase fixes
* update glide
* add test for ChainDecorators
2017-12-21 03:31:33 -08:00

34 lines
550 B
Go

package auth
import (
"github.com/cosmos/cosmos-sdk/types"
)
/*
Usage:
import "accounts"
var acc accounts.Account
accounts.SetAccount(ctx, acc)
acc2 := accounts.GetAccount(ctx)
*/
type contextKey int // local to the auth module
const (
// A context key of the Account variety
contextKeyAccount contextKey = iota
)
func SetAccount(ctx types.Context, account Account) types.Context {
return ctx.WithValueSDK(contextKeyAccount, account)
}
func GetAccount(ctx types.Context) Account {
return ctx.Value(contextKeyAccount).(Account)
}