Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOM_1.1.0 #38

Merged
merged 89 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c009c23
Add kotlin bindings for lib in Rust
jakubuid Sep 25, 2024
710887c
Yttrium demo
jakubuid Oct 7, 2024
f70b48e
Get yttrium with bindings from remote
jakubuid Oct 18, 2024
ff729b0
Remove deprecations
jakubuid Oct 18, 2024
ce40d2a
Fetch Yttrium
jakubuid Oct 28, 2024
a893520
Remove logs
jakubuid Oct 28, 2024
7bd33b5
Bump Yttrium
jakubuid Oct 30, 2024
a52a423
Merge branch 'develop' of github.com:reown-com/reown-kotlin into yttr…
jakubuid Oct 30, 2024
806be5a
Fix merge
jakubuid Oct 30, 2024
448bd9c
Add Logs
jakubuid Oct 30, 2024
bfdbdce
Error
jakubuid Oct 30, 2024
974a28b
Bump Yttrium
jakubuid Oct 30, 2024
1a53df7
Add more logs
jakubuid Oct 30, 2024
3dc38f7
Fix CI
jakubuid Oct 30, 2024
75d0728
Exclude bindings from lint
jakubuid Oct 30, 2024
a4f9ed2
Add SafeInteractor.kt
jakubuid Oct 31, 2024
14d07ea
Integrate Yttrium methods in WalletKit
jakubuid Oct 31, 2024
11b6a7c
2step tx in progress
jakubuid Oct 31, 2024
8cb6cca
Two step transaction works
jakubuid Nov 4, 2024
c1fe22e
Improve WK interface for Java
jakubuid Nov 4, 2024
1d1e310
Add SA toggle into settings screen
jakubuid Nov 4, 2024
4d6c112
Use SA switcher to approve session with SA address
jakubuid Nov 5, 2024
84eb664
Handle eth_sendTransaction for SA
jakubuid Nov 5, 2024
e2d240d
Add persistence for safe toggle state
jakubuid Nov 5, 2024
e802663
Remove using callbacks
jakubuid Nov 5, 2024
8f2c11f
Add canfulfil and fulfillmentStatus to WK
jakubuid Nov 15, 2024
2387554
Sign route txs
jakubuid Nov 15, 2024
ba6e6b3
Savepoint
jakubuid Nov 15, 2024
d7faf38
Blockchain API integration
jakubuid Nov 15, 2024
e84c345
Gas estimation savepoint
jakubuid Nov 18, 2024
f7398e3
Add CA use cases
jakubuid Nov 19, 2024
4611a58
Clean up WCDelegate
jakubuid Nov 20, 2024
7b9d551
Clean up signing and sending txs
jakubuid Nov 20, 2024
8064ddd
Clean up request route
jakubuid Nov 21, 2024
6ab3373
Clean up canFulfil logic
jakubuid Nov 21, 2024
6fa7c94
Handle transaction when CA not needed
jakubuid Nov 21, 2024
5edb5a3
Navigation for CA screen
jakubuid Nov 21, 2024
a6873e5
Add route error handling
jakubuid Nov 22, 2024
33dd9ef
Add error dialog
jakubuid Nov 22, 2024
5c66590
Add success screen
jakubuid Nov 22, 2024
efe9c6c
Respond with errors
jakubuid Nov 22, 2024
62d91cb
Respond with errors
jakubuid Nov 22, 2024
fcb92ae
Move polling into WK
jakubuid Nov 25, 2024
8c50857
Use OP and Base RPCs, handle timeout for status
jakubuid Nov 26, 2024
10b5b86
Send fulfilment txs in parallel
jakubuid Nov 26, 2024
646dc7a
Clean up
jakubuid Nov 26, 2024
aaa2fca
Change Arbitrum RPC
jakubuid Nov 27, 2024
f7d4892
Improve UI for CA request
jakubuid Nov 27, 2024
064b57f
Update UI for success and error cases
jakubuid Nov 27, 2024
6212b64
Fix icons not scaling
jakubuid Nov 28, 2024
dd4e429
Add timeout for the tx receipts await
jakubuid Nov 29, 2024
83b97ca
Fix getting tx details
jakubuid Nov 29, 2024
06b4407
Update type names
jakubuid Dec 3, 2024
21851fa
Integrate Yttrium via JitPack
jakubuid Dec 3, 2024
e2538ce
Snapshot build
jakubuid Dec 6, 2024
7772ccd
Clean up
jakubuid Dec 6, 2024
1bd7a47
Merge branch 'develop' of github.com:reown-com/reown-kotlin into chai…
jakubuid Dec 6, 2024
892b6d3
Fix value for funding conversion
jakubuid Dec 6, 2024
1074639
Add experimental annotations
jakubuid Dec 10, 2024
472fc1d
Merge branch 'develop' of github.com:reown-com/reown-kotlin into get_…
jakubuid Dec 10, 2024
5e7213b
Add getting erc20 token balance
jakubuid Dec 11, 2024
6b139fd
Handle transactions details
jakubuid Dec 12, 2024
df98a08
Merge branch 'develop' of github.com:reown-com/reown-kotlin into chai…
jakubuid Dec 12, 2024
fb28123
Merge branch 'chain_abstraction' of github.com:reown-com/reown-kotlin…
jakubuid Dec 12, 2024
747d3ee
Update method names
jakubuid Dec 12, 2024
ebebe04
Remove currency
jakubuid Dec 12, 2024
03634ea
Clean up
jakubuid Dec 12, 2024
2a9c954
Merge pull request #29 from reown-com/get_UI_fields
jakubuid Dec 12, 2024
7dd3410
Fix error case
jakubuid Dec 12, 2024
b33bc07
Fix fees parsing
jakubuid Dec 13, 2024
5d4e9a1
Change canFulfil method name
jakubuid Dec 16, 2024
6d6be3d
Change canFulfil usecase name
jakubuid Dec 16, 2024
6f7d67a
Handle gas estimation server side
jakubuid Dec 16, 2024
df0b7fb
Add PrepareFulfilmentUseCaseTest
jakubuid Dec 16, 2024
5f16c22
Add FulfilmentStatusUseCaseTest
jakubuid Dec 16, 2024
a031145
Add GetTransactionDetailsUseCaseTest
jakubuid Dec 16, 2024
8210faf
CLean up logs and add error logging
jakubuid Dec 17, 2024
da51130
Handle nullable types
jakubuid Dec 17, 2024
b133a49
Update
jakubuid Dec 17, 2024
2e786f9
Adjust to new types and add error test cases
jakubuid Dec 18, 2024
413f874
Update the type names
jakubuid Dec 19, 2024
8f6036d
Remove file
jakubuid Dec 19, 2024
28f6fb2
Update version
jakubuid Dec 19, 2024
0090743
Update name
jakubuid Dec 19, 2024
290516b
Add log
jakubuid Dec 20, 2024
2c5984a
Add annotation
jakubuid Dec 20, 2024
7b6a829
Merge pull request #28 from reown-com/chain_abstraction
jakubuid Dec 20, 2024
9066f6a
Versions Bump
jakubuid Dec 20, 2024
cbeb3c4
Add logs
jakubuid Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.sonarqube.gradle.SonarExtension
import java.net.URL
import java.util.Base64
import javax.xml.parsers.DocumentBuilderFactory

Expand Down Expand Up @@ -108,8 +109,6 @@ task<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}



nexusPublishing {
repositories {
// project.version = "-SNAPSHOT"
Expand Down
16 changes: 8 additions & 8 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID"
const val KEY_SDK_NAME = "SDK_NAME"

//Latest versions
const val BOM_VERSION = "1.0.4"
const val FOUNDATION_VERSION = "1.0.4"
const val CORE_VERSION = "1.0.4"
const val SIGN_VERSION = "1.0.4"
const val NOTIFY_VERSION = "1.0.4"
const val WALLETKIT_VERSION = "1.0.4"
const val APPKIT_VERSION = "1.0.4"
const val MODAL_CORE_VERSION = "1.0.4"
const val BOM_VERSION = "1.1.0"
const val FOUNDATION_VERSION = "1.1.0"
const val CORE_VERSION = "1.1.0"
const val SIGN_VERSION = "1.1.0"
const val NOTIFY_VERSION = "1.1.0"
const val WALLETKIT_VERSION = "1.1.0"
const val APPKIT_VERSION = "1.1.0"
const val MODAL_CORE_VERSION = "1.1.0"

//Artifact ids
const val ANDROID_BOM = "android-bom"
Expand Down
6 changes: 6 additions & 0 deletions foundation/src/test/kotlin/com/reown/foundation/RelayTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ class RelayTest {
val (clientA: RelayInterface, clientB: RelayInterface) = initTwoClients(packageName = "com.test.failure")

clientA.eventsFlow.onEach { event ->
println("Test Result: A event: $event")
when (event) {
is Relay.Model.Event.OnConnectionFailed -> {
println("Test Result: A onFailed")
if (event.throwable.message?.contains("403") == true) {
println("Test Result: A Success")
testState.compareAndSet(expect = TestState.Idle, update = TestState.Success)
}
}
Expand All @@ -96,9 +99,12 @@ class RelayTest {
}.launchIn(testScope)

clientB.eventsFlow.onEach { event ->
println("Test Result: B event: $event")
when (event) {
is Relay.Model.Event.OnConnectionFailed -> {
println("Test Result: B onFailed")
if (event.throwable.message?.contains("403") == true) {
println("Test Result: B Success")
testState.compareAndSet(expect = TestState.Idle, update = TestState.Success)
}
}
Expand Down
28 changes: 28 additions & 0 deletions product/walletkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.android.build.api.dsl.Packaging
import java.net.URL

plugins {
id("com.android.library")
id(libs.plugins.kotlin.android.get().pluginId)
Expand Down Expand Up @@ -33,6 +36,7 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "${rootDir.path}/gradle/proguard-rules/sdk-rules.pro", "${projectDir}/web3wallet-rules.pro")
}
}

lint {
abortOnError = true
ignoreWarnings = true
Expand All @@ -43,6 +47,12 @@ android {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
}

packaging {
jniLibs.pickFirsts.add("lib/arm64-v8a/libuniffi_yttrium.so")
jniLibs.pickFirsts.add("lib/armeabi-v7a/libuniffi_yttrium.so")
}

kotlinOptions {
jvmTarget = jvmVersion.toString()
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.time.ExperimentalTime"
Expand All @@ -54,6 +64,9 @@ android {
}

dependencies {
implementation("net.java.dev.jna:jna:5.15.0@aar")
implementation("com.github.reown-com:yttrium:0.4.11")

implementation(platform(libs.firebase.bom))
implementation(libs.firebase.messaging)

Expand All @@ -62,4 +75,19 @@ dependencies {

releaseImplementation("com.reown:android-core:$CORE_VERSION")
releaseImplementation("com.reown:sign:$SIGN_VERSION")

testImplementation(libs.bundles.androidxTest)
testImplementation(libs.robolectric)
testImplementation(libs.json)
testImplementation(libs.coroutines.test)
testImplementation(libs.bundles.scarlet.test)
testImplementation(libs.bundles.sqlDelight.test)
testImplementation(libs.koin.test)

androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.coroutines.test)
androidTestImplementation(libs.core)

androidTestUtil(libs.androidx.testOrchestrator)
androidTestImplementation(libs.bundles.androidxAndroidTest)
}
7 changes: 7 additions & 0 deletions product/walletkit/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Exclude the 'kotlin-bindings' directory from all lint checks -->
<issue id="all">
<ignore path="build/yttrium/kotlin-bindings/**" />
</issue>
</lint>
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.reown.walletkit

import com.reown.walletkit.client.Wallet
import com.reown.walletkit.use_cases.ChainAbstractionStatusUseCase
import io.mockk.coEvery
import io.mockk.mockk
import junit.framework.TestCase.assertTrue
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.test.runTest
import org.junit.Test
import uniffi.uniffi_yttrium.ChainAbstractionClient
import uniffi.yttrium.StatusResponse
import uniffi.yttrium.StatusResponseCompleted
import uniffi.yttrium.StatusResponseError
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

@ExperimentalCoroutinesApi
class ChainAbstractionStatusUseCaseTest {
private val chainAbstractionClient: ChainAbstractionClient = mockk()
private val chainAbstractionStatusUseCase = ChainAbstractionStatusUseCase(chainAbstractionClient)

@Test
fun shouldCallOnSuccessWhenStatusIsCompleted() = runTest {
val fulfilmentId = "123"
val checkIn = 1000L
val completedResult = StatusResponse.Completed(StatusResponseCompleted(createdAt = 1u))

coEvery { chainAbstractionClient.status(fulfilmentId) } returns completedResult

val result = async {
suspendCoroutine { continuation ->
chainAbstractionStatusUseCase.invoke(
fulfilmentId,
checkIn,
onSuccess = {
continuation.resume(true)
},
onError = {
continuation.resume(false)
}
)
}
}.await()

assertTrue(result)
}

@Test
fun shouldCallOnErrorWhenStatusIsError() = runTest {
val fulfilmentId = "123"
val checkIn = 1000L
val errorResult = StatusResponse.Error(StatusResponseError(createdAt = 1u, error = "error"))

coEvery { chainAbstractionClient.status(fulfilmentId) } returns errorResult

val result = async {
suspendCoroutine { continuation ->
chainAbstractionStatusUseCase.invoke(
fulfilmentId,
checkIn,
onSuccess = {
continuation.resume(true)
},
onError = {
continuation.resume(it)
}
)
}
}.await()

assertTrue(result is Wallet.Model.Status.Error)
}

@Test
fun shouldCallOnErrorWhenErrorIsThrown() = runTest {
val fulfilmentId = "123"
val checkIn = 1000L

coEvery { chainAbstractionClient.status(fulfilmentId) } throws RuntimeException("error")

val result = async {
suspendCoroutine { continuation ->
chainAbstractionStatusUseCase.invoke(
fulfilmentId,
checkIn,
onSuccess = {
continuation.resume(false)
},
onError = {
continuation.resume(true)
}
)
}
}.await()

assertTrue(result)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.reown.walletkit

import com.reown.walletkit.client.Wallet
import com.reown.walletkit.client.toWallet
import com.reown.walletkit.use_cases.GetTransactionDetailsUseCase
import io.mockk.coEvery
import io.mockk.mockk
import junit.framework.TestCase.assertTrue
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.test.runTest
import org.junit.Test
import uniffi.uniffi_yttrium.ChainAbstractionClient
import uniffi.yttrium.Amount
import uniffi.yttrium.FeeEstimatedTransaction
import uniffi.yttrium.Transaction
import uniffi.yttrium.TransactionFee
import uniffi.yttrium.TxnDetails
import uniffi.yttrium.UiFields
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

@ExperimentalCoroutinesApi
class GetTransactionDetailsUseCaseTest {
private val chainAbstractionClient: ChainAbstractionClient = mockk()
private val getTransactionDetailsUseCase = GetTransactionDetailsUseCase(chainAbstractionClient)

@Test
fun shouldCallOnSuccessWithExpectedResultWhenClientSucceeds() = runTest {
val available = Wallet.Model.PrepareSuccess.Available(
fulfilmentId = "123",
checkIn = 11,
initialTransaction = transaction.toWallet(),
transactions = listOf(transaction.toWallet()),
funding = listOf(Wallet.Model.FundingMetadata(chainId = "1", tokenContract = "token", symbol = "s", amount = "11", decimals = 18, bridgingFee = "0")),
initialTransactionMetadata = Wallet.Model.InitialTransactionMetadata(transferTo = "aa", amount = "11", tokenContract = "cc", symbol = "s", decimals = 18)
)
val resultFields = UiFields(
route = listOf(txDetails),
initial = txDetails,
bridge = listOf(TransactionFee(Amount("11", "18", 2u, "22", "1222"), Amount("11", "18", 2u, "22", "1222"))),
localTotal = Amount("11", "18", 2u, "22", "1222"),
localBridgeTotal = Amount("11", "18", 2u, "22", "1222"),
localRouteTotal = Amount("11", "18", 2u, "22", "1222"),
)

coEvery { chainAbstractionClient.getUiFields(any(), any()) } returns resultFields

val result = async {
suspendCoroutine { continuation ->
getTransactionDetailsUseCase.invoke(
available,
onSuccess = {
continuation.resume(true)
},
onError = {
continuation.resume(false)
}
)
}
}.await()

assertTrue(result)
}

@Test
fun shouldCallOnErrorWhenClientThrowsAnException() = runTest {
val available = Wallet.Model.PrepareSuccess.Available(
fulfilmentId = "123",
checkIn = 11,
initialTransaction = transaction.toWallet(),
transactions = listOf(transaction.toWallet()),
funding = listOf(Wallet.Model.FundingMetadata(chainId = "1", tokenContract = "token", symbol = "s", amount = "11", decimals = 18, bridgingFee = "0")),
initialTransactionMetadata = Wallet.Model.InitialTransactionMetadata(transferTo = "aa", amount = "11", tokenContract = "cc", symbol = "s", decimals = 18)
)
val exception = Exception("Some error occurred")

coEvery { chainAbstractionClient.getUiFields(any(), any()) } throws exception

val result = async {
suspendCoroutine { continuation ->
getTransactionDetailsUseCase.invoke(
available,
onSuccess = {
println("success: $it")
continuation.resume(false)
},
onError = {
println("test1 error: $it")
continuation.resume(true)
}
)
}
}.await()

assertTrue(result)
}

companion object {
val transaction = Transaction(
from = "from",
to = "to",
value = "value",
input = "data",
nonce = "nonce",
gasLimit = "gas",
chainId = "1"
)

private val feeEstimatedTransactionMetadata = FeeEstimatedTransaction(
from = "from",
to = "to",
value = "value",
input = "data",
nonce = "nonce",
gasLimit = "gas",
chainId = "1",
maxPriorityFeePerGas = "11",
maxFeePerGas = "33"
)

val txDetails = TxnDetails(
transaction = feeEstimatedTransactionMetadata,
fee = TransactionFee(Amount("11", "18", 2u, "22", "1222"), Amount("11", "18", 2u, "22", "1222")),
)
}
}
Loading
Loading