Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
fix file resource load
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Stavetski committed Apr 18, 2018
1 parent bf7a70a commit ced1dc1
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import fund.cyber.markets.connector.etherdelta.ParityTokenRegistryContract
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.Tags
import io.micrometer.core.instrument.Timer
import org.apache.commons.io.IOUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.io.ClassPathResource
import org.springframework.context.support.GenericApplicationContext
import org.springframework.kafka.core.KafkaTemplate
import org.springframework.stereotype.Component
import org.web3j.protocol.Web3j
Expand All @@ -38,6 +39,7 @@ import java.math.BigDecimal
import java.math.BigInteger
import java.math.RoundingMode
import java.net.URL
import java.nio.charset.Charset
import java.util.*
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
Expand All @@ -60,6 +62,9 @@ class EtherdeltaConnector : ExchangeConnector {
private lateinit var parityTokenRegistryContract: ParityTokenRegistryContract
private lateinit var etherdeltaContract: EtherdeltaContract

@Autowired
private lateinit var resourceLoader: GenericApplicationContext

@Autowired
private lateinit var configuration: ConnectorConfiguration

Expand Down Expand Up @@ -267,7 +272,10 @@ class EtherdeltaConnector : ExchangeConnector {
val tokens = mutableMapOf<String, EtherdeltaToken>()
val base = BigInteger.TEN

val tokenListTree = mapper.readValue<Iterable<JsonNode>>(ClassPathResource("tokens-eth.json").file)
val tokenDefinitionInputStream = resourceLoader.getResource("classpath:tokens-eth.json").inputStream
val tokenDefinitionString = IOUtils.toString(tokenDefinitionInputStream, Charset.forName("UTF-8"))

val tokenListTree = mapper.readValue<Iterable<JsonNode>>(tokenDefinitionString)
tokenListTree.asIterable().forEach { tokenNode ->

if (tokenNode.get("decimals").asInt() != 0) {
Expand Down

0 comments on commit ced1dc1

Please sign in to comment.