From a23d56775421671659b431e51cb8ac4d25ffb47c Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Tue, 21 Nov 2023 15:48:33 -0600 Subject: [PATCH] feat: add --nameserver as shortcut in test data script Fixes #79 --- scripts/create-test-data/main.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/create-test-data/main.ts b/scripts/create-test-data/main.ts index c601e83..70d76a4 100644 --- a/scripts/create-test-data/main.ts +++ b/scripts/create-test-data/main.ts @@ -15,10 +15,23 @@ const generate = new Command() .description("Generate an unsigned TX with the test domain data") .env("MAESTRO_API_KEY=", "Maestro API key", { required: true }) .option("-D, --domain ", "Domain to create test data for", { required: true }) - .option("-r, --record ", "Record for domain, specified as: [,],, (can be specified multiple times)", { collect: true, required: true }) + .option("-n, --nameserver ", "Nameserver for domain, specified as: , (can be specified multiple times)", { collect: true, required: true }) + .option("-r, --record ", "Record for domain, specified as: [,],, (can be specified multiple times)", { collect: true }) .option("-s, --source-address
", "Source wallet address to send from (you must be able to sign transactions for this)", { required: true }) .option("-d, --dest-address
", "Destination wallet address to send to (this will be read by cdnsd)", { required: true }) - .action(async ({ maestroApiKey, domain, record, sourceAddress, destAddress }) => { + .action(async ({ maestroApiKey, domain, nameserver, record, sourceAddress, destAddress }) => { + // Merge --nameserver and --record values + let records = [] + for (var tmpNameserver of nameserver) { + const tmpNameserverParts = tmpNameserver.split(",") + // Nameservers for a domain need both a NS record on the domain and an A record for themselves + records.push(`${domain},ns,${tmpNameserverParts[0]}`) + records.push(`${tmpNameserverParts[0]},a,${tmpNameserverParts[1]}`) + } + for (var tmpRecord in record) { + records.push(tmpRecord) + } + console.log(`Building transaction...`); const provider = new Maestro({ @@ -31,7 +44,7 @@ const generate = new Command() lucid.selectWalletFrom({ address: sourceAddress }); let outDatumRecords = [] - record.forEach((tmpRecord) => { + records.forEach((tmpRecord) => { const recordParts = tmpRecord.split(",") if (recordParts.length == 3) { outDatumRecords.push(new Constr(