Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashpay):improve request username and save info #1302

Merged
merged 18 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
715772b
feat: update dashpay icon
HashEngineering Aug 30, 2024
e7fa054
fix: update More Fragment
HashEngineering Aug 30, 2024
716bae8
fix: restore singleTop launch mode to prevent other tasks from appearing
HashEngineering Aug 30, 2024
968528e
fix: update UsernameRegistrationFragment
HashEngineering Aug 30, 2024
4c3b0e0
fix: keep times in ms
HashEngineering Aug 30, 2024
bf7f876
fix: repair publishing of identity verify document
HashEngineering Aug 30, 2024
2424a7c
fix: repair publishing of identity verify document
HashEngineering Aug 30, 2024
05614b4
fix: save new data to DataStore for BlockchainIdentityConfig
HashEngineering Aug 30, 2024
d6bf7dd
fix: fix time on request details
HashEngineering Aug 30, 2024
91d7a6c
fix: during username request, move the identity verify saving step
HashEngineering Sep 3, 2024
daf0419
fix: remove unused handler and runnable
HashEngineering Sep 3, 2024
9a157cc
fix: fix bug re: setting verification link later
HashEngineering Sep 3, 2024
31cf520
fix: update dashpay strings and fix non-escaped characters
HashEngineering Sep 5, 2024
5a1103b
fix: catch exceptions when updating the username voting information
HashEngineering Sep 5, 2024
5401f92
fix: use new registerIdentity in BlockchainIdentity
HashEngineering Sep 5, 2024
8d63d83
fix: fix UI on MoreFragment with contested names
HashEngineering Sep 5, 2024
3dd363b
fix: move some methods to CreateIdentityViewModel
HashEngineering Sep 5, 2024
ae095f5
Merge branch 'dashpay' of https://github.com/dashevo/dash-wallet into…
HashEngineering Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions wallet/res/drawable/ic_join_dashpay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M1.366,1.366C0.862,0.862 0,1.219 0,1.931V18.069C0,18.781 0.862,19.138 1.366,18.634L10,10L1.366,1.366Z"
android:fillColor="#008DE4"/>
<path
android:pathData="M10.663,1.326C10.498,0.996 10,1.113 10,1.483V18.517C10,18.887 10.498,19.004 10.663,18.674L15,10L10.663,1.326Z"
android:fillColor="#008DE4"/>
<path
android:pathData="M15.392,1.305C15.325,1.085 15,1.132 15,1.363V18.637C15,18.868 15.325,18.916 15.392,18.695L18,10L15.392,1.305Z"
android:fillColor="#008DE4"/>
<path
android:pathData="M18.257,1.287C18.227,1.133 18,1.156 18,1.313V18.687C18,18.844 18.227,18.867 18.257,18.713L20,10L18.257,1.287Z"
android:fillColor="#008DE4"/>
</vector>
117 changes: 71 additions & 46 deletions wallet/res/layout/fragment_more.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,59 +179,84 @@

</ViewFlipper>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/requested_username_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_height="110dp"
style="@style/MenuRow">

<ImageView
android:id="@+id/requested_username_icon"
style="@style/MenuRowIcon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_avatar_blue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingTop="0dp">

<TextView
android:id="@+id/requested_username_title"
style="@style/MenuRowTitle"
app:layout_constraintStart_toEndOf="@+id/requested_username_icon"
app:layout_constraintTop_toTopOf="@+id/requested_username_icon"
tools:text="@string/shortcut_action_join_dashpay" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/requested_username_container"
android:visibility="gone"
tools:visibility="visible"
android:layout_height="76dp"
style="@style/MenuRow">

<TextView
android:id="@+id/requested_username_subtitle"
style="@style/MenuRowSubTitle"
android:text="@string/requested_username_has_been"
app:layout_constraintStart_toStartOf="@+id/requested_username_title"
app:layout_constraintTop_toBottomOf="@+id/requested_username_title" />
<ImageView
android:id="@+id/requested_username_icon"
style="@style/MenuRowIcon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_join_dashpay" />

<LinearLayout
android:id="@+id/join_dashpay_text_section"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp"
app:layout_constraintStart_toEndOf="@+id/requested_username_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" >

<TextView
android:id="@+id/requested_username_title"
style="@style/MenuRowTitle"
android:layout_marginStart="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="requested-username" />

<TextView
android:id="@+id/requested_username_subtitle"
style="@style/MenuRowSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="@string/requested_username_has_been" />

<TextView
android:id="@+id/requested_username_subtitle_two"
style="@style/MenuRowSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/requested_voting_duration"
/>
</LinearLayout>

<TextView
android:id="@+id/requested_username_subtitle_two"
style="@style/MenuRowSubTitle"
android:text="@string/requested_voting_duration"
app:layout_constraintStart_toStartOf="@+id/requested_username_subtitle"
app:layout_constraintTop_toBottomOf="@+id/requested_username_subtitle" />

<ImageView
android:id="@+id/requested_username_arrow"
style="@style/MenuRowArrow"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu_row_arrow" />
<TextView
android:id="@+id/retry_request_button"
style="@style/Overline.SemiBold.Blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/retry"
android:layout_marginEnd="20dp" />
<ImageView
android:id="@+id/requested_username_arrow"
style="@style/MenuRowArrow"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu_row_arrow" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:paddingTop="20dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/invite"
Expand Down
14 changes: 9 additions & 5 deletions wallet/res/values/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<string name="accepting_contact_request">Accepting Contact Request</string>
<string name="accepting_contact_request_short">Accepting</string>
<string name="search_user_no_results">There are no users that match</string>
<string name="search_user_loading">Searching for username <b>"%"</b> on the Dash Network</string>
<string name="search_user_loading">Searching for username <b>\"%\"</b> on the Dash Network</string>
<string name="contact_request_pending">Contact Request Pending</string>
<string name="pay">Pay</string>
<string name="contact_request_received_title">%s has requested to be a friend</string>
Expand Down Expand Up @@ -130,6 +130,7 @@
<string name="notifications_you_received">%s has sent you a contact request</string>

<string name="identity_complete_message">Your username %s has been successfully created on the Dash Network</string>
<string name="request_complete_message">Your username %s has been successfully requested on the Dash Network</string>

<string name="scan_to_pay_username_dialog_message">Not a valid Dash Username or Identity\n\n%s</string>
<string name="send_coins_to_username">Sending to</string>
Expand Down Expand Up @@ -252,7 +253,7 @@
<string name="welcome_to_dash_pay">Welcome to Dash Pay</string>
<string name="pay_to_usernames">Pay to usernames. No more alphanumeric addresses.</string>
<string name="create_a_username">Create a username</string>
<string name="add_your_friends_family">"Add your friends &amp; family"</string>
<string name="add_your_friends_family">Add your friends &amp; family</string>
<string name="invite_your_family">Invite your family, find your friends by searching their usernames.</string>
<string name="personalise_profile">Personalise profile</string>
<string name="upload_your_picture">Upload your picture, personalize your identity.</string>
Expand Down Expand Up @@ -301,7 +302,10 @@
<string name="request_username_available">Username is available</string>
<string name="request_username_unavailable">Username is unavailable or blocked</string>
<string name="request_username_taken">Username is taken</string>

<string name="requesting_your_username_title">Creating your username</string>
<string name="requesting_your_username_message">Your username johndoe is being requested on the Dash network. It may take some time.</string>
<string name="requesting_your_username_error_title">Your username request failed</string>
<string name="requesting_your_username_error_message">For some reason, the request has failed. Please try again.</string>
<string name="voting">Voting:</string>
<string name="this_username_has_already_been_requested">This username has already been requested, but you can request it too and let the network vote to decide if you can have it</string>
<string name="request_details">Request details</string>
Expand Down Expand Up @@ -332,7 +336,7 @@
<string name="vote_submitted">Your vote was submitted</string>
<string name="vote_cancelled">Your vote was cancelled</string>
<string name="quick_vote">Quick Voting</string>
<string name="quick_vote_subtitle">By tapping the "Vote for All" button, you will automatically vote for all of the filtered usernames (%d) that were submitted first</string>
<string name="quick_vote_subtitle">By tapping the \"Vote for All\" button, you will automatically vote for all of the filtered usernames (%d) that were submitted first</string>
<string name="vote_for_all">Vote for All</string>
<string name="voting_period_active">Username Voting Period Active</string>
<string name="there_was_a_network_error">There was a network error, you can try again at no extra cost</string>
Expand Down Expand Up @@ -384,7 +388,7 @@
<!-- credit balance messages / buttons -->
<string name="credit_balance_empty_warning_title">Your credit balance is low</string>
<string name="credit_balance_low_warning_title">Your credit balance is fully depleted</string>
<string name="credit_balance_empty_warning_message">"You can continue to use DashPay for payments but you cannot update your profile or add more contacts until you top up your credit balance</string>
<string name="credit_balance_empty_warning_message">You can continue to use DashPay for payments but you cannot update your profile or add more contacts until you top up your credit balance</string>
<string name="credit_balance_low_warning_message">Top-up your credits to continue making changes to your profile and adding contacts</string>
<string name="credit_balance_button_maybe_later">Maybe later</string>
<string name="credit_balance_button_buy">Buy Credits</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ open class BlockchainIdentityConfig @Inject constructor(
blockchainIdentityData.usernameStatus?.let { prefs[USERNAME_REGISTRATION_STATUS] = it.name }
blockchainIdentityData.privacyMode?.let { prefs[PRIVACY_MODE] = it.name }
blockchainIdentityData.creditBalance?.let { prefs[BALANCE] = it.value }
blockchainIdentityData.usernameRequested?.let { prefs[USERNAME_REQUESTED] = it.name}
blockchainIdentityData.verificationLink?.let { prefs[REQUESTED_USERNAME_LINK] = it }
blockchainIdentityData.votingPeriodStart?.let { prefs[VOTING_PERIOD_START] = it }
blockchainIdentityData.cancelledVerificationLink?.let { prefs[CANCELED_REQUESTED_USERNAME_LINK] = it }
}
}

Expand All @@ -256,6 +260,10 @@ open class BlockchainIdentityConfig @Inject constructor(
blockchainIdentityBaseData.creditFundingTxId?.let { prefs[ASSET_LOCK_TXID] = it.toString() }
prefs[USING_INVITE] = blockchainIdentityBaseData.usingInvite
blockchainIdentityBaseData.invite?.let { prefs[INVITE_LINK] = it.link.toString() }
blockchainIdentityBaseData.usernameRequested?.let { prefs[USERNAME_REQUESTED] = it.name}
blockchainIdentityBaseData.verificationLink?.let { prefs[REQUESTED_USERNAME_LINK] = it }
blockchainIdentityBaseData.votingPeriodStart?.let { prefs[VOTING_PERIOD_START] = it }
blockchainIdentityBaseData.cancelledVerificationLink?.let { prefs[CANCELED_REQUESTED_USERNAME_LINK] = it }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,30 +1025,34 @@ class PlatformSynchronizationService @Inject constructor(
}

override suspend fun updateUsernameRequestsWithVotes() {
val contestedNames = platform.platform.names.getContestedNames()
for (name in contestedNames) {
val voteContender = platform.platform.names.getVoteContenders(name)
voteContender.map.forEach { (identifier, contender) ->
try {
val contestedNames = platform.platform.names.getContestedNames()
for (name in contestedNames) {
val voteContender = platform.platform.names.getVoteContenders(name)
voteContender.map.forEach { (identifier, contender) ->

val contestedDocument = DomainDocument(
platform.platform.names.deserialize(contender.seralizedDocument)
)
val contestedDocument = DomainDocument(
platform.platform.names.deserialize(contender.seralizedDocument)
)

val identityVerifyDocument = IdentityVerify(platform.platform).get(identifier, name)

val usernameRequest = UsernameRequest(
UsernameRequest.getRequestId(identifier.toString(), name),
contestedDocument.label,
name,
contestedDocument.createdAt?.div(1000) ?: -1L,
identifier.toString(),
identityVerifyDocument?.url,
contender.votes,
voteContender.lockVoteTally,
false
)
usernameRequestDao.insert(usernameRequest)
val identityVerifyDocument = IdentityVerify(platform.platform).get(identifier, name)

val usernameRequest = UsernameRequest(
UsernameRequest.getRequestId(identifier.toString(), name),
contestedDocument.label,
name,
contestedDocument.createdAt?.div(1000) ?: -1L,
identifier.toString(),
identityVerifyDocument?.url,
contender.votes,
voteContender.lockVoteTally,
false
)
usernameRequestDao.insert(usernameRequest)
}
}
} catch (e: Exception) {
log.info("problem obtaining votes:", e)
}
}

Expand Down
25 changes: 13 additions & 12 deletions wallet/src/de/schildbach/wallet/ui/dashpay/CreateIdentityService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -645,23 +645,13 @@ class CreateIdentityService : LifecycleService() {
val document = DomainDocument(
platformRepo.platform.names.deserialize(documentWithVotes.seralizedDocument)
)
blockchainIdentityData.verificationLink?.let { verificationLink ->
if (verificationLink.startsWith("https://") || verificationLink.startsWith("http://")) {
IdentityVerify(platformRepo.platform.platform).createForDashDomain(
blockchainIdentityData.username!!,
verificationLink,
blockchainIdentity.identity!!,
WalletSignerCallback(walletApplication.wallet!!, encryptionKey)
)
}
}

usernameRequestDao.insert(
UsernameRequest(
blockchainIdentity.uniqueIdString + " " + blockchainIdentityData.username!!,
blockchainIdentityData.username!!,
Names.normalizeString(blockchainIdentityData.username!!),
document.createdAt!! / 1000,
document.createdAt!!,
blockchainIdentity.uniqueIdString,
blockchainIdentityData.verificationLink,
documentWithVotes.votes,
Expand All @@ -681,6 +671,17 @@ class CreateIdentityService : LifecycleService() {
if (blockchainIdentityData.creationState <= CreationState.REQUESTED_NAME_CHECKED) {
platformRepo.updateIdentityCreationState(blockchainIdentityData, CreationState.REQUESTED_NAME_CHECKED)
platformRepo.updateBlockchainIdentityData(blockchainIdentityData, blockchainIdentity)

blockchainIdentityData.verificationLink?.let { verificationLink ->
if (verificationLink.startsWith("https://") || verificationLink.startsWith("http://")) {
IdentityVerify(platformRepo.platform.platform).createForDashDomain(
blockchainIdentityData.username!!,
verificationLink,
blockchainIdentity.identity!!,
WalletSignerCallback(walletApplication.wallet!!, encryptionKey)
)
}
}
}

if (blockchainIdentityData.creationState <= CreationState.REQUESTED_NAME_LINK_SAVING) {
Expand Down Expand Up @@ -847,7 +848,7 @@ class CreateIdentityService : LifecycleService() {
UsernameRequest.getRequestId(blockchainIdentity.uniqueIdString, blockchainIdentity.currentUsername!!),
contestedDocument.label,
contestedDocument.normalizedLabel,
contestedDocument.createdAt!! / 1000,
contestedDocument.createdAt!!,
blockchainIdentity.uniqueIdString,
verifyDocument?.url, // get it from the document
documentWithVotes.votes,
Expand Down
Loading
Loading