Skip to content

Instantly share code, notes, and snippets.

@vitiko

vitiko/block7.go Secret

Created July 23, 2019 07:45
Show Gist options
  • Save vitiko/c139c746505573c43be7244bb1036cc7 to your computer and use it in GitHub Desktop.
Save vitiko/c139c746505573c43be7244bb1036cc7 to your computer and use it in GitHub Desktop.
type CPaperImpl struct {
}
func (cc *CPaperImpl) state(ctx router.Context) m.MappedState {
return m.WrapState(ctx.State(), m.StateMappings{}.
// Create mapping for Commercial Paper entity
Add(&schema.CommercialPaper{},
m.PKeySchema(&schema.CommercialPaperId{}), // Key namespace will be <"CommercialPaper", Issuer, PaperNumber>
m.List(&schema.CommercialPaperList{}), // Structure of result for List method
m.UniqKey("ExternalId"), // External Id is unique
))
}
func (cc *CPaperImpl) event(ctx router.Context) state.Event {
return m.WrapEvent(ctx.Event(), m.EventMappings{}.
// Event name will be "IssueCommercialPaper", payload - same as issue payload
Add(&schema.IssueCommercialPaper{}).
// Event name will be "BuyCommercialPaper"
Add(&schema.BuyCommercialPaper{}).
// Event name will be "RedeemCommercialPaper"
Add(&schema.RedeemCommercialPaper{}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment