Skip to content

Commit d312e87

Browse files
authored
Merge pull request #82 from blinklabs-io/feat/datum-format-update
feat: output test data transaction to file
2 parents 4063f4b + 8f6be80 commit d312e87

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

scripts/create-test-data/create-test-data

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ _deno_image='denoland/deno:1.37.2'
44
_deno_flags=(
55
'--allow-net'
66
'--allow-read'
7+
'--allow-write'
78
'--allow-env'
89
)
910

@@ -15,6 +16,7 @@ docker run \
1516
-v $(pwd):/work \
1617
-v ${HOME}/.deno:/deno-dir \
1718
-w /work \
19+
-u $(id -u) \
1820
-e MAESTRO_API_KEY=${MAESTRO_API_KEY} \
1921
"${_deno_image}" \
2022
run "${_deno_flags[@]}" /app/main.ts generate "$@"

scripts/create-test-data/main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const generate = new Command()
1919
.option("-r, --record <record>", "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)", { collect: true })
2020
.option("-s, --source-address <address>", "Source wallet address to send from (you must be able to sign transactions for this)", { required: true })
2121
.option("-d, --dest-address <address>", "Destination wallet address to send to (this will be read by cdnsd)", { required: true })
22-
.action(async ({ maestroApiKey, domain, nameserver, record, sourceAddress, destAddress }) => {
22+
.option("-o, --output <file>", "Output file for generated transaction")
23+
.action(async ({ maestroApiKey, domain, nameserver, record, sourceAddress, destAddress, output }) => {
2324
// Merge --nameserver and --record values
2425
let records = []
2526
for (var tmpNameserver of nameserver) {
@@ -97,8 +98,14 @@ const generate = new Command()
9798
"description": "unsigned",
9899
"cborHex": txOut.toString(),
99100
};
100-
console.log(`\nTX (unsigned):\n`);
101-
console.log(JSON.stringify(txJsonObj));
101+
const txJson = JSON.stringify(txJsonObj)
102+
103+
if (output === undefined) {
104+
output = `./tx-cdnsd-test-data-${domain}-${txOut.toHash()}.json`
105+
}
106+
Deno.writeTextFileSync(output, txJson)
107+
108+
console.log(`\nWrote tranaction to output file: ${output}`)
102109
console.log(`\nNOTE: you must import this transaction into a wallet such as Eternl to sign and submit it`);
103110
} catch (e) {
104111
console.log(e);

0 commit comments

Comments
 (0)