File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
packages/fasset-indexer-xrp/src Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ export interface IXrpTransaction {
2121 hash : string
2222 metaData ?: {
2323 TransactionResult : string
24- } ,
24+ }
25+ meta ?: {
26+ TransactionResult : string
27+ }
2528 Destination ?: string
2629 ledger_index : number
2730 date : number
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type {
33 IXrpAccountInfoResponse , IXrpAccountTxResponse ,
44 IXrpBlock , IXrpBlockQueryResponse ,
55 IXrpLedgerCurrentResponse , IXrpServerInfoResponse ,
6+ IXrpTransaction ,
67 IXrpWeirdAfTx
78} from "./interface"
89
@@ -16,6 +17,15 @@ export class XrpClient {
1617 return resp . result . ledger
1718 }
1819
20+ async transaction ( hash : string ) : Promise < IXrpTransaction > {
21+ const resp = await this . request ( 'tx' , [ {
22+ transaction : hash ,
23+ binary : false
24+ } ] )
25+ this . ensureSuccess ( resp )
26+ return resp . result
27+ }
28+
1929 async blockHeight ( ) : Promise < number > {
2030 let current_block = 0
2131 if ( this . config . xrpNodeIsAmendmentBlocked ) {
Original file line number Diff line number Diff line change 1+ import { UnderlyingTransaction } from "fasset-indexer-core/entities"
2+ import { XrpContext } from "../context"
3+ import { XrpClient } from "../client/xrp-client"
4+ import { XrpConfigLoader } from "../config/config"
5+
6+ const TX_UPDATE_LIMIT = 1e4
7+
8+ export async function addTransactionResults ( context : XrpContext , client : XrpClient ) {
9+ const em = context . orm . em . fork ( )
10+ const transactions = await em . find ( UnderlyingTransaction , { result : null } , { limit : TX_UPDATE_LIMIT } )
11+ console . log ( `transaction to process ${ transactions . length } ` )
12+ for ( const transaction of transactions ) {
13+ const tx = await client . transaction ( transaction . hash )
14+ transaction . result = tx . meta ?. TransactionResult
15+ console . log ( `obtained tx with result ${ transaction . result } ` )
16+ transaction . fee = BigInt ( tx . Fee ?? 0 )
17+ await em . persistAndFlush ( transaction )
18+ }
19+ await context . orm . close ( )
20+ }
21+
22+ async function main ( ) {
23+ const config = new XrpConfigLoader ( )
24+ const client = new XrpClient ( config )
25+ const context = await XrpContext . create ( config )
26+ await addTransactionResults ( context , client )
27+ }
28+
29+ main ( )
You can’t perform that action at this time.
0 commit comments