Skip to content

Commit

Permalink
chore: replace GetSigners() with protobuf annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Nov 30, 2023
1 parent 7b86d82 commit 8610c43
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 87 deletions.
4 changes: 2 additions & 2 deletions cmd/seda-chaind/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewRootCmd() *cobra.Command {
app.DefaultNodeHome,
0,
simtestutil.NewAppOptionsWithFlagHome(tempDir()),
baseapp.SetChainID("tempid"),
baseapp.SetChainID("tempchainid"),
)
encodingConfig := app.EncodingConfig{
InterfaceRegistry: tempApp.InterfaceRegistry(),
Expand Down Expand Up @@ -347,7 +347,7 @@ func appExport(
}

var tempDir = func() string {
dir, err := os.MkdirTemp("", "sedachain")
dir, err := os.MkdirTemp("", "tempchain")
if err != nil {
panic("failed to create temp dir: " + err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/CosmWasm/wasmd v0.50.0
github.com/cometbft/cometbft v0.38.1
github.com/cosmos/cosmos-db v1.0.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.50.1
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.11
Expand Down Expand Up @@ -73,7 +74,6 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.8.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.0.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
Expand Down
21 changes: 15 additions & 6 deletions proto/sedachain/wasm_storage/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
syntax = "proto3";
package sedachain.wasm_storage.v1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "sedachain/wasm_storage/v1/wasm_storage.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/wasm-storage/types";

Expand All @@ -18,24 +20,30 @@ service Msg {
}

message MsgStoreDataRequestWasm {
string sender = 1;
option (cosmos.msg.v1.signer) = "sender";

string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
bytes wasm = 2;
WasmType wasmType = 3;
}

message MsgStoreDataRequestWasmResponse { string hash = 1; }

message MsgStoreOverlayWasm {
string sender = 1;
option (cosmos.msg.v1.signer) = "sender";

string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
bytes wasm = 2;
WasmType wasmType = 3;
}

message MsgStoreOverlayWasmResponse { string hash = 1; }

message MsgInstantiateAndRegisterProxyContract {
string sender = 1;
string admin = 2;
option (cosmos.msg.v1.signer) = "sender";

string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string admin = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
string label = 4;
bytes msg = 5
Expand All @@ -50,5 +58,6 @@ message MsgInstantiateAndRegisterProxyContract {
}

message MsgInstantiateAndRegisterProxyContractResponse {
string contract_address = 1;
string contract_address = 1
[ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}
36 changes: 0 additions & 36 deletions x/wasm-storage/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ func (msg MsgStoreDataRequestWasm) ValidateBasic() error {
return nil
}

func (msg MsgStoreDataRequestWasm) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgStoreDataRequestWasm) GetSigners() []sdk.AccAddress {
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil { // should never happen as ValidateBasic() rejects invalid addresses
panic(err.Error())
}
return []sdk.AccAddress{senderAddr}
}

func (msg MsgStoreOverlayWasm) Route() string {
return RouterKey
}
Expand All @@ -61,18 +49,6 @@ func (msg MsgStoreOverlayWasm) ValidateBasic() error {
return nil
}

func (msg MsgStoreOverlayWasm) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgStoreOverlayWasm) GetSigners() []sdk.AccAddress {
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil { // should never happen as ValidateBasic() rejects invalid addresses
panic(err.Error())
}
return []sdk.AccAddress{senderAddr}
}

func (msg MsgInstantiateAndRegisterProxyContract) Route() string {
return RouterKey
}
Expand Down Expand Up @@ -111,15 +87,3 @@ func (msg MsgInstantiateAndRegisterProxyContract) ValidateBasic() error {
}
return nil
}

func (msg MsgInstantiateAndRegisterProxyContract) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgInstantiateAndRegisterProxyContract) GetSigners() []sdk.AccAddress {
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil { // should never happen as ValidateBasic() rejects invalid addresses
panic(err.Error())
}
return []sdk.AccAddress{senderAddr}
}
89 changes: 47 additions & 42 deletions x/wasm-storage/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8610c43

Please sign in to comment.