/// <inheritdoc />
        public async Task <(ProposePresentationMessage, ProofRecord)> CreateProposalAsync(IAgentContext agentContext, ProofProposal proofProposal, string connectionId)
        {
            Logger.LogInformation(LoggingEvents.CreateProofRequest, "ConnectionId {0}", connectionId);

            if (proofProposal == null)
            {
                throw new ArgumentNullException(nameof(proofProposal), "You must provide a presentation preview");;
            }
            if (connectionId != null)
            {
                var connection = await ConnectionService.GetAsync(agentContext, connectionId);

                if (connection.State != ConnectionState.Connected)
                {
                    throw new AriesFrameworkException(ErrorCode.RecordInInvalidState,
                                                      $"Connection state was invalid. Expected '{ConnectionState.Connected}', found '{connection.State}'");
                }
            }
            this.CheckProofProposalParameters(proofProposal);


            var threadId    = Guid.NewGuid().ToString();
            var proofRecord = new ProofRecord
            {
                Id           = Guid.NewGuid().ToString(),
                ConnectionId = connectionId,
                ProposalJson = proofProposal.ToJson(),
                State        = ProofState.Proposed
            };

            proofRecord.SetTag(TagConstants.Role, TagConstants.Holder);
            proofRecord.SetTag(TagConstants.LastThreadId, threadId);

            await RecordService.AddAsync(agentContext.Wallet, proofRecord);

            var message = new ProposePresentationMessage
            {
                Id      = threadId,
                Comment = proofProposal.Comment,
                PresentationPreviewMessage = new PresentationPreviewMessage()
                {
                    ProposedAttributes = proofProposal.ProposedAttributes.ToArray(),
                    ProposedPredicates = proofProposal.ProposedPredicates.ToArray()
                }
            };

            message.ThreadFrom(threadId);
            return(message, proofRecord);
        }
        public async Task <ProofRecord> ProcessProposalAsync(IAgentContext agentContext, ProposePresentationMessage proposePresentationMessage, ConnectionRecord connection)
        {
            // save in wallet

            var proofProposal = new ProofProposal
            {
                Comment            = proposePresentationMessage.Comment,
                ProposedAttributes = proposePresentationMessage.PresentationPreviewMessage.ProposedAttributes.ToList <ProposedAttribute>(),
                ProposedPredicates = proposePresentationMessage.PresentationPreviewMessage.ProposedPredicates.ToList <ProposedPredicate>()
            };

            var proofRecord = new ProofRecord
            {
                Id           = Guid.NewGuid().ToString(),
                ProposalJson = proofProposal.ToJson(),
                ConnectionId = connection?.Id,
                State        = ProofState.Proposed
            };

            proofRecord.SetTag(TagConstants.LastThreadId, proposePresentationMessage.GetThreadId());
            proofRecord.SetTag(TagConstants.Role, TagConstants.Requestor);
            await RecordService.AddAsync(agentContext.Wallet, proofRecord);

            EventAggregator.Publish(new ServiceMessageProcessingEvent
            {
                RecordId    = proofRecord.Id,
                MessageType = proposePresentationMessage.Type,
                ThreadId    = proposePresentationMessage.GetThreadId()
            });

            return(proofRecord);
        }