private void ConvertThroughProto(TransactionTree source)
        {
            Com.DigitalAsset.Ledger.Api.V1.TransactionTree protoValue = source.ToProto();
            TransactionTree target = TransactionTree.FromProto(protoValue);

            Assert.IsTrue(source == target);
        }
Example #2
0
        public Com.DigitalAsset.Ledger.Api.V1.TransactionTree ToProto()
        {
            var transactionTree = new Com.DigitalAsset.Ledger.Api.V1.TransactionTree {
                TransactionId = TransactionId, CommandId = CommandId, WorkflowId = WorkflowId,
                EffectiveAt   = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(EffectiveAt), Offset = Offset
            };

            transactionTree.EventsById.Add(EventsById.Select(p => (p.Key, p.Value.ToProtoTreeEvent())).ToDictionary(p => p.Item1, p => p.Item2));
            transactionTree.RootEventIds.AddRange(RootEventIds);

            return(transactionTree);
        }
Example #3
0
        public static TransactionTree FromProto(Com.DigitalAsset.Ledger.Api.V1.TransactionTree tree)
        {
            var eventsById = tree.EventsById.Values.Select(e => (e.Created?.EventId ?? e.Exercised?.EventId, TreeEvent.FromProtoTreeEvent(e))).ToDictionary(p => p.Item1, p => p.Item2);

            return(new TransactionTree(tree.TransactionId, tree.CommandId, tree.WorkflowId, tree.EffectiveAt.ToDateTimeOffset(), eventsById, tree.RootEventIds.ToList(), tree.Offset));
        }