Beispiel #1
0
        /// <inheritdoc />
        public virtual async Task RegisterNymAsync(IAgentContext context, string submitterDid, string theirDid,
                                                   string theirVerkey, string role, TransactionCost paymentInfo = null)
        {
            if (DidUtils.IsFullVerkey(theirVerkey))
            {
                theirVerkey = await Did.AbbreviateVerkeyAsync(theirDid, theirVerkey);
            }

            var req = await IndyLedger.BuildNymRequestAsync(submitterDid, theirDid, theirVerkey, null, role);

            var res = await SignAndSubmitAsync(context, submitterDid, req, paymentInfo);
        }
Beispiel #2
0
        private async Task <string> SignAndSubmitAsync(IAgentContext context, string submitterDid, string request, TransactionCost paymentInfo)
        {
            if (paymentInfo != null)
            {
                var requestWithFees = await IndyPayments.AddRequestFeesAsync(
                    wallet : context.Wallet,
                    submitterDid : null,
                    reqJson : request,
                    inputsJson : paymentInfo.PaymentAddress.Sources.Select(x => x.Source).ToJson(),
                    outputsJson : new[]
                {
                    new IndyPaymentOutputSource
                    {
                        Recipient = paymentInfo.PaymentAddress.Address,
                        Amount    = paymentInfo.PaymentAddress.Balance - paymentInfo.Amount
                    }
                }.ToJson(),
                    extra : null);

                request = requestWithFees.Result;
            }
            var signedRequest = await _signingService.SignRequestAsync(context, submitterDid, request);

            var response = await IndyLedger.SubmitRequestAsync(await context.Pool, signedRequest);

            EnsureSuccessResponse(response);

            if (paymentInfo != null)
            {
                var responsePayment = await IndyPayments.ParseResponseWithFeesAsync(paymentInfo.PaymentMethod, response);

                var paymentOutputs = responsePayment.ToObject <IList <IndyPaymentOutputSource> >();
                paymentInfo.PaymentAddress.Sources = paymentOutputs
                                                     .Where(x => x.Recipient == paymentInfo.PaymentAddress.Address)
                                                     .Select(x => new IndyPaymentInputSource
                {
                    Amount         = x.Amount,
                    PaymentAddress = x.Recipient,
                    Source         = x.Receipt
                })
                                                     .ToList();
            }
            return(response);
        }
Beispiel #3
0
        /// <inheritdoc />
        public virtual async Task RegisterAttributeAsync(IAgentContext context, string submittedDid, string targetDid,
                                                         string attributeName, object value, TransactionCost paymentInfo = null)
        {
            var data = $"{{\"{attributeName}\": {value.ToJson()}}}";

            var req = await IndyLedger.BuildAttribRequestAsync(submittedDid, targetDid, null, data, null);

            var res = await SignAndSubmitAsync(context, submittedDid, req, paymentInfo);
        }
Beispiel #4
0
        /// <inheritdoc />
        public virtual async Task RegisterRevocationRegistryDefinitionAsync(IAgentContext context, string submitterDid,
                                                                            string data, TransactionCost paymentInfo = null)
        {
            var req = await IndyLedger.BuildRevocRegDefRequestAsync(submitterDid, data);

            var res = await SignAndSubmitAsync(context, submitterDid, req, paymentInfo);
        }
Beispiel #5
0
        /// <inheritdoc />
        public virtual async Task SendRevocationRegistryEntryAsync(IAgentContext context, string issuerDid,
                                                                   string revocationRegistryDefinitionId, string revocationDefinitionType, string value, TransactionCost paymentInfo = null)
        {
            var req = await IndyLedger.BuildRevocRegEntryRequestAsync(issuerDid, revocationRegistryDefinitionId,
                                                                      revocationDefinitionType, value);

            var res = await SignAndSubmitAsync(context, issuerDid, req, paymentInfo);

            EnsureSuccessResponse(res);
        }
Beispiel #6
0
        /// <inheritdoc />
        public virtual async Task RegisterSchemaAsync(IAgentContext context, string issuerDid, string schemaJson, TransactionCost paymentInfo = null)
        {
            var req = await IndyLedger.BuildSchemaRequestAsync(issuerDid, schemaJson);

            var res = await SignAndSubmitAsync(context, issuerDid, req, paymentInfo);
        }
        /// <inheritdoc />
        public async Task RegisterServiceEndpointAsync(IAgentContext context, string did, string serviceEndpoint, TransactionCost paymentInfo = null)
        {
            var value = new { endpoint = serviceEndpoint };

            await RegisterAttributeAsync(context, did, did, "endpoint", value);
        }
        /// <inheritdoc />
        public virtual async Task RegisterRevocationRegistryDefinitionAsync(Wallet wallet, Pool pool, string submitterDid,
                                                                            string data, TransactionCost paymentInfo = null)
        {
            var req = await Ledger.BuildRevocRegDefRequestAsync(submitterDid, data);

            var res = await SignAndSubmitAsync(pool, wallet, submitterDid, req, paymentInfo);
        }
        /// <inheritdoc />
        public virtual async Task RegisterSchemaAsync(Pool pool, Wallet wallet, string issuerDid, string schemaJson, TransactionCost paymentInfo = null)
        {
            var req = await Ledger.BuildSchemaRequestAsync(issuerDid, schemaJson);

            var res = await SignAndSubmitAsync(pool, wallet, issuerDid, req, paymentInfo);
        }
        /// <inheritdoc />
        public virtual async Task SendRevocationRegistryEntryAsync(Wallet wallet, Pool pool, string issuerDid,
                                                                   string revocationRegistryDefinitionId, string revocationDefinitionType, string value, TransactionCost paymentInfo = null)
        {
            var req = await Ledger.BuildRevocRegEntryRequestAsync(issuerDid, revocationRegistryDefinitionId,
                                                                  revocationDefinitionType, value);

            var res = await SignAndSubmitAsync(pool, wallet, issuerDid, req, paymentInfo);
        }