github.com/s7techlab/cckit@v0.10.5/examples/token/service/config/state.go (about)

     1  package config
     2  
     3  import (
     4  	"github.com/s7techlab/cckit/router"
     5  	"github.com/s7techlab/cckit/state"
     6  	m "github.com/s7techlab/cckit/state/mapping"
     7  )
     8  
     9  var (
    10  	StateMappings = m.StateMappings{}.
    11  			Add(&TokenType{},
    12  			m.PKeySchema(&TokenTypeId{}),
    13  			m.List(&TokenTypes{})).
    14  		Add(&TokenGroup{},
    15  			m.PKeySchema(&TokenGroupId{}),
    16  			m.List(&TokenGroups{})).
    17  		Add(&Config{},
    18  			m.WithConstPKey())
    19  
    20  	EventMappings = m.EventMappings{}.
    21  			Add(&TokenTypeCreated{}).
    22  			Add(&TokenGroupCreated{})
    23  )
    24  
    25  // State with chaincode mappings
    26  func State(ctx router.Context) m.MappedState {
    27  	return m.WrapState(ctx.State(), StateMappings)
    28  }
    29  
    30  // Event with chaincode mappings
    31  func Event(ctx router.Context) state.Event {
    32  	return m.WrapEvent(ctx.Event(), EventMappings)
    33  }