diff --git a/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/util/DAOJoinHelper.kt b/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/util/DAOJoinHelper.kt index ee54cd27a..ac482a6f0 100644 --- a/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/util/DAOJoinHelper.kt +++ b/currencyii/src/main/java/nl/tudelft/trustchain/currencyii/util/DAOJoinHelper.kt @@ -34,7 +34,7 @@ class DAOJoinHelper { * 2.1 Send a proposal on the trust chain to join a shared wallet and to collect signatures. * The proposal is a serialized bitcoin join transaction. * **NOTE** the latest walletBlockData should be given, otherwise the serialized transaction is invalid. - * @param mostRecentWalletBlock - the latest (that you know of) sharedwallet block. + * @param mostRecentWalletBlock - the latest (that you know of) shared wallet block. */ fun proposeJoinWallet( myPeer: Peer, @@ -91,7 +91,7 @@ class DAOJoinHelper { * Create a bitcoin transaction that creates a new shared wallet. This takes some time to complete. * * NOTE: - * - the latest walletBlockData should be given, otherwise the serialized transaction is invalid. + * - the latest walletBlockData should be given, otherwise the serialized transaction is invalid. * - It takes some time before the shared wallet is accepted on the bitcoin blockchain. * @param sharedWalletData data of the shared wallet that you want to join. */ diff --git a/musicdao-datafeeder/libs/jlibtorrent-1.2.15.2.jar b/musicdao-datafeeder/libs/jlibtorrent-1.2.15.2.jar deleted file mode 100644 index 57e6352f6..000000000 Binary files a/musicdao-datafeeder/libs/jlibtorrent-1.2.15.2.jar and /dev/null differ diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/ReleaseBlockGossiper.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/ReleaseBlockGossiper.kt index e28368e4a..c4ffc5542 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/ReleaseBlockGossiper.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/ReleaseBlockGossiper.kt @@ -1,7 +1,7 @@ package nl.tudelft.trustchain.musicdao.core.ipv8 import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlock -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish.ReleasePublishBlockValidator +import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlockValidator import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.isActive @@ -11,7 +11,7 @@ import javax.inject.Inject class ReleaseBlockGossiper @Inject constructor( private val musicCommunity: MusicCommunity, - private val releasePublishBlockSigner: ReleasePublishBlockValidator, + private val releasePublishBlockSigner: ReleasePublishBlockValidator ) { fun startGossip(coroutineScope: CoroutineScope) { diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/SetupMusicCommunity.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/SetupMusicCommunity.kt index 9480e71ab..68772218e 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/SetupMusicCommunity.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/SetupMusicCommunity.kt @@ -1,13 +1,13 @@ package nl.tudelft.trustchain.musicdao.core.ipv8 -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish.ReleasePublishBlockSigner -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish.ReleasePublishBlockValidator +import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlockSigner +import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlockValidator import javax.inject.Inject class SetupMusicCommunity @Inject constructor( private val musicCommunity: MusicCommunity, private val releasePublishBlockSigner: ReleasePublishBlockSigner, - private val releasePublishBlockValidator: ReleasePublishBlockValidator, + private val releasePublishBlockValidator: ReleasePublishBlockValidator ) { fun registerListeners() { diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockRepository.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockRepository.kt similarity index 92% rename from musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockRepository.kt rename to musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockRepository.kt index b73efba96..56278f23c 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockRepository.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockRepository.kt @@ -1,16 +1,15 @@ -package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish +package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.Constants import nl.tudelft.ipv8.android.IPv8Android import nl.tudelft.ipv8.attestation.trustchain.TrustChainBlock import nl.tudelft.ipv8.util.toHex -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlock import javax.inject.Inject class ReleasePublishBlockRepository @Inject constructor( private val musicCommunity: MusicCommunity, - private val releasePublishBlockValidator: ReleasePublishBlockValidator, + private val releasePublishBlockValidator: ReleasePublishBlockValidator ) { fun getValidBlocks(): List { @@ -24,7 +23,7 @@ class ReleasePublishBlockRepository @Inject constructor( magnet: String, title: String, artist: String, - releaseDate: String, + releaseDate: String ): TrustChainBlock? { val myPeer = IPv8Android.getInstance().myPeer val transaction = mutableMapOf( diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockSigner.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockSigner.kt similarity index 77% rename from musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockSigner.kt rename to musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockSigner.kt index 0c399ab7e..4e5143225 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockSigner.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockSigner.kt @@ -1,9 +1,8 @@ -package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish +package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity import nl.tudelft.ipv8.attestation.trustchain.BlockSigner import nl.tudelft.ipv8.attestation.trustchain.TrustChainBlock -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlock import javax.inject.Inject class ReleasePublishBlockSigner @Inject constructor(val musicCommunity: MusicCommunity) : diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockValidator.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockValidator.kt similarity index 88% rename from musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockValidator.kt rename to musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockValidator.kt index 955d8aa20..f14bf0cff 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/release_publish/ReleasePublishBlockValidator.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/ipv8/blocks/releasePublish/ReleasePublishBlockValidator.kt @@ -1,4 +1,4 @@ -package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish +package nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish import nl.tudelft.trustchain.musicdao.core.ipv8.MusicCommunity import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.Constants @@ -7,7 +7,6 @@ import nl.tudelft.ipv8.attestation.trustchain.TrustChainTransaction import nl.tudelft.ipv8.attestation.trustchain.store.TrustChainStore import nl.tudelft.ipv8.attestation.trustchain.validation.TransactionValidator import nl.tudelft.ipv8.attestation.trustchain.validation.ValidationResult -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlock import javax.inject.Inject class ReleasePublishBlockValidator @Inject constructor(val musicCommunity: MusicCommunity) : @@ -34,8 +33,6 @@ class ReleasePublishBlockValidator @Inject constructor(val musicCommunity: Music val releaseDate = transaction["releaseDate"] val protocolVersion = transaction["protocolVersion"] -// Log.d("MusicDao", "Validating: $protocolVersion === ${Constants.PROTOCOL_VERSION} = ${protocolVersion == Constants.PROTOCOL_VERSION}") - return ( releaseId is String && releaseId.isNotEmpty() && transaction.containsKey("releaseId") && magnet is String && magnet.isNotEmpty() && transaction.containsKey("magnet") && diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/repositories/AlbumRepository.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/repositories/AlbumRepository.kt index 35537df5a..61517de47 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/repositories/AlbumRepository.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/core/repositories/AlbumRepository.kt @@ -7,7 +7,7 @@ import androidx.lifecycle.map import nl.tudelft.trustchain.musicdao.core.cache.CacheDatabase import nl.tudelft.trustchain.musicdao.core.cache.entities.AlbumEntity import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlock -import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.release_publish.ReleasePublishBlockRepository +import nl.tudelft.trustchain.musicdao.core.ipv8.blocks.releasePublish.ReleasePublishBlockRepository import nl.tudelft.trustchain.musicdao.core.repositories.model.Album import nl.tudelft.trustchain.musicdao.core.torrent.TorrentEngine import javax.inject.Inject diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/MusicDAOApp.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/MusicDAOApp.kt index 8e4bd9547..a7d464872 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/MusicDAOApp.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/MusicDAOApp.kt @@ -11,8 +11,6 @@ import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayArrow import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi @@ -42,11 +40,6 @@ fun MusicDAOApp() { val context = LocalContext.current - val openCreateReleaseDialog = remember { mutableStateOf(false) } - val closeDialog = { - openCreateReleaseDialog.value = false - } - val playerViewModel: PlayerViewModel = viewModel(factory = PlayerViewModel.provideFactory(context = context)) val ownProfileViewScreenModel: MyProfileScreenViewModel = hiltViewModel() diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/navigation/AppNavigation.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/navigation/AppNavigation.kt index 6a936dfc5..3fcbebdfd 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/navigation/AppNavigation.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/navigation/AppNavigation.kt @@ -13,7 +13,6 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController import androidx.navigation.NavType @@ -25,7 +24,6 @@ import nl.tudelft.trustchain.musicdao.ui.screens.artists.DiscoverArtistsScreen import nl.tudelft.trustchain.musicdao.ui.screens.debug.Debug import nl.tudelft.trustchain.musicdao.ui.screens.donate.DonateScreen import nl.tudelft.trustchain.musicdao.ui.screens.home.HomeScreen -import nl.tudelft.trustchain.musicdao.ui.screens.home.HomeScreenViewModel import nl.tudelft.trustchain.musicdao.ui.screens.release.create.CreateReleaseDialog import nl.tudelft.trustchain.musicdao.ui.screens.release.ReleaseScreen import nl.tudelft.trustchain.musicdao.ui.screens.search.SearchScreen @@ -67,11 +65,9 @@ fun AppNavigation( startDestination = Screen.Home.route, builder = { composable(Screen.Home.route) { - val homeScreenViewModel: HomeScreenViewModel = hiltViewModel() val searchScreenViewModel: SearchScreenViewModel = hiltViewModel() HomeScreen( navController = navController, - homeScreenViewModel = homeScreenViewModel, screenViewModel = searchScreenViewModel ) } diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/dao/DaoViewModel.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/dao/DaoViewModel.kt index 8b8bb463a..3a9d052ba 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/dao/DaoViewModel.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/dao/DaoViewModel.kt @@ -23,7 +23,6 @@ import nl.tudelft.ipv8.attestation.trustchain.TrustChainCommunity import nl.tudelft.ipv8.util.hexToBytes import nl.tudelft.ipv8.util.toHex import nl.tudelft.trustchain.currencyii.CoinCommunity -import nl.tudelft.trustchain.currencyii.CoinCommunity.Companion.SIGNATURE_AGREEMENT_BLOCK import nl.tudelft.trustchain.currencyii.TrustChainHelper import nl.tudelft.trustchain.currencyii.coin.WalletManager import nl.tudelft.trustchain.currencyii.coin.WalletManagerAndroid @@ -74,23 +73,6 @@ class DaoViewModel @Inject constructor(val artistRepository: ArtistRepository) : } } - /** - * Fetch all DAO blocks that contain a signature. These blocks are the response of a signature request. - * Signatures are fetched from [SIGNATURE_AGREEMENT_BLOCK] type blocks. - */ - fun fetchProposalResponses( - walletId: String, - proposalId: String - ): List { - return getTrustChainCommunity().database.getBlocksWithType(SIGNATURE_AGREEMENT_BLOCK) - .filter { - val blockData = SWResponseSignatureTransactionData(it.transaction) - blockData.matchesProposal(walletId, proposalId) - }.map { - SWResponseSignatureTransactionData(it.transaction).getData() - } - } - /** * Refresh the state of the DAOs/proposals */ @@ -268,7 +250,7 @@ class DaoViewModel @Inject constructor(val artistRepository: ArtistRepository) : // TODO: Commented this line out, it causes the app to crash // withTimeout(SW_CRAWLING_TIMEOUT_MILLI) { trustchain.crawlChain(peer) - val crawlResult = trustchain + trustchain .getChainByUser(peer.publicKey.keyToBin()) } catch (t: Throwable) { val message = t.message ?: "No further information" @@ -306,9 +288,9 @@ class DaoViewModel @Inject constructor(val artistRepository: ArtistRepository) : var signatures: List? = null while (signatures == null) { Thread.sleep(1000) - val oldSignatureCounbt = signatures?.size ?: 0 + val oldSignatureCount = signatures?.size ?: 0 signatures = collectJoinWalletResponses(proposeBlockData) - if (signatures != null && signatures.size != oldSignatureCounbt) { + if (signatures != null && signatures.size != oldSignatureCount) { SnackbarHandler.displaySnackbar( "Received a new signature: ${signatures.size}/${ requiredSignatures( diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/home/HomeScreen.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/home/HomeScreen.kt index 4f23c8cab..a1ab001ce 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/home/HomeScreen.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/home/HomeScreen.kt @@ -28,7 +28,6 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState @Composable fun HomeScreen( navController: NavHostController, - homeScreenViewModel: HomeScreenViewModel, screenViewModel: SearchScreenViewModel ) { val isRefreshing by screenViewModel.isRefreshing.observeAsState(false) diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/profile/EditProfileScreen.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/profile/EditProfileScreen.kt index 7fb46f73f..b59d043ee 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/profile/EditProfileScreen.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/profile/EditProfileScreen.kt @@ -11,7 +11,6 @@ import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.runtime.* import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -22,7 +21,6 @@ import kotlinx.coroutines.launch @RequiresApi(Build.VERSION_CODES.O) @Composable fun EditProfileScreen(navController: NavController) { - val ownProfileViewScreenModel: MyProfileScreenViewModel = hiltViewModel() val profile = ownProfileViewScreenModel.profile.collectAsState() @@ -30,8 +28,6 @@ fun EditProfileScreen(navController: NavController) { val bitcoinPublicKey = remember { mutableStateOf(profile.value?.bitcoinAddress) } val biography = remember { mutableStateOf(profile.value?.biography) } val socials = remember { mutableStateOf(profile.value?.socials) } - - val context = LocalContext.current val coroutine = rememberCoroutineScope() fun save() { diff --git a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/release/ReleaseScreen.kt b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/release/ReleaseScreen.kt index 05cba085a..fbb3c3bd4 100644 --- a/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/release/ReleaseScreen.kt +++ b/musicdao/src/main/java/nl/tudelft/trustchain/musicdao/ui/screens/release/ReleaseScreen.kt @@ -51,7 +51,6 @@ fun ReleaseScreen( playerViewModel: PlayerViewModel, navController: NavController ) { - var state by remember { mutableStateOf(0) } val titles = listOf("RELEASE", "TORRENT") @@ -65,7 +64,7 @@ fun ReleaseScreen( ) val torrentStatus by viewModel.torrentState.collectAsState() - val album by viewModel.saturatedReleaseState.observeAsState() + val albumState by viewModel.saturatedReleaseState.observeAsState() val playingTrack = playerViewModel.playingTrack.collectAsState() @@ -81,15 +80,16 @@ fun ReleaseScreen( Song( file = track.file, artist = track.artist, - title = track.title, + title = track.title ), - context, cover + context, + cover ) } val scrollState = rememberScrollState() - album?.let { album -> + albumState?.let { album -> LaunchedEffect( key1 = playerViewModel, block = { @@ -144,7 +144,6 @@ fun ReleaseScreen( if (album.songs != null && album.songs.isNotEmpty()) { val files = album.songs files.map { - val isPlayingModifier = playingTrack.value?.let { current -> if (it.title == current.title) { MaterialTheme.colors.primary @@ -263,7 +262,7 @@ fun Header(album: Album, navController: NavController) { IconButton(onClick = { /*TODO*/ }) { Icon( imageVector = Icons.Outlined.Favorite, - contentDescription = null, + contentDescription = null ) } IconButton( @@ -275,7 +274,7 @@ fun Header(album: Album, navController: NavController) { ) { Icon( imageVector = Icons.Outlined.Person, - contentDescription = null, + contentDescription = null ) } IconButton( @@ -287,7 +286,7 @@ fun Header(album: Album, navController: NavController) { ) { Icon( imageVector = Icons.Default.ShoppingCart, - contentDescription = null, + contentDescription = null ) } @@ -296,7 +295,7 @@ fun Header(album: Album, navController: NavController) { IconButton(onClick = { expanded = true }) { Icon( imageVector = Icons.Outlined.MoreVert, - contentDescription = null, + contentDescription = null ) } DropdownMenu( @@ -330,15 +329,9 @@ fun Header(album: Album, navController: NavController) { IconButton(onClick = { /*TODO*/ }) { Icon( imageVector = Icons.Outlined.PlayArrow, - contentDescription = null, - + contentDescription = null ) } -// OutlinedButton(onClick = { navController.navigate(Screen.Donate.route) }) { -// Row { -// Icon(imageVector = Icons.Default.Send, contentDescription = null) -// } -// } } } }