github.com/s7techlab/cckit@v0.10.5/examples/token/service/account/account.pb.cc.go (about) 1 // Code generated by protoc-gen-cc-gateway. DO NOT EDIT. 2 // source: token/service/account/account.proto 3 4 /* 5 Package account contains 6 * chaincode methods names {service_name}Chaincode_{method_name} 7 * chaincode interface definition {service_name}Chaincode 8 * chaincode gateway definition {service_name}}Gateway 9 * chaincode service to cckit router registration func 10 */ 11 package account 12 13 import ( 14 context "context" 15 _ "embed" 16 errors "errors" 17 18 cckit_gateway "github.com/s7techlab/cckit/gateway" 19 cckit_router "github.com/s7techlab/cckit/router" 20 cckit_defparam "github.com/s7techlab/cckit/router/param/defparam" 21 cckit_sdk "github.com/s7techlab/cckit/sdk" 22 "google.golang.org/protobuf/types/known/emptypb" 23 ) 24 25 // AccountServiceChaincode method names 26 const ( 27 28 // AccountServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode 29 AccountServiceChaincodeMethodPrefix = "" 30 31 AccountServiceChaincode_GetInvokerAddress = AccountServiceChaincodeMethodPrefix + "GetInvokerAddress" 32 33 AccountServiceChaincode_GetAddress = AccountServiceChaincodeMethodPrefix + "GetAddress" 34 35 AccountServiceChaincode_GetAccount = AccountServiceChaincodeMethodPrefix + "GetAccount" 36 ) 37 38 // AccountServiceChaincode chaincode methods interface 39 type AccountServiceChaincode interface { 40 GetInvokerAddress(cckit_router.Context, *emptypb.Empty) (*AddressId, error) 41 42 GetAddress(cckit_router.Context, *GetAddressRequest) (*AddressId, error) 43 44 GetAccount(cckit_router.Context, *AccountId) (*Account, error) 45 } 46 47 // RegisterAccountServiceChaincode registers service methods as chaincode router handlers 48 func RegisterAccountServiceChaincode(r *cckit_router.Group, cc AccountServiceChaincode) error { 49 50 r.Query(AccountServiceChaincode_GetInvokerAddress, 51 func(ctx cckit_router.Context) (interface{}, error) { 52 return cc.GetInvokerAddress(ctx, ctx.Param().(*emptypb.Empty)) 53 }, 54 cckit_defparam.Proto(&emptypb.Empty{})) 55 56 r.Query(AccountServiceChaincode_GetAddress, 57 func(ctx cckit_router.Context) (interface{}, error) { 58 return cc.GetAddress(ctx, ctx.Param().(*GetAddressRequest)) 59 }, 60 cckit_defparam.Proto(&GetAddressRequest{})) 61 62 r.Query(AccountServiceChaincode_GetAccount, 63 func(ctx cckit_router.Context) (interface{}, error) { 64 return cc.GetAccount(ctx, ctx.Param().(*AccountId)) 65 }, 66 cckit_defparam.Proto(&AccountId{})) 67 68 return nil 69 } 70 71 //go:embed account.swagger.json 72 var AccountServiceSwagger []byte 73 74 // NewAccountServiceGateway creates gateway to access chaincode method via chaincode service 75 func NewAccountServiceGateway(sdk cckit_sdk.SDK, channel, chaincode string, opts ...cckit_gateway.Opt) *AccountServiceGateway { 76 return NewAccountServiceGatewayFromInstance( 77 cckit_gateway.NewChaincodeInstanceService( 78 sdk, 79 &cckit_gateway.ChaincodeLocator{Channel: channel, Chaincode: chaincode}, 80 opts..., 81 )) 82 } 83 84 func NewAccountServiceGatewayFromInstance(chaincodeInstance cckit_gateway.ChaincodeInstance) *AccountServiceGateway { 85 return &AccountServiceGateway{ 86 ChaincodeInstance: chaincodeInstance, 87 } 88 } 89 90 // gateway implementation 91 // gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay ) 92 type AccountServiceGateway struct { 93 ChaincodeInstance cckit_gateway.ChaincodeInstance 94 } 95 96 func (c *AccountServiceGateway) Invoker() cckit_gateway.ChaincodeInstanceInvoker { 97 return cckit_gateway.NewChaincodeInstanceServiceInvoker(c.ChaincodeInstance) 98 } 99 100 // ServiceDef returns service definition 101 func (c *AccountServiceGateway) ServiceDef() cckit_gateway.ServiceDef { 102 return cckit_gateway.NewServiceDef( 103 _AccountService_serviceDesc.ServiceName, 104 AccountServiceSwagger, 105 &_AccountService_serviceDesc, 106 c, 107 RegisterAccountServiceHandlerFromEndpoint, 108 ) 109 } 110 111 func (c *AccountServiceGateway) GetInvokerAddress(ctx context.Context, in *emptypb.Empty) (*AddressId, error) { 112 var inMsg interface{} = in 113 if v, ok := inMsg.(interface{ Validate() error }); ok { 114 if err := v.Validate(); err != nil { 115 return nil, err 116 } 117 } 118 119 if res, err := c.Invoker().Query(ctx, AccountServiceChaincode_GetInvokerAddress, []interface{}{in}, &AddressId{}); err != nil { 120 return nil, err 121 } else { 122 return res.(*AddressId), nil 123 } 124 } 125 126 func (c *AccountServiceGateway) GetAddress(ctx context.Context, in *GetAddressRequest) (*AddressId, error) { 127 var inMsg interface{} = in 128 if v, ok := inMsg.(interface{ Validate() error }); ok { 129 if err := v.Validate(); err != nil { 130 return nil, err 131 } 132 } 133 134 if res, err := c.Invoker().Query(ctx, AccountServiceChaincode_GetAddress, []interface{}{in}, &AddressId{}); err != nil { 135 return nil, err 136 } else { 137 return res.(*AddressId), nil 138 } 139 } 140 141 func (c *AccountServiceGateway) GetAccount(ctx context.Context, in *AccountId) (*Account, error) { 142 var inMsg interface{} = in 143 if v, ok := inMsg.(interface{ Validate() error }); ok { 144 if err := v.Validate(); err != nil { 145 return nil, err 146 } 147 } 148 149 if res, err := c.Invoker().Query(ctx, AccountServiceChaincode_GetAccount, []interface{}{in}, &Account{}); err != nil { 150 return nil, err 151 } else { 152 return res.(*Account), nil 153 } 154 } 155 156 // AccountServiceChaincodeResolver interface for service resolver 157 type ( 158 AccountServiceChaincodeResolver interface { 159 Resolve(ctx cckit_router.Context) (AccountServiceChaincode, error) 160 } 161 162 AccountServiceChaincodeLocalResolver struct { 163 service AccountServiceChaincode 164 } 165 166 AccountServiceChaincodeLocatorResolver struct { 167 locatorResolver cckit_gateway.ChaincodeLocatorResolver 168 service AccountServiceChaincode 169 } 170 ) 171 172 func NewAccountServiceChaincodeLocalResolver(service AccountServiceChaincode) *AccountServiceChaincodeLocalResolver { 173 return &AccountServiceChaincodeLocalResolver{ 174 service: service, 175 } 176 } 177 178 func (r *AccountServiceChaincodeLocalResolver) Resolve(ctx cckit_router.Context) (AccountServiceChaincode, error) { 179 if r.service == nil { 180 return nil, errors.New("service not set for local chaincode resolver") 181 } 182 183 return r.service, nil 184 } 185 186 func NewAccountServiceChaincodeResolver(locatorResolver cckit_gateway.ChaincodeLocatorResolver) *AccountServiceChaincodeLocatorResolver { 187 return &AccountServiceChaincodeLocatorResolver{ 188 locatorResolver: locatorResolver, 189 } 190 } 191 192 func (r *AccountServiceChaincodeLocatorResolver) Resolve(ctx cckit_router.Context) (AccountServiceChaincode, error) { 193 if r.service != nil { 194 return r.service, nil 195 } 196 197 locator, err := r.locatorResolver(ctx, _AccountService_serviceDesc.ServiceName) 198 if err != nil { 199 return nil, err 200 } 201 202 r.service = NewAccountServiceChaincodeStubInvoker(locator) 203 return r.service, nil 204 } 205 206 type AccountServiceChaincodeStubInvoker struct { 207 Invoker cckit_gateway.ChaincodeStubInvoker 208 } 209 210 func NewAccountServiceChaincodeStubInvoker(locator *cckit_gateway.ChaincodeLocator) *AccountServiceChaincodeStubInvoker { 211 return &AccountServiceChaincodeStubInvoker{ 212 Invoker: &cckit_gateway.LocatorChaincodeStubInvoker{Locator: locator}, 213 } 214 } 215 216 func (c *AccountServiceChaincodeStubInvoker) GetInvokerAddress(ctx cckit_router.Context, in *emptypb.Empty) (*AddressId, error) { 217 218 var inMsg interface{} = in 219 if v, ok := inMsg.(interface{ Validate() error }); ok { 220 if err := v.Validate(); err != nil { 221 return nil, err 222 } 223 } 224 225 if res, err := c.Invoker.Query(ctx.Stub(), AccountServiceChaincode_GetInvokerAddress, []interface{}{in}, &AddressId{}); err != nil { 226 return nil, err 227 } else { 228 return res.(*AddressId), nil 229 } 230 231 } 232 233 func (c *AccountServiceChaincodeStubInvoker) GetAddress(ctx cckit_router.Context, in *GetAddressRequest) (*AddressId, error) { 234 235 var inMsg interface{} = in 236 if v, ok := inMsg.(interface{ Validate() error }); ok { 237 if err := v.Validate(); err != nil { 238 return nil, err 239 } 240 } 241 242 if res, err := c.Invoker.Query(ctx.Stub(), AccountServiceChaincode_GetAddress, []interface{}{in}, &AddressId{}); err != nil { 243 return nil, err 244 } else { 245 return res.(*AddressId), nil 246 } 247 248 } 249 250 func (c *AccountServiceChaincodeStubInvoker) GetAccount(ctx cckit_router.Context, in *AccountId) (*Account, error) { 251 252 var inMsg interface{} = in 253 if v, ok := inMsg.(interface{ Validate() error }); ok { 254 if err := v.Validate(); err != nil { 255 return nil, err 256 } 257 } 258 259 if res, err := c.Invoker.Query(ctx.Stub(), AccountServiceChaincode_GetAccount, []interface{}{in}, &Account{}); err != nil { 260 return nil, err 261 } else { 262 return res.(*Account), nil 263 } 264 265 }