Skip to content

Commit 4afee6f

Browse files
authored
Fixed NPE when attempting to mint using PayPal (#653)
1 parent 6a6262a commit 4afee6f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

newm-server/src/main/kotlin/io/newm/server/features/minting/repo/MintingRepositoryImpl.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class MintingRepositoryImpl(
105105
Pair(collabUser.walletAddress!!, amount)
106106
}
107107
log.info { "Royalty splits for songId: ${song.id} - $streamTokenSplits" }
108-
val paymentKey = cardanoRepository.getKey(song.paymentKeyId!!)
109108

110109
// Convert release.mintPaymentType String to PaymentType enum
111110
val paymentTypeEnum = PaymentType.valueOf(release.mintPaymentType ?: PaymentType.ADA.name)
@@ -122,8 +121,10 @@ class MintingRepositoryImpl(
122121
val newmTokenName =
123122
if (isMainnet) CardanoRepository.NEWM_TOKEN_NAME else CardanoRepository.NEWM_TOKEN_NAME_PREPROD
124123

124+
var paymentKey: Key? = null
125125
val paymentUtxo = when (paymentTypeEnum) {
126126
PaymentType.NEWM -> {
127+
paymentKey = cardanoRepository.getKey(song.paymentKeyId!!)
127128
requireNotNull(
128129
cardanoRepository.queryLiveUtxos(paymentKey.address).firstOrNull { utxo ->
129130
utxo.nativeAssetsCount == 1 &&
@@ -140,7 +141,7 @@ class MintingRepositoryImpl(
140141

141142
else -> {
142143
// Handles PaymentType.ADA and legacy cases (where release.mintPaymentType might be null)
143-
144+
paymentKey = cardanoRepository.getKey(song.paymentKeyId!!)
144145
val costToUse = if (release.mintPaymentType != null && paymentTypeEnum == PaymentType.ADA) {
145146
mintCost // This is release.mintCost, which would be ADA amount
146147
} else {

0 commit comments

Comments
 (0)