allowance

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package allowance contains

  • chaincode methods names {service_name}Chaincode_{method_name}
  • chaincode interface definition {service_name}Chaincode
  • chaincode gateway definition {service_name}}Gateway
  • chaincode service to cckit router registration func

Package allowance is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (

	// AllowanceServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode
	AllowanceServiceChaincodeMethodPrefix = ""

	AllowanceServiceChaincode_GetAllowance = AllowanceServiceChaincodeMethodPrefix + "GetAllowance"

	AllowanceServiceChaincode_Approve = AllowanceServiceChaincodeMethodPrefix + "Approve"

	AllowanceServiceChaincode_TransferFrom = AllowanceServiceChaincodeMethodPrefix + "TransferFrom"
)

AllowanceServiceChaincode method names

Variables

View Source
var (
	ErrOwnerOnly             = errors.New(`owner only`)
	ErrAllowanceInsufficient = errors.New(`allowance insufficient`)
)
View Source
var (
	StateMappings = m.StateMappings{}.
					Add(&Allowance{},
			m.PKeySchema(&AllowanceId{}),
			m.List(&Allowances{}),
		)

	EventMappings = m.EventMappings{}.
					Add(&Approved{}).
					Add(&TransferredFrom{})
)
View Source
var AllowanceServiceSwagger []byte
View Source
var File_erc20_utxo_service_allowance_allowance_proto protoreflect.FileDescriptor

Functions

func Event

func Event(ctx router.Context) state.Event

Event with chaincode mappings

func RegisterAllowanceServiceChaincode

func RegisterAllowanceServiceChaincode(r *cckit_router.Group, cc AllowanceServiceChaincode) error

RegisterAllowanceServiceChaincode registers service methods as chaincode router handlers

func RegisterAllowanceServiceHandler

func RegisterAllowanceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterAllowanceServiceHandler registers the http handlers for service AllowanceService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterAllowanceServiceHandlerClient

func RegisterAllowanceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AllowanceServiceClient) error

RegisterAllowanceServiceHandlerClient registers the http handlers for service AllowanceService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AllowanceServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AllowanceServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "AllowanceServiceClient" to call the correct interceptors.

func RegisterAllowanceServiceHandlerFromEndpoint

func RegisterAllowanceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterAllowanceServiceHandlerFromEndpoint is same as RegisterAllowanceServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterAllowanceServiceHandlerServer

func RegisterAllowanceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AllowanceServiceServer) error

RegisterAllowanceServiceHandlerServer registers the http handlers for service AllowanceService to "mux". UnaryRPC :call AllowanceServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAllowanceServiceHandlerFromEndpoint instead.

func RegisterAllowanceServiceServer

func RegisterAllowanceServiceServer(s *grpc.Server, srv AllowanceServiceServer)

func State

func State(ctx router.Context) m.MappedState

State with chaincode mappings

Types

type Allowance

type Allowance struct {
	Owner   string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender string           `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Symbol  string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group   []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount  *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

State: Allowance

func (*Allowance) Descriptor deprecated

func (*Allowance) Descriptor() ([]byte, []int)

Deprecated: Use Allowance.ProtoReflect.Descriptor instead.

func (*Allowance) GetAmount

func (x *Allowance) GetAmount() *decimal.Decimal

func (*Allowance) GetGroup

func (x *Allowance) GetGroup() []string

func (*Allowance) GetOwner

func (x *Allowance) GetOwner() string

func (*Allowance) GetSpender

func (x *Allowance) GetSpender() string

func (*Allowance) GetSymbol

func (x *Allowance) GetSymbol() string

func (*Allowance) ProtoMessage

func (*Allowance) ProtoMessage()

func (*Allowance) ProtoReflect

func (x *Allowance) ProtoReflect() protoreflect.Message

func (*Allowance) Reset

func (x *Allowance) Reset()

func (*Allowance) String

func (x *Allowance) String() string

func (*Allowance) Validate

func (this *Allowance) Validate() error

type AllowanceId

type AllowanceId struct {
	Owner   string   `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender string   `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Symbol  string   `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group   []string `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	// contains filtered or unexported fields
}

Id: Allowance identifier

func (*AllowanceId) Descriptor deprecated

func (*AllowanceId) Descriptor() ([]byte, []int)

Deprecated: Use AllowanceId.ProtoReflect.Descriptor instead.

func (*AllowanceId) GetGroup

func (x *AllowanceId) GetGroup() []string

func (*AllowanceId) GetOwner

func (x *AllowanceId) GetOwner() string

func (*AllowanceId) GetSpender

func (x *AllowanceId) GetSpender() string

func (*AllowanceId) GetSymbol

func (x *AllowanceId) GetSymbol() string

func (*AllowanceId) ProtoMessage

func (*AllowanceId) ProtoMessage()

func (*AllowanceId) ProtoReflect

func (x *AllowanceId) ProtoReflect() protoreflect.Message

func (*AllowanceId) Reset

func (x *AllowanceId) Reset()

func (*AllowanceId) String

func (x *AllowanceId) String() string

func (*AllowanceId) Validate

func (this *AllowanceId) Validate() error

type AllowanceServiceChaincode

type AllowanceServiceChaincode interface {
	GetAllowance(cckit_router.Context, *AllowanceId) (*Allowance, error)

	Approve(cckit_router.Context, *ApproveRequest) (*Allowance, error)

	TransferFrom(cckit_router.Context, *TransferFromRequest) (*TransferFromResponse, error)
}

AllowanceServiceChaincode chaincode methods interface

type AllowanceServiceChaincodeLocalResolver

type AllowanceServiceChaincodeLocalResolver struct {
	// contains filtered or unexported fields
}

AllowanceServiceChaincodeResolver interface for service resolver

func (*AllowanceServiceChaincodeLocalResolver) Resolve

type AllowanceServiceChaincodeLocatorResolver

type AllowanceServiceChaincodeLocatorResolver struct {
	// contains filtered or unexported fields
}

AllowanceServiceChaincodeResolver interface for service resolver

func (*AllowanceServiceChaincodeLocatorResolver) Resolve

type AllowanceServiceChaincodeResolver

type AllowanceServiceChaincodeResolver interface {
	Resolve(ctx cckit_router.Context) (AllowanceServiceChaincode, error)
}

AllowanceServiceChaincodeResolver interface for service resolver

type AllowanceServiceChaincodeStubInvoker

type AllowanceServiceChaincodeStubInvoker struct {
	Invoker cckit_gateway.ChaincodeStubInvoker
}

func (*AllowanceServiceChaincodeStubInvoker) Approve

func (*AllowanceServiceChaincodeStubInvoker) GetAllowance

func (*AllowanceServiceChaincodeStubInvoker) TransferFrom

type AllowanceServiceClient

type AllowanceServiceClient interface {
	// Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transfersender.
	// This is zero by default.
	GetAllowance(ctx context.Context, in *AllowanceId, opts ...grpc.CallOption) (*Allowance, error)
	// Sets amount as the allowance of spender over the caller’s tokens.
	// Emits an ApprovalEvent
	Approve(ctx context.Context, in *ApproveRequest, opts ...grpc.CallOption) (*Allowance, error)
	// Moves amount tokens from sender to recipient using the allowance mechanism.
	// Amount is then deducted from the caller’s allowance.
	// Emits TransferEvent
	TransferFrom(ctx context.Context, in *TransferFromRequest, opts ...grpc.CallOption) (*TransferFromResponse, error)
}

AllowanceServiceClient is the client API for AllowanceService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type AllowanceServiceGateway

type AllowanceServiceGateway struct {
	ChaincodeInstance cckit_gateway.ChaincodeInstance
}

gateway implementation gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay )

func NewAllowanceServiceGateway

func NewAllowanceServiceGateway(sdk cckit_sdk.SDK, channel, chaincode string, opts ...cckit_gateway.Opt) *AllowanceServiceGateway

NewAllowanceServiceGateway creates gateway to access chaincode method via chaincode service

func NewAllowanceServiceGatewayFromInstance

func NewAllowanceServiceGatewayFromInstance(chaincodeInstance cckit_gateway.ChaincodeInstance) *AllowanceServiceGateway

func (*AllowanceServiceGateway) Approve

func (*AllowanceServiceGateway) GetAllowance

func (c *AllowanceServiceGateway) GetAllowance(ctx context.Context, in *AllowanceId) (*Allowance, error)

func (*AllowanceServiceGateway) Invoker

func (*AllowanceServiceGateway) ServiceDef

ServiceDef returns service definition

func (*AllowanceServiceGateway) TransferFrom

type AllowanceServiceServer

type AllowanceServiceServer interface {
	// Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transfersender.
	// This is zero by default.
	GetAllowance(context.Context, *AllowanceId) (*Allowance, error)
	// Sets amount as the allowance of spender over the caller’s tokens.
	// Emits an ApprovalEvent
	Approve(context.Context, *ApproveRequest) (*Allowance, error)
	// Moves amount tokens from sender to recipient using the allowance mechanism.
	// Amount is then deducted from the caller’s allowance.
	// Emits TransferEvent
	TransferFrom(context.Context, *TransferFromRequest) (*TransferFromResponse, error)
}

AllowanceServiceServer is the server API for AllowanceService service.

type Allowances

type Allowances struct {
	Items []*Allowance `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

List:

func (*Allowances) Descriptor deprecated

func (*Allowances) Descriptor() ([]byte, []int)

Deprecated: Use Allowances.ProtoReflect.Descriptor instead.

func (*Allowances) GetItems

func (x *Allowances) GetItems() []*Allowance

func (*Allowances) ProtoMessage

func (*Allowances) ProtoMessage()

func (*Allowances) ProtoReflect

func (x *Allowances) ProtoReflect() protoreflect.Message

func (*Allowances) Reset

func (x *Allowances) Reset()

func (*Allowances) String

func (x *Allowances) String() string

func (*Allowances) Validate

func (this *Allowances) Validate() error

type ApproveRequest

type ApproveRequest struct {
	Owner   string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender string           `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Symbol  string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group   []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount  *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*ApproveRequest) Descriptor deprecated

func (*ApproveRequest) Descriptor() ([]byte, []int)

Deprecated: Use ApproveRequest.ProtoReflect.Descriptor instead.

func (*ApproveRequest) GetAmount

func (x *ApproveRequest) GetAmount() *decimal.Decimal

func (*ApproveRequest) GetGroup

func (x *ApproveRequest) GetGroup() []string

func (*ApproveRequest) GetOwner

func (x *ApproveRequest) GetOwner() string

func (*ApproveRequest) GetSpender

func (x *ApproveRequest) GetSpender() string

func (*ApproveRequest) GetSymbol

func (x *ApproveRequest) GetSymbol() string

func (*ApproveRequest) ProtoMessage

func (*ApproveRequest) ProtoMessage()

func (*ApproveRequest) ProtoReflect

func (x *ApproveRequest) ProtoReflect() protoreflect.Message

func (*ApproveRequest) Reset

func (x *ApproveRequest) Reset()

func (*ApproveRequest) String

func (x *ApproveRequest) String() string

func (*ApproveRequest) Validate

func (this *ApproveRequest) Validate() error

type Approved

type Approved struct {
	Owner   string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender string           `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Symbol  string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group   []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount  *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

Event: Approved event is emitted when Approve method has been invoked

func (*Approved) Descriptor deprecated

func (*Approved) Descriptor() ([]byte, []int)

Deprecated: Use Approved.ProtoReflect.Descriptor instead.

func (*Approved) GetAmount

func (x *Approved) GetAmount() *decimal.Decimal

func (*Approved) GetGroup

func (x *Approved) GetGroup() []string

func (*Approved) GetOwner

func (x *Approved) GetOwner() string

func (*Approved) GetSpender

func (x *Approved) GetSpender() string

func (*Approved) GetSymbol

func (x *Approved) GetSymbol() string

func (*Approved) ProtoMessage

func (*Approved) ProtoMessage()

func (*Approved) ProtoReflect

func (x *Approved) ProtoReflect() protoreflect.Message

func (*Approved) Reset

func (x *Approved) Reset()

func (*Approved) String

func (x *Approved) String() string

func (*Approved) Validate

func (this *Approved) Validate() error

type Operation

type Operation struct {
	Owner   string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender string           `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Symbol  string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group   []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount  *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*Operation) Descriptor deprecated

func (*Operation) Descriptor() ([]byte, []int)

Deprecated: Use Operation.ProtoReflect.Descriptor instead.

func (*Operation) GetAmount

func (x *Operation) GetAmount() *decimal.Decimal

func (*Operation) GetGroup

func (x *Operation) GetGroup() []string

func (*Operation) GetOwner

func (x *Operation) GetOwner() string

func (*Operation) GetSpender

func (x *Operation) GetSpender() string

func (*Operation) GetSymbol

func (x *Operation) GetSymbol() string

func (*Operation) ProtoMessage

func (*Operation) ProtoMessage()

func (*Operation) ProtoReflect

func (x *Operation) ProtoReflect() protoreflect.Message

func (*Operation) Reset

func (x *Operation) Reset()

func (*Operation) String

func (x *Operation) String() string

func (*Operation) Validate

func (this *Operation) Validate() error

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(account account.Getter, balance token.BalanceStore) *Service

func (*Service) Approve

func (s *Service) Approve(ctx router.Context, approve *ApproveRequest) (*Allowance, error)

func (*Service) GetAllowance

func (s *Service) GetAllowance(ctx router.Context, id *AllowanceId) (*Allowance, error)

func (*Service) TransferFrom

func (s *Service) TransferFrom(ctx router.Context, req *TransferFromRequest) (*TransferFromResponse, error)

type TransferFromRequest

type TransferFromRequest struct {
	Owner     string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Recipient string           `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"`
	Symbol    string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group     []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount    *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*TransferFromRequest) Descriptor deprecated

func (*TransferFromRequest) Descriptor() ([]byte, []int)

Deprecated: Use TransferFromRequest.ProtoReflect.Descriptor instead.

func (*TransferFromRequest) GetAmount

func (x *TransferFromRequest) GetAmount() *decimal.Decimal

func (*TransferFromRequest) GetGroup

func (x *TransferFromRequest) GetGroup() []string

func (*TransferFromRequest) GetOwner

func (x *TransferFromRequest) GetOwner() string

func (*TransferFromRequest) GetRecipient

func (x *TransferFromRequest) GetRecipient() string

func (*TransferFromRequest) GetSymbol

func (x *TransferFromRequest) GetSymbol() string

func (*TransferFromRequest) ProtoMessage

func (*TransferFromRequest) ProtoMessage()

func (*TransferFromRequest) ProtoReflect

func (x *TransferFromRequest) ProtoReflect() protoreflect.Message

func (*TransferFromRequest) Reset

func (x *TransferFromRequest) Reset()

func (*TransferFromRequest) String

func (x *TransferFromRequest) String() string

func (*TransferFromRequest) Validate

func (this *TransferFromRequest) Validate() error

type TransferFromResponse

type TransferFromResponse struct {
	Owner     string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Recipient string           `protobuf:"bytes,2,opt,name=recipient,proto3" json:"recipient,omitempty"`
	Symbol    string           `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group     []string         `protobuf:"bytes,4,rep,name=group,proto3" json:"group,omitempty"`
	Amount    *decimal.Decimal `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

func (*TransferFromResponse) Descriptor deprecated

func (*TransferFromResponse) Descriptor() ([]byte, []int)

Deprecated: Use TransferFromResponse.ProtoReflect.Descriptor instead.

func (*TransferFromResponse) GetAmount

func (x *TransferFromResponse) GetAmount() *decimal.Decimal

func (*TransferFromResponse) GetGroup

func (x *TransferFromResponse) GetGroup() []string

func (*TransferFromResponse) GetOwner

func (x *TransferFromResponse) GetOwner() string

func (*TransferFromResponse) GetRecipient

func (x *TransferFromResponse) GetRecipient() string

func (*TransferFromResponse) GetSymbol

func (x *TransferFromResponse) GetSymbol() string

func (*TransferFromResponse) ProtoMessage

func (*TransferFromResponse) ProtoMessage()

func (*TransferFromResponse) ProtoReflect

func (x *TransferFromResponse) ProtoReflect() protoreflect.Message

func (*TransferFromResponse) Reset

func (x *TransferFromResponse) Reset()

func (*TransferFromResponse) String

func (x *TransferFromResponse) String() string

func (*TransferFromResponse) Validate

func (this *TransferFromResponse) Validate() error

type TransferredFrom

type TransferredFrom struct {
	Owner     string           `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Spender   string           `protobuf:"bytes,2,opt,name=spender,proto3" json:"spender,omitempty"`
	Recipient string           `protobuf:"bytes,3,opt,name=recipient,proto3" json:"recipient,omitempty"`
	Symbol    string           `protobuf:"bytes,4,opt,name=symbol,proto3" json:"symbol,omitempty"`
	Group     []string         `protobuf:"bytes,5,rep,name=group,proto3" json:"group,omitempty"`
	Amount    *decimal.Decimal `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount,omitempty"`
	// contains filtered or unexported fields
}

Event: TransferredFrom event is emitted when TransferFrom method has been invoked

func (*TransferredFrom) Descriptor deprecated

func (*TransferredFrom) Descriptor() ([]byte, []int)

Deprecated: Use TransferredFrom.ProtoReflect.Descriptor instead.

func (*TransferredFrom) GetAmount

func (x *TransferredFrom) GetAmount() *decimal.Decimal

func (*TransferredFrom) GetGroup

func (x *TransferredFrom) GetGroup() []string

func (*TransferredFrom) GetOwner

func (x *TransferredFrom) GetOwner() string

func (*TransferredFrom) GetRecipient

func (x *TransferredFrom) GetRecipient() string

func (*TransferredFrom) GetSpender

func (x *TransferredFrom) GetSpender() string

func (*TransferredFrom) GetSymbol

func (x *TransferredFrom) GetSymbol() string

func (*TransferredFrom) ProtoMessage

func (*TransferredFrom) ProtoMessage()

func (*TransferredFrom) ProtoReflect

func (x *TransferredFrom) ProtoReflect() protoreflect.Message

func (*TransferredFrom) Reset

func (x *TransferredFrom) Reset()

func (*TransferredFrom) String

func (x *TransferredFrom) String() string

func (*TransferredFrom) Validate

func (this *TransferredFrom) Validate() error

type UnimplementedAllowanceServiceServer

type UnimplementedAllowanceServiceServer struct {
}

UnimplementedAllowanceServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedAllowanceServiceServer) Approve

func (*UnimplementedAllowanceServiceServer) GetAllowance

func (*UnimplementedAllowanceServiceServer) TransferFrom

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL