Пример #1
0
 private static IPromise BroadcastTransaction(TransactionBuilder builder, Action <TransactionConfirmationData> resultCallback = null)
 {
     return(new Promise((resolve, reject) => new Task(() =>
     {
         try
         {
             if (!builder.signed)
             {
                 builder.Sign();
             }
             if (!builder.IsFinalized)
             {
                 throw new InvalidOperationException("Not finalized");
             }
             if (builder.signatures.IsNullOrEmpty())
             {
                 throw new InvalidOperationException("Not signed");
             }
             if (builder.operations.IsNullOrEmpty())
             {
                 throw new InvalidOperationException("No operations");
             }
             EchoApiManager.Instance.NetworkBroadcast.BroadcastTransactionWithCallback(new SignedTransactionData(builder), async result =>
             {
                 resultCallback?.Invoke(result.IsNullOrEmpty() ? null : await result.First().ToObjectAsync <TransactionConfirmationData>());
             }).Then(resolve).Catch(reject);
         }
         catch (Exception ex)
         {
             reject(ex);
         }
     }).Start()));
 }
Пример #2
0
 static IPromise BroadcastTransaction(TransactionBuilder transactionBuilder, Action <JToken[]> resultCallback)
 {
     return(new Promise((resolve, reject) => {
         if (!transactionBuilder.signed)
         {
             transactionBuilder.Sign();
         }
         if (!transactionBuilder.IsFinalized)
         {
             throw new InvalidOperationException("Not finalized");
         }
         if (transactionBuilder.signatures.IsNullOrEmpty())
         {
             throw new InvalidOperationException("Not signed");
         }
         if (transactionBuilder.operations.IsNullOrEmpty())
         {
             throw new InvalidOperationException("No operations");
         }
         ApiManager.Instance.NetworkBroadcast.BroadcastTransactionWithCallback(resultCallback, new SignedTransactionData(transactionBuilder)).Then(resolve).Catch(reject);
     }));
 }