@@ -7,6 +7,7 @@ const parseTransaction = require('./parse/transaction');
7
7
const getTransaction = require ( './transaction' ) ;
8
8
const validate = utils . common . validate ;
9
9
const composeAsync = utils . common . composeAsync ;
10
+ const convertErrors = utils . common . convertErrors ;
10
11
11
12
function parseAccountTxTransaction ( tx ) {
12
13
// rippled uses a different response format for 'account_tx' than 'tx'
@@ -55,6 +56,17 @@ function orderFilter(options, tx) {
55
56
utils . compareTransactions ( tx , options . startTx ) < 0 ) ;
56
57
}
57
58
59
+ function formatPartialResponse ( address , options , data ) {
60
+ return {
61
+ marker : data . marker ,
62
+ results : data . transactions
63
+ . filter ( ( tx ) => tx . validated )
64
+ . map ( parseAccountTxTransaction )
65
+ . filter ( _ . partial ( transactionFilter , address , options ) )
66
+ . filter ( _ . partial ( orderFilter , options ) )
67
+ } ;
68
+ }
69
+
58
70
function getAccountTx ( remote , address , options , marker , limit , callback ) {
59
71
const params = {
60
72
account : address ,
@@ -66,16 +78,9 @@ function getAccountTx(remote, address, options, marker, limit, callback) {
66
78
marker : marker
67
79
} ;
68
80
69
- remote . requestAccountTx ( params , ( error , data ) => {
70
- return error ? callback ( error ) : callback ( null , {
71
- marker : data . marker ,
72
- results : data . transactions
73
- . filter ( ( tx ) => tx . validated )
74
- . map ( parseAccountTxTransaction )
75
- . filter ( _ . partial ( transactionFilter , address , options ) )
76
- . filter ( _ . partial ( orderFilter , options ) )
77
- } ) ;
78
- } ) ;
81
+ remote . requestAccountTx ( params ,
82
+ composeAsync ( _ . partial ( formatPartialResponse , address , options ) ,
83
+ convertErrors ( callback ) ) ) ;
79
84
}
80
85
81
86
function checkForLedgerGaps ( remote , options , transactions ) {
@@ -131,7 +136,7 @@ function getTransactionsAsync(account, options, callback) {
131
136
}
132
137
}
133
138
134
- function getTransactions ( account : string , options = { } ) {
139
+ function getTransactions ( account : string , options = { } ) {
135
140
return utils . promisify ( getTransactionsAsync ) . call ( this , account , options ) ;
136
141
}
137
142
0 commit comments