-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add nova address transaction history (#1158)
* feat: Add transaction history api (nova) * feat: Add TransactionHistoryView to AddressPageTabbedSection (and support in state hooks) * feat: Fix param passing and chronicle ledger updates endpoint * feat: Fix transaction date computation * fix: Fix Address balance rendering * feat: Disable Transactions tab if no transactions * feat: Show balance from the address output even if no chronicle data
- Loading branch information
Showing
30 changed files
with
981 additions
and
15 deletions.
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
14 changes: 12 additions & 2 deletions
14
api/src/models/api/nova/chronicle/IAddressBalanceResponse.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
34 changes: 34 additions & 0 deletions
34
api/src/models/api/nova/chronicle/ITransactionHistoryRequest.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,34 @@ | ||
/** | ||
* The request for Transaction History on nova. | ||
*/ | ||
export interface ITransactionHistoryRequest { | ||
/** | ||
* The network in context. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The address to get the history for. | ||
*/ | ||
address: string; | ||
|
||
/** | ||
* The page size of the request (default is 100). | ||
*/ | ||
pageSize?: number; | ||
|
||
/** | ||
* The sort by date to use. | ||
*/ | ||
sort?: string; | ||
|
||
/** | ||
* The lower bound slot index to use. | ||
*/ | ||
startSlotIndex?: number; | ||
|
||
/** | ||
* The cursor state for the request. | ||
*/ | ||
cursor?: string; | ||
} |
41 changes: 41 additions & 0 deletions
41
api/src/models/api/nova/chronicle/ITransactionHistoryResponse.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,41 @@ | ||
import { IResponse } from "../../IResponse"; | ||
|
||
/** | ||
* A transaction history item. | ||
*/ | ||
export interface ITransactionHistoryItem { | ||
/** | ||
* The slot index this item is included in. | ||
*/ | ||
slotIndex: number; | ||
|
||
/** | ||
* The outputId. | ||
*/ | ||
outputId: string; | ||
|
||
/** | ||
* Is the output spent. | ||
*/ | ||
isSpent: boolean; | ||
} | ||
|
||
/* | ||
* The transaction history response. | ||
*/ | ||
export interface ITransactionHistoryResponse extends IResponse { | ||
/** | ||
* Address the history is for. | ||
*/ | ||
address?: string; | ||
|
||
/** | ||
* The history items. | ||
*/ | ||
items?: ITransactionHistoryItem[]; | ||
|
||
/** | ||
* The cursor for next request. | ||
*/ | ||
cursor?: string; | ||
} |
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
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,34 @@ | ||
import { ServiceFactory } from "../../../factories/serviceFactory"; | ||
import { ITransactionHistoryRequest } from "../../../models/api/nova/chronicle/ITransactionHistoryRequest"; | ||
import { ITransactionHistoryResponse } from "../../../models/api/nova/chronicle/ITransactionHistoryResponse"; | ||
import { IConfiguration } from "../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../services/networkService"; | ||
import { ChronicleService } from "../../../services/nova/chronicleService"; | ||
import { ValidationHelper } from "../../../utils/validationHelper"; | ||
|
||
/** | ||
* Fetch the transaction history from chronicle nova. | ||
* @param config The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(config: IConfiguration, request: ITransactionHistoryRequest): Promise<ITransactionHistoryResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
if (!networkConfig.permaNodeEndpoint) { | ||
return {}; | ||
} | ||
|
||
const chronicleService = ServiceFactory.get<ChronicleService>(`chronicle-${networkConfig.network}`); | ||
|
||
return chronicleService.transactionHistory(request); | ||
} |
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
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
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
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
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
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
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
36 changes: 36 additions & 0 deletions
36
client/src/app/components/nova/history/ITransactionHistoryEntryProps.tsx
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,36 @@ | ||
export interface ITransactionHistoryEntryProps { | ||
/** | ||
* The transaction id. | ||
*/ | ||
transactionId: string; | ||
|
||
/** | ||
* The formatted date of the transaction. | ||
*/ | ||
dateFormatted: string; | ||
|
||
/** | ||
* Is the transaction spent. | ||
*/ | ||
isSpent: boolean; | ||
|
||
/** | ||
* Are the amounts formatted. | ||
*/ | ||
isFormattedAmounts: boolean; | ||
|
||
/** | ||
* The setter for formatted amounts toggle. | ||
*/ | ||
setIsFormattedAmounts: React.Dispatch<React.SetStateAction<boolean>>; | ||
|
||
/** | ||
* The formatted transaction amount. | ||
*/ | ||
balanceChangeFormatted: string; | ||
|
||
/** | ||
* The transaction link. | ||
*/ | ||
transactionLink: string; | ||
} |
Oops, something went wrong.