File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
services/opencode/src/main/kotlin/com/getcode/opencode/internal/transactors Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ internal class ReceiveGiftCardTransactor(
8989 .getOrNull()
9090
9191 if (token == null ) {
92- onStep(" intent " )
92+ onStep(" pre-claim checks " )
9393 return @timedTraceSuspend logAndFail(ReceiveGiftTransactorError .Other (message = " Token not found" ))
9494 }
9595
@@ -99,12 +99,24 @@ internal class ReceiveGiftCardTransactor(
9999
100100 val requestingTokenOwner = requestingOwner.withTimelockForToken(token)
101101
102- return @timedTraceSuspend transactionController.receiveRemotely(
103- giftCard = giftCard,
104- amount = amount,
105- owner = requestingTokenOwner,
106- mint = token.address
107- ).fold(
102+ // 3. create an account if we don't currently have one for this token
103+ val userAccountResult = if (! accountController.hasAccountFor(token.address)) {
104+ accountController.createUserAccount(
105+ ownerForMint = requestingTokenOwner,
106+ mint = token.address
107+ )
108+ } else {
109+ Result .success(Unit )
110+ }
111+
112+ return @timedTraceSuspend userAccountResult.map {
113+ transactionController.receiveRemotely(
114+ giftCard = giftCard,
115+ amount = amount,
116+ owner = requestingTokenOwner,
117+ mint = token.address
118+ )
119+ }.fold(
108120 onSuccess = {
109121 onStep(" intent" )
110122 Result .success(token to amount)
You can’t perform that action at this time.
0 commit comments