mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2025-01-12 16:09:40 -05:00
lib: change primary address type to PublicAddress
This commit is contained in:
parent
894788f3b2
commit
f5998ac369
@ -41,7 +41,9 @@ class WalletRepository(
|
|||||||
},
|
},
|
||||||
httpClient = httpClient,
|
httpClient = httpClient,
|
||||||
)
|
)
|
||||||
check(config.publicAddress == wallet.primaryAddress) { "primary address mismatch" }
|
check(config.publicAddress == wallet.primaryAddress.address) {
|
||||||
|
"primary address mismatch"
|
||||||
|
}
|
||||||
wallet
|
wallet
|
||||||
}
|
}
|
||||||
}.await()
|
}.await()
|
||||||
@ -69,7 +71,7 @@ class WalletRepository(
|
|||||||
val uniqueFilename = UUID.randomUUID().toString()
|
val uniqueFilename = UUID.randomUUID().toString()
|
||||||
val wallet = moneroSdkClient.createWallet(moneroNetwork, uniqueFilename)
|
val wallet = moneroSdkClient.createWallet(moneroNetwork, uniqueFilename)
|
||||||
val walletId = walletDataSource.createWalletConfig(
|
val walletId = walletDataSource.createWalletConfig(
|
||||||
publicAddress = wallet.primaryAddress,
|
publicAddress = wallet.primaryAddress.address,
|
||||||
filename = uniqueFilename,
|
filename = uniqueFilename,
|
||||||
name = name,
|
name = name,
|
||||||
remoteNodeIds = remoteNodeIds,
|
remoteNodeIds = remoteNodeIds,
|
||||||
@ -92,7 +94,7 @@ class WalletRepository(
|
|||||||
restorePoint,
|
restorePoint,
|
||||||
)
|
)
|
||||||
val walletId = walletDataSource.createWalletConfig(
|
val walletId = walletDataSource.createWalletConfig(
|
||||||
publicAddress = wallet.primaryAddress,
|
publicAddress = wallet.primaryAddress.address,
|
||||||
filename = uniqueFilename,
|
filename = uniqueFilename,
|
||||||
name = name,
|
name = name,
|
||||||
remoteNodeIds = remoteNodeIds,
|
remoteNodeIds = remoteNodeIds,
|
||||||
|
@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -56,10 +57,22 @@ fun WalletCardExpanded(
|
|||||||
uiState: WalletUiState.Loaded,
|
uiState: WalletUiState.Loaded,
|
||||||
) {
|
) {
|
||||||
Row {
|
Row {
|
||||||
Text(text = "Wallet ID #${uiState.config.id} (${uiState.config.name}) ${uiState.config.publicAddress}")
|
Text(
|
||||||
|
text = "Wallet ID #${uiState.config.id} (${uiState.config.name}) ${uiState.network.name}",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
Text(text = uiState.blockchainTime.toString())
|
Text(
|
||||||
|
text = uiState.config.publicAddress,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
Text(
|
||||||
|
text = uiState.blockchainTime.toString(),
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import im.molly.monero.Ledger
|
import im.molly.monero.Ledger
|
||||||
import im.molly.monero.MoneroCurrency
|
import im.molly.monero.MoneroCurrency
|
||||||
|
import im.molly.monero.PublicAddress
|
||||||
import im.molly.monero.demo.data.model.WalletConfig
|
import im.molly.monero.demo.data.model.WalletConfig
|
||||||
import im.molly.monero.demo.ui.component.Toolbar
|
import im.molly.monero.demo.ui.component.Toolbar
|
||||||
import im.molly.monero.demo.ui.preview.PreviewParameterData
|
import im.molly.monero.demo.ui.preview.PreviewParameterData
|
||||||
@ -240,11 +241,12 @@ private fun WalletScreenPopulated(
|
|||||||
uiState = WalletUiState.Loaded(
|
uiState = WalletUiState.Loaded(
|
||||||
config = WalletConfig(
|
config = WalletConfig(
|
||||||
id = 0,
|
id = 0,
|
||||||
publicAddress = ledger.primaryAddress,
|
publicAddress = ledger.primaryAddress.address,
|
||||||
filename = "",
|
filename = "",
|
||||||
name = "Personal",
|
name = "Personal",
|
||||||
remoteNodes = emptySet(),
|
remoteNodes = emptySet(),
|
||||||
),
|
),
|
||||||
|
network = ledger.primaryAddress.network,
|
||||||
balance = ledger.balance,
|
balance = ledger.balance,
|
||||||
blockchainTime = ledger.checkedAt,
|
blockchainTime = ledger.checkedAt,
|
||||||
transactions = emptyList(),
|
transactions = emptyList(),
|
||||||
|
@ -6,6 +6,7 @@ import androidx.lifecycle.viewmodel.initializer
|
|||||||
import androidx.lifecycle.viewmodel.viewModelFactory
|
import androidx.lifecycle.viewmodel.viewModelFactory
|
||||||
import im.molly.monero.Balance
|
import im.molly.monero.Balance
|
||||||
import im.molly.monero.BlockchainTime
|
import im.molly.monero.BlockchainTime
|
||||||
|
import im.molly.monero.MoneroNetwork
|
||||||
import im.molly.monero.demo.AppModule
|
import im.molly.monero.demo.AppModule
|
||||||
import im.molly.monero.demo.common.Result
|
import im.molly.monero.demo.common.Result
|
||||||
import im.molly.monero.demo.common.asResult
|
import im.molly.monero.demo.common.asResult
|
||||||
@ -65,7 +66,8 @@ private fun walletUiState(
|
|||||||
ledger.transactions
|
ledger.transactions
|
||||||
.map { WalletTransaction(config.id, it.value) }
|
.map { WalletTransaction(config.id, it.value) }
|
||||||
.sortedByDescending { it.transaction.timestamp }
|
.sortedByDescending { it.transaction.timestamp }
|
||||||
WalletUiState.Loaded(config, blockchainTime, balance, transactions)
|
val network = ledger.primaryAddress.network
|
||||||
|
WalletUiState.Loaded(config, network, blockchainTime, balance, transactions)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
@ -82,6 +84,7 @@ private fun walletUiState(
|
|||||||
sealed interface WalletUiState {
|
sealed interface WalletUiState {
|
||||||
data class Loaded(
|
data class Loaded(
|
||||||
val config: WalletConfig,
|
val config: WalletConfig,
|
||||||
|
val network: MoneroNetwork,
|
||||||
val blockchainTime: BlockchainTime,
|
val blockchainTime: BlockchainTime,
|
||||||
val balance: Balance,
|
val balance: Balance,
|
||||||
val transactions: List<WalletTransaction>,
|
val transactions: List<WalletTransaction>,
|
||||||
|
@ -29,7 +29,7 @@ object PreviewParameterData {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val ledger = Ledger(
|
val ledger = Ledger(
|
||||||
primaryAddress = "4AYjQM9HoAFNUeC3cvSfgeAN89oMMpMqiByvunzSzhn97cj726rJj3x8hCbH58UnMqQJShczCxbpWRiCJQ3HCUDHLiKuo4T",
|
primaryAddress = PublicAddress.parse("4AYjQM9HoAFNUeC3cvSfgeAN89oMMpMqiByvunzSzhn97cj726rJj3x8hCbH58UnMqQJShczCxbpWRiCJQ3HCUDHLiKuo4T"),
|
||||||
checkedAt = BlockchainTime.Block(2999840),
|
checkedAt = BlockchainTime.Block(2999840),
|
||||||
enotes = emptySet(),
|
enotes = emptySet(),
|
||||||
transactions = transactions.associateBy { it.txId },
|
transactions = transactions.associateBy { it.txId },
|
||||||
|
@ -3,7 +3,7 @@ package im.molly.monero
|
|||||||
//import im.molly.monero.proto.LedgerProto
|
//import im.molly.monero.proto.LedgerProto
|
||||||
|
|
||||||
data class Ledger(
|
data class Ledger(
|
||||||
val primaryAddress: String,
|
val primaryAddress: PublicAddress,
|
||||||
val transactions: Map<String, Transaction>,
|
val transactions: Map<String, Transaction>,
|
||||||
val enotes: Set<TimeLocked<Enote>>,
|
val enotes: Set<TimeLocked<Enote>>,
|
||||||
val checkedAt: BlockchainTime,
|
val checkedAt: BlockchainTime,
|
||||||
|
@ -18,7 +18,7 @@ class MoneroWallet internal constructor(
|
|||||||
|
|
||||||
private val logger = loggerFor<MoneroWallet>()
|
private val logger = loggerFor<MoneroWallet>()
|
||||||
|
|
||||||
val primaryAddress: String = wallet.accountPrimaryAddress
|
val primaryAddress: PublicAddress = PublicAddress.parse(wallet.accountPrimaryAddress)
|
||||||
|
|
||||||
var dataStore by storageAdapter::dataStore
|
var dataStore by storageAdapter::dataStore
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user