@@ -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