-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f46f8ec
commit dcc3b0d
Showing
12 changed files
with
64 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
.../usecase/provenance/account/GetAccount.kt → ...n/usecase/provenance/account/GetSigner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
package io.provenance.onboarding.domain.usecase.provenance.account | ||
|
||
import io.provenance.api.models.account.AccountInfo | ||
import io.provenance.core.KeyType | ||
import io.provenance.hdwallet.wallet.Account | ||
import io.provenance.client.grpc.Signer | ||
import io.provenance.onboarding.domain.usecase.AbstractUseCase | ||
import io.provenance.onboarding.domain.usecase.common.originator.GetOriginator | ||
import io.provenance.onboarding.frameworks.provenance.utility.ProvenanceUtils | ||
import org.springframework.stereotype.Component | ||
import java.lang.IllegalStateException | ||
import java.security.PrivateKey | ||
import java.security.PublicKey | ||
|
||
@Component | ||
class GetAccount( | ||
class GetSigner( | ||
private val getOriginator: GetOriginator | ||
) : AbstractUseCase<AccountInfo, Account>() { | ||
override suspend fun execute(args: AccountInfo): Account { | ||
) : AbstractUseCase<AccountInfo, Signer>() { | ||
override suspend fun execute(args: AccountInfo): Signer { | ||
val utils = ProvenanceUtils() | ||
|
||
val originator = getOriginator.execute(args.originatorUuid) | ||
|
||
return originator.keys[KeyType.MNEMONIC]?.let { mnemonic -> | ||
utils.getAccount(mnemonic.toString(), args.isTestNet, args.keyRingIndex, args.keyIndex) | ||
} ?: throw IllegalStateException("Account does not exist: ${args.originatorUuid}.") | ||
return originator.signingPublicKey().let { public -> | ||
originator.signingPrivateKey().let { private -> | ||
utils.getSigner(public as PublicKey, private as PrivateKey, !args.isTestNet) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters