Skip to content

Commit 2529d5f

Browse files
committed
Added ERC20 transfer.(#11)
1 parent eb28b0d commit 2529d5f

4 files changed

Lines changed: 26 additions & 23 deletions

File tree

lib/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ android {
6262
}
6363

6464
dependencies {
65-
implementation("com.github.dora4:dora:1.3.37")
65+
implementation("com.github.dora4:dora:1.3.38")
6666
api("com.github.dora4:dview-alert-dialog:1.25")
6767
// wallet connect
6868
api(platform("com.walletconnect:android-bom:1.31.4"))
@@ -78,7 +78,7 @@ afterEvaluate {
7878
from(components["release"])
7979
groupId = "com.github.dora4"
8080
artifactId = "dora-walletconnect-support"
81-
version = "2.1.16"
81+
version = "2.1.17"
8282
}
8383
}
8484
}

lib/src/main/java/dora/pay/DoraFund.kt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.os.Build
1010
import android.util.Log
1111
import androidx.annotation.ColorInt
1212
import androidx.core.app.NotificationCompat
13+
import androidx.core.content.ContextCompat
1314
import com.walletconnect.android.Core
1415
import com.walletconnect.web3.modal.client.Modal
1516
import com.walletconnect.web3.modal.client.Web3Modal
@@ -61,7 +62,7 @@ object DoraFund {
6162
* Platform ERC20 wallet address.
6263
* @since 2.0
6364
*/
64-
private const val ERC20_ADDRESS = "0xcBa852Ef29a43a7542B88F60C999eD9cB66f6000"
65+
const val ERC20_ADDRESS = "0xcBa852Ef29a43a7542B88F60C999eD9cB66f6000"
6566

6667
/**
6768
* Success.
@@ -431,7 +432,7 @@ object DoraFund {
431432
val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_NATIVE)
432433
val chain = getCurrentChain()
433434
if (chain == null) {
434-
ToastUtils.showShort(context.getString(R.string.please_connect_wallet_first))
435+
ToastUtils.showShort(R.string.please_connect_wallet_first)
435436
return
436437
}
437438
// supports EIP-1559
@@ -553,7 +554,7 @@ object DoraFund {
553554
val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_NATIVE)
554555
val chain = getCurrentChain()
555556
if (chain == null) {
556-
ToastUtils.showShort(context.getString(R.string.please_connect_wallet_first))
557+
ToastUtils.showShort(R.string.please_connect_wallet_first)
557558
return
558559
}
559560
// supports EIP-1559
@@ -631,10 +632,10 @@ object DoraFund {
631632
orderListener: OrderListener
632633
) {
633634
if (payListener == null) throw PaymentException("No PayListener is set.")
634-
DoraAlertDialog(context).show("$goodsDesc\n\n${context.getString(R.string.dorafund_provides_technical_support)}") {
635+
DoraAlertDialog(context).show("$goodsDesc\n\n${ContextCompat.getString(context, R.string.dorafund_provides_technical_support)}") {
635636
title(orderTitle)
636637
themeColor(themeColor)
637-
positiveButton(context.getString(R.string.pay))
638+
positiveButton(ContextCompat.getString(context, R.string.pay))
638639
positiveListener {
639640
Web3Modal.getAccount()?.let { session ->
640641
sendTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -676,10 +677,11 @@ object DoraFund {
676677
orderListener: OrderListener
677678
) {
678679
if (payListener == null) throw PaymentException("No PayListener is set.")
679-
DoraAlertDialog(context).show("$goodsDesc\n\n${context.getString(R.string.dorafund_provides_technical_support)}") {
680+
DoraAlertDialog(context).show("$goodsDesc\n\n${ContextCompat.getString(context,
681+
R.string.dorafund_provides_technical_support)}") {
680682
title(orderTitle)
681683
themeColor(themeColor)
682-
positiveButton(context.getString(R.string.pay))
684+
positiveButton(ContextCompat.getString(context, R.string.pay))
683685
positiveListener {
684686
Web3Modal.getAccount()?.let { session ->
685687
sendNativeTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -721,10 +723,11 @@ object DoraFund {
721723
orderListener: OrderListener
722724
) {
723725
if (payListener == null) throw PaymentException("No PayListener is set.")
724-
DoraAlertDialog(context).show("$goodsDesc\n\n${context.getString(R.string.dorafund_provides_technical_support)}") {
726+
DoraAlertDialog(context).show("$goodsDesc\n\n${ContextCompat.getString(context,
727+
R.string.dorafund_provides_technical_support)}") {
725728
title(orderTitle)
726729
themeColor(themeColor)
727-
positiveButton(context.getString(R.string.pay))
730+
positiveButton(ContextCompat.getString(context, R.string.pay))
728731
positiveListener {
729732
Web3Modal.getAccount()?.let { session ->
730733
sendNativeTransactionRequest(context, accessKey, secretKey, session.address, account,
@@ -766,11 +769,11 @@ object DoraFund {
766769
val (gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas) = nativeGetGasParametersEIP1559(context, TRANSFER_TYPE_ERC20)
767770
val chain = getCurrentChain()
768771
if (chain == null) {
769-
ToastUtils.showShort(context.getString(R.string.please_connect_wallet_first))
772+
ToastUtils.showShort(R.string.please_connect_wallet_first)
770773
return
771774
}
772775
if (chain.id != token.chain.id) {
773-
ToastUtils.showShort(context.getString(R.string.please_switch_correct_chain_to_pay_with_tokens))
776+
ToastUtils.showShort(R.string.please_switch_correct_chain_to_pay_with_tokens)
774777
return
775778
}
776779
val isEIP1559Chain = when (token.chain) {
@@ -782,11 +785,11 @@ object DoraFund {
782785
}
783786
if (payListener == null) throw PaymentException("No PayListener is set.")
784787
DoraAlertDialog(context).show(
785-
"$goodsDesc\n\n${context.getString(R.string.dorafund_provides_technical_support)}"
788+
"$goodsDesc\n\n${ContextCompat.getString(context, R.string.dorafund_provides_technical_support)}"
786789
) {
787790
title(orderTitle)
788791
themeColor(themeColor)
789-
positiveButton(context.getString(R.string.pay))
792+
positiveButton(ContextCompat.getString(context, R.string.pay))
790793
positiveListener {
791794
Web3Modal.getAccount()?.let { session ->
792795
val status = if (isEIP1559Chain) {
@@ -1012,45 +1015,45 @@ object DoraFund {
10121015
val notificationManager =
10131016
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
10141017
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
1015-
var name = context.getString(R.string.channel_name_background)
1018+
var name = ContextCompat.getString(context, R.string.channel_name_background)
10161019
var channel = NotificationChannel(
10171020
OpenVPNService.NOTIFICATION_CHANNEL_BG_ID,
10181021
name,
10191022
NotificationManager.IMPORTANCE_MIN
10201023
).apply {
1021-
description = context.getString(R.string.channel_description_background)
1024+
description = ContextCompat.getString(context, R.string.channel_description_background)
10221025
enableLights(false)
10231026
lightColor = Color.DKGRAY
10241027
}
10251028
notificationManager.createNotificationChannel(channel)
10261029

1027-
name = context.getString(R.string.channel_name_status)
1030+
name = ContextCompat.getString(context, R.string.channel_name_status)
10281031
channel = NotificationChannel(
10291032
OpenVPNService.NOTIFICATION_CHANNEL_NEWSTATUS_ID,
10301033
name,
10311034
NotificationManager.IMPORTANCE_LOW
10321035
).apply {
1033-
description = context.getString(R.string.channel_description_status)
1036+
description = ContextCompat.getString(context, R.string.channel_description_status)
10341037
enableLights(true)
10351038
lightColor = Color.BLUE
10361039
}
10371040
notificationManager.createNotificationChannel(channel)
10381041

1039-
name = context.getString(R.string.channel_name_userreq)
1042+
name = ContextCompat.getString(context, R.string.channel_name_userreq)
10401043
channel = NotificationChannel(
10411044
OpenVPNService.NOTIFICATION_CHANNEL_USERREQ_ID,
10421045
name,
10431046
NotificationManager.IMPORTANCE_HIGH
10441047
).apply {
1045-
description = context.getString(R.string.channel_description_userreq)
1048+
description = ContextCompat.getString(context, R.string.channel_description_userreq)
10461049
enableVibration(true)
10471050
lightColor = Color.CYAN
10481051
}
10491052
notificationManager.createNotificationChannel(channel)
10501053
} else {
10511054
val notification = NotificationCompat.Builder(context)
1052-
.setContentTitle(context.getString(R.string.channel_name_status))
1053-
.setContentText(context.getString(R.string.channel_description_status))
1055+
.setContentTitle(ContextCompat.getString(context, R.string.channel_name_status))
1056+
.setContentText(ContextCompat.getString(context, R.string.channel_description_status))
10541057
.setSmallIcon(android.R.drawable.stat_sys_warning)
10551058
.setPriority(NotificationCompat.PRIORITY_LOW)
10561059
.build()
16 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)