@@ -9,30 +9,61 @@ async function get_protocol_params() {
99
1010let protocolParams = await get_protocol_params ( ) ;
1111
12+ const output = document . createElement ( "code" ) ;
13+ output . innerText = "" ;
14+ output . id = "test-output" ;
15+ document . body . appendChild ( output ) ;
16+
17+ function log ( out ) {
18+ console . log ( out ) ;
19+ if ( typeof ( out ) == "object" ) {
20+ output . innerText += "> [object] {\n" ;
21+ for ( let [ key , val ] of Object . entries ( out ) ) {
22+ let text = val . toString ( ) ;
23+ if ( typeof ( val ) == "function" ) {
24+ text = text . split ( "{" ) [ 0 ] ;
25+ }
26+ output . innerText += " " + key + ": " + text + "\n" ;
27+ }
28+ output . innerText += " }\n" ;
29+ } else {
30+ output . innerText += "> " + JSON . stringify ( out ) + "\n" ;
31+ }
32+ }
33+
34+ function finish_test ( ) {
35+ let finishTag = document . createElement ( "p" ) ;
36+ finishTag . innerText = "Finished test!" ;
37+ finishTag . id = "finish-tag" ;
38+ document . body . appendChild ( finishTag ) ;
39+ }
40+
1241async function do_async_work ( ) {
1342 let api = await promise ;
14- console . log ( "Api object:" ) ;
15- console . log ( api ) ;
43+ log ( "Api object:" ) ;
44+ log ( api ) ;
1645
1746 let emptyTx = await api . newConwayTx ( ) ;
18- console . log ( "UnsignedTx object:" ) ;
19- console . log ( emptyTx ) ;
47+ log ( "UnsignedTx object:" ) ;
48+ log ( emptyTx ) ;
2049
2150 let tx = await emptyTx . addTxInput ( "be6efd42a3d7b9a00d09d77a5d41e55ceaf0bd093a8aa8a893ce70d9caafd978" , 0 )
22- . addSimpleTxOut ( "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v" , 10_000_000n )
51+ . addSimpleTxOut ( "addr_test1vzpfxhjyjdlgk5c0xt8xw26avqxs52rtf69993j4tajehpcue4v2v" , 10_000_000n )
2352
2453 let feeEstimate = await tx . estimateMinFee ( protocolParams , 1 , 0 , 0 ) ;
25- console . log ( "Estimated fee:" ) ;
26- console . log ( feeEstimate ) ;
54+ log ( "Estimated fee:" ) ;
55+ log ( feeEstimate ) ;
2756
2857 let signedTx = await tx . setFee ( feeEstimate )
29- . signWithPaymentKey ( "addr_sk1648253w4tf6fv5fk28dc7crsjsaw7d9ymhztd4favg3cwkhz7x8sl5u3ms" ) ;
30- console . log ( "SignedTx object:" ) ;
31- console . log ( signedTx ) ;
58+ . signWithPaymentKey ( "addr_sk1648253w4tf6fv5fk28dc7crsjsaw7d9ymhztd4favg3cwkhz7x8sl5u3ms" ) ;
59+ log ( "SignedTx object:" ) ;
60+ log ( signedTx ) ;
3261
3362 let txCbor = await signedTx . txToCbor ( ) ;
34- console . log ( "Tx CBOR:" ) ;
35- console . log ( txCbor ) ;
63+ log ( "Tx CBOR:" ) ;
64+ log ( txCbor ) ;
65+
66+ finish_test ( ) ;
3667}
3768
3869do_async_work ( ) . then ( ( ) => { } ) ;
0 commit comments