Skip to content

feat: output test data transaction to file #82

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

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions scripts/create-test-data/create-test-data
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _deno_image='denoland/deno:1.37.2'
_deno_flags=(
'--allow-net'
'--allow-read'
'--allow-write'
'--allow-env'
)

Expand All @@ -15,6 +16,7 @@ docker run \
-v $(pwd):/work \
-v ${HOME}/.deno:/deno-dir \
-w /work \
-u $(id -u) \
-e MAESTRO_API_KEY=${MAESTRO_API_KEY} \
"${_deno_image}" \
run "${_deno_flags[@]}" /app/main.ts generate "$@"
13 changes: 10 additions & 3 deletions scripts/create-test-data/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const generate = new Command()
.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, nameserver, record, sourceAddress, destAddress }) => {
.option("-o, --output <file>", "Output file for generated transaction")
.action(async ({ maestroApiKey, domain, nameserver, record, sourceAddress, destAddress, output }) => {
// Merge --nameserver and --record values
let records = []
for (var tmpNameserver of nameserver) {
Expand Down Expand Up @@ -97,8 +98,14 @@ const generate = new Command()
"description": "unsigned",
"cborHex": txOut.toString(),
};
console.log(`\nTX (unsigned):\n`);
console.log(JSON.stringify(txJsonObj));
const txJson = JSON.stringify(txJsonObj)

if (output === undefined) {
output = `./tx-cdnsd-test-data-${domain}-${txOut.toHash()}.json`
}
Deno.writeTextFileSync(output, txJson)

console.log(`\nWrote tranaction to output file: ${output}`)
console.log(`\nNOTE: you must import this transaction into a wallet such as Eternl to sign and submit it`);
} catch (e) {
console.log(e);
Expand Down