Skip to content

Commit

Permalink
Merge branch 'main' into update-main-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulBernal authored Nov 4, 2022
2 parents bca3de6 + 5842195 commit 4621f86
Show file tree
Hide file tree
Showing 14 changed files with 666 additions and 788 deletions.
27 changes: 27 additions & 0 deletions .github/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ BitCanna provides a decentralized payment network, supply chain and trust networ
> Next version: [Update scheduled for November 7th](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md)

These docs at Github are chain related. For more information about our coin, partners and roadmap visit:
* Our website: https://www.bitcanna.io
* Our docs platform: https://docs.bitcanna.io
Expand Down
148 changes: 72 additions & 76 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"

// storetypes "github.com/cosmos/cosmos-sdk/store/types"
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 @@ -93,7 +93,7 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"github.com/ignite/cli/ignite/pkg/cosmoscmd"
appparams "github.com/BitCannaGlobal/bcna/app/params"
"github.com/ignite/cli/ignite/pkg/openapiconsole"

"github.com/BitCannaGlobal/bcna/docs"
Expand All @@ -114,10 +114,7 @@ import (
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
)

const (
AccountAddressPrefix = "bcna"
Name = "bcna"
)
const Name = "bcna"

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

Expand Down Expand Up @@ -182,7 +179,6 @@ var (
)

var (
_ cosmoscmd.App = (*App)(nil)
_ servertypes.Application = (*App)(nil)
_ simapp.App = (*App)(nil)
)
Expand Down Expand Up @@ -260,15 +256,15 @@ func New(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig cosmoscmd.EncodingConfig,
encodingCfg appparams.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) cosmoscmd.App {
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
) *App {
appCodec := encodingCfg.Marshaler
cdc := encodingCfg.Amino
interfaceRegistry := encodingCfg.InterfaceRegistry

bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
bApp := baseapp.NewBaseApp(Name, logger, db, encodingCfg.TxConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
Expand Down Expand Up @@ -466,7 +462,7 @@ func New(
app.mm = module.NewManager(
genutil.NewAppModule(
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
encodingConfig.TxConfig,
encodingCfg.TxConfig,
),
auth.NewAppModule(appCodec, app.AccountKeeper, nil),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
Expand Down Expand Up @@ -574,7 +570,7 @@ func New(
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingCfg.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

Expand Down Expand Up @@ -613,7 +609,7 @@ func New(
ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SignModeHandler: encodingCfg.TxConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
Expand Down Expand Up @@ -762,72 +758,72 @@ func (app *App) RegisterTendermintService(clientCtx client.Context) {
}

func (app *App) RegisterUpgradeHandlers() {
planName := "trichomemonster-ica-test"
planName := "trichomemonster-ica"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
/* // Set Initial Consensus Version
fromVM[icatypes.ModuleName] = app.mm.Modules[icatypes.ModuleName].ConsensusVersion()
// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{
ControllerEnabled: false,
}
// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
"/cosmos.authz.v1beta1.MsgExec",
"/cosmos.authz.v1beta1.MsgGrant",
"/cosmos.authz.v1beta1.MsgRevoke",
"/cosmos.bank.v1beta1.MsgSend",
"/cosmos.bank.v1beta1.MsgMultiSend",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.feegrant.v1beta1.MsgGrantAllowance",
"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",
"/cosmos.gov.v1beta1.MsgVoteWeighted",
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgDeposit",
"/cosmos.gov.v1beta1.MsgVote",
"/cosmos.staking.v1beta1.MsgEditValidator",
"/cosmos.staking.v1beta1.MsgDelegate",
"/cosmos.staking.v1beta1.MsgUndelegate",
"/cosmos.staking.v1beta1.MsgBeginRedelegate",
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
"/ibc.applications.transfer.v1.MsgTransfer",
"/tendermint.liquidity.v1beta1.MsgCreatePool",
"/tendermint.liquidity.v1beta1.MsgSwapWithinBatch",
"/tendermint.liquidity.v1beta1.MsgDepositWithinBatch",
"/tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch",
},
}
icaModule, ok := app.mm.Modules[icatypes.ModuleName].(ica.AppModule)
if !ok {
panic("module is not of type ica.AppModule")
}
ctx.Logger().Info("start to init interchainaccount module...")
// initialize ICS27 module
icaModule.InitModule(ctx, controllerParams, hostParams)
ctx.Logger().Info("start to run module migrations...")
*/
// Set Initial Consensus Version
fromVM[icatypes.ModuleName] = app.mm.Modules[icatypes.ModuleName].ConsensusVersion()
// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{
ControllerEnabled: false,
}
// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
"/cosmos.authz.v1beta1.MsgExec",
"/cosmos.authz.v1beta1.MsgGrant",
"/cosmos.authz.v1beta1.MsgRevoke",
"/cosmos.bank.v1beta1.MsgSend",
"/cosmos.bank.v1beta1.MsgMultiSend",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.feegrant.v1beta1.MsgGrantAllowance",
"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",
"/cosmos.gov.v1beta1.MsgVoteWeighted",
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgDeposit",
"/cosmos.gov.v1beta1.MsgVote",
"/cosmos.staking.v1beta1.MsgEditValidator",
"/cosmos.staking.v1beta1.MsgDelegate",
"/cosmos.staking.v1beta1.MsgUndelegate",
"/cosmos.staking.v1beta1.MsgBeginRedelegate",
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
"/ibc.applications.transfer.v1.MsgTransfer",
"/tendermint.liquidity.v1beta1.MsgCreatePool",
"/tendermint.liquidity.v1beta1.MsgSwapWithinBatch",
"/tendermint.liquidity.v1beta1.MsgDepositWithinBatch",
"/tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch",
},
}
icaModule, ok := app.mm.Modules[icatypes.ModuleName].(ica.AppModule)
if !ok {
panic("module is not of type ica.AppModule")
}
ctx.Logger().Info("start to init interchainaccount module...")
// initialize ICS27 module
icaModule.InitModule(ctx, controllerParams, hostParams)

ctx.Logger().Info("start to run module migrations...")

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

/* upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{icahosttypes.StoreKey, icacontrollertypes.StoreKey},
}
if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{icahosttypes.StoreKey, icacontrollertypes.StoreKey},
}

// Configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
} */
// Configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

// GetMaccPerms returns a copy of the module account permissions
Expand Down
33 changes: 33 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package app

import (
"github.com/BitCannaGlobal/bcna/app/params"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

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

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

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

// AccountAddressPrefix defines the Paloma network's Bech32 address prefix.
const AccountAddressPrefix = "bcna"

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

// SetAddressConfig sets Paloma's address configuration.
func SetAddressConfig() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix)
config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix)
config.Seal()
}
16 changes: 16 additions & 0 deletions app/params/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package params

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
)

// 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
}
Loading

0 comments on commit 4621f86

Please sign in to comment.