Skip to content

Commit 1abd712

Browse files
committed
chore(bills): allow rendering USDF conditionally as a bill for Bill Designer
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent aea7cd5 commit 1abd712

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/bill/BillState.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.getcode.opencode.internal.manager.VerifiedState
99
import com.getcode.opencode.model.financial.Fiat
1010
import com.getcode.opencode.model.financial.LocalFiat
1111
import com.getcode.opencode.model.financial.Token
12+
import com.getcode.opencode.model.financial.usdf
1213
import com.getcode.solana.keys.Mint
1314
import kotlin.time.Duration
1415

@@ -125,6 +126,7 @@ sealed interface Bill {
125126
val kind: Kind = Kind.cash,
126127
val verifiedState: VerifiedState? = null,
127128
val nonce: List<Byte> = emptyList(),
129+
val renderAsBill: Boolean = token.address != Mint.usdf,
128130
) : Bill {
129131
override val canFlip: Boolean = false
130132
}

apps/flipcash/shared/bill-customization/src/main/kotlin/com/flipcash/app/bill/customization/internal/InternalBillPlaygroundController.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class InternalBillPlaygroundController(
138138
token = token.copy(billCustomizations = customizations),
139139
amount = demoAmount,
140140
disableGestures = true,
141-
data = payloadInfo.codeData.toList()
141+
data = payloadInfo.codeData.toList(),
142+
renderAsBill = true,
142143
)
143144

144145
_state.update { current ->

apps/flipcash/shared/bills/src/main/kotlin/com/flipcash/app/bills/RenderedBill.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@ fun RenderedBill(
2222
modifier: Modifier = Modifier,
2323
bill: Bill,
2424
) {
25-
if (bill.token.address == Mint.usdf) {
26-
GoldBar(
27-
modifier = modifier
28-
.padding(horizontal = CodeTheme.dimens.inset),
29-
payloadData = bill.data,
30-
amount = bill.amount.underlyingTokenAmount,
31-
)
32-
} else {
33-
CashBill(
34-
modifier = modifier,
35-
payloadData = bill.data,
36-
amount = bill.amount,
37-
token = bill.token
38-
)
25+
when (bill) {
26+
is Bill.Cash -> {
27+
if (bill.renderAsBill) {
28+
CashBill(
29+
modifier = modifier,
30+
payloadData = bill.data,
31+
amount = bill.amount,
32+
token = bill.token
33+
)
34+
} else {
35+
GoldBar(
36+
modifier = modifier
37+
.padding(horizontal = CodeTheme.dimens.inset),
38+
payloadData = bill.data,
39+
amount = bill.amount.underlyingTokenAmount,
40+
)
41+
}
42+
}
3943
}
4044
}
4145

0 commit comments

Comments
 (0)