-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstate.go
More file actions
35 lines (30 loc) · 1.06 KB
/
state.go
File metadata and controls
35 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cpaper
import (
"github.com/s7techlab/cckit/router"
"github.com/s7techlab/cckit/state"
m "github.com/s7techlab/cckit/state/mapping"
)
var (
StateMappings = m.StateMappings{}.
// Create mapping for Commercial Paper entity
Add(&CommercialPaper{},
m.PKeySchema(&CommercialPaperId{}), // Key namespace will be <"CommercialPaper", Issuer, PaperNumber>
m.List(&CommercialPaperList{}), // Structure of result for List method
m.UniqKey("ExternalId"), // External Id is unique
)
EventMappings = m.EventMappings{}.
// Event name will be "IssueCommercialPaper", payload - same as issue payload
Add(&IssueCommercialPaper{}).
// Event name will be "BuyCommercialPaper"
Add(&BuyCommercialPaper{}).
// Event name will be "RedeemCommercialPaper"
Add(&RedeemCommercialPaper{})
)
// State with chaincode mappings
func State(ctx router.Context) m.MappedState {
return m.WrapState(ctx.State(), StateMappings)
}
// Event with chaincode mappings
func Event(ctx router.Context) state.Event {
return m.WrapEvent(ctx.Event(), EventMappings)
}