Skip to content

Commit

Permalink
chore: remove x/metaprotocols module
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Aug 22, 2024
1 parent 707f142 commit 8cc9a02
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 758 deletions.
7 changes: 0 additions & 7 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

atomoneappparams "github.com/atomone-hub/atomone/app/params"
"github.com/atomone-hub/atomone/x/metaprotocols"
metaprotocolstypes "github.com/atomone-hub/atomone/x/metaprotocols/types"
)

var maccPerms = map[string][]string{
Expand Down Expand Up @@ -84,7 +82,6 @@ var ModuleBasics = module.NewBasicManager(
evidence.AppModuleBasic{},
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
metaprotocols.AppModuleBasic{},
)

func appModules(
Expand Down Expand Up @@ -117,7 +114,6 @@ func appModules(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
sdkparams.NewAppModule(app.ParamsKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
metaprotocols.NewAppModule(),
}
}

Expand Down Expand Up @@ -178,7 +174,6 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
}
}

Expand Down Expand Up @@ -209,7 +204,6 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
}
}

Expand Down Expand Up @@ -240,6 +234,5 @@ func orderInitBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
}
}
19 changes: 0 additions & 19 deletions proto/gaia/metaprotocols/extensions.proto

This file was deleted.

2 changes: 0 additions & 2 deletions tests/e2e/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

atomoneparams "github.com/atomone-hub/atomone/app/params"
metaprotocoltypes "github.com/atomone-hub/atomone/x/metaprotocols/types"
)

const (
Expand Down Expand Up @@ -51,7 +50,6 @@ func init() {

upgradetypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
distribtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
metaprotocoltypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)

cdc = encodingConfig.Marshaler
txConfig = encodingConfig.TxConfig
Expand Down
120 changes: 0 additions & 120 deletions tests/e2e/e2e_bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ package e2e

import (
"fmt"
"path/filepath"
"time"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

extensiontypes "github.com/atomone-hub/atomone/x/metaprotocols/types"
)

func (s *IntegrationTestSuite) testBankTokenTransfer() {
Expand Down Expand Up @@ -102,117 +96,3 @@ func (s *IntegrationTestSuite) testBankTokenTransfer() {
)
})
}

// tests the bank send command with populated non_critical_extension_options field
// the Tx should succeed if the data can be properly encoded and decoded
// the tx is signed and broadcast using atomoned tx sign and broadcast commands
func (s *IntegrationTestSuite) bankSendWithNonCriticalExtensionOptions() {
s.Run("transfer_with_non_critical_extension_options", func() {
c := s.chainA

submitterAccount := c.genesisAccounts[1]
submitterAddress, err := submitterAccount.keyInfo.GetAddress()
s.Require().NoError(err)
sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(100))))

// valid non-critical extension options
ext := &extensiontypes.ExtensionData{
ProtocolId: "test-protocol",
ProtocolVersion: "1",
Data: []byte("Hello Cosmos"),
}

extAny, err := codectypes.NewAnyWithValue(ext)
s.Require().NoError(err)
s.Require().NotNil(extAny)

txBuilder := encodingConfig.TxConfig.NewTxBuilder()

s.Require().NoError(txBuilder.SetMsgs(sendMsg))

txBuilder.SetMemo("non-critical-ext-message-test")
txBuilder.SetFeeAmount(sdk.NewCoins(standardFees))
txBuilder.SetGasLimit(200000)

// add extension options
tx := txBuilder.GetTx()
if etx, ok := tx.(authTx.ExtensionOptionsTxBuilder); ok {
etx.SetNonCriticalExtensionOptions(extAny)
}

bz, err := encodingConfig.TxConfig.TxEncoder()(tx)
s.Require().NoError(err)
s.Require().NotNil(bz)

txWithExt, err := decodeTx(bz)
s.Require().NoError(err)
s.Require().NotNil(txWithExt)

rawTx, err := cdc.MarshalJSON(txWithExt)
s.Require().NoError(err)
s.Require().NotNil(rawTx)

unsignedFname := "unsigned_non_critical_extension_option_tx.json"
unsignedJSONFile := filepath.Join(c.validators[0].configDir(), unsignedFname)
err = writeFile(unsignedJSONFile, rawTx)
s.Require().NoError(err)

signedTx, err := s.signTxFileOnline(c, 0, submitterAddress.String(), unsignedFname)
s.Require().NoError(err)
s.Require().NotNil(signedTx)

signedFname := "signed_non_critical_extension_option_tx.json"
signedJSONFile := filepath.Join(c.validators[0].configDir(), signedFname)
err = writeFile(signedJSONFile, signedTx)
s.Require().NoError(err)

// if there's no errors the non_critical_extension_options field was properly encoded and decoded
out, err := s.broadcastTxFile(c, 0, submitterAddress.String(), signedFname)
s.Require().NoError(err)
s.Require().NotNil(out)
})
}

// tests the bank send command with invalid non_critical_extension_options field
// the tx should always fail to decode the extension options since no concrete type is registered for the provided extension field
func (s *IntegrationTestSuite) failedBankSendWithNonCriticalExtensionOptions() {
s.Run("fail_encoding_invalid_non_critical_extension_options", func() {
c := s.chainA

submitterAccount := c.genesisAccounts[1]
submitterAddress, err := submitterAccount.keyInfo.GetAddress()
s.Require().NoError(err)
sendMsg := banktypes.NewMsgSend(submitterAddress, submitterAddress, sdk.NewCoins(sdk.NewCoin(uatomDenom, sdk.NewInt(100))))

// the message does not matter, as long as it is in the interface registry
ext := &banktypes.MsgMultiSend{}

extAny, err := codectypes.NewAnyWithValue(ext)
s.Require().NoError(err)
s.Require().NotNil(extAny)

txBuilder := encodingConfig.TxConfig.NewTxBuilder()

s.Require().NoError(txBuilder.SetMsgs(sendMsg))

txBuilder.SetMemo("fail-non-critical-ext-message")
txBuilder.SetFeeAmount(sdk.NewCoins(standardFees))
txBuilder.SetGasLimit(200000)

// add extension options
tx := txBuilder.GetTx()
if etx, ok := tx.(authTx.ExtensionOptionsTxBuilder); ok {
etx.SetNonCriticalExtensionOptions(extAny)
}

bz, err := encodingConfig.TxConfig.TxEncoder()(tx)
s.Require().NoError(err)
s.Require().NotNil(bz)

// decode fails because the provided extension option does not implement the correct TxExtensionOptionI interface
txWithExt, err := decodeTx(bz)
s.Require().Error(err)
s.Require().ErrorContains(err, "failed to decode tx: no concrete type registered for type URL /cosmos.bank.v1beta1.MsgMultiSend against interface *tx.TxExtensionOptionI")
s.Require().Nil(txWithExt)
})
}
62 changes: 0 additions & 62 deletions x/metaprotocols/README.md

This file was deleted.

94 changes: 0 additions & 94 deletions x/metaprotocols/module.go

This file was deleted.

19 changes: 0 additions & 19 deletions x/metaprotocols/types/codec.go

This file was deleted.

Loading

0 comments on commit 8cc9a02

Please sign in to comment.