private object RouteInvokeContract(HTTPRequest request) { var chain = request.GetVariable("chain"); var contract = request.GetVariable("contract"); var method = request.GetVariable("method"); var param = request.GetVariable("params"); var context = InitContext(request); if (param == null) { PushError(request, "Parameters cannot be null!"); return(null); } List <object> paramList = SendUtils.BuildParamList(param); var keyPair = GetLoginKey(request); InvalidateCache(keyPair.Address); var result = AccountController.InvokeContractGeneric(keyPair, chain, contract, method, paramList.ToArray()).Result; if (result != null && result.GetType() == typeof(BigInteger)) { return(result.ToString()); } return(JsonConvert.SerializeObject(result, Formatting.Indented)); }
private object RouteConfirmSellNFT(HTTPRequest request) { var chainName = request.GetVariable("chain"); var contractName = request.GetVariable("contract"); var methodName = request.GetVariable("method"); var param = request.GetVariable("params"); var id = request.GetVariable("id"); if (param == null) { PushError(request, "Parameters cannot be null!"); return(null); } List <object> paramList = SendUtils.BuildParamList(param); var keyPair = GetLoginKey(request); InvalidateCache(keyPair.Address); string result; result = AccountController.ConfirmSellNFT(keyPair, chainName, contractName, methodName, paramList.ToArray(), id).Result; ResetSessionSendFields(request); if (!SendUtils.IsTxHashValid(result)) { PushError(request, result); Log.Information("No valid result"); return(""); } return(result); }
private object RouteMarketBuyCustomModal(HTTPRequest request) { var chain = request.GetVariable("chain"); var contract = request.GetVariable("contract"); var method = request.GetVariable("method"); var param = request.GetVariable("params"); var id = request.GetVariable("id"); var quotesymbol = request.GetVariable("quoteSymbol"); var pricenft = request.GetVariable("priceNFT"); var creatoraddress = request.GetVariable("creatorAddress"); var context = InitContext(request); if (param == null) { PushError(request, "Parameters cannot be null!"); return(null); } List <object> paramList = SendUtils.BuildParamList(param); if (context["holdings"] is Holding[] balance) { var kcalBalance = balance.SingleOrDefault(b => b.Symbol == "KCAL" && b.Chain == chain); if (kcalBalance.Amount > 0.1m) { var keyPair = GetLoginKey(request); InvalidateCache(keyPair.Address); var result = AccountController.MarketBuyCustomModal( keyPair, chain, contract, method, paramList.ToArray(), id, quotesymbol, pricenft, creatoraddress ).Result; if (result.GetType() == typeof(ErrorRes)) { return(JsonConvert.SerializeObject(result, Formatting.Indented)); } var contractTx = (string)result; if (SendUtils.IsTxHashValid(contractTx)) { request.session.SetString("confirmedHash", contractTx); return(contractTx); } PushError(request, contractTx); } else { PushError(request, "You need a small drop of KCAL to call a contract."); } } return(null); }
private static void TestFunc(string[] obj) { var json2 = @"{ 'parameters': [ { 'name': 'address', 'vmtype': 'Object', 'type': 'Phantasma.Cryptography.Address', 'input': 'P5ySorAXMaJLwe6AqTsshW3XD8ahkwNpWHU9KLX9CwkYd', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.ArchiveFlags', 'input': '1', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.ArchiveFlags', 'input': '1', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.Contracts.Native.ExchangeOrderSide', 'input': '1', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.Contracts.Native.ExchangeOrderSide', 'input': '2', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.Contracts.Native.ExchangeOrderType', 'input': '3', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Enum', 'type': 'Phantasma.Blockchain.Contracts.Native.ExchangeOrderType', 'input': '4', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Timestamp', 'type': 'Phantasma.Core.Types.Timestamp', 'input': '07/20/2019 20:04:30', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Bool', 'type': 'System.Boolean', 'input': 'False', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Bool', 'type': 'System.Boolean', 'input': 'True', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'String', 'type': 'System.String', 'input': 'ThisIsAString', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Bytes', 'type': 'System.Byte[]', 'input': 'ThisIsAByteArray', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Number', 'type': 'System.Int32', 'input': '987654321', 'info': 'info1' }, { 'name': 'address', 'vmtype': 'Number', 'type': 'Phantasma.Numerics.BigInteger', 'input': '12345678', 'info': 'info1' } ] }"; List <object> lst2 = SendUtils.BuildParamList(json2); }