diff --git a/protocol/common.go b/protocol/common.go new file mode 100644 index 0000000..ba641d1 --- /dev/null +++ b/protocol/common.go @@ -0,0 +1,25 @@ +package protocol + +import ( + "fmt" + + "github.com/iden3/iden3comm/v2" +) + +// GoalCode represents the goal code of targeted protocol message +type GoalCode string + +const ( + // ProposalRequest is the goal code for proposal request + ProposalRequest GoalCode = "iden3comm.credentials.v1-1.proposal-request" +) + +// GetProtocolMessageTypeByGoalCode returns the protocol message type by goal code +func GetProtocolMessageTypeByGoalCode(goalCode GoalCode) (iden3comm.ProtocolMessage, error) { + switch goalCode { + case ProposalRequest: + return CredentialProposalRequestMessageType, nil + default: + return "", fmt.Errorf("unknown goal code %s", goalCode) + } +} diff --git a/protocol/transparent_payment.go b/protocol/transparent_payment.go index f7d755e..9597657 100644 --- a/protocol/transparent_payment.go +++ b/protocol/transparent_payment.go @@ -28,7 +28,7 @@ type TransparentPaymentInstructionMessage struct { // TransparentPaymentInstructionMessageBody represents the body of the transparent payment instruction message type TransparentPaymentInstructionMessageBody struct { - GoalCode string `json:"goal_code"` + GoalCode GoalCode `json:"goal_code"` DID string `json:"did,omitempty"` Credentials []CredentialSchemaInfo `json:"credentials"` PaymentData TransparentPaymentData `json:"paymentData"`