Skip to content

Commit 6d94c80

Browse files
committed
Merge branch 'develop' into 'master'
Develop See merge request papers/airgap/beacon-android-sdk!65
2 parents 222172b + 6d97515 commit 6d94c80

File tree

10 files changed

+37
-23
lines changed

10 files changed

+37
-23
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ To add `Beacon Android SDK` into your project:
4545
#### Groovy
4646
```groovy
4747
dependencies {
48-
def beacon_version = "3.2.0"
48+
def beacon_version = "x.y.z"
4949
5050
// REQUIRED, core
5151
implementation "com.github.airgap-it.beacon-android-sdk:core:$beacon_version"
@@ -76,7 +76,7 @@ To add `Beacon Android SDK` into your project:
7676
#### Kotlin
7777
```kotlin
7878
dependencies {
79-
val beaconVersion = "3.2.0"
79+
val beaconVersion = "x.y.z"
8080

8181
// REQUIRED, core
8282
implementation("com.github.airgap-it.beacon-android-sdk:core:$beaconVersion")
@@ -368,6 +368,12 @@ $ ./gradlew testMock{Release|Debug}UnitTest
368368
---
369369
## Related Projects
370370

371-
[Beacon SDK](https://github.com/airgap-it/beacon-sdk) - an SDK for web developers (dApp & wallet)
371+
### AirGap Projects
372372

373-
[Beacon iOS SDK](https://github.com/airgap-it/beacon-ios-sdk) - an SDK for iOS developers (wallet)
373+
[Beacon SDK](https://github.com/airgap-it/beacon-sdk) - an SDK for web developers
374+
375+
[Beacon iOS SDK](https://github.com/airgap-it/beacon-ios-sdk) - an SDK for iOS developers
376+
377+
### Community Projects
378+
379+
[Beacon Flutter SDK](https://github.com/TalaoDAO/beacon) - an SDK for Flutter developers

blockchain-tezos/src/main/java/it/airgap/beaconsdk/blockchain/tezos/data/operation/MichelineMichelsonV1Expression.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ public data class MichelinePrimitiveBytes(public val bytes: String) : MichelineM
104104

105105
override fun deserialize(decoder: Decoder): MichelinePrimitiveBytes =
106106
decoder.decodeStructure(descriptor) {
107-
val primitive = decodeStringElement(descriptor, 0)
107+
val primitive = HexString(decodeStringElement(descriptor, 0))
108108

109-
return MichelinePrimitiveBytes(primitive)
109+
return MichelinePrimitiveBytes(primitive.asString(withPrefix = false))
110110
}
111111

112112
override fun serialize(encoder: Encoder, value: MichelinePrimitiveBytes) {
113113
encoder.encodeStructure(descriptor) {
114114
with(value) {
115-
encodeStringElement(descriptor, 0, HexString(bytes).asString(withPrefix = true))
115+
encodeStringElement(descriptor, 0, HexString(bytes).asString(withPrefix = false))
116116
}
117117
}
118118
}

buildSrc/src/main/java/GradleConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ object Android {
33
const val minSdk = 21
44
const val targetSdk = 32
55

6-
const val versionCode = 25
7-
const val versionName = "3.2.1"
6+
const val versionCode = 27
7+
const val versionName = "3.2.2"
88
}
99

1010
object Version {

core/src/main/java/it/airgap/beaconsdk/core/internal/data/HexString.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public value class HexString(private val value: String) {
2525

2626
public fun toByteArray(): ByteArray = asString().chunked(2).map { it.toInt(16).toByte() }.toByteArray()
2727
public fun toInt(): Int = asString().toUInt(16).toInt()
28-
public fun toBigInteger(): BigInteger = BigInteger(asString(), 16)
28+
public fun toBigInteger(): BigInteger = BigInteger(asString().ifEmpty { "00" }, 16)
2929

3030
public fun slice(indices: IntRange): HexString = HexString(value.slice(indices))
3131
public fun slice(startIndex: Int): HexString = HexString(value.substring(startIndex))

core/src/main/java/it/airgap/beaconsdk/core/internal/utils/Bytes.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import androidx.annotation.RestrictTo
44
import it.airgap.beaconsdk.core.internal.data.HexString
55
import java.math.BigInteger
66

7-
private val hexRegex: Regex = Regex("^(${HexString.PREFIX})?([0-9a-fA-F]{2})+$")
7+
private val hexRegex: Regex = Regex("^(${HexString.PREFIX})?([0-9a-fA-F]{2})*$")
88

99
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
1010
public fun String.isHex(): Boolean = this.matches(hexRegex)

core/src/test/java/it/airgap/beaconsdk/core/internal/data/HexStringTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ import kotlin.test.assertFailsWith
99

1010
internal class HexStringTest {
1111
private val validHexStrings: List<String> = listOf(
12+
"",
1213
"9434dc98",
1314
"0x7b1ea2cb",
1415
"e40476d7",
1516
"c47320abdd31",
1617
"0x5786dac9eaf4",
18+
"0x",
1719
)
1820

1921
private val invalidHexStrings: List<String> = listOf(
20-
"",
2122
"9434dc98az",
2223
"0xe40476d77t",
23-
"0x",
2424
"0x1",
2525
)
2626

@@ -122,7 +122,7 @@ internal class HexStringTest {
122122
@Test
123123
fun `creates BigInteger from HexString`() {
124124
val hexStringsWithExpected: List<Pair<String, BigInteger>> =
125-
validHexStrings.map { it to BigInteger(withoutHexPrefix(it), 16) }
125+
validHexStrings.map { it to BigInteger(withoutHexPrefix(it).ifEmpty { "00" }, 16) }
126126

127127
hexStringsWithExpected
128128
.map { it.first.asHexString().toBigInteger() to it.second }

core/src/test/java/it/airgap/beaconsdk/core/internal/utils/BytesTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import java.math.BigInteger
66

77
internal class BytesTest {
88
private val validHexStrings: List<String> = listOf(
9+
"",
910
"9434dc98",
1011
"0x7b1ea2cb",
1112
"e40476d7",
1213
"c47320abdd31",
1314
"0x5786dac9eaf4",
15+
"0x",
1416
)
1517

1618
private val invalidHexStrings: List<String> = listOf(
17-
"",
1819
"9434dc98az",
1920
"0xe40476d77t",
20-
"0x",
2121
"0x1",
2222
)
2323

demo/src/main/java/it/airgap/beaconsdkdemo/dapp/DAppFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import it.airgap.beaconsdk.core.message.BeaconResponse
1212
import it.airgap.beaconsdkdemo.R
1313
import it.airgap.beaconsdkdemo.utils.toJson
1414
import kotlinx.android.synthetic.main.fragment_dapp.*
15-
import kotlinx.coroutines.flow.collect
1615
import kotlinx.coroutines.launch
1716
import kotlinx.serialization.encodeToString
1817
import kotlinx.serialization.json.Json

demo/src/main/java/it/airgap/beaconsdkdemo/dapp/DAppFragmentViewModel.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ class DAppFragmentViewModel : ViewModel() {
4444
viewModelScope.launch {
4545
val beaconClient = beaconClient ?: return@launch
4646

47-
val pairingRequest = beaconClient.pair()
48-
val serializerPairingRequest = beaconClient.serializePairingData(pairingRequest)
49-
50-
_state.emit { copy(pairingRequest = serializerPairingRequest) }
47+
try {
48+
val pairingRequest = beaconClient.pair()
49+
val serializerPairingRequest = beaconClient.serializePairingData(pairingRequest)
50+
51+
_state.emit { copy(pairingRequest = serializerPairingRequest) }
52+
} catch (e: Throwable) {
53+
onError(e)
54+
}
5155
}
5256
}
5357

demo/src/main/java/it/airgap/beaconsdkdemo/wallet/WalletFragmentViewModel.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ class WalletFragmentViewModel : ViewModel() {
7676
/* Others */
7777
else -> ErrorBeaconResponse.from(request, BeaconError.Unknown)
7878
}
79-
beaconClient.respond(response)
80-
removeAwaitingRequest()
79+
80+
try {
81+
beaconClient.respond(response)
82+
removeAwaitingRequest()
83+
} catch (e: Throwable) {
84+
onError(e)
85+
}
8186
}
8287
}
8388

0 commit comments

Comments
 (0)