From 0794e21ac8bbeb1dc71578af9f24d332e699cb80 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Sat, 30 Sep 2023 19:23:03 -0700 Subject: [PATCH] Update several dependencies. --- gradle/libs.versions.toml | 16 +- .../java/com/lightspark/javatest/UmaTest.java | 222 ------------------ 2 files changed, 8 insertions(+), 230 deletions(-) delete mode 100644 javatest/src/test/java/com/lightspark/javatest/UmaTest.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d98169c4..473d5c99 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] # Core SDK deps (or common): -acinqSecp256k1 = "0.10.0" -androidGradlePlugin = "8.1.1" +acinqSecp256k1 = "0.10.1" +androidGradlePlugin = "8.1.2" appAuth = "0.11.1" buildKonfig = "0.13.3" dataStore = "1.0.0" desugar_jdk_libs = "2.0.3" -dokka = "1.8.10" +dokka = "1.9.0" downloadFile = "5.4.0" gradleS3 = "1.2.1" jna = "5.13.0" @@ -14,7 +14,7 @@ kase64 = "1.0.6" kotest = "5.5.4" kotlin = "1.9.0" kotlinCompilerExtension = "1.4.0" -kotlinCoroutines = "1.6.4" +kotlinCoroutines = "1.7.2" kotlinxDateTime = "0.4.0" kotlinSerializationJson = "1.4.1" krypt = "0.3.1" @@ -32,15 +32,15 @@ accompanist = "0.28.0" activityCompose = "1.7.2" barcodeScanning = "17.2.0" cameraX = "1.3.0-beta02" -composeBom = "2023.08.00" -coreKtx = "1.10.1" +composeBom = "2023.09.01" +coreKtx = "1.12.0" espresso = "3.5.1" hilt = "2.47" hiltComposeNavigation = "1.0.0" junit = "4.13.2" junitExt = "1.1.5" -lifecycleRuntimeKtx = "2.6.1" -navigationCompose = "2.7.0" +lifecycleRuntimeKtx = "2.6.2" +navigationCompose = "2.7.3" retrofit = "2.9.0" qrCode = "1.0.1" zxing = "3.5.1" diff --git a/javatest/src/test/java/com/lightspark/javatest/UmaTest.java b/javatest/src/test/java/com/lightspark/javatest/UmaTest.java deleted file mode 100644 index 22deeac3..00000000 --- a/javatest/src/test/java/com/lightspark/javatest/UmaTest.java +++ /dev/null @@ -1,222 +0,0 @@ -package com.lightspark.javatest; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.google.gson.Gson; -import com.lightspark.sdk.model.BitcoinNetwork; -import com.lightspark.sdk.model.CurrencyAmount; -import com.lightspark.sdk.model.CurrencyUnit; -import com.lightspark.sdk.model.GraphNode; -import com.lightspark.sdk.model.Invoice; -import com.lightspark.sdk.model.InvoiceData; -import com.lightspark.sdk.model.PaymentRequestStatus; -import com.lightspark.sdk.uma.Currency; -import com.lightspark.sdk.uma.InMemoryPublicKeyCache; -import com.lightspark.sdk.uma.KycStatus; -import com.lightspark.sdk.uma.LnurlpRequest; -import com.lightspark.sdk.uma.LnurlpResponse; -import com.lightspark.sdk.uma.PayReqResponse; -import com.lightspark.sdk.uma.PayRequest; -import com.lightspark.sdk.uma.PayerData; -import com.lightspark.sdk.uma.PayerDataOptions; -import com.lightspark.sdk.uma.PubKeyResponse; -import com.lightspark.sdk.uma.UmaInvoiceCreator; -import com.lightspark.sdk.uma.UmaProtocolHelper; -import com.lightspark.sdk.uma.UmaRequester; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.junit.jupiter.api.Test; - -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import kotlin.coroutines.Continuation; -import kotlinx.datetime.Clock; - -public class UmaTest { - UmaProtocolHelper umaProtocolHelper = new UmaProtocolHelper(new InMemoryPublicKeyCache(), new TestUmaRequester()); - private static String PUBKEY_HEX = "02061e5634646e60cfbe2ca42e2be920b4deb749f0159ed7c428cdd8e3ea69c133"; - private static String PRIVKEY_HEX = "0e120a3c9ff18d295c6452cbb7ee3bb0f3d9c34f4db9e62293d2773f338a3b9d"; - - - @Test - public void testFetchPublicKeySync() throws Exception { - PubKeyResponse pubKeys = umaProtocolHelper.fetchPublicKeysForVaspSync("https://vasp.com"); - assertNotNull(pubKeys); - System.out.println(pubKeys); - } - - @Test - public void testFetchPublicKeyFuture() throws Exception { - PubKeyResponse pubKeys = umaProtocolHelper.fetchPublicKeysForVaspFuture("https://vasp.com").get(); - assertNotNull(pubKeys); - System.out.println(pubKeys); - } - - @Test - public void testGetLnurlpRequest() throws Exception { - String lnurlpUrl = umaProtocolHelper.getSignedLnurlpRequestUrl( - privateKeyBytes(), - "$bob@vasp2.com", - "https://vasp.com", - true); - assertNotNull(lnurlpUrl); - System.out.println(lnurlpUrl); - LnurlpRequest request = umaProtocolHelper.parseLnurlpRequest(lnurlpUrl); - assertNotNull(request); - System.out.println(request); - } - - @Test - public void testGetLnurlpResponse() throws Exception { - String lnurlpUrl = umaProtocolHelper.getSignedLnurlpRequestUrl( - privateKeyBytes(), - "$bob@vasp2.com", - "https://vasp.com", - true); - LnurlpRequest request = umaProtocolHelper.parseLnurlpRequest(lnurlpUrl); - assertNotNull(request); - - LnurlpResponse lnurlpResponse = umaProtocolHelper.getLnurlpResponse( - request, - privateKeyBytes(), - true, - "https://vasp2.com/callback", - "encoded metadata", - 1, - 10_000_000, - new PayerDataOptions(false, false, true), - List.of( - new Currency( - "USD", - "US Dollar", - "$", - 34_150, - 1, - 10_000_000 - ) - ), - KycStatus.VERIFIED - ); - assertNotNull(lnurlpResponse); - String responseJson = lnurlpResponse.toJson(); - System.out.println(responseJson); - LnurlpResponse parsedResponse = umaProtocolHelper.parseAsLnurlpResponse(responseJson); - assertNotNull(parsedResponse); - assertEquals(lnurlpResponse, parsedResponse); - } - - @Test - public void testGetPayReqResponseSync() throws Exception { - PayRequest request = new PayRequest( - "USD", - 100, - new PayerData("$alice@vasp1.com") - ); - PayReqResponse response = umaProtocolHelper.getPayReqResponseSync( - request, - new TestUmaInvoiceCreator(), - "metadata", - "USD", - 12345L, - 0L, - List.of(), - null, - "" - ); - assertNotNull(response); - assertEquals("lnbc12345", response.getEncodedInvoice()); - System.out.println(response); - } - - @Test - public void testGetPayReqResponseFuture() throws Exception { - PayRequest request = new PayRequest( - "USD", - 100, - new PayerData("$alice@vasp1.com") - ); - PayReqResponse response = umaProtocolHelper.getPayReqResponseFuture( - request, - new TestUmaInvoiceCreator(), - "metadata", - "USD", - 12345L, - 0L, - List.of(), - null, - "" - ).get(); - assertNotNull(response); - assertEquals("lnbc12345", response.getEncodedInvoice()); - System.out.println(response); - } - - static byte[] hexToBytes(String hex) { - byte[] bytes = new byte[hex.length() / 2]; - for (int i = 0; i < hex.length(); i += 2) { - bytes[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) - + Character.digit(hex.charAt(i + 1), 16)); - } - return bytes; - } - - private byte[] privateKeyBytes() { - return hexToBytes(UmaTest.PRIVKEY_HEX); - } - - private byte[] publicKeyBytes() { - return hexToBytes(UmaTest.PUBKEY_HEX); - } -} - -class TestUmaRequester implements UmaRequester { - @Nullable - @Override - public Object makeGetRequest(@NotNull String url, @NotNull Continuation $completion) { - if (url.contains("lnurlpubkey")) { - PubKeyResponse response = new PubKeyResponse( - UmaTest.hexToBytes("02d5fe"), - UmaTest.hexToBytes("123456")); - return response.toJson(); - } - return null; - } -} - -class TestUmaInvoiceCreator implements UmaInvoiceCreator { - @NotNull - @Override - public CompletableFuture createUmaInvoice(long amountMsats, @NotNull String metadata) { - return CompletableFuture.completedFuture(new Invoice( - "lnbc12345", - Clock.System.INSTANCE.now(), - Clock.System.INSTANCE.now(), - new InvoiceData( - "lnbc12345", - BitcoinNetwork.MAINNET, - "12345", - new CurrencyAmount(12345, CurrencyUnit.SATOSHI, CurrencyUnit.SATOSHI, 12345, 12345), - Clock.System.INSTANCE.now(), - Clock.System.INSTANCE.now(), - new GraphNode( - "1234", - Clock.System.INSTANCE.now(), - Clock.System.INSTANCE.now(), - BitcoinNetwork.MAINNET, - "1234", - "1234", - "blue", - 100, - "38hd" - ), - null - ), - PaymentRequestStatus.CLOSED, - null - )); - } -}