|
@@ -49,12 +49,13 @@ namespace HyperCube.Models
|
|
|
return "0x" + hex;
|
|
|
}
|
|
|
|
|
|
- public static string zerofill(string hex, int byteCount, bool hexPrefix0x)
|
|
|
+ public static string zerofill(string hex, int charCount, bool hexPrefix0x)
|
|
|
{
|
|
|
if (hexPrefix0x)
|
|
|
hex = hex.Remove(0, 2);
|
|
|
- var res = hex.PadRight(byteCount, '0');
|
|
|
- Console.WriteLine($"zerofill input {hex} out {res}");
|
|
|
+ Console.WriteLine($"zerofill input {hex} count {hex.Length}");
|
|
|
+ var res = hex.PadLeft(charCount, '0');
|
|
|
+ Console.WriteLine($"zerofill out {hex} count {res.Length}");
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -172,8 +173,6 @@ namespace HyperCube.Models
|
|
|
|
|
|
public async Task<object[]> AddContract(string name, string code, string bytecode)
|
|
|
{
|
|
|
- int id = (int)MySQLConnector.Instance().SQLInsert($"insert into smart_contracts (code, bytecode, name, date_add) values ('{code}','{bytecode}','{name}',NOW())");
|
|
|
-
|
|
|
Console.WriteLine("bytecode " + bytecode);
|
|
|
var req = $"{{ \"jsonrpc\":\"2.0\",\"method\":\"eth_sendTransaction\",\"params\":[{{\"from\":\"{address}\",\"gas\":\"0x31b2e\", \"data\":\"{bytecode}\"}}], \"id\":1}}";
|
|
|
|
|
@@ -181,11 +180,15 @@ namespace HyperCube.Models
|
|
|
dynamic jsonDe = JsonConvert.DeserializeObject(answer);
|
|
|
var res = jsonDe.result;
|
|
|
Console.WriteLine("result AddContract transactionAddress: " + res);
|
|
|
-
|
|
|
- SmartContract newctr = new SmartContract(id, name, code, bytecode);
|
|
|
- contracts.Add(id, newctr);
|
|
|
- contractNames.Add(name, newctr);
|
|
|
- return new object[]{ res, newctr };
|
|
|
+ if (res != null)
|
|
|
+ {
|
|
|
+ int id = (int)MySQLConnector.Instance().SQLInsert($"insert into smart_contracts (code, bytecode, name, date_add) values ('{code}','{bytecode}','{name}',NOW())");
|
|
|
+ SmartContract newctr = new SmartContract(id, name, code, bytecode);
|
|
|
+ contracts.Add(id, newctr);
|
|
|
+ contractNames.Add(name, newctr);
|
|
|
+ return new object[] { res, newctr };
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public async Task<string> ListAccounts()
|