Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --nameserver as shortcut in test data script #80

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions scripts/create-test-data/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ const generate = new Command()
.description("Generate an unsigned TX with the test domain data")
.env("MAESTRO_API_KEY=<value:string>", "Maestro API key", { required: true })
.option("-D, --domain <domain>", "Domain to create test data for", { required: true })
.option("-r, --record <record>", "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)", { collect: true, required: true })
.option("-n, --nameserver <nameserver>", "Nameserver for domain, specified as: <name>,<ipaddr> (can be specified multiple times)", { collect: true, required: true })
.option("-r, --record <record>", "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)", { collect: true })
.option("-s, --source-address <address>", "Source wallet address to send from (you must be able to sign transactions for this)", { required: true })
.option("-d, --dest-address <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({
Expand All @@ -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(
Expand Down
Loading