fix(wallet): fix cardano-client-lib API compatibility
- Rename getNetworks() to getNetwork() in CardanoNetworkConfig - Return Network type instead of Networks - Update all callers in CardanoKeyStorageImpl, CardanoWalletManager, DefaultTransactionBuilder
This commit is contained in:
parent
11ebaf5042
commit
31d4537a71
4 changed files with 8 additions and 8 deletions
|
|
@ -77,9 +77,9 @@ object CardanoNetworkConfig {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the Networks instance for cardano-client-lib.
|
||||
* Returns the Network instance for cardano-client-lib.
|
||||
*/
|
||||
fun getNetworks(): com.bloxbean.cardano.client.common.model.Networks = when (NETWORK) {
|
||||
fun getNetwork(): com.bloxbean.cardano.client.common.model.Network = when (NETWORK) {
|
||||
CardanoNetwork.TESTNET -> com.bloxbean.cardano.client.common.model.Networks.preprod()
|
||||
CardanoNetwork.MAINNET -> com.bloxbean.cardano.client.common.model.Networks.mainnet()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class DefaultCardanoWalletManager @Inject constructor(
|
|||
val mnemonicString = mnemonic.joinToString(" ")
|
||||
|
||||
// Create account and get private key bytes
|
||||
val account = Account(CardanoNetworkConfig.getNetworks(), mnemonicString, addressIndex)
|
||||
val account = Account(CardanoNetworkConfig.getNetwork(), mnemonicString, addressIndex)
|
||||
val privateKeyBytes = account.privateKeyBytes()
|
||||
|
||||
// Clear mnemonic string reference (best effort - JVM strings are immutable)
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class DefaultTransactionBuilder @Inject constructor(
|
|||
mnemonic: String,
|
||||
): SignedTransaction {
|
||||
// Create Account from mnemonic (handles CIP-1852 derivation internally)
|
||||
val account = Account(CardanoNetworkConfig.getNetworks(), mnemonic)
|
||||
val account = Account(CardanoNetworkConfig.getNetwork(), mnemonic)
|
||||
|
||||
// Build transaction using QuickTx (high-level API)
|
||||
val tx = Tx()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class CardanoKeyStorageImpl @Inject constructor(
|
|||
|
||||
// Derive addresses
|
||||
val mnemonicString = wordList.joinToString(" ")
|
||||
val account = Account(CardanoNetworkConfig.getNetworks(), mnemonicString)
|
||||
val account = Account(CardanoNetworkConfig.getNetwork(), mnemonicString)
|
||||
|
||||
val result = WalletCreationResult(
|
||||
mnemonic = wordList,
|
||||
|
|
@ -141,7 +141,7 @@ class CardanoKeyStorageImpl @Inject constructor(
|
|||
// Verify it produces valid Cardano addresses
|
||||
val mnemonicString = mnemonic.joinToString(" ")
|
||||
val account = try {
|
||||
Account(CardanoNetworkConfig.getNetworks(), mnemonicString)
|
||||
Account(CardanoNetworkConfig.getNetwork(), mnemonicString)
|
||||
} catch (e: Exception) {
|
||||
throw IllegalArgumentException("Failed to derive Cardano keys: ${e.message}")
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ class CardanoKeyStorageImpl @Inject constructor(
|
|||
runCatching {
|
||||
val mnemonic = retrieveMnemonic(sessionId)
|
||||
val mnemonicString = mnemonic.joinToString(" ")
|
||||
val account = Account(CardanoNetworkConfig.getNetworks(), mnemonicString, addressIndex)
|
||||
val account = Account(CardanoNetworkConfig.getNetwork(), mnemonicString, addressIndex)
|
||||
account.baseAddress()
|
||||
}
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ class CardanoKeyStorageImpl @Inject constructor(
|
|||
runCatching {
|
||||
val mnemonic = retrieveMnemonic(sessionId)
|
||||
val mnemonicString = mnemonic.joinToString(" ")
|
||||
val account = Account(CardanoNetworkConfig.getNetworks(), mnemonicString)
|
||||
val account = Account(CardanoNetworkConfig.getNetwork(), mnemonicString)
|
||||
account.stakeAddress()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue