public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect("ws://127.0.0.1:9944");
                BigInteger maxValue = (new BigInteger(1) << 128) - 1;

                string     addr          = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
                bool       doneS         = false;
                BigInteger balanceResult = maxValue;
                var        sid           = app.SubscribeBalance(addr, (balance) => {
                    output.WriteLine($"Balance: {balance}");
                    Console.WriteLine($"\nBalance: {balance}\n");
                    balanceResult = balance;
                    doneS         = true;
                });

                while (!doneS)
                {
                    Thread.Sleep(1000);
                }

                app.UnsubscribeBalance(sid);

                app.Disconnect();

                Assert.True(balanceResult < maxValue);
            }
        }
Exemplo n.º 2
0
        public ParseDemocracy()
        {
            var dbCon        = "Host=localhost;Port=5432;Database=postgres;Username=postgres;Password="******"wss://kusama-rpc.polkadot.io/";

            _app = PolkaApi.GetAppication();
            _sch = new MetadataSchema();

            string nodeUrl = substrateCon;

            _app.Connect(nodeUrl);

            // Connect to db and check metadata version
            _postgres = new Postgres(dbCon);
            _indexer  = new Indexer(_app, _postgres);

            // Create or update current schema
            var metadata = _app.GetMetadata(null);

            _sch.ParseMetadata(metadata);
            var si = _app.GetSystemInfo();

            _sch.DatabaseSchema.Title = "Test_ParseBalances";

            _sch.CommitToDb(_postgres, si);

            // Check current schema
            _indexer.CheckSystemInfo();
        }
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                long blockNum      = 0;
                int  messagesCount = 0;
                app.Connect();

                var subId = app.SubscribeBlockNumber((blockNumber) =>
                {
                    blockNum = blockNumber;
                    messagesCount++;
                    output.WriteLine($"Last block number        : {blockNumber}");
                });

                while (messagesCount < 1)
                {
                    Thread.Sleep(300);
                }

                app.UnsubscribeBlockNumber(subId);

                app.Disconnect();

                Assert.True(blockNum > 0);
            }
        }
Exemplo n.º 4
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();

                // Subscribe to storage updates (timestamp)
                var    module   = "Timestamp";
                var    variable = "Now";
                var    key      = app.GetKeys("", module, variable);
                bool   doneS    = false;
                string tsUpdate = string.Empty;
                var    sid      = app.SubscribeStorage(key, (update) => {
                    output.WriteLine($"Timestamp update: {update}");
                    tsUpdate = update;
                    doneS    = true;
                });

                while (!doneS)
                {
                    Thread.SpinWait(1000);
                }

                app.UnsubscribeStorage(sid);

                app.Disconnect();

                Assert.True(tsUpdate.Length > 0);
                Assert.True(tsUpdate.Substring(0, 2) == "0x");
            }
        }
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                BigInteger maxValue = (new BigInteger(1) << 128) - 1;

                string     addr          = "5HQdHxuPgQ1BpJasmm5ZzfSk5RDvYiH6YHfDJVE8jXmp4eig";
                bool       doneS         = false;
                BigInteger balanceResult = maxValue;
                var        sid           = app.SubscribeBalance(addr, (balance) => {
                    output.WriteLine($"Balance: {balance}");
                    Console.WriteLine($"\nBalance: {balance}\n");
                    balanceResult = balance;
                    doneS         = true;
                });

                while (!doneS)
                {
                    Thread.Sleep(1000);
                }

                app.UnsubscribeBalance(sid);

                app.Disconnect();

                Assert.True(balanceResult < maxValue);
            }
        }
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result = app.GetSystemInfo();

                Assert.True(result.ChainId.Length > 0);

                // Check chainName
                Assert.Equal("parity-polkadot", result.ChainName);

                // Check version
                Assert.NotEqual(string.Empty, result.Version);

                // Check tokenSymbol
                Assert.Equal("DOT", result.TokenSymbol);

                // Check tokenDecimals
                Assert.Equal(15, result.TokenDecimals);

                output.WriteLine($"Chain id        : {result.ChainId}");
                output.WriteLine($"Chain name      : {result.ChainName}");
                output.WriteLine($"Version         : {result.Version}");
                output.WriteLine($"Token symbol    : {result.TokenSymbol}");
                output.WriteLine($"Token decimals  : {result.TokenDecimals}");

                app.Disconnect();
            }
        }
Exemplo n.º 7
0
 public void Ok()
 {
     using (IApplication app = PolkaApi.GetAppication())
     {
         app.Connect("wss://kusama-rpc.polkadot.io/");
         app.Disconnect();
     }
 }
Exemplo n.º 8
0
        public void Ok()
        {
            string address   = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string address2  = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
            string module1   = "Balances";
            string variable1 = "TotalIssuance";
            string module2   = "System";
            string variable2 = "Account";
            string module3   = "Timestamp";
            string variable3 = "Now";


            //var aupk = AddressUtils.GetPublicKeyFromAddr("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY");
            //var str1 = BitConverter.ToString(aupk.Bytes).Replace("-", "");

            //var bts = Encoding.ASCII.GetBytes("T::AccountId 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY");
            //var sk = GetStorageKey(Hasher.BLAKE2, aupk.Bytes, aupk.Bytes.Length);

            var a = new Address(address2);
            var t = a.GetTypeEncoded();

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                //output.WriteLine("================== Get Storage 1: Address Balance ==================");
                // JObject prm1 = new JObject { { "type", "AccountId" }, { "value", address } };
                //string balance = app.GetStorage(prm1.ToString(), module1, variable1);
                //output.WriteLine($"Encoded balance: {balance}");
                //Assert.True(balance != "null");
                //Assert.True(balance.Length > 0);

                output.WriteLine("================== Get Storage 2: System Account ==================");
                // JObject prm2 = new JObject { { "type", "AccountId" }, { "value", address2 } };
                string accountBalance = app.GetStorage(new Address(address), module2, variable2);
                output.WriteLine($"Encoded account balance: {accountBalance}");
                Assert.True(accountBalance != "null");
                Assert.True(accountBalance.Length > 0);

                output.WriteLine("================== Get Storage 3: Timestamp ==================");
                string timeNow = app.GetStorage(module3, variable3);
                output.WriteLine($"Encoded timestamp: {timeNow}");
                Assert.True(timeNow != "null");
                Assert.True(timeNow.Length > 0);

                output.WriteLine("================== Get Storage 4: Non-existing storage key ==================");
                try
                {
                    string abra = app.GetStorage("Abra", "Cadabra");
                }
                catch (Exception)
                {
                    output.WriteLine("Caught expected ApplicationException");
                }

                app.Disconnect();
            }
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            MetadataSchema sch = new MetadataSchema();

            using (IApplication app = PolkaApi.GetAppication())
            {
                bool reconnect = true;

                while (reconnect)
                {
                    try {
                        string nodeUrl           = ConfigurationManager.AppSettings["Substrate"];
                        var    metadataBlockHash = ConfigurationManager.AppSettings["MetadataBlockHash"];
                        app.Connect(nodeUrl, metadataBlockHash);

                        // Connect to db and check metadata version
                        var postgres = new Postgres(ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString);
                        var indexer  = new Indexer(app, postgres);

                        // Create or update current schema

                        var startBlock = 0;
                        int.TryParse(ConfigurationManager.AppSettings["StartBlockNum"], out startBlock);
                        var metadata = app.GetMetadata(null);

                        //var metadata = app.GetMetadata(null);
                        sch.ParseMetadata(metadata);
                        var si = app.GetSystemInfo();
                        sch.CommitToDb(postgres, si);

                        // Check current schema
                        indexer.CheckSystemInfo();

                        // Parse blocks
                        indexer.Scan(startBlock);
                    } catch (System.ApplicationException appex) {
                        Console.WriteLine("ApplicationException caught: " + appex.Message);
                        reconnect = appex.Message.Contains("Not connected");
                    } catch (Exception e) {
                        Console.WriteLine("Exception caught: " + e.ToString());
                        if (e.Message.Contains("The operation has timed out"))
                        {
                            reconnect = true;
                        }
                        else
                        {
                            reconnect = false;
                        }
                    } finally {
                        app.Disconnect();
                    }
                }
            }

            Console.ReadLine();
        }
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result = app.GetFinalizedHead();

                output.WriteLine($"Finalized head hash: { result.BlockHash }");

                Assert.True(result.BlockHash.Length == 66);
                app.Disconnect();
            }
        }
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result = app.GetSystemHealth();

                Assert.True(result != null);

                output.WriteLine($"Peers : {result.Peers}");
                output.WriteLine($"ShouldHavePeers : {result.ShouldHavePeers}");

                app.Disconnect();
            }
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            // This is a manual test due to lack of test DOTs
            if (args.Length < 4)
            {
                Console.WriteLine("This is intended to be a manual test");
                Console.WriteLine("Usage: ");
                Console.WriteLine("<sender address> <recipient address> <amount in fDOTs> <sender private key (hex)>");
                Console.WriteLine("success");
            }
            else
            {
                var senderAddr          = args[0];
                var recipientAddr       = args[1];
                var amountStr           = args[2];
                var senderPrivateKeyStr = args[3];

                using (IApplication app = PolkaApi.GetAppication())
                {
                    // Receiving address public key
                    var pk = AddressUtils.GetPublicKeyFromAddr(recipientAddr);

                    // Compact-encode amount
                    var compactAmount = Scale.EncodeCompactInteger(BigInteger.Parse(amountStr));

                    var buf = new byte[pk.Bytes.Length + compactAmount.Bytes.Length];
                    pk.Bytes.CopyTo(buf.AsMemory());
                    compactAmount.Bytes.CopyTo(buf.AsMemory(pk.Bytes.Length));

                    app.Connect();
                    var exHash = app.SubmitExtrinsic(buf, "balances", "transfer", new Address(senderAddr), senderPrivateKeyStr);

                    Console.WriteLine($"Sent extrinsic with hash: {exHash} ");
                    Console.WriteLine("Now let's try to cancel it... ");

                    try
                    {
                        app.RemoveExtrinsic(exHash);
                    }
                    catch (ApplicationException)
                    {
                        Console.WriteLine("Yeah, looks like canceling is not yet supported");
                    }

                    app.Disconnect();
                }
            }
        }
Exemplo n.º 13
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result = app.GetBlockHash(new GetBlockHashParams {
                    BlockNumber = 2
                });

                Assert.Equal("0x2df84d4c6bb8441f7a1702b4589dc33f8dc43a0794a4df446c74110636456989", result.Hash);

                output.WriteLine($"Result hash : {result.Hash}");

                app.Disconnect();
            }
        }
Exemplo n.º 14
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result = app.GetBlockHash(new GetBlockHashParams {
                    BlockNumber = 2
                });

                Assert.Equal("0x37096ff58d1831c2ee64b026f8b70afab1942119c022d1dcfdbdc1558ebf63fa", result.Hash);

                output.WriteLine($"Result hash : {result.Hash}");

                app.Disconnect();
            }
        }
Exemplo n.º 15
0
        public void Ok()
        {
            string address   = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string module1   = "Balances";
            string variable1 = "FreeBalance";
            string module2   = "System";
            string variable2 = "AccountNonce";
            string module3   = "Timestamp";
            string variable3 = "Now";

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                output.WriteLine("================== Get Storage 1: Address Balance ==================");
                JObject prm1 = new JObject {
                    { "type", "AccountId" }, { "value", address }
                };
                string balance = app.GetStorage(prm1.ToString(), module1, variable1);
                output.WriteLine($"Encoded balance: {balance}");
                Assert.True(balance != "null");
                Assert.True(balance.Length > 0);

                output.WriteLine("================== Get Storage 2: Address Nonce ==================");
                string nonce = app.GetStorage(prm1.ToString(), module2, variable2);
                output.WriteLine($"Encoded nonce: {nonce}");
                Assert.True(balance != "null");
                Assert.True(balance.Length > 0);

                output.WriteLine("================== Get Storage 3: Timestamp ==================");
                string timeNow = app.GetStorage(string.Empty, module3, variable3);
                output.WriteLine($"Encoded timestamp: {timeNow}");
                Assert.True(balance != "null");
                Assert.True(balance.Length > 0);

                output.WriteLine("================== Get Storage 4: Non-existing storage key ==================");
                try
                {
                    string abra = app.GetStorage("", "Abra", "Cadabra");
                }
                catch (Exception)
                {
                    output.WriteLine("Caught expected ApplicationException");
                }

                app.Disconnect();
            }
        }
Exemplo n.º 16
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect("wss://kusama-rpc.polkadot.io/");
                var result = app.GetNetworkState();

                Assert.True(result != null);

                output.WriteLine($"AverageDownloadPerSec : {result.AverageDownloadPerSec}");
                output.WriteLine($"AverageUploadPerSec : {result.AverageUploadPerSec}");
                output.WriteLine($"PeerId : {result.PeerId}");
                output.WriteLine($"Peerset : {result.Peerset}");

                app.Disconnect();
            }
        }
Exemplo n.º 17
0
        public void Ok()
        {
            string address   = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string module1   = "System";
            string variable1 = "Account";

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                output.WriteLine("================== Get Storage Hash: Address Balance ==================");
                string storageHash = app.GetStorageHash(new Address(address), module1, variable1);
                output.WriteLine($"Storage hash: {storageHash}");
                Assert.True(storageHash.Length == 66);

                app.Disconnect();
            }
        }
Exemplo n.º 18
0
        public void Ok()
        {
            var cert = File.ReadAllBytes(Consts.CertFileName);

            File.Delete(Consts.CertFileName);

            Assert.Throws <FileNotFoundException>(() =>
            {
                using (IApplication app = PolkaApi.GetAppication())
                {
                    app.Connect();

                    app.Disconnect();
                }
            });

            File.WriteAllBytes(Consts.CertFileName, cert);
        }
Exemplo n.º 19
0
        public void Ok()
        {
            string address             = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string module1             = "System";
            string variable1           = "Account";
            int    expectedBalanceSize = 16; // 128 bits

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                output.WriteLine("================== Get Storage Size: Address Balance ==================");
                var storageSize = app.GetStorageSize(new Address(address), module1, variable1);
                output.WriteLine($"Storage size: {storageSize}");
                Assert.True(storageSize == expectedBalanceSize);

                app.Disconnect();
            }
        }
Exemplo n.º 20
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                string address  = "5HQdHxuPgQ1BpJasmm5ZzfSk5RDvYiH6YHfDJVE8jXmp4eig";
                string module   = "System";
                string variable = "Account";

                app.Connect();

                var actualKey = app.GetKeys(new Address(address), module, variable);

                output.WriteLine($"Storage key for prefix {module} {variable} for address {address} : {actualKey}");
                Console.WriteLine($"\nStorage key for prefix {module} {variable} for address {address} : {actualKey}\n");

                app.Disconnect();
            }
        }
Exemplo n.º 21
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                // Get the most recent block number and hash
                var lastblock  = app.GetBlock(null);
                var lastNumber = (int)lastblock.Block.Header.Number;
                var lastHash   = app.GetBlockHash(new GetBlockHashParams {
                    BlockNumber = lastNumber
                });

                // Get the 10 blocks back number and hash
                var prm2 = new GetBlockHashParams
                {
                    BlockNumber = lastNumber - 10
                };
                var tenBackHash = app.GetBlockHash(prm2);
                output.WriteLine($"Most recent block  : {lastNumber}, hash: {lastHash.Hash} ");

                // Get timestamp history for last 50 blocks
                string        module   = "Timestamp";
                string        variable = "Now";
                string        key      = app.GetKeys("", module, variable);
                StorageItem[] items    = app.QueryStorage(key, tenBackHash.Hash, lastHash.Hash, 20);

                // Assert that item count is at least 10
                output.WriteLine($"Item count returned : {items.Length} ");
                Assert.True(items.Length >= 10);

                // Assert that all items are different (time changes every block)
                // set<string> values;
                foreach (var item in items)
                {
                    output.WriteLine($"Block: {item.BlockHash}, value: {item.Value} ");
                }

                Assert.True(items.ToList().Distinct(new StorageItemTimestampComparer()).Count() == items.Length);
                output.WriteLine("All timestamps are different");

                app.Disconnect();
            }
        }
Exemplo n.º 22
0
        public void Ok()
        {
            var testBlock = new GetBlockParams {
                BlockHash = "0xbd6c40490d8272f2c03bb19627add2ac6fddc1fd7e0eefd690ca47e4f9729d8f"
            };

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result1 = app.GetBlock(testBlock);
                var result2 = app.GetBlockHeader(testBlock);

                output.WriteLine($"Parent hash from block  : { result1.Block.Header.ParentHash}");
                output.WriteLine($"Parent hash from header : { result2.ParentHash}");

                Assert.Equal(result1.Block.Header.ParentHash, result2.ParentHash);
                app.Disconnect();
            }
        }
Exemplo n.º 23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins(ConfigurationManager.AppSettings["ClientUIHost"])
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });

            MetadataSchema sch = new MetadataSchema();
            var            MetadataBlockHash = ConfigurationManager.AppSettings["MetadataBlockHash"];

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect("wss://kusama-rpc.polkadot.io/", MetadataBlockHash);
                sch.ParseMetadata(app.GetMetadata(null));
                app.Disconnect();
            }

            var rt = File.ReadAllText("runtime.txt");

            var dataReader = new Postgres(ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString);

            services.AddSingleton(sch);
            services.AddSingleton(dataReader);
            services.AddSingleton <IRuntime>(new Runtime(rt));
            services.AddSingleton <IWebApiDataAdapter>(new IndexedWebApi(dataReader, sch));
            services.AddMvc()
            .AddJsonOptions(x =>
            {
                x.SerializerSettings.ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            });
        }
        public void Ok()
        {
            var testBlock = new GetBlockParams {
                BlockHash = "0x37096ff58d1831c2ee64b026f8b70afab1942119c022d1dcfdbdc1558ebf63fa"
            };

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                var result1 = app.GetBlock(testBlock);
                var result2 = app.GetBlockHeader(testBlock);

                output.WriteLine($"Parent hash from block  : { result1.Block.Header.ParentHash}");
                output.WriteLine($"Parent hash from header : { result2.ParentHash}");

                Assert.Equal(result1.Block.Header.ParentHash, result2.ParentHash);
                app.Disconnect();
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            // This is a manual test due to lack of test DOTs
            if (args.Length < 4)
            {
                Console.WriteLine("This is intended to be a manual test");
                Console.WriteLine("Usage: ");
                Console.WriteLine("<sender address> <recipient address> <amount in fDOTs> <sender private key (hex)>");
                Console.WriteLine("success");
            }
            else
            {
                var senderAddr          = args[0];
                var recipientAddr       = args[1];
                var amountStr           = args[2];
                var senderPrivateKeyStr = args[3];

                using (IApplication app = PolkaApi.GetAppication())
                {
                    bool done = false;

                    var cb = new Action <string>((json) =>
                    {
                        Console.WriteLine(json);
                        done = true;
                    });

                    var amount = BigInteger.Parse(amountStr);

                    app.Connect("ws://127.0.0.1:9944");
                    app.SignAndSendTransfer(senderAddr, senderPrivateKeyStr, recipientAddr, amount, cb);

                    // Wait until transaction is mined
                    while (!done)
                    {
                        Thread.Sleep(100);
                    }

                    app.Disconnect();
                }
            }
        }
        public void Ok()
        {
            string address   = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string module1   = "Balances";
            string variable1 = "FreeBalance";

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                output.WriteLine("================== Get Storage Hash: Address Balance ==================");
                JObject prm1 = new JObject {
                    { "type", "AccountId" }, { "value", address }
                };
                string storageHash = app.GetStorageHash(prm1.ToString(), module1, variable1);
                output.WriteLine($"Storage hash: {storageHash}");
                Assert.True(storageHash.Length == 66);

                app.Disconnect();
            }
        }
Exemplo n.º 27
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect("wss://kusama-rpc.polkadot.io/");

                //var childKeysResponse = app.GetChildKeys(string.Empty, string.Empty);
                //output.WriteLine($"Child Keys Response: {childKeysResponse}");

                //var childStorageResponse = app.GetChildStorage(string.Empty, string.Empty);
                //output.WriteLine($"Child Storage Response: {childStorageResponse}");

                //var childStorageHashResponse = app.GetChildStorageHash(string.Empty, string.Empty);
                //output.WriteLine($"Child Storage Hash Response: {childStorageHashResponse}");

                //var childStorageSizeResponse = app.GetChildStorageSize(string.Empty, string.Empty);
                //output.WriteLine($"Child Storage Size Response: {childKeysResponse}");

                app.Disconnect();
            }
        }
Exemplo n.º 28
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                string address  = "5HQdHxuPgQ1BpJasmm5ZzfSk5RDvYiH6YHfDJVE8jXmp4eig";
                string module   = "Balances";
                string variable = "FreeBalance";

                app.Connect();

                JObject prm = new JObject {
                    { "type", "AccountId" }, { "value", address }
                };
                var actualKey = app.GetKeys(prm.ToString(), module, variable);

                output.WriteLine($"Storage key for prefix {module} {variable} for address {address} : {actualKey}");
                Console.WriteLine($"\nStorage key for prefix {module} {variable} for address {address} : {actualKey}\n");

                app.Disconnect();
            }
        }
        public void Ok()
        {
            string address             = "5ECcjykmdAQK71qHBCkEWpWkoMJY6NXvpdKy8UeMx16q5gFr";
            string module1             = "Balances";
            string variable1           = "FreeBalance";
            int    expectedBalanceSize = 16; // 128 bits

            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();
                output.WriteLine("================== Get Storage Size: Address Balance ==================");
                JObject prm1 = new JObject {
                    { "type", "AccountId" }, { "value", address }
                };
                var storageSize = app.GetStorageSize(prm1.ToString(), module1, variable1);
                output.WriteLine($"Storage size: {storageSize}");
                Assert.True(storageSize == expectedBalanceSize);

                app.Disconnect();
            }
        }
Exemplo n.º 30
0
        public void Ok()
        {
            using (IApplication app = PolkaApi.GetAppication())
            {
                app.Connect();

                foreach (var item in app.PendingExtrinsics(10))
                {
                    output.WriteLine($"SignerAddress: {item.SignerAddress}");
                    output.WriteLine($"Signature: {item.Signature}");
                    output.WriteLine($"Method: {item.Method}");
                    output.WriteLine($"Length: {item.Length}");

                    Console.WriteLine($"SignerAddress: {item.SignerAddress}");
                    Console.WriteLine($"Signature: {item.Signature}");
                    Console.WriteLine($"Method: {item.Method}");
                    Console.WriteLine($"Length: {item.Length}");
                }

                app.Disconnect();
            }
        }