github.com/s7techlab/cckit@v0.10.5/extensions/owner/state.go (about)

     1  package owner
     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  // OwnerStateKey key used to store owner grant struct in chain code state
    10  // "handler" part of owner extension supports only one owner
    11  // "service" part of owner extension supports multiple owners
    12  const OwnerStateKey = `OWNER`
    13  
    14  var (
    15  	StateMappings = m.StateMappings{}.
    16  			Add(&ChaincodeOwner{},
    17  			m.PKeySchema(&OwnerId{}),
    18  			m.List(&ChaincodeOwners{}))
    19  
    20  	EventMappings = m.EventMappings{}.
    21  			Add(&ChaincodeOwnerCreated{}).
    22  			Add(&ChaincodeOwnerUpdated{}).
    23  			Add(&ChaincodeOwnerDeleted{})
    24  )
    25  
    26  func State(ctx router.Context) m.MappedState {
    27  	return m.WrapState(ctx.State(), StateMappings)
    28  }
    29  
    30  func Event(ctx router.Context) state.Event {
    31  	return m.WrapEvent(ctx.Event(), EventMappings)
    32  }