Example #1
0
        /// <summary>
        /// Helper method used to reject a transfer request. Note that group
        /// is calculated from parent link. Parent link must have been provided!
        /// </summary>
        /// <param name="data"> the optional data </param>
        /// <returns>The <see cref="TraceLinkBuilder{TLinkData}"/></returns>
        public TraceLinkBuilder <TLinkData> ForRejectTransfer(TLinkData data)
        {
            TraceLink <TLinkData> parent = this.ParentLink;
            string action = TraceActionType.REJECT_TRANSFER.ToString();
            string type   = TraceLinkType.OWNED.ToString();

            this.WithGroup(parent.Group())
            .WithHashedData(data)
            .WithAction(action)
            .WithProcessState(type);
            return(this);
        }
Example #2
0
        /// <summary>
        /// Helper method used to cancel a transfer request. Note that owner and group
        /// are calculated from parent link. Parent link must have been provided!
        /// </summary>
        /// <param name="data"> the optional data </param>
        /// <returns>The <see cref="TraceLinkBuilder{TLinkData}"/></returns>
        public TraceLinkBuilder <TLinkData> ForCancelTransfer(TLinkData data)
        {
            TraceLink <TLinkData> parent = this.ParentLink;
            string action = TraceActionType.CANCEL_TRANSFER.ToString();
            string type   = TraceLinkType.OWNED.ToString();

            this.WithOwner(parent.Owner().GetAccount())
            .WithGroup(parent.Group())
            .WithHashedData(data)
            .WithAction(action)
            .WithProcessState(type);
            return(this);
        }
Example #3
0
        /// <summary>
        /// Helper method used for transfer of ownership requests (push). Note
        /// that group is calculated from parent link. Parent link must have
        /// been provided!
        /// </summary>
        /// <param name="to">     the group to which the transfer is made for </param>
        /// <param name="action"> the action (_PUSH_OWNERSHIP_ or _PULL_OWNERSHIP_) </param>
        /// <param name="type">   the type (PUSHING OR PULLING) </param>
        /// <param name="data">   the optional data </param>
        /// <returns>The <see cref="TraceLinkBuilder{TLinkData}"/></returns>
        public TraceLinkBuilder <TLinkData> ForTransferRequest(string to, TraceActionType action, TraceLinkType type, TLinkData data)
        {
            TraceLink <TLinkData> parent = this.ParentLink;

            this.WithGroup(parent.Group())
            .WithHashedData(data)
            .WithAction(action.ToString())
            .WithProcessState(type.ToString());

            this.metadata.Inputs     = new string[] { to };
            this.metadata.LastFormId = parent.Form() != null?parent.Form() : parent.LastForm();

            return(this);
        }
Example #4
0
        /// <summary>
        /// The MakeTraceState
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="trace">The trace<see cref="dynamic"/></param>
        /// <returns>The <see cref="TraceState{TState, TLinkData}"/></returns>
        private TraceState <TState, TLinkData> MakeTraceState <TLinkData>(dynamic trace)
        {
            JObject raw = trace.head.raw;

            var data = trace.head.data;

            string rawJson = raw.ToString(Newtonsoft.Json.Formatting.None);

            var linkObj = JsonHelper.FromJson <Link>(rawJson);

            TraceLink <TLinkData> headLink = new TraceLink <TLinkData>(new Stratumn.Chainscript.Link(linkObj), JsonHelper.ObjectToObject <TLinkData>(data));


            TraceState <TState, TLinkData> traceState = new TraceState <TState, TLinkData>(headLink.TraceId(), headLink, headLink.CreatedAt(),
                                                                                           headLink.CreatedBy(), JsonHelper.ObjectToObject <TState>(trace.state.data), trace.tags ?? new string[0], headLink.Group()
                                                                                           );

            return(traceState);
        }