|
@@ -20,16 +20,17 @@ namespace HyperCube.Models
|
|
return "none";
|
|
return "none";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public static int selectedNum;
|
|
|
|
|
|
+ public static int selectedId;
|
|
public static string URLdefault = "127.0.0.1";
|
|
public static string URLdefault = "127.0.0.1";
|
|
//public static int defaultPort = 8545;
|
|
//public static int defaultPort = 8545;
|
|
public static int defaultPort = 8666;
|
|
public static int defaultPort = 8666;
|
|
public static string defaultName = "Ethereum dev network";
|
|
public static string defaultName = "Ethereum dev network";
|
|
|
|
|
|
public static bool newData = false;
|
|
public static bool newData = false;
|
|
- public static Dictionary<string, Blockchain> loaded = new();
|
|
|
|
|
|
+ public static Dictionary<int, Blockchain> loaded = new();
|
|
public Dictionary<int, SmartContract> contracts = new();
|
|
public Dictionary<int, SmartContract> contracts = new();
|
|
public Dictionary<string, SmartContract> contractNames = new();
|
|
public Dictionary<string, SmartContract> contractNames = new();
|
|
|
|
+ public int id;
|
|
public int port;
|
|
public int port;
|
|
public string url;
|
|
public string url;
|
|
public string address = "";
|
|
public string address = "";
|
|
@@ -38,24 +39,29 @@ namespace HyperCube.Models
|
|
|
|
|
|
public static void RegisterNetworks()
|
|
public static void RegisterNetworks()
|
|
{
|
|
{
|
|
- //Initialize(name, url, port)
|
|
|
|
|
|
+ var ethDev = new Blockchain(0, "Ethereum Dev Network", "127.0.0.1", 8545);
|
|
|
|
+ var ethRinkeby = new Blockchain(1, "Ethereum Test Network", "127.0.0.1", 8666);
|
|
|
|
+ ethDev.Initialize();
|
|
|
|
+ ethRinkeby.Initialize();
|
|
}
|
|
}
|
|
|
|
|
|
- public static Blockchain GetInstance()
|
|
|
|
- {
|
|
|
|
- if (instance == null)
|
|
|
|
- instance = new Blockchain(URLdefault, defaultPort);
|
|
|
|
- return instance;
|
|
|
|
- }
|
|
|
|
|
|
+ //public static Blockchain GetInstance()
|
|
|
|
+ //{
|
|
|
|
+ // if (instance == null)
|
|
|
|
+ // instance = new Blockchain(URLdefault, defaultPort);
|
|
|
|
+ // return instance;
|
|
|
|
+ //}
|
|
|
|
|
|
- Blockchain()
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
|
|
+ //Blockchain()
|
|
|
|
+ //{
|
|
|
|
+ //}
|
|
|
|
|
|
- public Blockchain(string url, int port)
|
|
|
|
|
|
+ public Blockchain(int id, string name, string url, int port)
|
|
{
|
|
{
|
|
|
|
+ this.id = id;
|
|
this.url = url;
|
|
this.url = url;
|
|
this.port = port;
|
|
this.port = port;
|
|
|
|
+ this.name = name;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<string> CreateBlockchainAccount(AccountModel account)
|
|
public async Task<string> CreateBlockchainAccount(AccountModel account)
|
|
@@ -92,15 +98,15 @@ namespace HyperCube.Models
|
|
public static Blockchain GetMain()
|
|
public static Blockchain GetMain()
|
|
{
|
|
{
|
|
if (loaded.Count > 0)
|
|
if (loaded.Count > 0)
|
|
- return loaded.Last().Value;
|
|
|
|
|
|
+ return loaded[selectedId];
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<string> Initialize()
|
|
public async Task<string> Initialize()
|
|
{
|
|
{
|
|
string addr = await ListAccounts();
|
|
string addr = await ListAccounts();
|
|
- if (!loaded.ContainsKey(addr))
|
|
|
|
- loaded.Add(addr, this);
|
|
|
|
|
|
+ if (!loaded.ContainsKey(id))
|
|
|
|
+ loaded.Add(selectedId, this);
|
|
name = defaultName;
|
|
name = defaultName;
|
|
url = URLdefault;
|
|
url = URLdefault;
|
|
port = defaultPort;
|
|
port = defaultPort;
|