Skip to content

Commit

Permalink
Merge pull request #25 from schnetzlerjoe/main
Browse files Browse the repository at this point in the history
Merge initial work for v0.1.0-alpha
  • Loading branch information
schnetzlerjoe committed Jul 26, 2022
2 parents 2057c7b + 29ba21a commit f158e40
Show file tree
Hide file tree
Showing 588 changed files with 299,785 additions and 4,114 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ vue/dist
release/
network/data
test.txt
vue
build
build
vue/data
.vscode
hermes.log
defundosmosis.log
osmosisdefund.log
relayer/keys/
relayer/config/
37 changes: 33 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ proto-update-deps:

create-connection:
@echo "Making Relayer Connection"
@echo "Creating Defund -> Theta Connection"
hermes -c ./network/hermes/config.toml create connection defund theta-testnet-001
@echo "Creating Defund -> Osmosis Connection"
hermes -c ./network/hermes/config.toml create connection defund osmosis

init: kill-dev
@echo "Initializing both blockchains..."
Expand All @@ -235,9 +235,38 @@ create-conn:
start-rly:
./network/relayer/start.sh

start-hermes:
./network/hermes/start.sh

install-all:
./network/osmosis/osmosis.sh
./network/hermes/install.sh

kill-dev:
@echo "Killing defundd, gaiad and removing previous data"
@echo "Killing defundd, osmosis and removing previous data"
-@rm -rf ./network/data
-@killall defundd 2>/dev/null
-@killall gaiad 2>/dev/null
-@killall osmosis 2>/dev/null
-@killall rly 2>/dev/null

###############################################################################
### Test ###
###############################################################################

test-all:
@echo "Running all bash tests......."
test-create-fund
test-create-shares
test-redeem-shares

test-create-fund:
@echo "Running create fund bash test......."
./test/create-fund.sh

test-create-shares:
@echo "Running create shares bash test......."
./test/create-shares.sh

test-redeem-shares:
@echo "Running redeem shares bash test......."
./test/redeem-shares.sh
62 changes: 32 additions & 30 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -190,10 +191,10 @@ var (
func init() {
userHomeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
panic(fmt.Sprintf("failed to get user home directory: %s", err))
}

DefaultNodeHome = filepath.Join(userHomeDir, "."+Name)
DefaultNodeHome = filepath.Join(userHomeDir, fmt.Sprintf(".%s", Name))
}

// App extends an ABCI application, but with most of its parameters exported.
Expand Down Expand Up @@ -248,7 +249,7 @@ type App struct {
mm *module.Manager
}

// New returns a reference to an initialized Gaia.
// New returns a reference to an initialized Defund.
func New(
logger log.Logger,
db dbm.DB,
Expand All @@ -257,10 +258,10 @@ func New(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig cosmoscmd.EncodingConfig,
encodingConfig EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) cosmoscmd.App {
) *App {
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand All @@ -275,8 +276,7 @@ func New(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey,
capabilitytypes.StoreKey, brokermoduletypes.StoreKey, querymoduletypes.StoreKey,
etfmoduletypes.StoreKey,
capabilitytypes.StoreKey, querymoduletypes.StoreKey, brokermoduletypes.StoreKey, etfmoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -382,7 +382,18 @@ func New(
)
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)

app.BrokerKeeper = brokermodulekeeper.NewKeeper(appCodec, keys[brokermoduletypes.StoreKey], app.ICAControllerKeeper, scopedBrokerKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper)
app.QueryKeeper = *querymodulekeeper.NewKeeper(
appCodec,
keys[querymoduletypes.StoreKey],
keys[querymoduletypes.MemStoreKey],

app.AccountKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ClientKeeper,
)
queryModule := querymodule.NewAppModule(appCodec, app.QueryKeeper, app.AccountKeeper)

app.BrokerKeeper = brokermodulekeeper.NewKeeper(appCodec, keys[brokermoduletypes.StoreKey], app.ICAControllerKeeper, scopedBrokerKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.QueryKeeper, app.EtfKeeper, app.BankKeeper)
brokerModule := brokermodule.NewAppModule(appCodec, app.BrokerKeeper, app.TransferKeeper)
brokerIBCModule := brokermodule.NewIBCModule(app.BrokerKeeper)

Expand All @@ -408,18 +419,6 @@ func New(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
)

app.QueryKeeper = *querymodulekeeper.NewKeeper(
appCodec,
keys[querymoduletypes.StoreKey],
keys[querymoduletypes.MemStoreKey],

app.AccountKeeper,
app.EtfKeeper,
app.BrokerKeeper,
)
queryModule := querymodule.NewAppModule(appCodec, app.QueryKeeper, app.AccountKeeper)

app.EtfKeeper = *etfmodulekeeper.NewKeeper(
appCodec,
keys[etfmoduletypes.StoreKey],
Expand All @@ -430,6 +429,9 @@ func New(
app.IBCKeeper.ChannelKeeper,
app.QueryKeeper,
app.BrokerKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ClientKeeper,
app.ICAControllerKeeper,
)
etfModule := etfmodule.NewAppModule(appCodec, app.EtfKeeper, app.AccountKeeper, app.BankKeeper, app.QueryKeeper, app.BrokerKeeper)

Expand Down Expand Up @@ -465,10 +467,10 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
etfModule,
queryModule,
icaModule,
queryModule,
brokerModule,
etfModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand All @@ -482,8 +484,8 @@ func New(
stakingtypes.ModuleName, ibchost.ModuleName, feegrant.ModuleName,
vestingtypes.ModuleName, banktypes.ModuleName, crisistypes.ModuleName,
govtypes.ModuleName, ibctransfertypes.ModuleName, genutiltypes.ModuleName,
authtypes.ModuleName, etfmoduletypes.ModuleName, icatypes.ModuleName,
paramstypes.ModuleName, brokermoduletypes.ModuleName, querymoduletypes.ModuleName,
authtypes.ModuleName, icatypes.ModuleName, paramstypes.ModuleName,
querymoduletypes.ModuleName, brokermoduletypes.ModuleName, etfmoduletypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand All @@ -492,8 +494,8 @@ func New(
stakingtypes.ModuleName, ibchost.ModuleName, feegrant.ModuleName,
vestingtypes.ModuleName, banktypes.ModuleName, crisistypes.ModuleName,
govtypes.ModuleName, ibctransfertypes.ModuleName, genutiltypes.ModuleName,
authtypes.ModuleName, etfmoduletypes.ModuleName, icatypes.ModuleName,
paramstypes.ModuleName, brokermoduletypes.ModuleName, querymoduletypes.ModuleName,
authtypes.ModuleName, icatypes.ModuleName, paramstypes.ModuleName,
querymoduletypes.ModuleName, brokermoduletypes.ModuleName, etfmoduletypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -515,14 +517,14 @@ func New(
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
etfmoduletypes.ModuleName,
querymoduletypes.ModuleName,
icatypes.ModuleName,
brokermoduletypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
querymoduletypes.ModuleName,
brokermoduletypes.ModuleName,
etfmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down
44 changes: 44 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package app

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

// EncodingConfig specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

// makeEncodingConfig creates an EncodingConfig for an amino based test configuration.
func makeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: txCfg,
Amino: amino,
}
}

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig(moduleBasics module.BasicManager) EncodingConfig {
encodingConfig := makeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
moduleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
moduleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
21 changes: 21 additions & 0 deletions app/prefix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package app

import sdk "github.com/cosmos/cosmos-sdk/types"

// Account specific Bech32 prefixes.
var (
AccountPubKeyPrefix = AccountAddressPrefix + "pub"
ValidatorAddressPrefix = AccountAddressPrefix + "valoper"
ValidatorPubKeyPrefix = AccountAddressPrefix + "valoperpub"
ConsNodeAddressPrefix = AccountAddressPrefix + "valcons"
ConsNodePubKeyPrefix = AccountAddressPrefix + "valconspub"
)

// SetAddressConfig sets Defund's address configuration.
func SetAddressConfig() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix)
config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix)
config.Seal()
}
Loading

0 comments on commit f158e40

Please sign in to comment.