diff --git a/proto/cosmos/accesscontrol/accesscontrol.proto b/proto/cosmos/accesscontrol/accesscontrol.proto index efbccb69d..219f777a8 100644 --- a/proto/cosmos/accesscontrol/accesscontrol.proto +++ b/proto/cosmos/accesscontrol/accesscontrol.proto @@ -19,3 +19,11 @@ message MessageDependencyMapping { ]; bool dynamic_enabled = 3; } + +message WasmFunctionDependencyMapping { + string wasm_function = 1; + bool enabled = 2; + repeated AccessOperation access_ops = 3 [ + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/cosmos/accesscontrol_x/genesis.proto b/proto/cosmos/accesscontrol_x/genesis.proto index e468abc41..c2e8095f1 100644 --- a/proto/cosmos/accesscontrol_x/genesis.proto +++ b/proto/cosmos/accesscontrol_x/genesis.proto @@ -14,6 +14,11 @@ message GenesisState { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"message_dependency_mapping\"" ]; + + repeated cosmos.accesscontrol.v1beta1.WasmFunctionDependencyMapping wasm_function_dependency_mappings = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"wasm_function_dependency_mappings\"" + ]; } message Params { diff --git a/proto/cosmos/accesscontrol_x/query.proto b/proto/cosmos/accesscontrol_x/query.proto index be197e4dd..bb9992230 100644 --- a/proto/cosmos/accesscontrol_x/query.proto +++ b/proto/cosmos/accesscontrol_x/query.proto @@ -26,6 +26,18 @@ service Query { option (google.api.http).get = "/cosmos/cosmos-sdk/accesscontrol/list_resource_dependency_mapping"; } + + rpc WasmFunctionDependencyMapping(WasmFunctionDependencyMappingRequest) + returns (WasmFunctionDependencyMappingResponse) { + option (google.api.http).get = + "/cosmos/cosmos-sdk/accesscontrol/wasm_function_dependency_mapping/{code_id}/{wasm_function}"; + } + + rpc ListWasmFunctionDependencyMapping(ListWasmFunctionDependencyMappingRequest) + returns (ListWasmFunctionDependencyMappingResponse) { + option (google.api.http).get = + "/cosmos/cosmos-sdk/accesscontrol/list_wasm_function_dependency_mapping"; + } } @@ -48,6 +60,19 @@ message ResourceDependencyMappingFromMessageKeyResponse { ]; } +message WasmFunctionDependencyMappingRequest { + uint64 code_id = 1 [ (gogoproto.moretags) = "yaml:\"code_id\"" ]; + string wasm_function = 2 [ (gogoproto.moretags) = "yaml:\"wasm_function\"" ]; +} + +message WasmFunctionDependencyMappingResponse { + cosmos.accesscontrol.v1beta1.WasmFunctionDependencyMapping wasm_function_dependency_mapping = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"wasm_function_dependency_mapping\"" + ]; +} + + message ListResourceDependencyMappingRequest {} message ListResourceDependencyMappingResponse { @@ -56,3 +81,12 @@ message ListResourceDependencyMappingResponse { (gogoproto.moretags) = "yaml:\"message_dependency_mapping_list\"" ]; } + +message ListWasmFunctionDependencyMappingRequest {} + +message ListWasmFunctionDependencyMappingResponse { + repeated cosmos.accesscontrol.v1beta1.WasmFunctionDependencyMapping wasm_function_dependency_mapping_list = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"wasm_function_dependency_mapping_list\"" + ]; +} diff --git a/types/accesscontrol/accesscontrol.pb.go b/types/accesscontrol/accesscontrol.pb.go index c87cc611b..7128bc756 100644 --- a/types/accesscontrol/accesscontrol.pb.go +++ b/types/accesscontrol/accesscontrol.pb.go @@ -143,9 +143,70 @@ func (m *MessageDependencyMapping) GetDynamicEnabled() bool { return false } +type WasmFunctionDependencyMapping struct { + WasmFunction string `protobuf:"bytes,1,opt,name=wasm_function,json=wasmFunction,proto3" json:"wasm_function,omitempty"` + Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` + AccessOps []AccessOperation `protobuf:"bytes,3,rep,name=access_ops,json=accessOps,proto3" json:"access_ops"` +} + +func (m *WasmFunctionDependencyMapping) Reset() { *m = WasmFunctionDependencyMapping{} } +func (m *WasmFunctionDependencyMapping) String() string { return proto.CompactTextString(m) } +func (*WasmFunctionDependencyMapping) ProtoMessage() {} +func (*WasmFunctionDependencyMapping) Descriptor() ([]byte, []int) { + return fileDescriptor_d636a082612ba091, []int{2} +} +func (m *WasmFunctionDependencyMapping) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WasmFunctionDependencyMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WasmFunctionDependencyMapping.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WasmFunctionDependencyMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmFunctionDependencyMapping.Merge(m, src) +} +func (m *WasmFunctionDependencyMapping) XXX_Size() int { + return m.Size() +} +func (m *WasmFunctionDependencyMapping) XXX_DiscardUnknown() { + xxx_messageInfo_WasmFunctionDependencyMapping.DiscardUnknown(m) +} + +var xxx_messageInfo_WasmFunctionDependencyMapping proto.InternalMessageInfo + +func (m *WasmFunctionDependencyMapping) GetWasmFunction() string { + if m != nil { + return m.WasmFunction + } + return "" +} + +func (m *WasmFunctionDependencyMapping) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +func (m *WasmFunctionDependencyMapping) GetAccessOps() []AccessOperation { + if m != nil { + return m.AccessOps + } + return nil +} + func init() { proto.RegisterType((*AccessOperation)(nil), "cosmos.accesscontrol.v1beta1.AccessOperation") proto.RegisterType((*MessageDependencyMapping)(nil), "cosmos.accesscontrol.v1beta1.MessageDependencyMapping") + proto.RegisterType((*WasmFunctionDependencyMapping)(nil), "cosmos.accesscontrol.v1beta1.WasmFunctionDependencyMapping") } func init() { @@ -153,31 +214,34 @@ func init() { } var fileDescriptor_d636a082612ba091 = []byte{ - // 373 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0xd1, 0x6a, 0xe2, 0x40, - 0x14, 0xcd, 0xe8, 0xb2, 0xac, 0xe3, 0xae, 0xc2, 0x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xc8, - 0x43, 0x0d, 0x99, 0x5c, 0x50, 0x0d, 0x76, 0xbd, 0x87, 0xdc, 0x46, 0x40, 0x5e, 0xa8, 0x59, 0xc5, - 0xf4, 0x1f, 0x10, 0xb6, 0x27, 0xa0, 0x14, 0x4d, 0xe0, 0x0c, 0x24, 0xf0, 0x18, 0x38, 0x2b, 0x26, - 0x54, 0xca, 0x94, 0x27, 0xa4, 0x8b, 0x9b, 0x99, 0xe1, 0xc2, 0x39, 0x14, 0xe5, 0xa6, 0x8d, 0x00, - 0x57, 0xd0, 0x15, 0x14, 0x24, 0xc0, 0xd5, 0x36, 0xa1, 0x90, 0xca, 0xae, 0xf5, 0xea, 0x6e, 0x73, - 0x34, 0xf8, 0xc8, 0x25, 0x0e, 0xd7, 0x1c, 0x7f, 0x5a, 0x6d, 0xba, 0x56, 0xd0, 0xa0, 0x15, 0xac, - 0xc8, 0x6f, 0xdc, 0x8e, 0x0b, 0x4e, 0xb3, 0x94, 0x85, 0xc0, 0x69, 0xb4, 0x80, 0xb8, 0x1c, 0xff, - 0x4b, 0xd0, 0xaa, 0xe0, 0x73, 0x83, 0x8e, 0x2f, 0x57, 0x5b, 0x07, 0xad, 0xb7, 0x0e, 0x7a, 0xda, - 0x3a, 0xe8, 0x7e, 0xe7, 0x58, 0xeb, 0x9d, 0x63, 0x3d, 0xee, 0x1c, 0xeb, 0xfa, 0x6f, 0x92, 0xea, - 0xdb, 0x65, 0xe4, 0x31, 0x91, 0xf9, 0x55, 0xcc, 0xe6, 0x19, 0xa8, 0x78, 0xee, 0xef, 0x0f, 0xfd, - 0x26, 0xf7, 0xe8, 0x73, 0x19, 0xf7, 0xbf, 0xe7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x9f, 0x8f, - 0xf9, 0x74, 0x02, 0x00, 0x00, + // 424 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0xdd, 0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x8b, 0xc0, 0xfb, 0xb1, 0x08, 0xbc, 0x4f, + 0x2f, 0x8a, 0x52, 0x7f, 0x1e, 0x65, 0x11, 0x13, 0x55, 0xec, 0xb2, 0x69, 0x8f, 0x33, 0x95, 0x0f, + 0xe2, 0x65, 0x3a, 0x76, 0xc2, 0x9a, 0xdd, 0x35, 0x19, 0x7d, 0xf9, 0x2b, 0x00, 0x00, 0xff, 0xff, + 0xf2, 0xdc, 0x22, 0xf3, 0x29, 0x03, 0x00, 0x00, } func (m *AccessOperation) Marshal() (dAtA []byte, err error) { @@ -274,6 +338,60 @@ func (m *MessageDependencyMapping) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *WasmFunctionDependencyMapping) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WasmFunctionDependencyMapping) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WasmFunctionDependencyMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AccessOps) > 0 { + for iNdEx := len(m.AccessOps) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AccessOps[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAccesscontrol(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.WasmFunction) > 0 { + i -= len(m.WasmFunction) + copy(dAtA[i:], m.WasmFunction) + i = encodeVarintAccesscontrol(dAtA, i, uint64(len(m.WasmFunction))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintAccesscontrol(dAtA []byte, offset int, v uint64) int { offset -= sovAccesscontrol(v) base := offset @@ -326,6 +444,28 @@ func (m *MessageDependencyMapping) Size() (n int) { return n } +func (m *WasmFunctionDependencyMapping) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.WasmFunction) + if l > 0 { + n += 1 + l + sovAccesscontrol(uint64(l)) + } + if m.Enabled { + n += 2 + } + if len(m.AccessOps) > 0 { + for _, e := range m.AccessOps { + l = e.Size() + n += 1 + l + sovAccesscontrol(uint64(l)) + } + } + return n +} + func sovAccesscontrol(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -588,6 +728,142 @@ func (m *MessageDependencyMapping) Unmarshal(dAtA []byte) error { } return nil } +func (m *WasmFunctionDependencyMapping) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccesscontrol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WasmFunctionDependencyMapping: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WasmFunctionDependencyMapping: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmFunction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccesscontrol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAccesscontrol + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAccesscontrol + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WasmFunction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccesscontrol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccessOps", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccesscontrol + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAccesscontrol + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAccesscontrol + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccessOps = append(m.AccessOps, AccessOperation{}) + if err := m.AccessOps[len(m.AccessOps)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAccesscontrol(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAccesscontrol + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipAccesscontrol(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accesscontrol/keeper/genesis.go b/x/accesscontrol/keeper/genesis.go index 764b58f7b..19734e48f 100644 --- a/x/accesscontrol/keeper/genesis.go +++ b/x/accesscontrol/keeper/genesis.go @@ -19,8 +19,14 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { resourceDependencyMappings = append(resourceDependencyMappings, dependencyMapping) return false }) + wasmDependencyMappings := []acltypes.WasmFunctionDependencyMapping{} + k.IterateWasmDependencies(ctx, func(dependencyMapping acltypes.WasmFunctionDependencyMapping) (stop bool) { + wasmDependencyMappings = append(wasmDependencyMappings, dependencyMapping) + return false + }) return &types.GenesisState{ - Params: k.GetParams(ctx), - MessageDependencyMapping: resourceDependencyMappings, + Params: k.GetParams(ctx), + MessageDependencyMapping: resourceDependencyMappings, + WasmFunctionDependencyMappings: wasmDependencyMappings, } } diff --git a/x/accesscontrol/keeper/grpc_query.go b/x/accesscontrol/keeper/grpc_query.go index 47358261b..47d9ace83 100644 --- a/x/accesscontrol/keeper/grpc_query.go +++ b/x/accesscontrol/keeper/grpc_query.go @@ -24,6 +24,16 @@ func (k Keeper) ResourceDependencyMappingFromMessageKey(ctx context.Context, req return &types.ResourceDependencyMappingFromMessageKeyResponse{MessageDependencyMapping: resourceDependency}, nil } +func (k Keeper) WasmFunctionDependencyMapping(ctx context.Context, req *types.WasmFunctionDependencyMappingRequest) (*types.WasmFunctionDependencyMappingResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + wasmDependency, err := k.GetWasmFunctionDependencyMapping(sdkCtx, req.CodeId, req.WasmFunction) + if err != nil { + return nil, err + } + return &types.WasmFunctionDependencyMappingResponse{WasmFunctionDependencyMapping: wasmDependency}, nil +} + func (k Keeper) ListResourceDependencyMapping(ctx context.Context, req *types.ListResourceDependencyMappingRequest) (*types.ListResourceDependencyMappingResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) resourceDependencyMappings := []acltypes.MessageDependencyMapping{} @@ -34,3 +44,14 @@ func (k Keeper) ListResourceDependencyMapping(ctx context.Context, req *types.Li return &types.ListResourceDependencyMappingResponse{MessageDependencyMappingList: resourceDependencyMappings}, nil } + +func (k Keeper) ListWasmFunctionDependencyMapping(ctx context.Context, req *types.ListWasmFunctionDependencyMappingRequest) (*types.ListWasmFunctionDependencyMappingResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + wasmDependencyMappings := []acltypes.WasmFunctionDependencyMapping{} + k.IterateWasmDependencies(sdkCtx, func(dependencyMapping acltypes.WasmFunctionDependencyMapping) (stop bool) { + wasmDependencyMappings = append(wasmDependencyMappings, dependencyMapping) + return false + }) + + return &types.ListWasmFunctionDependencyMappingResponse{WasmFunctionDependencyMappingList: wasmDependencyMappings}, nil +} diff --git a/x/accesscontrol/keeper/keeper.go b/x/accesscontrol/keeper/keeper.go index 49d8dfdfb..6277be9d7 100644 --- a/x/accesscontrol/keeper/keeper.go +++ b/x/accesscontrol/keeper/keeper.go @@ -35,6 +35,8 @@ type ( } ) +var ErrWasmFunctionDependencyMappingNotFound = fmt.Errorf("wasm function dependency mapping not found") + func NewKeeper( cdc codec.Codec, storeKey sdk.StoreKey, @@ -110,6 +112,59 @@ func (k Keeper) SetDependencyMappingDynamicFlag(ctx sdk.Context, messageKey type return k.SetResourceDependencyMapping(ctx, dependencyMapping) } +func (k Keeper) GetWasmFunctionDependencyMapping(ctx sdk.Context, codeID uint64, wasmFunction string) (acltypes.WasmFunctionDependencyMapping, error) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.GetWasmFunctionDependencyKey(codeID, wasmFunction)) + if b == nil { + return acltypes.WasmFunctionDependencyMapping{}, ErrWasmFunctionDependencyMappingNotFound + } + dependencyMapping := acltypes.WasmFunctionDependencyMapping{} + k.cdc.MustUnmarshal(b, &dependencyMapping) + return dependencyMapping, nil +} + +func (k Keeper) SetWasmFunctionDependencyMapping( + ctx sdk.Context, + codeID uint64, + dependencyMapping acltypes.WasmFunctionDependencyMapping, +) error { + err := types.ValidateWasmFunctionDependencyMapping(dependencyMapping) + if err != nil { + return err + } + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&dependencyMapping) + resourceKey := types.GetWasmFunctionDependencyKey(codeID, dependencyMapping.WasmFunction) + store.Set(resourceKey, b) + return nil +} + +func (k Keeper) IterateWasmDependenciesForCodeID(ctx sdk.Context, codeID uint64, handler func(wasmDependencyMapping acltypes.WasmFunctionDependencyMapping) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetKeyForCodeID(codeID)) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + dependencyMapping := acltypes.WasmFunctionDependencyMapping{} + k.cdc.MustUnmarshal(iter.Value(), &dependencyMapping) + if handler(dependencyMapping) { + break + } + } +} + +func (k Keeper) IterateWasmDependencies(ctx sdk.Context, handler func(wasmDependencyMapping acltypes.WasmFunctionDependencyMapping) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.GetWasmMappingKey()) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + dependencyMapping := acltypes.WasmFunctionDependencyMapping{} + k.cdc.MustUnmarshal(iter.Value(), &dependencyMapping) + if handler(dependencyMapping) { + break + } + } +} + func (k Keeper) BuildDependencyDag(ctx sdk.Context, txDecoder sdk.TxDecoder, txs [][]byte) (*types.Dag, error) { defer MeasureBuildDagDuration(time.Now(), "BuildDependencyDag") // contains the latest msg index for a specific Access Operation diff --git a/x/accesscontrol/keeper/keeper_test.go b/x/accesscontrol/keeper/keeper_test.go index c1d67fe5b..79998296b 100644 --- a/x/accesscontrol/keeper/keeper_test.go +++ b/x/accesscontrol/keeper/keeper_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" + aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper" "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -52,11 +53,7 @@ func TestResourceDependencyMapping(t *testing.T) { AccessType: acltypes.AccessType_READ, IdentifierTemplate: "someIdentifier", }, - { - ResourceType: acltypes.ResourceType_ANY, - AccessType: acltypes.AccessType_COMMIT, - IdentifierTemplate: "*", - }, + types.CommitAccessOp(), }, } invalidDependencyMapping := acltypes.MessageDependencyMapping{ @@ -90,6 +87,32 @@ func TestResourceDependencyMapping(t *testing.T) { require.Equal(t, 1, counter) } +func TestWasmFunctionDependencyMapping(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + wasmCodeID := uint64(1) + wasmFunction := "execute_wasm_testfunction" + wasmMapping := acltypes.WasmFunctionDependencyMapping{ + WasmFunction: wasmFunction, + Enabled: true, + AccessOps: []acltypes.AccessOperation{ + {ResourceType: acltypes.ResourceType_KV, AccessType: acltypes.AccessType_WRITE, IdentifierTemplate: "someResource"}, + types.CommitAccessOp(), + }, + } + // set the dependency mapping + err := app.AccessControlKeeper.SetWasmFunctionDependencyMapping(ctx, wasmCodeID, wasmMapping) + require.NoError(t, err) + // test getting the dependency mapping + mapping, err := app.AccessControlKeeper.GetWasmFunctionDependencyMapping(ctx, wasmCodeID, wasmFunction) + require.NoError(t, err) + require.Equal(t, wasmMapping, mapping) + // test getting a dependency mapping for something function that isn't present + _, err = app.AccessControlKeeper.GetWasmFunctionDependencyMapping(ctx, wasmCodeID, "some_other_function") + require.Error(t, aclkeeper.ErrWasmFunctionDependencyMappingNotFound, err) +} + func (suite *KeeperTestSuite) TestMessageDependencies() { suite.SetupTest() app := suite.app @@ -121,11 +144,7 @@ func (suite *KeeperTestSuite) TestMessageDependencies() { AccessType: acltypes.AccessType_WRITE, IdentifierTemplate: "stakingPrefix", }, - { - ResourceType: acltypes.ResourceType_ANY, - AccessType: acltypes.AccessType_COMMIT, - IdentifierTemplate: "*", - }, + types.CommitAccessOp(), }, DynamicEnabled: true, } @@ -148,11 +167,7 @@ func (suite *KeeperTestSuite) TestMessageDependencies() { AccessType: acltypes.AccessType_WRITE, IdentifierTemplate: "stakingUndelegatePrefix", }, - { - ResourceType: acltypes.ResourceType_ANY, - AccessType: acltypes.AccessType_COMMIT, - IdentifierTemplate: "*", - }, + types.CommitAccessOp(), }, DynamicEnabled: true, } @@ -172,11 +187,7 @@ func (suite *KeeperTestSuite) TestMessageDependencies() { AccessType: acltypes.AccessType_WRITE, IdentifierTemplate: "bankPrefix", }, - { - ResourceType: acltypes.ResourceType_ANY, - AccessType: acltypes.AccessType_COMMIT, - IdentifierTemplate: "*", - }, + types.CommitAccessOp(), }, DynamicEnabled: false, } diff --git a/x/accesscontrol/types/genesis.go b/x/accesscontrol/types/genesis.go index c0cb40ad7..f91d5f696 100644 --- a/x/accesscontrol/types/genesis.go +++ b/x/accesscontrol/types/genesis.go @@ -8,18 +8,20 @@ import ( ) // NewGenesisState creates a new GenesisState object -func NewGenesisState(params Params, messageDependencyMapping []acltypes.MessageDependencyMapping) *GenesisState { +func NewGenesisState(params Params, messageDependencyMapping []acltypes.MessageDependencyMapping, wasmDependencyMappings []acltypes.WasmFunctionDependencyMapping) *GenesisState { return &GenesisState{ - Params: params, - MessageDependencyMapping: messageDependencyMapping, + Params: params, + MessageDependencyMapping: messageDependencyMapping, + WasmFunctionDependencyMappings: wasmDependencyMappings, } } // DefaultGenesisState - default GenesisState used by columbus-2 func DefaultGenesisState() *GenesisState { return &GenesisState{ - Params: DefaultParams(), - MessageDependencyMapping: DefaultMessageDependencyMapping(), + Params: DefaultParams(), + MessageDependencyMapping: DefaultMessageDependencyMapping(), + WasmFunctionDependencyMappings: DefaultWasmDependencyMappings(), } } @@ -31,6 +33,12 @@ func ValidateGenesis(data GenesisState) error { return err } } + for _, mapping := range data.WasmFunctionDependencyMappings { + err := ValidateWasmFunctionDependencyMapping(mapping) + if err != nil { + return err + } + } return data.Params.Validate() } diff --git a/x/accesscontrol/types/genesis.pb.go b/x/accesscontrol/types/genesis.pb.go index aefb7410c..d2878b97f 100644 --- a/x/accesscontrol/types/genesis.pb.go +++ b/x/accesscontrol/types/genesis.pb.go @@ -27,7 +27,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // mapping between every message type and its predetermined resource read/write sequence - MessageDependencyMapping []accesscontrol.MessageDependencyMapping `protobuf:"bytes,2,rep,name=message_dependency_mapping,json=messageDependencyMapping,proto3" json:"message_dependency_mapping" yaml:"message_dependency_mapping"` + MessageDependencyMapping []accesscontrol.MessageDependencyMapping `protobuf:"bytes,2,rep,name=message_dependency_mapping,json=messageDependencyMapping,proto3" json:"message_dependency_mapping" yaml:"message_dependency_mapping"` + WasmFunctionDependencyMappings []accesscontrol.WasmFunctionDependencyMapping `protobuf:"bytes,3,rep,name=wasm_function_dependency_mappings,json=wasmFunctionDependencyMappings,proto3" json:"wasm_function_dependency_mappings" yaml:"wasm_function_dependency_mappings"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -77,6 +78,13 @@ func (m *GenesisState) GetMessageDependencyMapping() []accesscontrol.MessageDepe return nil } +func (m *GenesisState) GetWasmFunctionDependencyMappings() []accesscontrol.WasmFunctionDependencyMapping { + if m != nil { + return m.WasmFunctionDependencyMappings + } + return nil +} + type Params struct { } @@ -122,26 +130,30 @@ func init() { } var fileDescriptor_35812e6814a64fba = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, 0x2e, 0x4e, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, - 0x89, 0xaf, 0xd0, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x92, 0x83, 0xa8, 0xd2, 0x43, 0x53, 0xa5, 0x57, 0x66, 0x98, 0x94, 0x5a, 0x92, 0x68, 0x28, - 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xaa, 0x0f, 0x62, 0x41, 0x74, 0x49, 0x69, 0x60, 0x33, - 0x1b, 0x95, 0x07, 0x51, 0xa9, 0xf4, 0x8d, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x63, 0x70, 0x49, 0x62, - 0x49, 0xaa, 0x90, 0x0b, 0x17, 0x5b, 0x41, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x04, 0xa3, 0x02, 0xa3, - 0x06, 0xb7, 0x91, 0x9a, 0x1e, 0x7e, 0x17, 0xe8, 0x05, 0x80, 0x55, 0x3b, 0xb1, 0x9c, 0xb8, 0x27, - 0xcf, 0x10, 0x04, 0xd5, 0x2b, 0x34, 0x9f, 0x91, 0x4b, 0x2a, 0x37, 0xb5, 0xb8, 0x38, 0x31, 0x3d, - 0x35, 0x3e, 0x25, 0xb5, 0x20, 0x35, 0x2f, 0x25, 0x35, 0x2f, 0xb9, 0x32, 0x3e, 0x37, 0xb1, 0xa0, - 0x20, 0x33, 0x2f, 0x5d, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0xc8, 0x0c, 0xab, 0xd1, 0x70, 0x83, - 0x7d, 0x21, 0xfa, 0x5d, 0xe0, 0xda, 0x7d, 0x21, 0xba, 0x9d, 0x34, 0x41, 0x56, 0x7d, 0xba, 0x27, - 0xaf, 0x58, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x84, 0xdb, 0x1e, 0xa5, 0x20, 0x89, 0x5c, 0x1c, 0x86, - 0x28, 0xf1, 0x71, 0xb1, 0x41, 0x5c, 0x6e, 0xc5, 0x32, 0x63, 0x81, 0x3c, 0x83, 0x93, 0xcf, 0x89, - 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, - 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, - 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xc3, 0x15, 0x42, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x57, 0xa0, - 0x05, 0x72, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x74, 0x8d, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x8f, 0xb2, 0x0e, 0x92, 0xe5, 0x01, 0x00, 0x00, + // 353 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xbf, 0x4e, 0xc2, 0x40, + 0x1c, 0xc7, 0x7b, 0x42, 0x18, 0x8a, 0x71, 0x68, 0x1c, 0x1a, 0x86, 0x03, 0x1a, 0x63, 0xea, 0x60, + 0x2b, 0x98, 0x38, 0xe0, 0x46, 0x88, 0x2e, 0x92, 0x18, 0x1c, 0x4c, 0x5c, 0x9a, 0xe3, 0x38, 0x6b, + 0x23, 0x77, 0xd7, 0xf0, 0x3b, 0x04, 0xde, 0xc2, 0xd1, 0x4d, 0x5f, 0xc1, 0xcd, 0x47, 0x60, 0x64, + 0x74, 0x22, 0x06, 0xde, 0xc0, 0x27, 0x30, 0xf4, 0x1a, 0x12, 0x11, 0x70, 0xba, 0xbb, 0xe4, 0xfb, + 0xe7, 0x93, 0xcb, 0xd7, 0x3c, 0xa0, 0x12, 0xb8, 0x04, 0x9f, 0x50, 0xca, 0x00, 0xa8, 0x14, 0xaa, + 0x27, 0xbb, 0xc1, 0xd0, 0x0f, 0x99, 0x60, 0x10, 0x81, 0x17, 0xf7, 0xa4, 0x92, 0x16, 0xd6, 0x2a, + 0x6f, 0x45, 0xe5, 0x3d, 0x55, 0xda, 0x4c, 0x91, 0x4a, 0x61, 0x3f, 0x94, 0xa1, 0x4c, 0xa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x1c, 0x1b, 0x77, 0xd5, 0x30, 0x52, 0x0f, 0xfd, 0xb6, 0x47, 0x25, 0xf7, + 0xd3, 0x49, 0xe8, 0xe3, 0x18, 0x3a, 0x8f, 0xfe, 0x70, 0x65, 0x1f, 0x6a, 0x14, 0x33, 0x68, 0xe7, + 0x92, 0x61, 0x9c, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xba, 0x86, 0xfb, 0x10, 0xa0, 0x02, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -164,6 +176,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.WasmFunctionDependencyMappings) > 0 { + for iNdEx := len(m.WasmFunctionDependencyMappings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WasmFunctionDependencyMappings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } if len(m.MessageDependencyMapping) > 0 { for iNdEx := len(m.MessageDependencyMapping) - 1; iNdEx >= 0; iNdEx-- { { @@ -239,6 +265,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.WasmFunctionDependencyMappings) > 0 { + for _, e := range m.WasmFunctionDependencyMappings { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -353,6 +385,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmFunctionDependencyMappings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WasmFunctionDependencyMappings = append(m.WasmFunctionDependencyMappings, accesscontrol.WasmFunctionDependencyMapping{}) + if err := m.WasmFunctionDependencyMappings[len(m.WasmFunctionDependencyMappings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/accesscontrol/types/keys.go b/x/accesscontrol/types/keys.go index 0b1f3b4f1..029b9fad6 100644 --- a/x/accesscontrol/types/keys.go +++ b/x/accesscontrol/types/keys.go @@ -1,7 +1,12 @@ package types +import "encoding/binary" + // ResourceDependencyMappingKey is the key used for the keeper store -var ResourceDependencyMappingKey = 0x01 +var ( + ResourceDependencyMappingKey = 0x01 + WasmMappingKey = 0x02 +) const ( // ModuleName defines the module name @@ -22,3 +27,22 @@ func GetResourceDependencyMappingKey() []byte { func GetResourceDependencyKey(messageKey MessageKey) []byte { return append(GetResourceDependencyMappingKey(), []byte(messageKey)...) } + +func GetWasmMappingKey() []byte { + return []byte{byte(WasmMappingKey)} +} + +func GetKeyForCodeID(codeID uint64) []byte { + key := make([]byte, 8) + binary.BigEndian.PutUint64(key, codeID) + return key +} + +func GetWasmCodeIDPrefix(codeID uint64) []byte { + return append(GetWasmMappingKey(), GetKeyForCodeID(codeID)...) +} + +// wasmFunctionName is the top level object key in the execute JSON payload +func GetWasmFunctionDependencyKey(codeID uint64, wasmFunctionName string) []byte { + return append(GetWasmCodeIDPrefix(codeID), []byte(wasmFunctionName)...) +} diff --git a/x/accesscontrol/types/message_dependency_mapping.go b/x/accesscontrol/types/message_dependency_mapping.go index e4b5840d3..a7da46ae8 100644 --- a/x/accesscontrol/types/message_dependency_mapping.go +++ b/x/accesscontrol/types/message_dependency_mapping.go @@ -35,7 +35,8 @@ func ValidateMessageDependencyMapping(mapping acltypes.MessageDependencyMapping) func SynchronousMessageDependencyMapping(messageKey MessageKey) acltypes.MessageDependencyMapping { return acltypes.MessageDependencyMapping{ - MessageKey: string(messageKey), + MessageKey: string(messageKey), + DynamicEnabled: false, AccessOps: []acltypes.AccessOperation{ {AccessType: acltypes.AccessType_UNKNOWN, ResourceType: acltypes.ResourceType_ANY, IdentifierTemplate: "*"}, {AccessType: acltypes.AccessType_COMMIT, ResourceType: acltypes.ResourceType_ANY, IdentifierTemplate: "*"}, @@ -48,3 +49,15 @@ func DefaultMessageDependencyMapping() []acltypes.MessageDependencyMapping { SynchronousMessageDependencyMapping(""), } } + +func DefaultWasmDependencyMappings() []acltypes.WasmFunctionDependencyMapping { + return []acltypes.WasmFunctionDependencyMapping{} +} + +func ValidateWasmFunctionDependencyMapping(mapping acltypes.WasmFunctionDependencyMapping) error { + lastAccessOp := mapping.AccessOps[len(mapping.AccessOps)-1] + if lastAccessOp.AccessType != acltypes.AccessType_COMMIT { + return ErrNoCommitAccessOp + } + return nil +} diff --git a/x/accesscontrol/types/query.pb.go b/x/accesscontrol/types/query.pb.go index 56df3b5a5..7658a335d 100644 --- a/x/accesscontrol/types/query.pb.go +++ b/x/accesscontrol/types/query.pb.go @@ -208,6 +208,102 @@ func (m *ResourceDependencyMappingFromMessageKeyResponse) GetMessageDependencyMa return accesscontrol.MessageDependencyMapping{} } +type WasmFunctionDependencyMappingRequest struct { + CodeId uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty" yaml:"code_id"` + WasmFunction string `protobuf:"bytes,2,opt,name=wasm_function,json=wasmFunction,proto3" json:"wasm_function,omitempty" yaml:"wasm_function"` +} + +func (m *WasmFunctionDependencyMappingRequest) Reset() { *m = WasmFunctionDependencyMappingRequest{} } +func (m *WasmFunctionDependencyMappingRequest) String() string { return proto.CompactTextString(m) } +func (*WasmFunctionDependencyMappingRequest) ProtoMessage() {} +func (*WasmFunctionDependencyMappingRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d83f2274e13e6a16, []int{4} +} +func (m *WasmFunctionDependencyMappingRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WasmFunctionDependencyMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WasmFunctionDependencyMappingRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WasmFunctionDependencyMappingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmFunctionDependencyMappingRequest.Merge(m, src) +} +func (m *WasmFunctionDependencyMappingRequest) XXX_Size() int { + return m.Size() +} +func (m *WasmFunctionDependencyMappingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_WasmFunctionDependencyMappingRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_WasmFunctionDependencyMappingRequest proto.InternalMessageInfo + +func (m *WasmFunctionDependencyMappingRequest) GetCodeId() uint64 { + if m != nil { + return m.CodeId + } + return 0 +} + +func (m *WasmFunctionDependencyMappingRequest) GetWasmFunction() string { + if m != nil { + return m.WasmFunction + } + return "" +} + +type WasmFunctionDependencyMappingResponse struct { + WasmFunctionDependencyMapping accesscontrol.WasmFunctionDependencyMapping `protobuf:"bytes,1,opt,name=wasm_function_dependency_mapping,json=wasmFunctionDependencyMapping,proto3" json:"wasm_function_dependency_mapping" yaml:"wasm_function_dependency_mapping"` +} + +func (m *WasmFunctionDependencyMappingResponse) Reset() { *m = WasmFunctionDependencyMappingResponse{} } +func (m *WasmFunctionDependencyMappingResponse) String() string { return proto.CompactTextString(m) } +func (*WasmFunctionDependencyMappingResponse) ProtoMessage() {} +func (*WasmFunctionDependencyMappingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d83f2274e13e6a16, []int{5} +} +func (m *WasmFunctionDependencyMappingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WasmFunctionDependencyMappingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WasmFunctionDependencyMappingResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WasmFunctionDependencyMappingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmFunctionDependencyMappingResponse.Merge(m, src) +} +func (m *WasmFunctionDependencyMappingResponse) XXX_Size() int { + return m.Size() +} +func (m *WasmFunctionDependencyMappingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_WasmFunctionDependencyMappingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_WasmFunctionDependencyMappingResponse proto.InternalMessageInfo + +func (m *WasmFunctionDependencyMappingResponse) GetWasmFunctionDependencyMapping() accesscontrol.WasmFunctionDependencyMapping { + if m != nil { + return m.WasmFunctionDependencyMapping + } + return accesscontrol.WasmFunctionDependencyMapping{} +} + type ListResourceDependencyMappingRequest struct { } @@ -215,7 +311,7 @@ func (m *ListResourceDependencyMappingRequest) Reset() { *m = ListResour func (m *ListResourceDependencyMappingRequest) String() string { return proto.CompactTextString(m) } func (*ListResourceDependencyMappingRequest) ProtoMessage() {} func (*ListResourceDependencyMappingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d83f2274e13e6a16, []int{4} + return fileDescriptor_d83f2274e13e6a16, []int{6} } func (m *ListResourceDependencyMappingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +348,7 @@ func (m *ListResourceDependencyMappingResponse) Reset() { *m = ListResou func (m *ListResourceDependencyMappingResponse) String() string { return proto.CompactTextString(m) } func (*ListResourceDependencyMappingResponse) ProtoMessage() {} func (*ListResourceDependencyMappingResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d83f2274e13e6a16, []int{5} + return fileDescriptor_d83f2274e13e6a16, []int{7} } func (m *ListResourceDependencyMappingResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -288,13 +384,103 @@ func (m *ListResourceDependencyMappingResponse) GetMessageDependencyMappingList( return nil } +type ListWasmFunctionDependencyMappingRequest struct { +} + +func (m *ListWasmFunctionDependencyMappingRequest) Reset() { + *m = ListWasmFunctionDependencyMappingRequest{} +} +func (m *ListWasmFunctionDependencyMappingRequest) String() string { return proto.CompactTextString(m) } +func (*ListWasmFunctionDependencyMappingRequest) ProtoMessage() {} +func (*ListWasmFunctionDependencyMappingRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d83f2274e13e6a16, []int{8} +} +func (m *ListWasmFunctionDependencyMappingRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListWasmFunctionDependencyMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListWasmFunctionDependencyMappingRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListWasmFunctionDependencyMappingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListWasmFunctionDependencyMappingRequest.Merge(m, src) +} +func (m *ListWasmFunctionDependencyMappingRequest) XXX_Size() int { + return m.Size() +} +func (m *ListWasmFunctionDependencyMappingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListWasmFunctionDependencyMappingRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListWasmFunctionDependencyMappingRequest proto.InternalMessageInfo + +type ListWasmFunctionDependencyMappingResponse struct { + WasmFunctionDependencyMappingList []accesscontrol.WasmFunctionDependencyMapping `protobuf:"bytes,1,rep,name=wasm_function_dependency_mapping_list,json=wasmFunctionDependencyMappingList,proto3" json:"wasm_function_dependency_mapping_list" yaml:"wasm_function_dependency_mapping_list"` +} + +func (m *ListWasmFunctionDependencyMappingResponse) Reset() { + *m = ListWasmFunctionDependencyMappingResponse{} +} +func (m *ListWasmFunctionDependencyMappingResponse) String() string { + return proto.CompactTextString(m) +} +func (*ListWasmFunctionDependencyMappingResponse) ProtoMessage() {} +func (*ListWasmFunctionDependencyMappingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d83f2274e13e6a16, []int{9} +} +func (m *ListWasmFunctionDependencyMappingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListWasmFunctionDependencyMappingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListWasmFunctionDependencyMappingResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListWasmFunctionDependencyMappingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListWasmFunctionDependencyMappingResponse.Merge(m, src) +} +func (m *ListWasmFunctionDependencyMappingResponse) XXX_Size() int { + return m.Size() +} +func (m *ListWasmFunctionDependencyMappingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListWasmFunctionDependencyMappingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListWasmFunctionDependencyMappingResponse proto.InternalMessageInfo + +func (m *ListWasmFunctionDependencyMappingResponse) GetWasmFunctionDependencyMappingList() []accesscontrol.WasmFunctionDependencyMapping { + if m != nil { + return m.WasmFunctionDependencyMappingList + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.accesscontrol_x.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.accesscontrol_x.v1beta1.QueryParamsResponse") proto.RegisterType((*ResourceDependencyMappingFromMessageKeyRequest)(nil), "cosmos.accesscontrol_x.v1beta1.ResourceDependencyMappingFromMessageKeyRequest") proto.RegisterType((*ResourceDependencyMappingFromMessageKeyResponse)(nil), "cosmos.accesscontrol_x.v1beta1.ResourceDependencyMappingFromMessageKeyResponse") + proto.RegisterType((*WasmFunctionDependencyMappingRequest)(nil), "cosmos.accesscontrol_x.v1beta1.WasmFunctionDependencyMappingRequest") + proto.RegisterType((*WasmFunctionDependencyMappingResponse)(nil), "cosmos.accesscontrol_x.v1beta1.WasmFunctionDependencyMappingResponse") proto.RegisterType((*ListResourceDependencyMappingRequest)(nil), "cosmos.accesscontrol_x.v1beta1.ListResourceDependencyMappingRequest") proto.RegisterType((*ListResourceDependencyMappingResponse)(nil), "cosmos.accesscontrol_x.v1beta1.ListResourceDependencyMappingResponse") + proto.RegisterType((*ListWasmFunctionDependencyMappingRequest)(nil), "cosmos.accesscontrol_x.v1beta1.ListWasmFunctionDependencyMappingRequest") + proto.RegisterType((*ListWasmFunctionDependencyMappingResponse)(nil), "cosmos.accesscontrol_x.v1beta1.ListWasmFunctionDependencyMappingResponse") } func init() { @@ -302,44 +488,58 @@ func init() { } var fileDescriptor_d83f2274e13e6a16 = []byte{ - // 586 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0xb3, 0x85, 0x46, 0x62, 0x7b, 0x5b, 0x2a, 0x14, 0x59, 0xc5, 0x29, 0xab, 0x92, 0xb6, - 0x48, 0x78, 0xd5, 0x54, 0x02, 0x89, 0x1b, 0x21, 0x20, 0x21, 0x5a, 0x3e, 0x7c, 0xa4, 0x42, 0xd6, - 0xc6, 0x19, 0x8c, 0xd5, 0xd8, 0xeb, 0x7a, 0x1d, 0x54, 0x0b, 0x71, 0xe1, 0x09, 0x90, 0x78, 0x00, - 0x24, 0xee, 0x88, 0xd7, 0xe8, 0xb1, 0x52, 0x0f, 0xf4, 0x14, 0xa1, 0x84, 0x27, 0xe8, 0x85, 0x2b, - 0x8a, 0xbd, 0x8d, 0xf2, 0xe5, 0x38, 0x55, 0x7b, 0x4a, 0xbc, 0x9e, 0x99, 0xff, 0xfc, 0x66, 0xff, - 0x63, 0x4c, 0x6d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0xbd, - 0xba, 0xb2, 0x7a, 0x8a, 0xde, 0x4e, 0xe8, 0xdf, 0x91, 0xbd, 0x5c, 0xfa, 0x50, 0x55, 0x9e, 0x76, - 0xcb, 0xef, 0x43, 0xe1, 0x59, 0x43, 0x7b, 0xcb, 0x3e, 0x0d, 0x3d, 0x7c, 0x26, 0xff, 0x10, 0xbe, - 0x3d, 0xd3, 0xba, 0xa4, 0x9e, 0xc7, 0x35, 0xcf, 0x8a, 0x68, 0x4f, 0x2f, 0x59, 0x45, 0xcd, 0xe4, - 0x79, 0x32, 0x93, 0x27, 0xe4, 0x71, 0xee, 0x4c, 0xfa, 0xee, 0xb6, 0x66, 0x0c, 0xa6, 0xb6, 0x73, - 0xd4, 0xd5, 0xd1, 0x71, 0x57, 0x47, 0x7f, 0xba, 0x3a, 0xfa, 0xda, 0xd3, 0x0b, 0xc7, 0x3d, 0xbd, - 0x70, 0xda, 0xd3, 0x0b, 0x6f, 0xab, 0x8e, 0x1b, 0x7d, 0x68, 0x37, 0x0c, 0x5b, 0x78, 0x53, 0x64, - 0x0e, 0xc7, 0x84, 0xa2, 0x38, 0x00, 0xd9, 0x28, 0x26, 0x5f, 0xf9, 0xed, 0xff, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x31, 0x19, 0x2e, 0xf2, 0xdb, 0x06, 0x00, 0x00, + // 808 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xee, 0x54, 0xac, 0x61, 0x50, 0x0f, 0x23, 0x31, 0x4d, 0x03, 0x5b, 0x98, 0xf0, 0x5b, 0xdd, + 0x0d, 0xc5, 0x68, 0xa2, 0xf1, 0x60, 0x45, 0x02, 0x11, 0x50, 0xf7, 0x62, 0x22, 0x31, 0x9b, 0xed, + 0x76, 0x58, 0x37, 0x74, 0x77, 0x96, 0x9d, 0xad, 0xd0, 0x10, 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, 0xd7, 0x5c, 0xc2, 0x4a, 0x99, 0xf0, 0xbf, 0xe9, 0xcc, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x45, 0x1a, 0xb4, 0x14, 0x91, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -357,6 +557,8 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) ResourceDependencyMappingFromMessageKey(ctx context.Context, in *ResourceDependencyMappingFromMessageKeyRequest, opts ...grpc.CallOption) (*ResourceDependencyMappingFromMessageKeyResponse, error) ListResourceDependencyMapping(ctx context.Context, in *ListResourceDependencyMappingRequest, opts ...grpc.CallOption) (*ListResourceDependencyMappingResponse, error) + WasmFunctionDependencyMapping(ctx context.Context, in *WasmFunctionDependencyMappingRequest, opts ...grpc.CallOption) (*WasmFunctionDependencyMappingResponse, error) + ListWasmFunctionDependencyMapping(ctx context.Context, in *ListWasmFunctionDependencyMappingRequest, opts ...grpc.CallOption) (*ListWasmFunctionDependencyMappingResponse, error) } type queryClient struct { @@ -394,11 +596,31 @@ func (c *queryClient) ListResourceDependencyMapping(ctx context.Context, in *Lis return out, nil } +func (c *queryClient) WasmFunctionDependencyMapping(ctx context.Context, in *WasmFunctionDependencyMappingRequest, opts ...grpc.CallOption) (*WasmFunctionDependencyMappingResponse, error) { + out := new(WasmFunctionDependencyMappingResponse) + err := c.cc.Invoke(ctx, "/cosmos.accesscontrol_x.v1beta1.Query/WasmFunctionDependencyMapping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ListWasmFunctionDependencyMapping(ctx context.Context, in *ListWasmFunctionDependencyMappingRequest, opts ...grpc.CallOption) (*ListWasmFunctionDependencyMappingResponse, error) { + out := new(ListWasmFunctionDependencyMappingResponse) + err := c.cc.Invoke(ctx, "/cosmos.accesscontrol_x.v1beta1.Query/ListWasmFunctionDependencyMapping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) ResourceDependencyMappingFromMessageKey(context.Context, *ResourceDependencyMappingFromMessageKeyRequest) (*ResourceDependencyMappingFromMessageKeyResponse, error) ListResourceDependencyMapping(context.Context, *ListResourceDependencyMappingRequest) (*ListResourceDependencyMappingResponse, error) + WasmFunctionDependencyMapping(context.Context, *WasmFunctionDependencyMappingRequest) (*WasmFunctionDependencyMappingResponse, error) + ListWasmFunctionDependencyMapping(context.Context, *ListWasmFunctionDependencyMappingRequest) (*ListWasmFunctionDependencyMappingResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -414,6 +636,12 @@ func (*UnimplementedQueryServer) ResourceDependencyMappingFromMessageKey(ctx con func (*UnimplementedQueryServer) ListResourceDependencyMapping(ctx context.Context, req *ListResourceDependencyMappingRequest) (*ListResourceDependencyMappingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListResourceDependencyMapping not implemented") } +func (*UnimplementedQueryServer) WasmFunctionDependencyMapping(ctx context.Context, req *WasmFunctionDependencyMappingRequest) (*WasmFunctionDependencyMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WasmFunctionDependencyMapping not implemented") +} +func (*UnimplementedQueryServer) ListWasmFunctionDependencyMapping(ctx context.Context, req *ListWasmFunctionDependencyMappingRequest) (*ListWasmFunctionDependencyMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListWasmFunctionDependencyMapping not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -473,6 +701,42 @@ func _Query_ListResourceDependencyMapping_Handler(srv interface{}, ctx context.C return interceptor(ctx, in, info, handler) } +func _Query_WasmFunctionDependencyMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WasmFunctionDependencyMappingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).WasmFunctionDependencyMapping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accesscontrol_x.v1beta1.Query/WasmFunctionDependencyMapping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).WasmFunctionDependencyMapping(ctx, req.(*WasmFunctionDependencyMappingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListWasmFunctionDependencyMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListWasmFunctionDependencyMappingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListWasmFunctionDependencyMapping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accesscontrol_x.v1beta1.Query/ListWasmFunctionDependencyMapping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListWasmFunctionDependencyMapping(ctx, req.(*ListWasmFunctionDependencyMappingRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.accesscontrol_x.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -489,6 +753,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ListResourceDependencyMapping", Handler: _Query_ListResourceDependencyMapping_Handler, }, + { + MethodName: "WasmFunctionDependencyMapping", + Handler: _Query_WasmFunctionDependencyMapping_Handler, + }, + { + MethodName: "ListWasmFunctionDependencyMapping", + Handler: _Query_ListWasmFunctionDependencyMapping_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/accesscontrol_x/query.proto", @@ -613,6 +885,74 @@ func (m *ResourceDependencyMappingFromMessageKeyResponse) MarshalToSizedBuffer(d return len(dAtA) - i, nil } +func (m *WasmFunctionDependencyMappingRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WasmFunctionDependencyMappingRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WasmFunctionDependencyMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WasmFunction) > 0 { + i -= len(m.WasmFunction) + copy(dAtA[i:], m.WasmFunction) + i = encodeVarintQuery(dAtA, i, uint64(len(m.WasmFunction))) + i-- + dAtA[i] = 0x12 + } + if m.CodeId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CodeId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *WasmFunctionDependencyMappingResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WasmFunctionDependencyMappingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WasmFunctionDependencyMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.WasmFunctionDependencyMapping.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *ListResourceDependencyMappingRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -673,53 +1013,113 @@ func (m *ListResourceDependencyMappingResponse) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *ListWasmFunctionDependencyMappingRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *ListWasmFunctionDependencyMappingRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ResourceDependencyMappingFromMessageKeyRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *ListWasmFunctionDependencyMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.MessageKey) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *ResourceDependencyMappingFromMessageKeyResponse) Size() (n int) { - if m == nil { - return 0 +func (m *ListWasmFunctionDependencyMappingResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListWasmFunctionDependencyMappingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListWasmFunctionDependencyMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WasmFunctionDependencyMappingList) > 0 { + for iNdEx := len(m.WasmFunctionDependencyMappingList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WasmFunctionDependencyMappingList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *ResourceDependencyMappingFromMessageKeyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MessageKey) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ResourceDependencyMappingFromMessageKeyResponse) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -728,6 +1128,33 @@ func (m *ResourceDependencyMappingFromMessageKeyResponse) Size() (n int) { return n } +func (m *WasmFunctionDependencyMappingRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CodeId != 0 { + n += 1 + sovQuery(uint64(m.CodeId)) + } + l = len(m.WasmFunction) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *WasmFunctionDependencyMappingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.WasmFunctionDependencyMapping.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *ListResourceDependencyMappingRequest) Size() (n int) { if m == nil { return 0 @@ -752,6 +1179,30 @@ func (m *ListResourceDependencyMappingResponse) Size() (n int) { return n } +func (m *ListWasmFunctionDependencyMappingRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ListWasmFunctionDependencyMappingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WasmFunctionDependencyMappingList) > 0 { + for _, e := range m.WasmFunctionDependencyMappingList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1056,6 +1507,190 @@ func (m *ResourceDependencyMappingFromMessageKeyResponse) Unmarshal(dAtA []byte) } return nil } +func (m *WasmFunctionDependencyMappingRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WasmFunctionDependencyMappingRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WasmFunctionDependencyMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + m.CodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmFunction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WasmFunction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *WasmFunctionDependencyMappingResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WasmFunctionDependencyMappingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WasmFunctionDependencyMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmFunctionDependencyMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WasmFunctionDependencyMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ListResourceDependencyMappingRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1190,6 +1825,140 @@ func (m *ListResourceDependencyMappingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *ListWasmFunctionDependencyMappingRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListWasmFunctionDependencyMappingRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListWasmFunctionDependencyMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListWasmFunctionDependencyMappingResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListWasmFunctionDependencyMappingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListWasmFunctionDependencyMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmFunctionDependencyMappingList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WasmFunctionDependencyMappingList = append(m.WasmFunctionDependencyMappingList, accesscontrol.WasmFunctionDependencyMapping{}) + if err := m.WasmFunctionDependencyMappingList[len(m.WasmFunctionDependencyMappingList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accesscontrol/types/query.pb.gw.go b/x/accesscontrol/types/query.pb.gw.go index 6aeb1dbd5..bcd9fca2b 100644 --- a/x/accesscontrol/types/query.pb.gw.go +++ b/x/accesscontrol/types/query.pb.gw.go @@ -123,6 +123,100 @@ func local_request_Query_ListResourceDependencyMapping_0(ctx context.Context, ma } +func request_Query_WasmFunctionDependencyMapping_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq WasmFunctionDependencyMappingRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["code_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "code_id") + } + + protoReq.CodeId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "code_id", err) + } + + val, ok = pathParams["wasm_function"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "wasm_function") + } + + protoReq.WasmFunction, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "wasm_function", err) + } + + msg, err := client.WasmFunctionDependencyMapping(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_WasmFunctionDependencyMapping_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq WasmFunctionDependencyMappingRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["code_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "code_id") + } + + protoReq.CodeId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "code_id", err) + } + + val, ok = pathParams["wasm_function"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "wasm_function") + } + + protoReq.WasmFunction, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "wasm_function", err) + } + + msg, err := server.WasmFunctionDependencyMapping(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ListWasmFunctionDependencyMapping_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListWasmFunctionDependencyMappingRequest + var metadata runtime.ServerMetadata + + msg, err := client.ListWasmFunctionDependencyMapping(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListWasmFunctionDependencyMapping_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListWasmFunctionDependencyMappingRequest + var metadata runtime.ServerMetadata + + msg, err := server.ListWasmFunctionDependencyMapping(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -198,6 +292,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_WasmFunctionDependencyMapping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_WasmFunctionDependencyMapping_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_WasmFunctionDependencyMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListWasmFunctionDependencyMapping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ListWasmFunctionDependencyMapping_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListWasmFunctionDependencyMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -299,6 +439,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_WasmFunctionDependencyMapping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_WasmFunctionDependencyMapping_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_WasmFunctionDependencyMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListWasmFunctionDependencyMapping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ListWasmFunctionDependencyMapping_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListWasmFunctionDependencyMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -308,6 +488,10 @@ var ( pattern_Query_ResourceDependencyMappingFromMessageKey_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "cosmos-sdk", "accesscontrol", "resource_dependency_mapping_from_message_key", "message_key"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ListResourceDependencyMapping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "cosmos-sdk", "accesscontrol", "list_resource_dependency_mapping"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_WasmFunctionDependencyMapping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmos", "cosmos-sdk", "accesscontrol", "wasm_function_dependency_mapping", "code_id", "wasm_function"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ListWasmFunctionDependencyMapping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "cosmos-sdk", "accesscontrol", "list_wasm_function_dependency_mapping"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -316,4 +500,8 @@ var ( forward_Query_ResourceDependencyMappingFromMessageKey_0 = runtime.ForwardResponseMessage forward_Query_ListResourceDependencyMapping_0 = runtime.ForwardResponseMessage + + forward_Query_WasmFunctionDependencyMapping_0 = runtime.ForwardResponseMessage + + forward_Query_ListWasmFunctionDependencyMapping_0 = runtime.ForwardResponseMessage )