Skip to content

Commit

Permalink
add constructor for create contract invoke message
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya committed Aug 16, 2023
1 parent b6406dd commit 582bf0d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,39 @@ func CreateAuthorizationRequestWithMessage(reason, message, sender,
return request
}

// CreateContractInvokeRequest creates new contract invoke request message
// reason - describes purpose of request
// sender - sender identifier
// transactionData - data for on chain verification
// zkRequests - zero knowledge proof request(s)
func CreateContractInvokeRequest(
reason, sender string,
transactionData protocol.TransactionData,
zkRequests ...protocol.ZeroKnowledgeProofRequest,
) protocol.ContractInvokeRequestMessage {
return CreateContractInvokeRequestWithMessage(reason, "", sender, transactionData, zkRequests...)
}

// CreateContractInvokeRequestWithMessage creates new contract invoke request message with message
func CreateContractInvokeRequestWithMessage(
reason, message, sender string,
transactionData protocol.TransactionData,
zkRequests ...protocol.ZeroKnowledgeProofRequest,
) protocol.ContractInvokeRequestMessage {
return protocol.ContractInvokeRequestMessage{
Typ: packers.MediaTypePlainMessage,
Type: protocol.AuthorizationRequestMessageType,
ID: uuid.New().String(),
From: sender,
Body: protocol.ContractInvokeRequestMessageBody{
Reason: reason,
Message: message,
TransactionData: transactionData,
Scope: zkRequests,
},
}
}

// VerifyAuthResponse performs verification of auth response based on auth request
func (v *Verifier) VerifyAuthResponse(
ctx context.Context,
Expand Down

0 comments on commit 582bf0d

Please sign in to comment.