Skip to content

Commit

Permalink
customgetsigners
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Oct 17, 2024
1 parent d810ac1 commit 79e2e3c
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 238 deletions.
252 changes: 127 additions & 125 deletions api/network/profile/v1/tx.pulsar.go

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions proto/network/launch/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/ignite/network/x/launch"
};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ignite/network/x/launch"};

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 1;


}
}
8 changes: 2 additions & 6 deletions proto/network/monitoringc/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/ignite/network/x/monitoringc"
};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ignite/network/x/monitoringc"};

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 1;


}
}
8 changes: 2 additions & 6 deletions proto/network/monitoringp/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/ignite/network/x/monitoringp"
};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ignite/network/x/monitoringp"};

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 1;


}
}
8 changes: 2 additions & 6 deletions proto/network/participation/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/ignite/network/x/participation"
};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ignite/network/x/participation"};

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 1;


}
}
8 changes: 2 additions & 6 deletions proto/network/profile/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/ignite/network/x/profile"
};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/ignite/network/x/profile"};

// authority defines the custom module authority. If not set, defaults to the governance module.
string authority = 1;


}
}
5 changes: 2 additions & 3 deletions proto/network/profile/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ message MsgUpdateValidatorDescription {
message MsgUpdateValidatorDescriptionResponse {}

message MsgAddValidatorOperatorAddress {
option (cosmos.msg.v1.signer) = "validatorAddress";
string validatorAddress = 1;
string operatorAddress = 2;
string validatorAddress = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string operatorAddress = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

message MsgAddValidatorOperatorAddressResponse {}
Expand Down
47 changes: 14 additions & 33 deletions x/profile/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/gogoproto/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/protobuf/proto"

// this line is used by starport scaffolding # 1

Expand Down Expand Up @@ -181,7 +180,7 @@ func init() {
&modulev1.Module{},
appmodule.Provide(
ProvideModule,
//ProvideInterfaceRegistry,
ProvideCustomGetSigners,
),
)
}
Expand Down Expand Up @@ -229,35 +228,17 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
return ModuleOutputs{ProfileKeeper: k, Module: m}
}

type (
// ValidatorAddressCodec is an alias for address.Codec for validator addresses.
ValidatorAddressCodec address.Codec

// ConsensusAddressCodec is an alias for address.Codec for validator consensus addresses.
ConsensusAddressCodec address.Codec
)

// TODO custom get signers
func ProvideInterfaceRegistry(addressCodec address.Codec, validatorAddressCodec ValidatorAddressCodec, customGetSigners []signing.CustomGetSigner) (codectypes.InterfaceRegistry, error) {
signingOptions := signing.Options{
AddressCodec: addressCodec,
ValidatorAddressCodec: validatorAddressCodec,
}
for _, signer := range customGetSigners {
signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn)
}

interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signingOptions,
})
if err != nil {
return nil, err
func ProvideCustomGetSigners() signing.CustomGetSigner {
return signing.CustomGetSigner{
MsgType: proto.MessageName(&types.MsgAddValidatorOperatorAddress{}),
Fn: func(msg proto.Message) ([][]byte, error) {
testMsg, ok := msg.(*types.MsgAddValidatorOperatorAddress)
if !ok {
return nil, fmt.Errorf("invalid message type: %T", msg)
}
validatorSigner := testMsg.validatorAddress
operatorSigner := testMsg.operatorAddress
return [][]byte{[]byte(validatorSigner), []byte(operatorSigner)}, nil
},
}

if err := interfaceRegistry.SigningContext().Validate(); err != nil {
return nil, err
}

return interfaceRegistry, nil
}
94 changes: 47 additions & 47 deletions x/profile/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 79e2e3c

Please sign in to comment.