private void OnCommandGetNonce(string[] args)
        {
            Task.Run(async() =>
            {
                string address = args[0].IsHexString() ? args[0] : wallets.TryGetValue(args[0], out var account) ? (string)account.Address : null;
                string arg     = args.Length > 1 ? args[1] : CyprusHelper.PENDING;

                if (string.IsNullOrEmpty(address))
                {
                    BConsole.WriteLine("address not found");
                    return;
                }

                (ulong?nonce, string error) = await web4b.GetTransactionCountAsync(address, arg);
                BConsole.WriteLine(Color.DarkGreen, nonce);
            });
        }
Beispiel #2
0
        public async Task ShouldPassCyprusCallTest()
        {
            string  error;
            Address coinbase;
            long    number;
            H256    hash;
            ulong?  balance, nonce;
            JObject block, block1;
            int     count;

            // cyprus_coinbase
            (coinbase, error) = await cyprus.GetCoinbaseAsync();

            Assert.True(string.IsNullOrEmpty(error));
            Assert.False(string.IsNullOrEmpty(coinbase));

            // cyprus_blockNumber
            (number, error) = await cyprus.GetBlockNumberAsync();

            Assert.True(string.IsNullOrEmpty(error));

            // cyprus_getBalance ( earliest )
            (balance, error) = await cyprus.GetBalanceAsync(coinbase, CyprusHelper.EARLIEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // cyprus_getBalance ( latest )
            (balance, error) = await cyprus.GetBalanceAsync(coinbase, CyprusHelper.LATEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // cyprus_getBalance ( pending )
            (balance, error) = await cyprus.GetBalanceAsync(coinbase, CyprusHelper.PENDING);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // cyprus_getBalance ( number )
            (balance, error) = await cyprus.GetBalanceAsync(coinbase, Hex.ToString(number, true));

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(balance);

            // cyprus_getTransactionCount ( earliest )
            (nonce, error) = await cyprus.GetTransactionCountAsync(coinbase, CyprusHelper.EARLIEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // cyprus_getTransactionCount ( latest )
            (nonce, error) = await cyprus.GetTransactionCountAsync(coinbase, CyprusHelper.LATEST);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // cyprus_getTransactionCount ( pending )
            (nonce, error) = await cyprus.GetTransactionCountAsync(coinbase, CyprusHelper.PENDING);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // cyprus_getBalance ( number )
            (nonce, error) = await cyprus.GetTransactionCountAsync(coinbase, Hex.ToString(number, true));

            Assert.True(string.IsNullOrEmpty(error));
            Assert.NotNull(nonce);

            // cyprus_getBlockByNumber / cyprus_getBlockByHash
            (block, error) = await cyprus.GetBlockByNumberAsync(number, true);

            Assert.True(string.IsNullOrEmpty(error));

            hash = block.Value <string>("hash");

            (block1, error) = await cyprus.GetBlockByHashAsync(block.Value <string>("hash"), true);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.Equal(block.Value <string>("hash"), block1.Value <string>("hash"));

            // cyprus_getBlockTransactionCountByHash
            (count, error) = await cyprus.GetBlockTransactionCountByHashAsync(hash);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.True(count >= 0);

            // cyprus_getBlockTransactionCountByNumber
            (count, error) = await cyprus.GetBlockTransactionCountByNumberAsync(number);

            Assert.True(string.IsNullOrEmpty(error));
            Assert.True(count >= 0);
        }
Beispiel #3
0
 /// <summary>
 /// get user nonce
 /// </summary>
 /// <param name="address"></param>
 /// <param name="arg"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public async Task <(ulong?nonce, string error)> GetNonceAsync(string address, string arg = CyprusHelper.PENDING, int id = 0)
 {
     return(await Cyprus.GetTransactionCountAsync(address, arg, id));
 }