Exemplo n.º 1
0
        /// <summary>
        /// Builds a CLAIM_DEF ledger request.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Builds a request message that is suitable for storing a claim definition on a ledger.
        /// A claim definition is published by a claim issuer (e.g. a bank, passport office etc). It
        /// references the relevant schema, the issuer that published the claim definition, and the
        /// signature types used.
        /// </para>
        /// <para>
        /// The <paramref name="data"/> parameter expects a JSON string with the components of a key.
        /// For example:
        /// <code>
        /// {
        ///     "primary":{
        ///         "n":"1",
        ///         "s":"2",
        ///         "rms":"3",
        ///         "r":{
        ///             "name":"1"
        ///          },
        ///          "rctxt":"1",
        ///          "z":"1"
        ///      }
        /// }
        /// </code>
        ///
        /// TODO: Better example required.
        /// </para>
        /// <note type="note">The <paramref name="signatureType"/> parameter only accepts the value
        /// 'CL' at present.</note>
        /// </remarks>
        /// <param name="submitterDid">The DID of the party that will submit the request.</param>
        /// <param name="xref">The sequence number of schema.</param>
        /// <param name="signatureType">The signature type.</param>
        /// <param name="data">A JSON string with the components of a key.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="string"/>
        /// containing the request JSON. </returns>
        public static Task <string> BuildClaimDefTxnAsync(string submitterDid, int xref, string signatureType, string data)
        {
            var taskCompletionSource = new TaskCompletionSource <string>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = IndyNativeMethods.indy_build_claim_def_txn(
                commandHandle,
                submitterDid,
                xref,
                signatureType,
                data,
                _buildRequestCallback
                );

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }