Skip to content

Commit

Permalink
fewat(rwa): update the investorbalance by graphql subscription (#2777)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans authored Jan 8, 2025
1 parent 3d7d20a commit e465bf3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/apps/rwa-demo/src/hooks/getInvestorBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ export const useGetInvestorBalance = ({

subscriptionData.events?.map((event) => {
const params = JSON.parse(event.parameters ?? '[]');
if (params[0] === investorAccount && params.length === 2) {
setData(parseInt(params[1]));

const senderAccount = params.length >= 2 && params[1];
const receiverAccount = params.length >= 3 && params[2];

if (senderAccount && senderAccount.account === investorAccount) {
setData(senderAccount.current);
}
if (receiverAccount && receiverAccount.account === investorAccount) {
setData(receiverAccount.current);
}
});
}, [subscriptionData]);
Expand Down

0 comments on commit e465bf3

Please sign in to comment.