@@ -12,18 +12,26 @@ import io.newm.server.features.ethereum.model.EthereumNft
1212import io.newm.server.features.ethereum.model.EthereumNftSong
1313import io.newm.server.features.ethereum.model.GetNftsByOwnerResponse
1414import io.newm.server.features.ethereum.parser.parseSong
15+ import io.newm.server.features.user.database.UserEntity
1516import io.newm.server.ktx.checkedBody
1617import io.newm.server.ktx.getSecureConfigString
18+ import io.newm.server.typealiases.UserId
1719import io.newm.shared.ktx.getConfigString
20+ import org.jetbrains.exposed.sql.transactions.transaction
1821
1922internal class EthereumRepositoryImpl (
2023 private val client : HttpClient ,
2124 private val environment : ApplicationEnvironment
2225) : EthereumRepository {
2326 private val logger = KotlinLogging .logger {}
2427
25- override suspend fun getNftSongs (ownerAddress : String ): List <EthereumNftSong > {
26- logger.debug { " getNftSongs: ownerAddress = $ownerAddress " }
28+ override suspend fun getWalletNftSongs (userId : UserId ): List <EthereumNftSong > {
29+ logger.debug { " getWalletNftSongs: userId = $userId " }
30+
31+ // Temporary test hook until Ethereum wallet connections are implemented
32+ val email = transaction { UserEntity [userId].email }
33+ if (! email.endsWith(" @newm.io" )) return emptyList()
34+ val address = " 0xbb13c0560c8a8354e6a914f1f2b873cefe0df9f7"
2735
2836 val apiUrl = environment.getConfigString(" alchemy.apiUrl" )
2937 val apiKey = environment.getSecureConfigString(" alchemy.apiKey" )
@@ -34,7 +42,7 @@ internal class EthereumRepositoryImpl(
3442 delayMillis { 500L }
3543 }
3644 accept(ContentType .Application .Json )
37- parameter(" owner" , ownerAddress )
45+ parameter(" owner" , address )
3846 }.checkedBody<GetNftsByOwnerResponse >()
3947 .ownedNfts
4048 .mapNotNull(EthereumNft ::parseSong)
0 commit comments