Skip to content

Commit

Permalink
fix: report queries (#56)
Browse files Browse the repository at this point in the history
* Fix null error in gql type

* Add missing fields for asset transactions

* [bot] New pkg version: 0.0.0-alpha.9

---------

Co-authored-by: GitHub Actions <actions@github.com>
  • Loading branch information
sophialittlejohn and actions-user authored Jan 27, 2025
1 parent ea44c2a commit 6c65656
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@centrifuge/sdk",
"version": "0.0.0-alpha.8",
"version": "0.0.0-alpha.9",
"description": "",
"homepage": "https://github.com/centrifuge/sdk/tree/main#readme",
"author": "",
Expand Down
10 changes: 6 additions & 4 deletions src/IndexerQueries/assetTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export type AssetTransaction = {
amount: Currency
settlementPrice: Price | null
quantity: string | null
principalAmount: Currency | undefined
interestAmount: Currency | undefined
principalAmount: Currency | null
interestAmount: Currency | null
hash: string
realizedProfitFifo: Currency | undefined
unrealizedProfitAtMarketPrice: Currency | undefined
Expand All @@ -24,6 +24,7 @@ export type AssetTransaction = {
metadata: string
type: AssetType
currentPrice: string | null
name: string
}
fromAsset?: {
id: string
Expand Down Expand Up @@ -111,10 +112,11 @@ export const assetTransactionsPostProcess = (data: SubqueryAssetTransactions): A
const decimals = tx.pool.currency.decimals
return {
...tx,
name: tx.asset.name,
settlementPrice: tx.settlementPrice ? new Price(tx.settlementPrice) : null,
amount: new Currency(tx?.amount ?? 0n, decimals),
principalAmount: tx.principalAmount ? new Currency(tx.principalAmount, decimals) : undefined,
interestAmount: tx.interestAmount ? new Currency(tx.interestAmount, decimals) : undefined,
principalAmount: tx.principalAmount ? new Currency(tx.principalAmount, decimals) : null,
interestAmount: tx.interestAmount ? new Currency(tx.interestAmount, decimals) : null,
realizedProfitFifo: tx.realizedProfitFifo ? new Currency(tx.realizedProfitFifo, decimals) : undefined,
sumRealizedProfitFifo: tx.asset.sumRealizedProfitFifo
? new Currency(tx.asset.sumRealizedProfitFifo, decimals)
Expand Down
6 changes: 3 additions & 3 deletions src/IndexerQueries/poolFeeTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type PoolFeeTransaction = {
timestamp: string
blockNumber: string
epochNumber: number
amount: Currency
amount: Currency | null
}

export type SubqueryPoolFeeTransactionType =
Expand All @@ -30,7 +30,7 @@ export type SubqueryPoolFeeTransaction = {
timestamp: string
blockNumber: string
epochNumber: number
amount: string
amount: string | null
poolFee: {
feeId: string
pool: {
Expand All @@ -50,7 +50,7 @@ export function poolFeeTransactionPostProcess(data: SubqueryPoolFeeTransaction):
timestamp: tx.timestamp,
blockNumber: tx.blockNumber,
epochNumber: tx.epochNumber,
amount: new Currency(tx.amount, tx.poolFee.pool.currency.decimals),
amount: tx.amount ? new Currency(tx.amount, tx.poolFee.pool.currency.decimals) : null,
}))
}

Expand Down
3 changes: 3 additions & 0 deletions src/Reports/Processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ export class Processor {
epoch: tx.epochId,
transactionType: tx.type,
amount: tx.amount,
principalAmount: tx.principalAmount,
interestAmount: tx.interestAmount,
transactionHash: tx.hash,
name: tx.asset.name,
fromAsset: tx.fromAsset
? {
id: tx.fromAsset.id,
Expand Down
5 changes: 4 additions & 1 deletion src/types/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ export type AssetTransactionReport = {
epoch: string
transactionType: AssetTransactionType
amount: Currency
name: string
principalAmount: Currency | null
interestAmount: Currency | null
transactionHash: string
fromAsset?: {
id: string
Expand Down Expand Up @@ -202,7 +205,7 @@ export type FeeTransactionReport = {
type: 'feeTransactions'
timestamp: string
feeId: string
amount: Currency
amount: Currency | null
}

export type FeeTransactionReportFilter = {
Expand Down

0 comments on commit 6c65656

Please sign in to comment.