public ContractProjectGenerator CreateGenerator(string defaultNamespace, string projectFolder) { SetBinPath(); var abiString = ABI ?? GeneratorConfigurationUtils.GetFileContent(projectFolder, ABIFile); var byteCode = ByteCode ?? GeneratorConfigurationUtils.GetFileContent(projectFolder, BinFile); var abi = new GeneratorModelABIDeserialiser().DeserialiseABI(abiString); return(new ContractProjectGenerator( abi, ContractName, byteCode, BaseNamespace ?? defaultNamespace, ServiceNamespace ?? $"{ContractName}.Service", CQSNamespace ?? $"{ContractName}.CQS", DTONamespace ?? $"{ContractName}.DTO", BaseOutputPath ?? projectFolder, Path.DirectorySeparatorChar.ToString(), CodeGenLanguage )); }
public IEnumerable <ContractProjectGenerator> FromAbi(string contractName, string abiFilePath, string binFilePath, string baseNamespace, string outputFolder) { var abi = GeneratorConfigurationUtils.GetFileContent(outputFolder, abiFilePath); if (string.IsNullOrEmpty(abi)) { throw new ArgumentException("Could not find abi file or abi content is empty"); } if (string.IsNullOrEmpty(binFilePath)) { binFilePath = abiFilePath.Replace(".abi", ".bin"); } var byteCode = GeneratorConfigurationUtils.GetFileContent(outputFolder, binFilePath); if (string.IsNullOrEmpty(contractName)) { contractName = Path.GetFileNameWithoutExtension(abiFilePath); } var generator = new ProjectGenerator { Namespace = baseNamespace, OutputFolder = outputFolder, Contracts = new List <ContractDefinition> { new ContractDefinition(abi) { ContractName = contractName, Bytecode = byteCode } } }; return(generator.GetProjectGenerators()); }
public GeneratorConfiguration FromAbi(string contractName, string abiFilePath, string binFilePath, string baseNamespace, string outputFolder) { var config = new GeneratorConfiguration(); var abi = GeneratorConfigurationUtils.GetFileContent(outputFolder, abiFilePath); if (string.IsNullOrEmpty(abi)) { throw new ArgumentException("Could not find abi file or abi content is empty"); } if (string.IsNullOrEmpty(binFilePath)) { binFilePath = abiFilePath.Replace(".abi", ".bin"); } var byteCode = GeneratorConfigurationUtils.GetFileContent(outputFolder, binFilePath); if (string.IsNullOrEmpty(contractName)) { contractName = Path.GetFileNameWithoutExtension(abiFilePath); } var abiConfig = new ABIConfiguration { ABI = abi, ByteCode = byteCode, ContractName = contractName }; abiConfig.ResolveEmptyValuesWithDefaults(baseNamespace, outputFolder); config.ABIConfigurations = new List <ABIConfiguration>(); config.ABIConfigurations.Add(abiConfig); return(config); }