public async Task CompileAndSetContractTests()
        {
            // Arrange
            await client.PushActionAsync("eosio.token", "create", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY" });

            await client.PushActionAsync("eosio.token", "issue", "eosio.token", "active", new[] { "eosio.token", "1000000000.0000 KBY", "OneBox Init" });

            await client.CreateFolderAsync("/opt/eosio/contracts/pomelo");

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.hpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.hpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/pomelo.cpp", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/pomelo.cpp")));

            await client.UploadFileAsync("/opt/eosio/contracts/pomelo/CMakeLists.txt", File.ReadAllBytes(Path.Combine(GetProjectRootPath(), "Contract/CMakeLists.txt")));

            await client.CompileSmartContractAsync("/opt/eosio/contracts/pomelo");

            await client.GenerateKeyValuePair("/home/cleos-net/wallet/pomelo.txt");

            var keys = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/pomelo.txt");

            await client.ImportPrivateKeyToWalletAsync(keys.PrivateKey, "eosio.token");

            await client.CreateAccountAsync("eosio", "pomelo", keys.PublicKey, keys.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new[] { "eosio.token", "pomelo", "1000.0000 EOS", "" });

            var result = await client.SetContractAsync("/opt/eosio/contracts/pomelo", "pomelo", "pomelo");

            await client.PushActionAsync("pomelo", "setwhitelist", "pomelo", "active", new[] { "KBY", "eosio.token" });

            // Assert
            Assert.True(result.IsSucceeded);
        }
示例#2
0
        static async Task Main(string[] args)
        {
            var client = new CleosClient("http://localhost:8888");
            await client.QuickLaunchOneBoxAsync();

            var keys = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.CreateAccountAsync("eosio", "yuko", keys.PublicKey, keys.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "yuko", "1000.0000 EOS", "" });

            var keys2 = await client.RetriveKeyPairsAsync("/home/cleos-net/wallet/eosio.token.key.txt");

            await client.ImportPrivateKeyToWalletAsync(keys2.PrivateKey, "eosio.token");

            await client.CreateAccountAsync("eosio", "counter", keys2.PublicKey, keys2.PublicKey);

            await client.PushActionAsync("eosio.token", "transfer", "eosio.token", "active", new object[] { "eosio.token", "counter", "1000.0000 EOS", "" });

            await client.CreateFolderAsync("/opt/eosio/contracts/counter");

            await client.UploadFileAsync("/opt/eosio/contracts/counter/counter.cpp", File.ReadAllBytes("counter.cpp"));

            await client.UploadFileAsync("/opt/eosio/contracts/counter/CMakeLists.txt", File.ReadAllBytes("CMakeLists.txt"));

            await client.CompileSmartContractAsync("/opt/eosio/contracts/counter");

            await client.SetContractAsync("/opt/eosio/contracts/counter/build", "counter", "pomelo");

            await client.PushActionAsync("counter", "init", "counter", "active", new object[] { });

            await client.PushActionAsync("counter", "add", "counter", "active", new object[] { "counter" });
        }
        public FavoriteTokenTests()
        {
            client = new CleosClient();
            config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("config.json"));
            client.CreateWalletAsync("default", "/home/cleos-net/wallet/wallet.key").Wait();
            client.ImportPrivateKeyToWalletAsync(config.PrivateKey, "default").Wait();
            var builder = new DbContextOptionsBuilder();

            builder.UseMySql(config.MySql);
            db = new KyubeyContext(builder.Options);
        }
示例#4
0
        static async Task InitializeOneBox()
        {
            var configFileName = "config";
            var builder        = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetCurrentDirectory())
                                 .AddJsonFile($"{configFileName}.json")
                                 .AddEnvironmentVariables();
            var config = builder.Build();

            configObject = config.Get <Config>();

            var optionsBuilder = new DbContextOptionsBuilder <KyubeyContext>();

            optionsBuilder.UseMySql(config["MySQL"]);
            dbContext = new KyubeyContext(optionsBuilder.Options);

            client = new CleosClient();
            var createResult = await client.CreateWalletAsync("default", "/home/cleos-net/wallet/wallet.key");

            var privateKey = SecurityTool.Decrypt(config["EncryptText"], config["EncryptKey"]);
            //manual unlock
            //var unlockResult = await client.UnlockWalletAsync(SecurityTool.Decrypt(config["EncryptWalletKey"], config["EncryptKey"]));
            var importResult = await client.ImportPrivateKeyToWalletAsync(privateKey, "default");
        }