export async function deployContract()

in cli-functions.js [156:202]


export async function deployContract(config, contract, name, args, owner, type = 'path') {
  let configPath = config;
  let contractPath = contract;

  if (type === 'data') {
    const configFilename = path.join(os.tmpdir(), `config-${crypto.randomUUID()}.tmp`);
    fs.writeFileSync(configFilename, config);
    configPath = configFilename;
    contractPath = path.join(compiledContractsDir, contract);
  }

  const command = 'rescontract';

  const argList = args.split(',').map((arg) => arg.trim());
  const cliArgs = [
    'deploy',
    '--config',
    configPath,
    '--contract',
    contractPath,
    '--name',
    name,
    '--arguments',
    argList.join(','),
    '--owner',
    owner,
  ];

  try {
    const result = await handleExecFile(command, cliArgs);
    const ownerAddress = result.match(/owner_address: \"(0x[0-9a-fA-F]+)\"/)[1];
    const contractAddress = result.match(/contract_address: \"(0x[0-9a-fA-F]+)\"/)[1];
    const contractName = result.match(/contract_name: \"([^\"]+)\"/)[1];

    return {
      ownerAddress,
      contractAddress,
      contractName
    };
  } catch (error) {
    throw error;
  } finally {
    if (type === 'data' && fs.existsSync(configPath)) {
      fs.unlinkSync(configPath);
    }
  }
}