Skip to content

Commit fb53e53

Browse files
authored
Merge pull request #80 from blinklabs-io/feat/datum-format-update
feat: add --nameserver as shortcut in test data script
2 parents bc8d747 + a23d567 commit fb53e53

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

scripts/create-test-data/main.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,23 @@ const generate = new Command()
1515
.description("Generate an unsigned TX with the test domain data")
1616
.env("MAESTRO_API_KEY=<value:string>", "Maestro API key", { required: true })
1717
.option("-D, --domain <domain>", "Domain to create test data for", { required: true })
18-
.option("-r, --record <record>", "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)", { collect: true, required: true })
18+
.option("-n, --nameserver <nameserver>", "Nameserver for domain, specified as: <name>,<ipaddr> (can be specified multiple times)", { collect: true, required: true })
19+
.option("-r, --record <record>", "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)", { collect: true })
1920
.option("-s, --source-address <address>", "Source wallet address to send from (you must be able to sign transactions for this)", { required: true })
2021
.option("-d, --dest-address <address>", "Destination wallet address to send to (this will be read by cdnsd)", { required: true })
21-
.action(async ({ maestroApiKey, domain, record, sourceAddress, destAddress }) => {
22+
.action(async ({ maestroApiKey, domain, nameserver, record, sourceAddress, destAddress }) => {
23+
// Merge --nameserver and --record values
24+
let records = []
25+
for (var tmpNameserver of nameserver) {
26+
const tmpNameserverParts = tmpNameserver.split(",")
27+
// Nameservers for a domain need both a NS record on the domain and an A record for themselves
28+
records.push(`${domain},ns,${tmpNameserverParts[0]}`)
29+
records.push(`${tmpNameserverParts[0]},a,${tmpNameserverParts[1]}`)
30+
}
31+
for (var tmpRecord in record) {
32+
records.push(tmpRecord)
33+
}
34+
2235
console.log(`Building transaction...`);
2336

2437
const provider = new Maestro({
@@ -31,7 +44,7 @@ const generate = new Command()
3144
lucid.selectWalletFrom({ address: sourceAddress });
3245

3346
let outDatumRecords = []
34-
record.forEach((tmpRecord) => {
47+
records.forEach((tmpRecord) => {
3548
const recordParts = tmpRecord.split(",")
3649
if (recordParts.length == 3) {
3750
outDatumRecords.push(new Constr(

0 commit comments

Comments
 (0)