@@ -7,13 +7,12 @@ import { PoolService } from '../services/poolService'
77import { TrancheService } from '../services/trancheService'
88import { InvestorTransactionData , InvestorTransactionService } from '../services/investorTransactionService'
99import { CurrencyService } from '../services/currencyService'
10- import { BlockchainService } from '../services/blockchainService'
10+ import { BlockchainService , LOCAL_CHAIN_ID } from '../services/blockchainService'
1111import { CurrencyBalanceService } from '../services/currencyBalanceService'
1212import { TrancheBalanceService } from '../services/trancheBalanceService'
1313import { escrows } from '../../config'
1414import { InvestorPositionService } from '../services/investorPositionService'
1515import { getPeriodStart } from '../../helpers/timekeeperService'
16- //const networkPromise = typeof ethApi.getNetwork === 'function' ? ethApi.getNetwork() : null
1716
1817export const handleEvmDeployTranche = errorHandler ( _handleEvmDeployTranche )
1918async function _handleEvmDeployTranche ( event : DeployTrancheLog ) : Promise < void > {
@@ -23,6 +22,7 @@ async function _handleEvmDeployTranche(event: DeployTrancheLog): Promise<void> {
2322
2423 const chainId = await getNodeEvmChainId ( )
2524 if ( ! chainId ) throw new Error ( 'Unable to retrieve chainId' )
25+ await BlockchainService . getOrInit ( LOCAL_CHAIN_ID )
2626 const evmBlockchain = await BlockchainService . getOrInit ( chainId )
2727
2828 const poolId = _poolId . toString ( )
@@ -73,12 +73,14 @@ async function _handleEvmTransfer(event: TransferLog): Promise<void> {
7373 const _isFromUserEscrow = fromEvmAddress === userEscrowAddress
7474
7575 if ( ! evmToken . poolId || ! evmToken . trancheId ) throw new Error ( 'This is not a tranche token' )
76+ const pool = await PoolService . getById ( evmToken . poolId )
77+ if ( ! pool ) throw new Error ( 'Pool not found!' )
7678 const trancheId = evmToken . trancheId . split ( '-' ) [ 1 ]
77- const tranche = await TrancheService . getById ( evmToken . poolId , trancheId )
79+ const tranche = await TrancheService . getById ( pool . id , trancheId )
7880 if ( ! tranche ) throw new Error ( 'Tranche not found!' )
7981
8082 const orderData : Omit < InvestorTransactionData , 'address' > = {
81- poolId : evmToken . poolId ,
83+ poolId : pool . id ,
8284 trancheId : trancheId ,
8385 hash : event . transactionHash ,
8486 timestamp : timestamp ,
0 commit comments