File tree Expand file tree Collapse file tree 10 files changed +37
-23
lines changed
blockchain-tezos/src/main/java/it/airgap/beaconsdk/blockchain/tezos/data/operation
main/java/it/airgap/beaconsdk/core/internal
test/java/it/airgap/beaconsdk/core/internal
demo/src/main/java/it/airgap/beaconsdkdemo Expand file tree Collapse file tree 10 files changed +37
-23
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ To add `Beacon Android SDK` into your project:
45
45
#### Groovy
46
46
``` groovy
47
47
dependencies {
48
- def beacon_version = "3.2.0 "
48
+ def beacon_version = "x.y.z "
49
49
50
50
// REQUIRED, core
51
51
implementation "com.github.airgap-it.beacon-android-sdk:core:$beacon_version"
@@ -76,7 +76,7 @@ To add `Beacon Android SDK` into your project:
76
76
#### Kotlin
77
77
``` kotlin
78
78
dependencies {
79
- val beaconVersion = " 3.2.0 "
79
+ val beaconVersion = " x.y.z "
80
80
81
81
// REQUIRED, core
82
82
implementation(" com.github.airgap-it.beacon-android-sdk:core:$beaconVersion " )
@@ -368,6 +368,12 @@ $ ./gradlew testMock{Release|Debug}UnitTest
368
368
---
369
369
## Related Projects
370
370
371
- [ Beacon SDK ] ( https://github.com/airgap-it/beacon-sdk ) - an SDK for web developers (dApp & wallet)
371
+ ### AirGap Projects
372
372
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
Original file line number Diff line number Diff line change @@ -104,15 +104,15 @@ public data class MichelinePrimitiveBytes(public val bytes: String) : MichelineM
104
104
105
105
override fun deserialize (decoder : Decoder ): MichelinePrimitiveBytes =
106
106
decoder.decodeStructure(descriptor) {
107
- val primitive = decodeStringElement(descriptor, 0 )
107
+ val primitive = HexString ( decodeStringElement(descriptor, 0 ) )
108
108
109
- return MichelinePrimitiveBytes (primitive)
109
+ return MichelinePrimitiveBytes (primitive.asString(withPrefix = false ) )
110
110
}
111
111
112
112
override fun serialize (encoder : Encoder , value : MichelinePrimitiveBytes ) {
113
113
encoder.encodeStructure(descriptor) {
114
114
with (value) {
115
- encodeStringElement(descriptor, 0 , HexString (bytes).asString(withPrefix = true ))
115
+ encodeStringElement(descriptor, 0 , HexString (bytes).asString(withPrefix = false ))
116
116
}
117
117
}
118
118
}
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ object Android {
3
3
const val minSdk = 21
4
4
const val targetSdk = 32
5
5
6
- const val versionCode = 25
7
- const val versionName = " 3.2.1 "
6
+ const val versionCode = 27
7
+ const val versionName = " 3.2.2 "
8
8
}
9
9
10
10
object Version {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public value class HexString(private val value: String) {
25
25
26
26
public fun toByteArray (): ByteArray = asString().chunked(2 ).map { it.toInt(16 ).toByte() }.toByteArray()
27
27
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 )
29
29
30
30
public fun slice (indices : IntRange ): HexString = HexString (value.slice(indices))
31
31
public fun slice (startIndex : Int ): HexString = HexString (value.substring(startIndex))
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import androidx.annotation.RestrictTo
4
4
import it.airgap.beaconsdk.core.internal.data.HexString
5
5
import java.math.BigInteger
6
6
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})* $" )
8
8
9
9
@RestrictTo(RestrictTo .Scope .LIBRARY_GROUP )
10
10
public fun String.isHex (): Boolean = this .matches(hexRegex)
Original file line number Diff line number Diff line change @@ -9,18 +9,18 @@ import kotlin.test.assertFailsWith
9
9
10
10
internal class HexStringTest {
11
11
private val validHexStrings: List <String > = listOf (
12
+ " " ,
12
13
" 9434dc98" ,
13
14
" 0x7b1ea2cb" ,
14
15
" e40476d7" ,
15
16
" c47320abdd31" ,
16
17
" 0x5786dac9eaf4" ,
18
+ " 0x" ,
17
19
)
18
20
19
21
private val invalidHexStrings: List <String > = listOf (
20
- " " ,
21
22
" 9434dc98az" ,
22
23
" 0xe40476d77t" ,
23
- " 0x" ,
24
24
" 0x1" ,
25
25
)
26
26
@@ -122,7 +122,7 @@ internal class HexStringTest {
122
122
@Test
123
123
fun `creates BigInteger from HexString` () {
124
124
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 ) }
126
126
127
127
hexStringsWithExpected
128
128
.map { it.first.asHexString().toBigInteger() to it.second }
Original file line number Diff line number Diff line change @@ -6,18 +6,18 @@ import java.math.BigInteger
6
6
7
7
internal class BytesTest {
8
8
private val validHexStrings: List <String > = listOf (
9
+ " " ,
9
10
" 9434dc98" ,
10
11
" 0x7b1ea2cb" ,
11
12
" e40476d7" ,
12
13
" c47320abdd31" ,
13
14
" 0x5786dac9eaf4" ,
15
+ " 0x" ,
14
16
)
15
17
16
18
private val invalidHexStrings: List <String > = listOf (
17
- " " ,
18
19
" 9434dc98az" ,
19
20
" 0xe40476d77t" ,
20
- " 0x" ,
21
21
" 0x1" ,
22
22
)
23
23
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import it.airgap.beaconsdk.core.message.BeaconResponse
12
12
import it.airgap.beaconsdkdemo.R
13
13
import it.airgap.beaconsdkdemo.utils.toJson
14
14
import kotlinx.android.synthetic.main.fragment_dapp.*
15
- import kotlinx.coroutines.flow.collect
16
15
import kotlinx.coroutines.launch
17
16
import kotlinx.serialization.encodeToString
18
17
import kotlinx.serialization.json.Json
Original file line number Diff line number Diff line change @@ -44,10 +44,14 @@ class DAppFragmentViewModel : ViewModel() {
44
44
viewModelScope.launch {
45
45
val beaconClient = beaconClient ? : return @launch
46
46
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
+ }
51
55
}
52
56
}
53
57
Original file line number Diff line number Diff line change @@ -76,8 +76,13 @@ class WalletFragmentViewModel : ViewModel() {
76
76
/* Others */
77
77
else -> ErrorBeaconResponse .from(request, BeaconError .Unknown )
78
78
}
79
- beaconClient.respond(response)
80
- removeAwaitingRequest()
79
+
80
+ try {
81
+ beaconClient.respond(response)
82
+ removeAwaitingRequest()
83
+ } catch (e: Throwable ) {
84
+ onError(e)
85
+ }
81
86
}
82
87
}
83
88
You can’t perform that action at this time.
0 commit comments