diff --git a/CHANGELOG.md b/CHANGELOG.md index e7bd59d0a9..745a40b75f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,9 +48,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (client) [\#817](https://github.com/line/lbm-sdk/pull/817) remove support for composite (BLS) type -* (x/foundation) [#834](https://github.com/line/lbm-sdk/pull/834) Apply foundation audit -* (x/collection,token) [#849](https://github.com/line/lbm-sdk/pull/849) Introduce codespace into x/collection,token -* (x/token,collection) [#863](https://github.com/line/lbm-sdk/pull/863) Update x/collection,token proto +* (x/foundation) [\#834](https://github.com/line/lbm-sdk/pull/834) Apply foundation audit +* (x/collection,token) [\#849](https://github.com/line/lbm-sdk/pull/849) Introduce codespace into x/collection,token +* (x/token,collection) [\#863](https://github.com/line/lbm-sdk/pull/863) Update x/collection,token proto +* (x/collection,token) [\#866](https://github.com/line/lbm-sdk/pull/866) Do not create account on x/token,collection ### Removed * [\#853](https://github.com/line/lbm-sdk/pull/853) remove useless stub BeginBlock, EndBlock methods from modules below @@ -59,8 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Breaking Changes * (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API - -* (codec) [#833](https://github.com/line/lbm-sdk/pull/833) Fix foundation amino codec +* (codec) [\#833](https://github.com/line/lbm-sdk/pull/833) Fix foundation amino codec ### Build, CI * (ci) [\#829](https://github.com/line/lbm-sdk/pull/829) automate release process diff --git a/simapp/app.go b/simapp/app.go index d65171d6ec..a72f2509ff 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -315,8 +315,8 @@ func NewSimApp( app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundationConfig, foundation.DefaultAuthority().String()) app.ClassKeeper = classkeeper.NewKeeper(appCodec, keys[class.StoreKey]) - app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.AccountKeeper, app.ClassKeeper) - app.CollectionKeeper = collectionkeeper.NewKeeper(appCodec, keys[collection.StoreKey], app.AccountKeeper, app.ClassKeeper) + app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.ClassKeeper) + app.CollectionKeeper = collectionkeeper.NewKeeper(appCodec, keys[collection.StoreKey], app.ClassKeeper) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks diff --git a/x/collection/expected_keepers.go b/x/collection/expected_keepers.go index 458b1e7bdf..3de4c66e52 100644 --- a/x/collection/expected_keepers.go +++ b/x/collection/expected_keepers.go @@ -2,18 +2,9 @@ package collection import ( sdk "github.com/line/lbm-sdk/types" - authtypes "github.com/line/lbm-sdk/x/auth/types" ) type ( - // AccountKeeper defines the contract required for account APIs. - AccountKeeper interface { - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, account authtypes.AccountI) - - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - } - // ClassKeeper defines the contract needed to be fulfilled for class dependencies. ClassKeeper interface { NewID(ctx sdk.Context) string diff --git a/x/collection/keeper/keeper.go b/x/collection/keeper/keeper.go index 3559f5d59b..9ec4a326a8 100644 --- a/x/collection/keeper/keeper.go +++ b/x/collection/keeper/keeper.go @@ -2,7 +2,6 @@ package keeper import ( "github.com/line/lbm-sdk/codec" - "github.com/line/lbm-sdk/telemetry" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/x/collection" "github.com/line/lbm-sdk/x/token/class" @@ -10,8 +9,7 @@ import ( // Keeper defines the collection module Keeper type Keeper struct { - accountKeeper collection.AccountKeeper - classKeeper collection.ClassKeeper + classKeeper collection.ClassKeeper // The (unexposed) keys used to access the stores from the Context. storeKey sdk.StoreKey @@ -24,21 +22,12 @@ type Keeper struct { func NewKeeper( cdc codec.Codec, key sdk.StoreKey, - ak collection.AccountKeeper, ck collection.ClassKeeper, ) Keeper { return Keeper{ - accountKeeper: ak, - classKeeper: ck, - storeKey: key, - cdc: cdc, - } -} - -func (k Keeper) createAccountOnAbsence(ctx sdk.Context, address sdk.AccAddress) { - if !k.accountKeeper.HasAccount(ctx, address) { - defer telemetry.IncrCounter(1, "new", "account") - k.accountKeeper.SetAccount(ctx, k.accountKeeper.NewAccountWithAddress(ctx, address)) + classKeeper: ck, + storeKey: key, + cdc: cdc, } } diff --git a/x/collection/keeper/send.go b/x/collection/keeper/send.go index 51f0055d69..145c0cba49 100644 --- a/x/collection/keeper/send.go +++ b/x/collection/keeper/send.go @@ -43,9 +43,6 @@ func (k Keeper) addCoins(ctx sdk.Context, contractID string, address sdk.AccAddr k.setOwner(ctx, contractID, coin.TokenId, address) } } - - // create account if recipient does not exist. - k.createAccountOnAbsence(ctx, address) } func (k Keeper) subtractCoins(ctx sdk.Context, contractID string, address sdk.AccAddress, amount []collection.Coin) error { @@ -106,9 +103,6 @@ func (k Keeper) AuthorizeOperator(ctx sdk.Context, contractID string, holder, op k.setAuthorization(ctx, contractID, holder, operator) - // create account if operator does not exist. - k.createAccountOnAbsence(ctx, operator) - return nil } diff --git a/x/collection/keeper/supply.go b/x/collection/keeper/supply.go index b57ffba071..2ca870efda 100644 --- a/x/collection/keeper/supply.go +++ b/x/collection/keeper/supply.go @@ -441,9 +441,6 @@ func (k Keeper) Grant(ctx sdk.Context, contractID string, granter, grantee sdk.A func (k Keeper) grant(ctx sdk.Context, contractID string, grantee sdk.AccAddress, permission collection.Permission) { k.setGrant(ctx, contractID, grantee, permission) - - // create account if grantee does not exist. - k.createAccountOnAbsence(ctx, grantee) } func (k Keeper) Abandon(ctx sdk.Context, contractID string, grantee sdk.AccAddress, permission collection.Permission) { diff --git a/x/token/expected_keepers.go b/x/token/expected_keepers.go index b016098ada..bc85027126 100644 --- a/x/token/expected_keepers.go +++ b/x/token/expected_keepers.go @@ -2,18 +2,9 @@ package token import ( sdk "github.com/line/lbm-sdk/types" - authtypes "github.com/line/lbm-sdk/x/auth/types" ) type ( - // AccountKeeper defines the contract required for account APIs. - AccountKeeper interface { - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, account authtypes.AccountI) - - NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - } - // ClassKeeper defines the contract needed to be fulfilled for class dependencies. ClassKeeper interface { NewID(ctx sdk.Context) string diff --git a/x/token/keeper/keeper.go b/x/token/keeper/keeper.go index 05a08ec21a..32e917409b 100644 --- a/x/token/keeper/keeper.go +++ b/x/token/keeper/keeper.go @@ -9,8 +9,7 @@ import ( // Keeper defines the token module Keeper type Keeper struct { - accountKeeper token.AccountKeeper - classKeeper token.ClassKeeper + classKeeper token.ClassKeeper // The (unexposed) keys used to access the stores from the Context. storeKey sdk.StoreKey @@ -23,14 +22,12 @@ type Keeper struct { func NewKeeper( cdc codec.Codec, key sdk.StoreKey, - ak token.AccountKeeper, ck token.ClassKeeper, ) Keeper { return Keeper{ - accountKeeper: ak, - classKeeper: ck, - storeKey: key, - cdc: cdc, + classKeeper: ck, + storeKey: key, + cdc: cdc, } } diff --git a/x/token/keeper/send.go b/x/token/keeper/send.go index 0fb65aa698..9c85131284 100644 --- a/x/token/keeper/send.go +++ b/x/token/keeper/send.go @@ -30,10 +30,6 @@ func (k Keeper) AuthorizeOperator(ctx sdk.Context, contractID string, holder, op k.setAuthorization(ctx, contractID, holder, operator) - if !k.accountKeeper.HasAccount(ctx, operator) { - k.accountKeeper.SetAccount(ctx, k.accountKeeper.NewAccountWithAddress(ctx, operator)) - } - return nil } @@ -87,10 +83,6 @@ func (k Keeper) addToken(ctx sdk.Context, contractID string, addr sdk.AccAddress newBalance := balance.Add(amount) k.setBalance(ctx, contractID, addr, newBalance) - - if !k.accountKeeper.HasAccount(ctx, addr) { - k.accountKeeper.SetAccount(ctx, k.accountKeeper.NewAccountWithAddress(ctx, addr)) - } } func (k Keeper) GetBalance(ctx sdk.Context, contractID string, addr sdk.AccAddress) sdk.Int { diff --git a/x/token/keeper/supply.go b/x/token/keeper/supply.go index c61104846e..8361d554f8 100644 --- a/x/token/keeper/supply.go +++ b/x/token/keeper/supply.go @@ -326,10 +326,6 @@ func (k Keeper) Grant(ctx sdk.Context, contractID string, granter, grantee sdk.A func (k Keeper) grant(ctx sdk.Context, contractID string, grantee sdk.AccAddress, permission token.Permission) { k.setGrant(ctx, contractID, grantee, permission) - - if !k.accountKeeper.HasAccount(ctx, grantee) { - k.accountKeeper.SetAccount(ctx, k.accountKeeper.NewAccountWithAddress(ctx, grantee)) - } } func (k Keeper) Abandon(ctx sdk.Context, contractID string, grantee sdk.AccAddress, permission token.Permission) {