Skip to content

Commit

Permalink
Merge pull request #70 from StevenL98/master
Browse files Browse the repository at this point in the history
Bounty payout voting and payment execution - self-evolving AI-DAO #5986
  • Loading branch information
xoriole authored May 26, 2021
2 parents e570128 + e76d087 commit 70c7774
Show file tree
Hide file tree
Showing 70 changed files with 3,876 additions and 1,533 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ We build a DAO for a better world. Luxury communism is an Android application bu
* **My DAO's**: A list of all DAO's that the user participates in. Selecting a DAO will allow a user to create a transfer proposal from that DAO.
* **All DAO's**: A list of all discovered DAO's in the network which the user can propose to join.
* **Proposals**: A list of all proposals that the user can vote on. This can either be join proposals or proposals from someone else to transfer funds from one of the DAO's.
* **My Wallet**: Overview of the used Bitcoin wallet and the ability to chane this to another.
* **Duplicate Wallet**: In case the user has wallet files for both TestNet and Production, the user is allowed to select which one to keep. After the user selected either one, the files belonging to other network type are backed up. This, thus, ensures that the wallet is not lost.
* **My Wallet**: Overview of the used Bitcoin wallet and the ability to chain this to another.
* **Duplicate Wallet**: In case the user has wallet files for TestNet, Production or Regtest, the user is allowed to select which one to keep. After the user selected either one, the files belonging to other network type are backed up. This, thus, ensures that the wallet is not lost.

Currently, the Luxury Communism app only allows Regtest, since it uses a future update of Bitcoin called Taproot. Once Taproot is officially released, the app can support TestNet or Production again. Taproot allows the DAO to scale to thousands or even millions of users. The beauty of Taproot is that it uses Schnorr signatures for each transaction. This enables transaction sizes that are equal independent of the number of users in a DAO, since each user combines their signature collaberatively into one for the whole DAO. This also ensures privacy, since it is no longer possible to tell if a transaction's is from a single person, or a million of persons.

<img src="currencyii/docs/images/screenshot_7.png" width="200px"> <img src="currencyii/docs/images/screenshot_6.png" width="200px"> <img src="currencyii/docs/images/screenshot_10.png" width="200px">
<br />

<p float="left">
<img src="https://user-images.githubusercontent.com/23526224/111478102-0c54dc00-8730-11eb-9fbb-3cd65e2ee7ad.gif" width="200"/>
<img src="https://user-images.githubusercontent.com/23526224/111478323-42925b80-8730-11eb-9bb9-d90b703385a3.jpeg" width="200"/>
<img src="https://user-images.githubusercontent.com/23526224/111479002-e2e88000-8730-11eb-9246-dc487e5268b4.jpeg" width="200"/>
</p>
<br />

https://user-images.githubusercontent.com/23526224/116259903-85efd900-a776-11eb-93b1-384936d215c4.mp4


[More about Luxury Communism](currencyii/README.md)

### TrustChain Voter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class TrustChainApplication : Application() {
super.onCreate()

defaultCryptoProvider = AndroidCryptoProvider

initIPv8()
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
<domain-config cleartextTrafficPermitted="true">
<!-- This is for bitcoin faucet, to claim some starter money using a REST call-->
<domain includeSubdomains="true">134.122.59.107</domain>
<!-- This is for RegTest faucet, to claim some starter money -->
<domain includeSubdomains="true">131.180.27.224</domain>
</domain-config>
</network-security-config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package nl.tudelft.trustchain.common.ui

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ListView
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import nl.tudelft.trustchain.common.R

/**
* The adapter for showing the tab fragments in the voting fragment
*/
class TabsAdapter(fragment: Fragment, private val voters: Array<ArrayList<String>>) :
FragmentStateAdapter(fragment) {

override fun getItemCount(): Int = 3

override fun createFragment(position: Int): Fragment {
// Return a NEW fragment instance in createFragment(int)
val fragment = TabFragment()
fragment.arguments = Bundle().apply {
putInt("tabPosition", position)
putStringArrayList("voters", voters[position])
}
return fragment
}
}

/**
* The fragment for showing the votes in a list
*/
class TabFragment : Fragment() {

private lateinit var votesAdapter: VotesAdapter

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return inflater.inflate(R.layout.fragment_votes_tab, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
arguments?.takeIf {
it.containsKey("voters")
}?.apply {

val votesList = view.findViewById<ListView>(R.id.votes)
votesAdapter = VotesAdapter(
view.context,
requireArguments().getStringArrayList("voters")!!
)
votesList.adapter = votesAdapter
}
}
}

/**
* The adapter for showing the vote entries in the TabFragment in the list.
*/
class VotesAdapter(
private val context: Context,
private val voters: ArrayList<String>
) : BaseAdapter() {

override fun getCount(): Int {
return voters.size
}

override fun getItem(position: Int): Any {
return voters[position]
}

override fun getItemId(position: Int): Long {
return position.toLong()
}

override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val view =
LayoutInflater.from(context).inflate(R.layout.fragment_votes_entry, parent, false)

view.findViewById<TextView>(R.id.voter_name).text = voters[position]

return view
}
}
66 changes: 66 additions & 0 deletions common/src/main/res/layout/fragment_votes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAllCaps="true"
android:textSize="24sp"
android:textStyle="bold" />

<TextView
android:id="@+id/sub_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp" />

<TextView
android:id="@+id/required_votes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.appbar.AppBarLayout>

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="20dp"
android:contentDescription="@string/vote"
android:gravity="center"
android:text="@string/voteUser"
android:theme="@style/VoteButton"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlayExtended" />

</FrameLayout>
15 changes: 15 additions & 0 deletions common/src/main/res/layout/fragment_votes_entry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/voter_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textSize="20sp" />

</LinearLayout>
12 changes: 12 additions & 0 deletions common/src/main/res/layout/fragment_votes_tab.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ListView
android:id="@+id/votes"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>
16 changes: 16 additions & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@
<string name="stored"><![CDATA[<b>Stored:</b> %s]]></string>

<string name="x_bytes">%d B</string>

<string name="vote">Vote</string>
<string name="voteUser">Vote</string>
<string name="bounty_payout">Pay %1$s from our common funds to address: %2$s?</string>
<string name="bounty_payout_message">Do you agree on paying %1$s from our common funds to address: %2$s?</string>
<string name="bounty_payout_upvoted">You voted in favor of paying %1$s from our common funds to address: %2$s</string>
<string name="bounty_payout_downvoted">You voted against paying %1$s from our common funds to address: %2$s</string>

<string name="vote_join_request_title">Join Request</string>
<string name="vote_join_request_message">Allow %1$s into our shared wallet with id: %2$s?</string>
<string name="votes_required">We need %1$d votes</string>
<string name="votes_required_fails">We needed %1$d votes, but that isn\'t possible anymore</string>
<string name="vote_join_request_upvoted">You voted in favor of allowing %1$s into our shared wallet with id: %2$s</string>
<string name="vote_join_request_downvoted">You voted against allowing %1$s into our shared wallet with id: %2$s</string>
<string name="vote_join_request_voted">The majority voted, based on the majority we execute the transaction</string>

</resources>
12 changes: 12 additions & 0 deletions common/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="VoteButton" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="textAppearanceButton">@style/AppTextAppearance.Button</item>
</style>
<!--To fix rendering in preview -->
<style name="AppTextAppearance.Button" parent="TextAppearance.MaterialComponents.Button">
<item name="android:textAllCaps">true</item>
</style>

<style name="ShapeAppearanceOverlayExtended" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">0dp</item>
</style>
</resources>
Loading

0 comments on commit 70c7774

Please sign in to comment.