public static bool IsFA12(this ContractScript contract) { return(contract.Entrypoints.TryGetValue("transfer", out var transfer) && CheckTransfer(transfer) && contract.Entrypoints.TryGetValue("approve", out var approve) && CheckApprove(approve) && contract.Entrypoints.TryGetValue("getAllowance", out var getAllowance) && CheckGetAllowance(getAllowance) && contract.Entrypoints.TryGetValue("getBalance", out var getBalance) && CheckGetBalance(getBalance) && contract.Entrypoints.TryGetValue("getTotalSupply", out var getTotalSupply) && CheckGetTotalSupply(getTotalSupply)); }
public void ContractSelected() { if (currentContract) { ContractScript newContract = currentContract.GetComponent <ContractScript>(); Team.currentContract = new Contract(newContract.contractLevel, newContract.typeCrystalContract, newContract.typeTimeContract, newContract.currentModifiers, newContract.currentCrystals, newContract.currentTime, newContract.reward); foreach (var c in allContracts) { c.GetComponent <Image>().color = unselectedColor; } currentContract.GetComponent <Image>().color = selectedColor; } }
public void ContractClicked(GameObject contract) { ContractScript newContract = contract.GetComponent <ContractScript>(); reward.text = newContract.reward.ToString() + " $"; currentContract = contract; // description.text = description.text = ""; foreach (var a in newContract.objectives) { description.text += "\n" + a; } }
public async void TestJsonSchemaGeneration() { foreach (var address in Directory.GetFiles($@"../../../Contracts/Parameters").Select(x => x.Substring(x.Length - 41, 36))) { var script = DJson.Read($@"../../../Contracts/Scripts/{address}.json"); var contract = new ContractScript(Micheline.FromJson((string)script.code)); foreach (var sample in DJson.Read($@"../../../Contracts/Parameters/{address}.json")) { var jsonSchemaSrc = contract.Parameter.GetJsonSchema((string)sample.human.entrypoint); var jsonSchema = await JsonSchema.FromJsonAsync(jsonSchemaSrc); if (jsonSchema.Type == JsonObjectType.String) { continue; // Newtonsoft does not handle that } var errors = jsonSchema.Validate((string)sample.human.value); Assert.Empty(errors); } } }
public void TestHumanizeParameters() { foreach (var address in Directory.GetFiles($@"../../../Contracts/Parameters").Select(x => x.Substring(x.Length - 41, 36))) { var script = DJson.Read($@"../../../Contracts/Scripts/{address}.json"); var contract = new ContractScript(Micheline.FromJson((string)script.code)); var storage = Micheline.FromJson((string)script.storage); var storageJson = contract.HumanizeStorage(storage); foreach (var sample in DJson.Read($@"../../../Contracts/Parameters/{address}.json")) { var rawEntrypoint = sample.raw.entrypoint; var rawValue = Micheline.FromJson(sample.raw.value); var(normEntrypoint, normValue) = contract.NormalizeParameter((string)rawEntrypoint, (IMicheline)rawValue); var humanized = contract.HumanizeParameter(normEntrypoint, normValue); Assert.Equal( ((string)sample.human.value).Replace("\t", "").Replace("\r", "").Replace("\n", "").Replace(" ", ""), humanized.Replace("\t", "").Replace("\r", "").Replace("\n", "").Replace(" ", "").Trim('\"')); } } }
public void Add(Contract contract, ContractScript schema) { CheckSpace(); CachedById[contract.Id] = schema; }
public static bool IsFA2(this ContractScript contract) { return(contract.Entrypoints.TryGetValue("transfer", out var transfer) && CheckTransfer(transfer) && contract.Entrypoints.TryGetValue("balance_of", out var balanceOf) && CheckBalanceOf(balanceOf) && contract.Entrypoints.TryGetValue("update_operators", out var updateOperators) && CheckUpdateOperators(updateOperators)); }