From 22b108cb96f4dd0710616fa08cc1ca2d879dc61e Mon Sep 17 00:00:00 2001 From: Alexander Tarasenko Date: Thu, 9 Apr 2020 02:02:38 +0300 Subject: [PATCH 1/5] Support EIP-1191 --- .../main/kotlin/org/kethereum/erc55/ERC55.kt | 19 ++++++++++---- .../kotlin/org/kethereum/erc55/TheERC55.kt | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt b/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt index dd82c34f..b8a50281 100644 --- a/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt +++ b/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt @@ -2,14 +2,23 @@ package org.kethereum.erc55 import org.kethereum.keccakshortcut.keccak import org.kethereum.model.Address +import org.kethereum.model.ChainId import org.komputing.khex.extensions.toNoPrefixHexString import java.util.* /* ERC-55 Checksum as in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md +https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md */ -fun Address.withERC55Checksum() = cleanHex.toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> +private fun Address.cleanHexWithPrefix(chainId: ChainId?) = + if (chainId != null) { + "${chainId.value}0x${cleanHex}" + } else { + cleanHex + } + +fun Address.withERC55Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(chainId).toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> Address(cleanHex.mapIndexed { index, hexChar -> when { hexChar in '0'..'9' -> hexChar @@ -19,10 +28,10 @@ fun Address.withERC55Checksum() = cleanHex.toLowerCase(Locale.ROOT).toByteArray( }.joinToString("")) } -private fun Address.hasValidERC55ChecksumAssumingValidAddress() = withERC55Checksum().hex == hex +private fun Address.hasValidERC55ChecksumAssumingValidAddress(chainId: ChainId? = null) = withERC55Checksum(chainId).hex == hex -fun Address.hasValidERC55Checksum() = isValid() && hasValidERC55ChecksumAssumingValidAddress() -fun Address.hasValidERC55ChecksumOrNoChecksum() = isValid() && - (hasValidERC55ChecksumAssumingValidAddress() || +fun Address.hasValidERC55Checksum(chainId: ChainId? = null) = isValid() && hasValidERC55ChecksumAssumingValidAddress(chainId) +fun Address.hasValidERC55ChecksumOrNoChecksum(chainId: ChainId? = null) = isValid() && + (hasValidERC55ChecksumAssumingValidAddress(chainId) || cleanHex.toLowerCase() == cleanHex || cleanHex.toUpperCase() == cleanHex) diff --git a/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt b/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt index 19da8b4a..ac4b116c 100644 --- a/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt +++ b/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt @@ -3,9 +3,13 @@ package org.kethereum.erc55 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.kethereum.model.Address +import org.kethereum.model.ChainId class TheERC55 { + val rskMainnet = ChainId(30) + val rskTestnet = ChainId(31) + @Test fun returnsTrueForValidChecksum() { assertThat(Address("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed") @@ -54,5 +58,27 @@ class TheERC55 { } + @Test + fun returnsTrueForValidEIP1191(){ + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidERC55Checksum(null)).isTrue() + assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") + .hasValidERC55Checksum(rskMainnet)).isTrue() + assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") + .hasValidERC55Checksum(rskTestnet)).isTrue() + } + + @Test + fun returnsFalseForInvalidEIP1191(){ + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidERC55Checksum(rskTestnet)).isFalse() + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidERC55Checksum(rskMainnet)).isFalse() + assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") + .hasValidERC55Checksum(rskTestnet)).isFalse() + assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") + .hasValidERC55Checksum(rskMainnet)).isFalse() + } + } \ No newline at end of file From 933d719f5edbf6d0fabaaf01e1bc81a4d27726ae Mon Sep 17 00:00:00 2001 From: Alexander Tarasenko Date: Thu, 9 Apr 2020 02:53:49 +0300 Subject: [PATCH 2/5] Revert "Support EIP-1191" This reverts commit 22b108cb96f4dd0710616fa08cc1ca2d879dc61e. --- .../main/kotlin/org/kethereum/erc55/ERC55.kt | 19 ++++---------- .../kotlin/org/kethereum/erc55/TheERC55.kt | 26 ------------------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt b/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt index b8a50281..dd82c34f 100644 --- a/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt +++ b/erc55/src/main/kotlin/org/kethereum/erc55/ERC55.kt @@ -2,23 +2,14 @@ package org.kethereum.erc55 import org.kethereum.keccakshortcut.keccak import org.kethereum.model.Address -import org.kethereum.model.ChainId import org.komputing.khex.extensions.toNoPrefixHexString import java.util.* /* ERC-55 Checksum as in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md -https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md */ -private fun Address.cleanHexWithPrefix(chainId: ChainId?) = - if (chainId != null) { - "${chainId.value}0x${cleanHex}" - } else { - cleanHex - } - -fun Address.withERC55Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(chainId).toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> +fun Address.withERC55Checksum() = cleanHex.toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> Address(cleanHex.mapIndexed { index, hexChar -> when { hexChar in '0'..'9' -> hexChar @@ -28,10 +19,10 @@ fun Address.withERC55Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(cha }.joinToString("")) } -private fun Address.hasValidERC55ChecksumAssumingValidAddress(chainId: ChainId? = null) = withERC55Checksum(chainId).hex == hex +private fun Address.hasValidERC55ChecksumAssumingValidAddress() = withERC55Checksum().hex == hex -fun Address.hasValidERC55Checksum(chainId: ChainId? = null) = isValid() && hasValidERC55ChecksumAssumingValidAddress(chainId) -fun Address.hasValidERC55ChecksumOrNoChecksum(chainId: ChainId? = null) = isValid() && - (hasValidERC55ChecksumAssumingValidAddress(chainId) || +fun Address.hasValidERC55Checksum() = isValid() && hasValidERC55ChecksumAssumingValidAddress() +fun Address.hasValidERC55ChecksumOrNoChecksum() = isValid() && + (hasValidERC55ChecksumAssumingValidAddress() || cleanHex.toLowerCase() == cleanHex || cleanHex.toUpperCase() == cleanHex) diff --git a/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt b/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt index ac4b116c..19da8b4a 100644 --- a/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt +++ b/erc55/src/test/kotlin/org/kethereum/erc55/TheERC55.kt @@ -3,13 +3,9 @@ package org.kethereum.erc55 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.kethereum.model.Address -import org.kethereum.model.ChainId class TheERC55 { - val rskMainnet = ChainId(30) - val rskTestnet = ChainId(31) - @Test fun returnsTrueForValidChecksum() { assertThat(Address("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed") @@ -58,27 +54,5 @@ class TheERC55 { } - @Test - fun returnsTrueForValidEIP1191(){ - assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidERC55Checksum(null)).isTrue() - assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") - .hasValidERC55Checksum(rskMainnet)).isTrue() - assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") - .hasValidERC55Checksum(rskTestnet)).isTrue() - } - - @Test - fun returnsFalseForInvalidEIP1191(){ - assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidERC55Checksum(rskTestnet)).isFalse() - assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidERC55Checksum(rskMainnet)).isFalse() - assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") - .hasValidERC55Checksum(rskTestnet)).isFalse() - assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") - .hasValidERC55Checksum(rskMainnet)).isFalse() - } - } \ No newline at end of file From 2e6ac6e8df6922b911c2b9460218eb7c98e3dd2d Mon Sep 17 00:00:00 2001 From: Alexander Tarasenko Date: Thu, 9 Apr 2020 03:15:08 +0300 Subject: [PATCH 3/5] include EIP-1191 as a separate module --- eip1191/build.gradle.kts | 7 ++++ .../kotlin/org.kethereum.eip1191/EIP1191.kt | 38 +++++++++++++++++++ .../org/kethereum/eip1191/TheEIP1191.kt | 37 ++++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 83 insertions(+) create mode 100644 eip1191/build.gradle.kts create mode 100644 eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt create mode 100644 eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt diff --git a/eip1191/build.gradle.kts b/eip1191/build.gradle.kts new file mode 100644 index 00000000..2b86efc7 --- /dev/null +++ b/eip1191/build.gradle.kts @@ -0,0 +1,7 @@ +dependencies { + "implementation"(project(":model")) + "implementation"(project(":keccak_shortcut")) + "implementation"("com.github.komputing:khex:${Versions.khex}") + "implementation"(project(":erc55")) +} + diff --git a/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt b/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt new file mode 100644 index 00000000..821205cb --- /dev/null +++ b/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt @@ -0,0 +1,38 @@ +package org.kethereum.eip1191 + +import org.kethereum.erc55.isValid +import org.kethereum.keccakshortcut.keccak +import org.kethereum.model.Address +import org.kethereum.model.ChainId +import org.komputing.khex.extensions.toNoPrefixHexString +import java.util.* + +/* +EIP-1191 Checksum as in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md + */ + +private fun Address.cleanHexWithPrefix(chainId: ChainId?) = + if (chainId != null) { + "${chainId.value}0x${cleanHex}" + } else { + cleanHex + } + +fun Address.withEIP1191Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(chainId).toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> + Address(cleanHex.mapIndexed { index, hexChar -> + when { + hexChar in '0'..'9' -> hexChar + hexHash[index] in '0'..'7' -> hexChar.toLowerCase() + else -> hexChar.toUpperCase() + } + }.joinToString("")) +} + +private fun Address.hasValidEIP1191ChecksumAssumingValidAddress(chainId: ChainId? = null) = withEIP1191Checksum(chainId).hex == hex + +fun Address.hasValidEIP1191Checksum(chainId: ChainId? = null) = isValid() && hasValidEIP1191ChecksumAssumingValidAddress(chainId) +fun Address.hasValidEIP1191ChecksumOrNoChecksum(chainId: ChainId? = null) = isValid() && + (hasValidEIP1191ChecksumAssumingValidAddress(chainId) || + cleanHex.toLowerCase() == cleanHex || + cleanHex.toUpperCase() == cleanHex) + diff --git a/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt b/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt new file mode 100644 index 00000000..25b45d2a --- /dev/null +++ b/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt @@ -0,0 +1,37 @@ +package org.kethereum.eip1191 + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.kethereum.model.Address +import org.kethereum.model.ChainId + +class TheEIP1191 { + + val rskMainnet = ChainId(30) + val rskTestnet = ChainId(31) + + @Test + fun returnsTrueForValidEIP1191(){ + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidEIP1191Checksum(null)).isTrue() + assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") + .hasValidEIP1191Checksum(rskMainnet)).isTrue() + assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") + .hasValidEIP1191Checksum(rskTestnet)).isTrue() + } + + @Test + fun returnsFalseForInvalidEIP1191(){ + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidEIP1191Checksum(rskTestnet)).isFalse() + assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") + .hasValidEIP1191Checksum(rskMainnet)).isFalse() + assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") + .hasValidEIP1191Checksum(rskTestnet)).isFalse() + assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") + .hasValidEIP1191Checksum(rskMainnet)).isFalse() + } + + + +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index fd3aa212..e5e58070 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,3 +52,4 @@ include(":types") include(":uri_common") include(":userdoc") include(":wallet") +include(":eip1191") From ec4681e34d183b888884eed0392a40d70e8966d2 Mon Sep 17 00:00:00 2001 From: Alexander Tarasenko Date: Thu, 9 Apr 2020 03:27:10 +0300 Subject: [PATCH 4/5] make chainId parameter non-optional, code cleanup --- .../main/kotlin/org.kethereum.eip1191/EIP1191.kt | 15 ++++----------- .../kotlin/org/kethereum/eip1191/TheEIP1191.kt | 2 -- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt b/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt index 821205cb..8aa60f90 100644 --- a/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt +++ b/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt @@ -11,14 +11,7 @@ import java.util.* EIP-1191 Checksum as in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md */ -private fun Address.cleanHexWithPrefix(chainId: ChainId?) = - if (chainId != null) { - "${chainId.value}0x${cleanHex}" - } else { - cleanHex - } - -fun Address.withEIP1191Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(chainId).toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> +fun Address.withEIP1191Checksum(chainId: ChainId) = "${chainId.value}${hex}".toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> Address(cleanHex.mapIndexed { index, hexChar -> when { hexChar in '0'..'9' -> hexChar @@ -28,10 +21,10 @@ fun Address.withEIP1191Checksum(chainId: ChainId? = null) = cleanHexWithPrefix(c }.joinToString("")) } -private fun Address.hasValidEIP1191ChecksumAssumingValidAddress(chainId: ChainId? = null) = withEIP1191Checksum(chainId).hex == hex +private fun Address.hasValidEIP1191ChecksumAssumingValidAddress(chainId: ChainId) = withEIP1191Checksum(chainId).hex == hex -fun Address.hasValidEIP1191Checksum(chainId: ChainId? = null) = isValid() && hasValidEIP1191ChecksumAssumingValidAddress(chainId) -fun Address.hasValidEIP1191ChecksumOrNoChecksum(chainId: ChainId? = null) = isValid() && +fun Address.hasValidEIP1191Checksum(chainId: ChainId) = isValid() && hasValidEIP1191ChecksumAssumingValidAddress(chainId) +fun Address.hasValidEIP1191ChecksumOrNoChecksum(chainId: ChainId) = isValid() && (hasValidEIP1191ChecksumAssumingValidAddress(chainId) || cleanHex.toLowerCase() == cleanHex || cleanHex.toUpperCase() == cleanHex) diff --git a/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt b/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt index 25b45d2a..2c1a443d 100644 --- a/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt +++ b/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt @@ -12,8 +12,6 @@ class TheEIP1191 { @Test fun returnsTrueForValidEIP1191(){ - assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidEIP1191Checksum(null)).isTrue() assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") .hasValidEIP1191Checksum(rskMainnet)).isTrue() assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") From a30e143aa82b22f626279cb11695bc3e0c7d37c2 Mon Sep 17 00:00:00 2001 From: Alexander Tarasenko Date: Thu, 9 Apr 2020 04:06:58 +0300 Subject: [PATCH 5/5] rename to ERC1191 --- {eip1191 => erc1191}/build.gradle.kts | 0 .../kotlin/org/kethereum/erc1191/ERC1191.kt | 12 +++++------ .../org/kethereum/erc1191/TheERC1191.kt | 20 +++++++++---------- settings.gradle.kts | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) rename {eip1191 => erc1191}/build.gradle.kts (100%) rename eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt => erc1191/src/main/kotlin/org/kethereum/erc1191/ERC1191.kt (63%) rename eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt => erc1191/src/test/kotlin/org/kethereum/erc1191/TheERC1191.kt (57%) diff --git a/eip1191/build.gradle.kts b/erc1191/build.gradle.kts similarity index 100% rename from eip1191/build.gradle.kts rename to erc1191/build.gradle.kts diff --git a/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt b/erc1191/src/main/kotlin/org/kethereum/erc1191/ERC1191.kt similarity index 63% rename from eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt rename to erc1191/src/main/kotlin/org/kethereum/erc1191/ERC1191.kt index 8aa60f90..c7bbcb26 100644 --- a/eip1191/src/main/kotlin/org.kethereum.eip1191/EIP1191.kt +++ b/erc1191/src/main/kotlin/org/kethereum/erc1191/ERC1191.kt @@ -1,4 +1,4 @@ -package org.kethereum.eip1191 +package org.kethereum.erc1191 import org.kethereum.erc55.isValid import org.kethereum.keccakshortcut.keccak @@ -11,7 +11,7 @@ import java.util.* EIP-1191 Checksum as in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1191.md */ -fun Address.withEIP1191Checksum(chainId: ChainId) = "${chainId.value}${hex}".toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> +fun Address.withERC1191Checksum(chainId: ChainId) = "${chainId.value}${hex}".toLowerCase(Locale.ROOT).toByteArray().keccak().toNoPrefixHexString().let { hexHash -> Address(cleanHex.mapIndexed { index, hexChar -> when { hexChar in '0'..'9' -> hexChar @@ -21,11 +21,11 @@ fun Address.withEIP1191Checksum(chainId: ChainId) = "${chainId.value}${hex}".toL }.joinToString("")) } -private fun Address.hasValidEIP1191ChecksumAssumingValidAddress(chainId: ChainId) = withEIP1191Checksum(chainId).hex == hex +private fun Address.hasValidERC1191ChecksumAssumingValidAddress(chainId: ChainId) = withERC1191Checksum(chainId).hex == hex -fun Address.hasValidEIP1191Checksum(chainId: ChainId) = isValid() && hasValidEIP1191ChecksumAssumingValidAddress(chainId) -fun Address.hasValidEIP1191ChecksumOrNoChecksum(chainId: ChainId) = isValid() && - (hasValidEIP1191ChecksumAssumingValidAddress(chainId) || +fun Address.hasValidERC1191Checksum(chainId: ChainId) = isValid() && hasValidERC1191ChecksumAssumingValidAddress(chainId) +fun Address.hasValidERC1191ChecksumOrNoChecksum(chainId: ChainId) = isValid() && + (hasValidERC1191ChecksumAssumingValidAddress(chainId) || cleanHex.toLowerCase() == cleanHex || cleanHex.toUpperCase() == cleanHex) diff --git a/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt b/erc1191/src/test/kotlin/org/kethereum/erc1191/TheERC1191.kt similarity index 57% rename from eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt rename to erc1191/src/test/kotlin/org/kethereum/erc1191/TheERC1191.kt index 2c1a443d..5fe18420 100644 --- a/eip1191/src/test/kotlin/org/kethereum/eip1191/TheEIP1191.kt +++ b/erc1191/src/test/kotlin/org/kethereum/erc1191/TheERC1191.kt @@ -1,33 +1,33 @@ -package org.kethereum.eip1191 +package org.kethereum.erc1191 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.kethereum.model.Address import org.kethereum.model.ChainId -class TheEIP1191 { +class TheERC1191 { val rskMainnet = ChainId(30) val rskTestnet = ChainId(31) @Test - fun returnsTrueForValidEIP1191(){ + fun returnsTrueForValidERC1191(){ assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") - .hasValidEIP1191Checksum(rskMainnet)).isTrue() + .hasValidERC1191Checksum(rskMainnet)).isTrue() assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") - .hasValidEIP1191Checksum(rskTestnet)).isTrue() + .hasValidERC1191Checksum(rskTestnet)).isTrue() } @Test - fun returnsFalseForInvalidEIP1191(){ + fun returnsFalseForInvalidERC1191(){ assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidEIP1191Checksum(rskTestnet)).isFalse() + .hasValidERC1191Checksum(rskTestnet)).isFalse() assertThat(Address("0x27b1fdb04752bbc536007a920d24acb045561c26") - .hasValidEIP1191Checksum(rskMainnet)).isFalse() + .hasValidERC1191Checksum(rskMainnet)).isFalse() assertThat(Address("0x27b1FdB04752BBc536007A920D24ACB045561c26") - .hasValidEIP1191Checksum(rskTestnet)).isFalse() + .hasValidERC1191Checksum(rskTestnet)).isFalse() assertThat(Address("0x27B1FdB04752BbC536007a920D24acB045561C26") - .hasValidEIP1191Checksum(rskMainnet)).isFalse() + .hasValidERC1191Checksum(rskMainnet)).isFalse() } diff --git a/settings.gradle.kts b/settings.gradle.kts index e5e58070..84e1caed 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,4 +52,4 @@ include(":types") include(":uri_common") include(":userdoc") include(":wallet") -include(":eip1191") +include(":erc1191")