Пример #1
0
        public async Task <GetNonceByAddrResult> GetNonceAsync(string address = null, bool txPool = false)
        {
            var addr = string.IsNullOrEmpty(address) ? this.DefaultClient.Wallet.Address : address;

            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        var options = this.Clients[clientId].Wallet.Options.Clone();
                        options.TxPool = txPool;

                        var getNonceResult = await Wallet.Wallet.GetNonceAsync(addr, options);

                        return(getNonceResult);
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options);

            walletOptions.TxPool = txPool;

            return(await Wallet.Wallet.GetNonceAsync(addr, walletOptions));
        }
Пример #2
0
        public GetSubscriptionResult GetSubscriptionAsync(string topic, string subscriber)
        {
            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress) == false)
            {
                try
                {
                    return(NknSdk.Wallet.Wallet.GetSubscriptionAsync(topic, subscriber, this.Wallet.Options));
                }
                catch (Exception)
                {
                }
            }

            return(NknSdk.Wallet.Wallet.GetSubscriptionAsync(topic, subscriber, WalletOptions.NewFrom(this.options)));
        }
Пример #3
0
        public long GetSubscrinersCountAsync(string topic)
        {
            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress) == false)
            {
                try
                {
                    return(NknSdk.Wallet.Wallet.GetSubscribersCountAsync(topic, this.Wallet.Options));
                }
                catch (Exception)
                {
                }
            }

            return(NknSdk.Wallet.Wallet.GetSubscribersCountAsync(topic, WalletOptions.NewFrom(this.options)));
        }
Пример #4
0
        public GetRegistrantResult GetRegistrantAsync(string name)
        {
            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress))
            {
                try
                {
                    return(NknSdk.Wallet.Wallet.GetRegistrantAsync(name, this.Wallet.Options));
                }
                catch (Exception)
                {
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options);

            return(NknSdk.Wallet.Wallet.GetRegistrantAsync(name, walletOptions));
        }
Пример #5
0
        public GetLatestBlockHashResult GetLatestBlockAsync()
        {
            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress))
            {
                try
                {
                    return(NknSdk.Wallet.Wallet.GetLatestBlockAsync(this.Wallet.Options));
                }
                catch (Exception)
                {
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options);

            return(NknSdk.Wallet.Wallet.GetLatestBlockAsync(walletOptions));
        }
Пример #6
0
        public async Task <int> GetSubscribersCountAsync(string topic)
        {
            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        return(await Wallet.Wallet.GetSubscribersCountAsync(topic, this.Clients[clientId].Wallet.Options));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(await Wallet.Wallet.GetSubscribersCountAsync(topic, WalletOptions.NewFrom(this.options)));
        }
Пример #7
0
        public async Task <GetRegistrantResult> GetRegistrantAsync(string name)
        {
            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        return(await Wallet.Wallet.GetRegistrantAsync(name, this.Clients[clientId].Wallet.Options));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(await Wallet.Wallet.GetRegistrantAsync(name, WalletOptions.NewFrom(this.options)));
        }
Пример #8
0
        public async Task <GetLatestBlockHashResult> GetLatestBlockAsync()
        {
            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        return(await Wallet.Wallet.GetLatestBlockAsync(this.Clients[clientId].Wallet.Options));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(await Wallet.Wallet.GetLatestBlockAsync(WalletOptions.NewFrom(this.options)));
        }
Пример #9
0
        public GetSubscribersResult GetSubscribersAsync(string topic, PublishOptions options = null)
        {
            options = options ?? new PublishOptions();

            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress))
            {
                try
                {
                    var mergedOptions = this.Wallet.Options.MergeWith(options);
                    return(NknSdk.Wallet.Wallet.GetSubscribersAsync(topic, mergedOptions));
                }
                catch (Exception)
                {
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options).AssignFrom(options);

            return(NknSdk.Wallet.Wallet.GetSubscribersAsync(topic, walletOptions));
        }
Пример #10
0
        public async Task <GetSubscribersResult> GetSubscribersAsync(string topic, PublishOptions options = null)
        {
            options = options ?? new PublishOptions();

            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        var mergedOptions = this.Clients[clientId].Wallet.Options.MergeWith(options);
                        return(await Wallet.Wallet.GetSubscribersAsync(topic, mergedOptions));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options).AssignFrom(options);

            return(await Wallet.Wallet.GetSubscribersAsync(topic, walletOptions));
        }
Пример #11
0
        public GetNonceByAddrResult GetNonceAsync(string address = null, bool txPool = false)
        {
            var addr = string.IsNullOrEmpty(address) ? this.Wallet.Address : address;

            if (string.IsNullOrWhiteSpace(this.Wallet.Options.RpcServerAddress))
            {
                try
                {
                    var options = this.Wallet.Options.Clone();
                    options.TxPool = txPool;

                    return(NknSdk.Wallet.Wallet.GetNonceAsync(addr, options));
                }
                catch (Exception)
                {
                }
            }

            var walletOptions = WalletOptions.NewFrom(this.options);

            walletOptions.TxPool = txPool;

            return(NknSdk.Wallet.Wallet.GetNonceAsync(addr, walletOptions));
        }
Пример #12
0
        public async Task <Amount> GetBalanceAsync(string address = null)
        {
            var addr = string.IsNullOrEmpty(address) ? this.DefaultClient.Wallet.Address : address;

            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        var balanceResult = await Wallet.Wallet.GetBalanceAsync(addr, this.Clients[clientId].Wallet.Options);

                        return(new Amount(balanceResult.Amount));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var result = await Wallet.Wallet.GetBalanceAsync(addr, WalletOptions.NewFrom(this.options));

            return(new Amount(result.Amount));
        }
Пример #13
0
        public GetSubscriptionResult GetSubscriptionAsync(string topic, string subscriber)
        {
            foreach (var clientId in this.Clients.Keys)
            {
                if (string.IsNullOrEmpty(this.Clients[clientId].Wallet.Options.RpcServerAddress) == false)
                {
                    try
                    {
                        return(Wallet.Wallet.GetSubscriptionAsync(
                                   topic,
                                   subscriber,
                                   this.Clients[clientId].Wallet.Options));
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(Wallet.Wallet.GetSubscriptionAsync(
                       topic,
                       subscriber,
                       WalletOptions.NewFrom(this.options)));
        }