@@ -3,7 +3,7 @@ import { Centrifuge } from '../Centrifuge.js'
33import type { HexString } from '../types/index.js'
44import { AssetId , PoolId , ShareClassId } from '../utils/types.js'
55import { Entity } from './Entity.js'
6- import { Balance } from '../utils/BigInt.js'
6+ import { Balance , Price } from '../utils/BigInt.js'
77
88export class Investor extends Entity {
99 address : HexString
@@ -131,8 +131,9 @@ export class Investor extends Entity {
131131 id : string
132132 address : string
133133 } | null
134- token : { name : string ; symbol : string ; decimals : string }
135- tokenAmount : string
134+ token : { name : string ; symbol : string ; decimals : string } | null
135+ tokenAmount : string | null
136+ tokenPrice : string | null
136137 centrifugeId : string
137138 poolId : string
138139 } [ ]
@@ -141,10 +142,10 @@ export class Investor extends Entity {
141142 } > (
142143 `query ($address: String!, $poolId: BigInt!, $limit: Int!, $offset: Int!) {
143144 investorTransactions(
144- where: {
145+ where: {
145146 account: $address,
146147 poolId: $poolId
147- }
148+ }
148149 limit: $limit
149150 offset: $offset
150151 ) {
@@ -162,6 +163,7 @@ export class Investor extends Entity {
162163 }
163164 token { name symbol decimals }
164165 tokenAmount
166+ tokenPrice
165167 centrifugeId
166168 poolId
167169 }
@@ -181,29 +183,33 @@ export class Investor extends Entity {
181183
182184 return {
183185 transactions : investorTransactions . items
184- . filter ( ( item ) => item . poolId === poolId . toString ( ) && item . currencyAsset !== null )
186+ . filter ( ( item ) => item . poolId === poolId . toString ( ) )
185187 . map ( ( item ) => {
186188 const chainId = chainsById . get ( item . centrifugeId )
187189 if ( ! chainId ) return null
188- if ( ! item . currencyAsset ) return null
189190
190191 return {
191192 type : item . type ,
192193 txHash : item . txHash ,
193194 createdAt : item . createdAt ,
194- currency : {
195- amount : new Balance ( item . currencyAmount , item . currencyAsset . decimals ) ,
196- symbol : item . currencyAsset . symbol ,
197- decimals : item . currencyAsset . decimals ,
198- id : item . currencyAsset . id ,
199- address : item . currencyAsset . address ,
200- } ,
201- token : {
202- name : item . token . name ,
203- symbol : item . token . symbol ,
204- decimals : Number ( item . token . decimals ) ,
205- amount : new Balance ( item . tokenAmount , Number ( item . token . decimals ) ) ,
206- } ,
195+ currency : item . currencyAsset
196+ ? {
197+ amount : new Balance ( item . currencyAmount , item . currencyAsset . decimals ) ,
198+ symbol : item . currencyAsset . symbol ,
199+ decimals : item . currencyAsset . decimals ,
200+ id : item . currencyAsset . id ,
201+ address : item . currencyAsset . address ,
202+ }
203+ : undefined ,
204+ token : item . token && item . tokenAmount
205+ ? {
206+ name : item . token . name ,
207+ symbol : item . token . symbol ,
208+ decimals : Number ( item . token . decimals ) ,
209+ amount : new Balance ( item . tokenAmount , Number ( item . token . decimals ) ) ,
210+ }
211+ : undefined ,
212+ tokenPrice : item . tokenPrice ? new Price ( item . tokenPrice ) : undefined ,
207213 chainId : Number ( chainId ) ,
208214 poolId : item . poolId ,
209215 }
0 commit comments