Skip to content

Commit

Permalink
Merge pull request #98 from iov-one/escrow
Browse files Browse the repository at this point in the history
Adds an escrow module for swaping starnames and tokens
  • Loading branch information
merge-when-green[bot] authored Nov 15, 2021
2 parents b6f8d9a + 9f05209 commit d9a64b5
Show file tree
Hide file tree
Showing 87 changed files with 17,957 additions and 332 deletions.
49 changes: 33 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,18 @@ import (
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -89,10 +79,22 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/iov-one/starnamed/x/burner"
burnertypes "github.com/iov-one/starnamed/x/burner/types"
"github.com/iov-one/starnamed/x/configuration"
"github.com/iov-one/starnamed/x/escrow"
escrowkeeper "github.com/iov-one/starnamed/x/escrow/keeper"
escrowtypes "github.com/iov-one/starnamed/x/escrow/types"
"github.com/iov-one/starnamed/x/offchain"
"github.com/iov-one/starnamed/x/starname"
"github.com/iov-one/starnamed/x/wasm"
Expand Down Expand Up @@ -197,6 +199,7 @@ var (
vesting.AppModuleBasic{},
configuration.AppModuleBasic{},
starname.AppModuleBasic{},
escrow.AppModuleBasic{},
offchain.AppModuleBasic{},
)

Expand All @@ -210,6 +213,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasm.ModuleName: {authtypes.Burner},
escrowtypes.ModuleName: nil,
burnertypes.ModuleName: {authtypes.Burner},
}

Expand Down Expand Up @@ -262,6 +266,7 @@ type WasmApp struct {
wasmKeeper wasm.Keeper
configKeeper configuration.Keeper
starnameKeeper starname.Keeper
escrowKeeper escrowkeeper.Keeper

scopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -301,7 +306,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
wasm.StoreKey, configuration.StoreKey, starname.DomainStoreKey,
wasm.StoreKey, configuration.StoreKey, starname.DomainStoreKey, escrowtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -429,12 +434,22 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
app.getSubspace(configuration.ModuleName),
)

// Create the escrow keeper
app.escrowKeeper = escrowkeeper.NewKeeper(appCodec,
keys[escrowtypes.StoreKey],
app.getSubspace(escrowtypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
app.configKeeper,
app.ModuleAccountAddrs(),
)
// starname keeper
app.starnameKeeper = starname.NewKeeper(
appCodec,
keys[starname.DomainStoreKey],
app.configKeeper,
app.bankKeeper,
app.escrowKeeper,
app.accountKeeper,
app.distrKeeper,
app.stakingKeeper,
Expand Down Expand Up @@ -489,6 +504,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
transferModule,
configuration.NewAppModule(app.configKeeper),
starname.NewAppModule(app.starnameKeeper),
escrow.NewAppModule(appCodec, app.escrowKeeper),
burner.NewAppModule(app.bankKeeper, app.accountKeeper),
)

Expand All @@ -498,7 +514,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, escrowtypes.ModuleName,
)
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, burnertypes.ModuleName, starname.ModuleName)

Expand All @@ -514,7 +530,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName, configuration.ModuleName, starname.ModuleName,
wasm.ModuleName, configuration.ModuleName, starname.ModuleName, escrowtypes.ModuleName,
)

app.mm.RegisterInvariants(&app.crisisKeeper)
Expand Down Expand Up @@ -721,6 +737,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(configuration.ModuleName)
paramsKeeper.Subspace(starname.ModuleName)
paramsKeeper.Subspace(escrowtypes.ModuleName)

return paramsKeeper
}
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestGetEnabledProposals(t *testing.T) {
}
}

func setGenesis(gapp *WasmApp) error {
func SetGenesis(gapp *WasmApp) error {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{
"url": "./tmp-swagger-gen/iov/configuration/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/iov/escrow/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/iov/starname/v1beta1/query.swagger.json"
},
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit d9a64b5

Please sign in to comment.