From 64ce7abebb6adf1e7cba431b3d4b8ce1f50a30b9 Mon Sep 17 00:00:00 2001 From: Ali Abdulmadzhidov Date: Mon, 16 Oct 2023 20:52:13 +0300 Subject: [PATCH 1/2] fix account generation error --- build.gradle | 4 ++-- .../data/repository/CredentialsRepositoryImpl.kt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 9b669ed92..f02dcd746 100644 --- a/build.gradle +++ b/build.gradle @@ -50,8 +50,8 @@ buildscript { xserializationjson : '1.5.1', ktor : '2.3.1', xbackup : '1.0.0', - xcrypto : '1.0.2', - xsubstrate : '1.0.1' + xcrypto : '1.0.3', + xsubstrate : '1.0.2' ] ext { diff --git a/feature_account_impl/src/main/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryImpl.kt b/feature_account_impl/src/main/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryImpl.kt index e81b51228..e7108fbd2 100644 --- a/feature_account_impl/src/main/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryImpl.kt +++ b/feature_account_impl/src/main/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryImpl.kt @@ -48,6 +48,7 @@ import jp.co.soramitsu.feature_account_api.domain.interfaces.CredentialsReposito import jp.co.soramitsu.feature_blockexplorer_api.data.SoraConfigManager import jp.co.soramitsu.sora.substrate.runtime.RuntimeManager import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider +import jp.co.soramitsu.sora.substrate.substrate.deriveSeed32 import jp.co.soramitsu.xcrypto.util.fromHex import jp.co.soramitsu.xcrypto.util.toHexString import jp.co.soramitsu.xsubstrate.encrypt.keypair.substrate.Sr25519Keypair @@ -81,7 +82,7 @@ class CredentialsRepositoryImpl constructor( } private suspend fun generateEntropyAndKeysFromMnemonic(mnemonic: Mnemonic): String { - val derivationResult = SubstrateSeedFactory.deriveSeed(mnemonic.words, null) + val derivationResult = SubstrateSeedFactory.deriveSeed32(mnemonic.words, null) val keyPair = SubstrateKeypairFactory.generate( SubstrateOptionsProvider.encryptionType, derivationResult.seed, From 5bc154c38f54e022693ea88a4a41bd888204afcb Mon Sep 17 00:00:00 2001 From: Ali Abdulmadzhidov Date: Mon, 16 Oct 2023 23:29:22 +0300 Subject: [PATCH 2/2] fix test --- .../data/repository/CredentialsRepositoryTest.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/feature_account_impl/src/test/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryTest.kt b/feature_account_impl/src/test/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryTest.kt index 509f9d792..8629dc028 100644 --- a/feature_account_impl/src/test/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryTest.kt +++ b/feature_account_impl/src/test/java/jp/co/soramitsu/feature_account_impl/data/repository/CredentialsRepositoryTest.kt @@ -106,7 +106,12 @@ class CredentialsRepositoryTest { every { SubstrateKeypairFactory.generate(any(), any()) } returns keypair every { SubstrateKeypairFactory.generate(any(), any(), any()) } returns keypair every { FirebaseWrapper.log("Keys were created") } just runs - every { derivationResult.seed } returns "seed".toByteArray() + every { derivationResult.seed } returns "seedseedseedseedseedseedseedseedseedseedseedseedseedseed".toByteArray() + every { derivationResult.mnemonic } returns Mnemonic( + "", + emptyList(), + ByteArray(1) { 1 }) + credentialsRepository = CredentialsRepositoryImpl( datasource, cryptoAssistant,