Skip to content

Commit

Permalink
Merge pull request #4 from uma-universal-money-address/feat/displayDe…
Browse files Browse the repository at this point in the history
…cimals

Add displayDecimals to the currency object.
  • Loading branch information
jklein24 authored Nov 15, 2023
2 parents 8aa24e1 + bcc0f29 commit 218b0f0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
local.properties

### IntelliJ IDEA ###
.idea/modules.xml
Expand Down Expand Up @@ -39,4 +40,4 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store
6 changes: 6 additions & 0 deletions .idea/artifacts/uma_sdk_jvm.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions javatest/src/test/java/me/uma/javatest/UmaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import me.uma.InMemoryPublicKeyCache;
import me.uma.UmaInvoiceCreator;
import me.uma.UmaProtocolHelper;
import me.uma.UmaRequester;
import me.uma.protocol.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.Test;
Expand All @@ -16,6 +11,19 @@
import java.util.concurrent.CompletableFuture;

import kotlin.coroutines.Continuation;
import me.uma.InMemoryPublicKeyCache;
import me.uma.UmaInvoiceCreator;
import me.uma.UmaProtocolHelper;
import me.uma.UmaRequester;
import me.uma.protocol.Currency;
import me.uma.protocol.KycStatus;
import me.uma.protocol.LnurlpRequest;
import me.uma.protocol.LnurlpResponse;
import me.uma.protocol.PayReqResponse;
import me.uma.protocol.PayRequest;
import me.uma.protocol.PayerData;
import me.uma.protocol.PayerDataOptions;
import me.uma.protocol.PubKeyResponse;

public class UmaTest {
UmaProtocolHelper umaProtocolHelper = new UmaProtocolHelper(new InMemoryPublicKeyCache(), new TestUmaRequester());
Expand Down Expand Up @@ -77,7 +85,8 @@ public void testGetLnurlpResponse() throws Exception {
"$",
34_150,
1,
10_000_000
10_000_000,
2
)
),
KycStatus.VERIFIED
Expand Down
36 changes: 35 additions & 1 deletion uma-sdk/src/commonMain/kotlin/me/uma/protocol/Currency.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,48 @@ import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

@Serializable
data class Currency(
data class Currency @JvmOverloads constructor(
/**
* The currency code, eg. "USD".
*/
val code: String,

/**
* The full currency name, eg. "US Dollars".
*/
val name: String,

/**
* The symbol of the currency, eg. "$".
*/
val symbol: String,

/**
* Estimated millisats per smallest "unit" of this currency (eg. 1 cent in USD).
*/
@SerialName("multiplier")
val millisatoshiPerUnit: Long,

/**
* Minimum amount that can be sent in this currency. This is in the smallest unit of the currency
* (eg. cents for USD).
*/
val minSendable: Long,

/**
* Maximum amount that can be sent in this currency. This is in the smallest unit of the currency
* (eg. cents for USD).
*/
val maxSendable: Long,

/**
* Number of digits after the decimal point for display on the sender side. For example,
* in USD, by convention, there are 2 digits for cents - $5.95. in this case, `displayDecimals`
* would be 2. Note that the multiplier is still always in the smallest unit (cents). This field
* is only for display purposes. The sender should assume zero if this field is omitted, unless
* they know the proper display format of the target currency.
*/
val displayDecimals: Int? = null,
) {
fun toJson() = Json.encodeToString(this)
}

0 comments on commit 218b0f0

Please sign in to comment.