Skip to content

Commit

Permalink
Merge pull request #82 from blinklabs-io/feat/datum-format-update
Browse files Browse the repository at this point in the history
feat: output test data transaction to file
  • Loading branch information
agaffney authored Nov 22, 2023
2 parents 4063f4b + 8f6be80 commit d312e87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit d312e87

Please sign in to comment.