Skip to content

Commit

Permalink
Merge branch 'release/0.4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Mar 20, 2020
2 parents 70181df + 0db97d7 commit c52430d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 30 deletions.
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repositories {
dependencies {
//...
compile "com.github.uport-project:kmnid:0.4.1"
compile "com.github.uport-project:kmnid:0.4.3"
}
```
Expand Down Expand Up @@ -105,6 +105,8 @@ assertFalse( MNID.isMNID('QmXuNqXmrkxs4WhTDC2GCnXEep4LUD87bu97LQMn1rkxmQ') )

## Changelog

* 0.4.3
* bump dependencies (kotlin 1.3.70, kethereum 0.81.4) ( 19f867ed )
* 0.4.2
* bump kethereum to 0.76.2 ( c2c5b070 )
* 0.4.1
Expand Down
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
buildscript {
ext {
//general
kotlin_version = '1.3.50'
serialization_version = '0.12.0'
kotlin_version = '1.3.70'
serialization_version = '0.20.0'

junit_version = "4.12"
jacoco_version = "0.8.4"

//mnid module
kethereum_version = "0.76.2"
khash_version = "1.0.0-RC2"
khex_version = "1.0.0-RC3"
kethereum_version = "0.81.4"
khash_version = "1.0.0-RC5"
khex_version = "1.0.0-RC6"
kbase58_version = "0.1"

//testing
test_runner_version = "1.0.2"

current_release_version = "0.4.2"
current_release_version = "0.4.3"
}

repositories {
Expand All @@ -25,7 +26,7 @@ buildscript {

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.5.3'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
7 changes: 3 additions & 4 deletions mnid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"

implementation "com.github.komputing.kethereum:base58:$kethereum_version"
implementation "com.github.komputing.kethereum:hashes:$kethereum_version"
implementation "com.github.komputing:khash:$khash_version"
api "com.github.komputing.khex:extensions-jvm:$khex_version"
api "com.github.komputing:kbase58:$kbase58_version"
api "com.github.komputing:khash:$khash_version"
api "com.github.komputing.khex:extensions:$khex_version"

testImplementation "junit:junit:$junit_version"
}
3 changes: 2 additions & 1 deletion mnid/src/main/java/me/uport/mnid/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.uport.mnid

import org.komputing.khex.extensions.clean0xPrefix
import org.komputing.khex.extensions.toHexString
import org.komputing.khex.model.HexString

/**
* A class that encapsulates an ethereum address and the network it corresponds to
Expand All @@ -20,7 +21,7 @@ data class Account internal constructor(val network: String, val address: String
throw NullPointerException("can't create an Account object using null network or address")
}

var strippedAddress = address.clean0xPrefix()
var strippedAddress = HexString(address).clean0xPrefix().string
val numZeros = 40 - strippedAddress.length
if (numZeros > 0) {
strippedAddress = String.format("%0" + numZeros + "d", 0) + strippedAddress
Expand Down
3 changes: 2 additions & 1 deletion mnid/src/main/java/me/uport/mnid/HexFun.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package me.uport.mnid

import org.komputing.khex.extensions.clean0xPrefix
import org.komputing.khex.model.HexString

fun String.hexToByteArrayLenient(): ByteArray {
val cleanInput = this.clean0xPrefix()
val cleanInput = HexString(this).clean0xPrefix().string
val evenInput = if (cleanInput.length % 2 != 0) "0$cleanInput" else cleanInput

return ByteArray(evenInput.length / 2).apply {
Expand Down
14 changes: 3 additions & 11 deletions mnid/src/main/java/me/uport/mnid/MNID.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package me.uport.mnid

import kotlinx.io.ByteBuffer
import org.kethereum.encodings.decodeBase58
import org.kethereum.encodings.encodeToBase58String
import org.komputing.kbase58.decodeBase58
import org.komputing.kbase58.encodeToBase58String
import java.nio.ByteBuffer

/**
* Multi Network Identifier
Expand Down Expand Up @@ -38,14 +38,6 @@ object MNID {
private const val CHECKSUM_WIDTH = 4
private const val VERSION: Byte = 1

private fun ByteBuffer.get(out: ByteArray): Unit = this.get(out, 0, out.size)
private fun ByteBuffer.rewind() : ByteBuffer {
val backup = this.array()
return this.clear().put(backup).flip()
}
private fun ByteBuffer.Companion.wrap(input: ByteArray): ByteBuffer =
allocate(input.size).put(input).flip()

/**
* Decodes a MNID encoded address into an address and network.
*
Expand Down
9 changes: 5 additions & 4 deletions mnid/src/test/java/me/uport/mnid/Base58Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package me.uport.mnid
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test
import org.kethereum.encodings.decodeBase58
import org.kethereum.encodings.encodeToBase58String
import org.komputing.kbase58.decodeBase58
import org.komputing.kbase58.encodeToBase58String
import org.komputing.khex.extensions.hexToByteArray
import org.komputing.khex.model.HexString
import java.util.Random

class Base58Test {
Expand Down Expand Up @@ -155,7 +156,7 @@ class Base58Test {
fun checkDecodeToByteArray() {
validPairs.forEach {
val decoded = it.base58.decodeBase58()
val actual = it.hex.hexToByteArray()
val actual = HexString(it.hex).hexToByteArray()
assertArrayEquals("invalid pair at: ${it.hex}:${it.base58}", decoded, actual)
}
}
Expand All @@ -164,7 +165,7 @@ class Base58Test {
fun checkEncodeByteArray() {

validPairs.forEach {
val input = it.hex.hexToByteArray()
val input = HexString(it.hex).hexToByteArray()
val encoded = input.encodeToBase58String()
assertEquals("invalid pair at: ${it.hex}:${it.base58}", it.base58, encoded)
}
Expand Down

0 comments on commit c52430d

Please sign in to comment.