-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3daab5e
commit 817d33d
Showing
5 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
"events": { | ||
"start": "tslint -c ./tslint.json -t stylish 'src/**/*.ts'" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { txSchema } from "./tx.schema"; | ||
export { txResolver } from "./tx.resolver"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { transactionType } from "./transaction.type"; | ||
export { transactionQuery } from "./transaction.query"; | ||
export { transactionSubscription } from "./transaction.subscription"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import stellar from "stellar-base"; | ||
|
||
export default class Transaction { | ||
public ID: string; | ||
public ledgerSeq: number; | ||
public index: number; | ||
public body: string; | ||
public result: string; | ||
public meta: string; | ||
|
||
constructor(data: { data: string }) { | ||
this.ID = data.txid; | ||
this.ledgerSeq = data.ledgerseq; | ||
this.index = data.txIndex; | ||
this.body = data.txBody; | ||
this.result = data.txResult; | ||
this.meta = data.txMeta; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IDatabase } from "pg-promise"; | ||
import Transaction from "./transaction.model"; | ||
|
||
export default class LedgersRepository { | ||
private db: IDatabase<any>; | ||
|
||
constructor(db: any) { | ||
this.db = db; | ||
} | ||
|
||
// Tries to find a transaction by id; | ||
public findByID(id: string): Promise<Transaction> { | ||
return this.db.oneOrNone("SELECT * FROM txhistory WHERE txid = $1", id, res => new Transaction(res)); | ||
} | ||
|
||
public findByLedgerSeq(ledgerSeq: number): Promise<Transaction[]> { | ||
return this.db.any("SELECT * FROM txhistory WHERE ledgerseq = $1 ORDER BY txindex", ledgerSeq, res => | ||
res.map(t => new Transaction(t)) | ||
); | ||
} | ||
} |