@@ -13,7 +13,8 @@ import type {
1313 ComputeResult ,
1414 RunningPlatform ,
1515 ComputeEnvFeesStructure ,
16- ComputeResourceRequest
16+ ComputeResourceRequest ,
17+ ComputeEnvFees
1718} from '../../@types/C2D/C2D.js'
1819import { getConfiguration } from '../../utils/config.js'
1920import { C2DEngine } from './compute_engine_base.js'
@@ -43,6 +44,7 @@ import { decryptFilesObject, omitDBComputeFieldsFromComputeJob } from './index.j
4344import * as drc from 'docker-registry-client'
4445import { ValidateParams } from '../httpRoutes/validateCommands.js'
4546import { Service } from '@oceanprotocol/ddo-js'
47+ import { getOceanTokenAddressForChain } from '../../utils/address.js'
4648
4749export class C2DEngineDocker extends C2DEngine {
4850 private envs : ComputeEnvironment [ ] = [ ]
@@ -113,7 +115,34 @@ export class C2DEngineDocker extends C2DEngine {
113115 if ( supportedChains . includes ( parseInt ( feeChain ) ) ) {
114116 if ( fees === null ) fees = { }
115117 if ( ! ( feeChain in fees ) ) fees [ feeChain ] = [ ]
116- fees [ feeChain ] = envConfig . fees [ feeChain ]
118+ const tmpFees : ComputeEnvFees [ ] = [ ]
119+ for ( let i = 0 ; i < envConfig . fees [ feeChain ] . length ; i ++ ) {
120+ if (
121+ envConfig . fees [ feeChain ] [ i ] . prices &&
122+ envConfig . fees [ feeChain ] [ i ] . prices . length > 0
123+ ) {
124+ if ( ! envConfig . fees [ feeChain ] [ i ] . feeToken ) {
125+ const tokenAddress = await getOceanTokenAddressForChain ( parseInt ( feeChain ) )
126+ if ( tokenAddress ) {
127+ envConfig . fees [ feeChain ] [ i ] . feeToken = tokenAddress
128+ tmpFees . push ( envConfig . fees [ feeChain ] [ i ] )
129+ } else {
130+ CORE_LOGGER . error (
131+ `Unable to find Ocean token address for chain ${ feeChain } and no custom token provided`
132+ )
133+ }
134+ } else {
135+ tmpFees . push ( envConfig . fees [ feeChain ] [ i ] )
136+ }
137+ } else {
138+ CORE_LOGGER . error (
139+ `Unable to find prices for fee ${ JSON . stringify (
140+ envConfig . fees [ feeChain ] [ i ]
141+ ) } on chain ${ feeChain } `
142+ )
143+ }
144+ }
145+ fees [ feeChain ] = tmpFees
117146 }
118147
119148 /* for (const chain of Object.keys(config.supportedNetworks)) {
0 commit comments