Skip to content

Commit

Permalink
feat(dashpay): finish topup feature (ui, backend) (#1338)
Browse files Browse the repository at this point in the history
* refactor: move BaseWorker

* feat: add BaseForegroundWorker

* feat: add RestoreIdentityWorker

* feat: topup backend

* feat: topup ui

* feat: topup during username request, if necessary

* chore: remove unused imports

* fix: hide Buy Credits if there is no username

* chore: cleanup some constructors, etc

* fix: align ui elements and icons

* feat: add topup database table

* fix: make topup more similar to send tx flow

* fix: for topups, show Send to: OP RETURN

* fix: improve tx details for topups

* fix: improve topup functionality

* fix: add isAssetLock to SendCoinViewModel

* fix: don't automatically put topup memo

* fix: improve tracking of topUp status

* fix: remove checkbox on topup confirm

* fix: remove use correct amount on Confirm Username Request Dialog

* fix: remove the preposition on for Buy Credits fragment
  • Loading branch information
HashEngineering authored Jan 15, 2025
1 parent 45d9743 commit dd8dd7b
Show file tree
Hide file tree
Showing 68 changed files with 3,453 additions and 343 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
coroutinesVersion = '1.6.4'
ok_http_version = '4.9.1'
dashjVersion = '21.1.4'
dppVersion = "1.5.2"
dppVersion = "1.7.0-SNAPSHOT"
hiltVersion = '2.51'
hiltCompilerVersion = '1.2.0'
hiltWorkVersion = '1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.bitcoinj.core.Address
import org.bitcoinj.core.Transaction
import org.bitcoinj.core.TransactionBag
import org.bitcoinj.script.ScriptException
import org.bitcoinj.script.ScriptPattern

object TransactionUtils {
fun getWalletAddressOfReceived(tx: Transaction, bag: TransactionBag): Address? {
Expand Down Expand Up @@ -86,6 +87,22 @@ object TransactionUtils {
return result
}

fun getOpReturnsOfSent(tx: Transaction, bag: TransactionBag): List<String> {
val result = mutableListOf<String>()

for (output in tx.outputs) {
try {
if (!output.isMine(bag) && ScriptPattern.isOpReturn(output.scriptPubKey)) {
result.add("OP RETURN")
}
} catch (x: ScriptException) {
// swallow
}
}

return result
}

fun Transaction.isEntirelySelf(bag: TransactionBag): Boolean {
for (input in inputs) {
val connectedOutput = input.connectedOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class PaymentHeaderView @JvmOverloads constructor(
binding.paymentAddressViewBalanceTitle.text = title
}

fun setProposition(title: String) {
binding.paymentAddressViewProposition.text = title
fun setPreposition(title: String) {
binding.paymentAddressViewPreposition.text = title
}

fun setSubtitle(title: String) {
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/res/layout/payment_header_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
tools:text="@string/to" />

<TextView
android:id="@+id/payment_address_view_proposition"
android:id="@+id/payment_address_view_preposition"
style="@style/Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<string name="receive_enter_amount_button">Specify Amount</string>
<string name="account_create">Create Account</string>
<string name="submit">Submit</string>
<string name="try_again">Try Again</string>

<!-- Design system UI elements -->
<string name="search_hint">Search</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class PurchaseGiftCardFragment : Fragment(R.layout.fragment_purchase_gift_card)

private fun setPaymentHeader() {
binding.paymentHeaderView.setTitle(getString(R.string.explore_option_buy))
binding.paymentHeaderView.setProposition(getString(R.string.purchase_gift_card_at))
binding.paymentHeaderView.setPreposition(getString(R.string.purchase_gift_card_at))
binding.paymentHeaderView.setOnShowHideBalanceClicked {
binding.paymentHeaderView.triggerRevealBalance()
viewModel.balance.value?.let { balance ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
<string name="something_wrong_title" translatable="false">Something went wrong!</string>
<string name="retry" translatable="false">Retry</string>
<string name="gift_card_purchase_failed" translatable="false">Gift card purchase failed</string>
<string name="try_again" translatable="false">Try Again</string>
<string name="cancel" translatable="false">Cancel</string>
<string name="gift_card_error" translatable="false">For some reason we were not able to buy a gift card. Please, try again.</string>
<string name="dashdirect_terms_conditions" translatable="false">Accept DashDirect terms and conditions</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ open class DatabaseMigrationTest {
"Pizza for Bob's party",
""
)
private val address = "yNo1YJcNBoveEHWB7eYmxFZBVEAYQo46Yb"
private val service = ServiceName.CrowdNode
private const val address = "yNo1YJcNBoveEHWB7eYmxFZBVEAYQo46Yb"
private const val service = ServiceName.CrowdNode
}

private val migrations = arrayOf(
AppDatabaseMigrations.migration11To12,
AppDatabaseMigrations.migration12To13,
AppDatabaseMigrations.migration13to14
AppDatabaseMigrations.migration13to14,
AppDatabaseMigrations.migration14to15
)

@Rule
Expand Down
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_block_home_indicator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="73dp"
android:height="2dp"
android:viewportWidth="73"
android:viewportHeight="2">
<path
android:pathData="M1.5,0L71.5,0A1,1 0,0 1,72.5 1L72.5,1A1,1 0,0 1,71.5 2L1.5,2A1,1 0,0 1,0.5 1L0.5,1A1,1 0,0 1,1.5 0z"
android:fillColor="#191C1F"/>
</vector>
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_credits.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M10.277,22C6.5,22 3.882,21.105 2.424,19.316C0.933,17.527 0.536,14.777 1.198,11C1.861,7.289 3.22,4.506 5.34,2.717C7.461,0.928 10.376,0 14.153,0H21.111L20.283,4.572H14.451C13.259,4.572 12.232,4.705 11.37,4.904C10.509,5.136 9.78,5.5 9.183,5.997C8.587,6.527 8.09,7.19 7.726,7.985C7.361,8.813 7.096,9.807 6.897,11C6.698,12.193 6.632,13.22 6.698,14.015C6.765,14.843 7.03,15.506 7.427,16.003C7.825,16.533 8.421,16.898 9.217,17.096C10.012,17.328 11.006,17.428 12.198,17.428H18.162L17.367,22H10.277Z"
android:fillColor="#008DE4"/>
</vector>
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_info_circle_filled_gray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="15dp"
android:height="16dp"
android:viewportWidth="15"
android:viewportHeight="16">
<path
android:pathData="M7.496,15.5C6.471,15.5 5.506,15.304 4.601,14.912C3.696,14.525 2.898,13.985 2.206,13.293C1.519,12.601 0.98,11.802 0.588,10.897C0.196,9.992 0,9.026 0,8C0,6.974 0.196,6.008 0.588,5.103C0.98,4.198 1.519,3.402 2.206,2.714C2.898,2.022 3.694,1.48 4.594,1.088C5.498,0.696 6.463,0.5 7.489,0.5C8.52,0.5 9.487,0.696 10.392,1.088C11.297,1.48 12.095,2.022 12.787,2.714C13.479,3.402 14.02,4.198 14.412,5.103C14.804,6.008 15,6.974 15,8C15,9.026 14.804,9.992 14.412,10.897C14.02,11.802 13.479,12.601 12.787,13.293C12.095,13.985 11.297,14.525 10.392,14.912C9.487,15.304 8.522,15.5 7.496,15.5ZM6.168,12.175H9.224C9.398,12.175 9.543,12.122 9.659,12.015C9.775,11.904 9.833,11.761 9.833,11.587C9.833,11.422 9.775,11.284 9.659,11.173C9.543,11.057 9.398,10.998 9.224,10.998H8.389V7.441C8.389,7.213 8.333,7.03 8.222,6.889C8.111,6.749 7.949,6.679 7.736,6.679H6.299C6.13,6.679 5.987,6.737 5.871,6.853C5.755,6.969 5.697,7.107 5.697,7.267C5.697,7.441 5.755,7.584 5.871,7.695C5.987,7.802 6.13,7.855 6.299,7.855H7.061V10.998H6.168C5.999,10.998 5.854,11.057 5.733,11.173C5.617,11.284 5.559,11.422 5.559,11.587C5.559,11.761 5.617,11.904 5.733,12.015C5.854,12.122 5.999,12.175 6.168,12.175ZM7.453,5.51C7.743,5.51 7.987,5.408 8.186,5.205C8.384,5.001 8.483,4.759 8.483,4.479C8.483,4.183 8.384,3.937 8.186,3.738C7.987,3.535 7.743,3.433 7.453,3.433C7.167,3.433 6.923,3.535 6.72,3.738C6.517,3.937 6.415,4.183 6.415,4.479C6.415,4.759 6.517,5.001 6.72,5.205C6.923,5.408 7.167,5.51 7.453,5.51Z"
android:fillColor="#B0B6BC"/>
</vector>
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_mail_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="20">
<path
android:pathData="M12.021,11.118C12.456,11.118 12.906,10.886 13.369,10.423L22.684,1.171C22.271,0.801 21.54,0.615 20.492,0.615H3.241C2.321,0.615 1.676,0.786 1.305,1.129L10.674,10.423C11.13,10.886 11.579,11.118 12.021,11.118ZM0.289,17.578L7.968,9.963L0.299,2.401C0.1,2.744 0,3.303 0,4.08V15.909C0,16.687 0.096,17.243 0.289,17.578ZM3.508,19.385H20.759C21.693,19.385 22.353,19.204 22.738,18.84L14.92,11.075L14.257,11.749C13.529,12.448 12.784,12.797 12.021,12.797C11.251,12.797 10.503,12.448 9.775,11.749L9.112,11.086L1.305,18.84C1.74,19.204 2.474,19.385 3.508,19.385ZM23.722,17.567C23.907,17.225 24,16.672 24,15.909V4.08C24,3.31 23.904,2.758 23.711,2.423L16.064,9.963L23.722,17.567Z"
android:fillColor="#008DE4"/>
</vector>
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_profile_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M2.908,22H19.092C19.773,22 20.309,21.846 20.698,21.538C21.087,21.237 21.282,20.816 21.282,20.272C21.282,19.501 21.043,18.682 20.564,17.814C20.086,16.946 19.396,16.139 18.496,15.393C17.603,14.638 16.524,14.026 15.259,13.555C13.993,13.077 12.57,12.837 10.988,12.837C9.414,12.837 7.994,13.077 6.729,13.555C5.463,14.026 4.381,14.638 3.48,15.393C2.588,16.139 1.902,16.946 1.424,17.814C0.953,18.682 0.718,19.501 0.718,20.272C0.718,20.816 0.913,21.237 1.302,21.538C1.691,21.846 2.227,22 2.908,22ZM11,10.684C11.884,10.684 12.7,10.444 13.446,9.966C14.192,9.487 14.788,8.842 15.234,8.031C15.689,7.212 15.916,6.291 15.916,5.269C15.916,4.279 15.689,3.387 15.234,2.592C14.788,1.789 14.192,1.156 13.446,0.694C12.7,0.231 11.884,0 11,0C10.124,0 9.313,0.235 8.566,0.706C7.82,1.176 7.22,1.813 6.765,2.616C6.319,3.411 6.096,4.303 6.096,5.293C6.096,6.307 6.319,7.22 6.765,8.031C7.22,8.842 7.816,9.487 8.554,9.966C9.3,10.444 10.116,10.684 11,10.684Z"
android:fillColor="#008DE4"/>
</vector>
129 changes: 129 additions & 0 deletions wallet/res/layout/dialog_confirm_topup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2023 Dash Core Group.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<View
android:id="@+id/drag_indicator"
android:layout_width="35dp"
android:layout_height="4dp"
android:layout_gravity="center"
android:layout_marginVertical="7dp"
android:background="@drawable/rounded_background"
android:theme="@style/DragIndicatorBackground"
tools:background="@color/light_gray" />

<TextView
style="@style/Subtitle2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:gravity="center_horizontal"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:text="@string/confirm" />

<TextView
android:id="@+id/confirm_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:gravity="center_horizontal"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:text="@string/topup_confirm_message" />


<LinearLayout
android:layout_marginTop="17dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/dash_amount_view"
style="@style/Headline3.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAlignment="gravity"
android:text="0.00" />

<ImageView
android:id="@+id/dash_symbol_view"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:layout_marginStart="8dp"
app:srcCompat="@drawable/ic_dash_d_black" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/fiat_symbol_view"
style="@style/Headline6.Regular.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$" />

<TextView
android:id="@+id/fiat_amount_view"
style="@style/Headline6.Regular.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0.00" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="25dp"
android:layout_marginBottom="15dp">

<Button
android:id="@+id/dismiss_btn"
style="@style/Button.Primary.Large.Grey"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:text="@string/cancel" />

<Button
android:id="@+id/confirm_btn"
style="@style/Button.Primary.Large.Blue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="15dp"
android:layout_weight="1"
android:text="@string/confirm" />
</LinearLayout>
</LinearLayout>
Loading

0 comments on commit dd8dd7b

Please sign in to comment.