github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/access/rest/request/proposal_key.go (about) 1 package request 2 3 import ( 4 "fmt" 5 6 "github.com/onflow/flow-go/engine/access/rest/models" 7 "github.com/onflow/flow-go/engine/access/rest/util" 8 "github.com/onflow/flow-go/model/flow" 9 ) 10 11 type ProposalKey flow.ProposalKey 12 13 func (p *ProposalKey) Parse(raw models.ProposalKey, chain flow.Chain) error { 14 address, err := ParseAddress(raw.Address, chain) 15 if err != nil { 16 return err 17 } 18 19 keyIndex, err := util.ToUint64(raw.KeyIndex) 20 if err != nil { 21 return fmt.Errorf("invalid key index: %w", err) 22 } 23 24 seqNumber, err := util.ToUint64(raw.SequenceNumber) 25 if err != nil { 26 return fmt.Errorf("invalid sequence number: %w", err) 27 } 28 29 *p = ProposalKey(flow.ProposalKey{ 30 Address: address, 31 KeyIndex: keyIndex, 32 SequenceNumber: seqNumber, 33 }) 34 return nil 35 } 36 37 func (p ProposalKey) Flow() flow.ProposalKey { 38 return flow.ProposalKey(p) 39 }