Skip to content

Commit 0048854

Browse files
committed
android: add create stake vote user interface.
1 parent e7867ff commit 0048854

File tree

11 files changed

+755
-3
lines changed

11 files changed

+755
-3
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@
310310
android:name=".ActivityAssetOpCommon"
311311
android:screenOrientation="portrait"
312312
android:theme="@style/AppTheme.NoActionBar" />
313+
<activity
314+
android:name=".ActivityAssetOpStakeVote"
315+
android:screenOrientation="portrait"
316+
android:theme="@style/AppTheme.NoActionBar" />
313317
<activity
314318
android:name=".ActivityAssetCreateOrEdit"
315319
android:screenOrientation="portrait"

android/app/src/main/java/bitshares/BitsharesClientManager.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,19 @@ class BitsharesClientManager {
760760
return runSingleTransaction(opdata, EBitsharesOperations.ebo_htlc_extend, opdata.getString("update_issuer"))
761761
}
762762

763+
/**
764+
* OP - 创建锁仓(投票)
765+
*/
766+
fun ticketCreate(opdata: JSONObject): Promise {
767+
return runSingleTransaction(opdata, EBitsharesOperations.ebo_ticket_create, opdata.getString("account"))
768+
}
769+
770+
/**
771+
* OP - 更新锁仓(投票)
772+
*/
773+
fun ticketUpdate(opdata: JSONObject): Promise {
774+
return runSingleTransaction(opdata, EBitsharesOperations.ebo_ticket_update, opdata.getString("account"))
775+
}
763776
}
764777

765778

android/app/src/main/java/bitshares/GrapheneSerializer.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ open class T_Base_companion {
108108
T_htlc_create.register_subfields()
109109
T_htlc_redeem.register_subfields()
110110
T_htlc_extend.register_subfields()
111+
T_ticket_create.register_subfields()
112+
T_ticket_update.register_subfields()
111113
}
112114

113115
open fun register_subfields() {
@@ -1370,6 +1372,31 @@ class T_htlc_extend : T_Base() {
13701372
}
13711373
}
13721374

1375+
class T_ticket_create : T_Base() {
1376+
companion object : T_Base_companion() {
1377+
override fun register_subfields() {
1378+
add_field("fee", T_asset)
1379+
add_field("account", Tm_protocol_id_type(EBitsharesObjectType.ebot_account))
1380+
add_field("target_type", T_varint32) // see struct unsigned_int
1381+
add_field("amount", T_asset)
1382+
add_field("extensions", Tm_set(T_future_extensions))
1383+
}
1384+
}
1385+
}
1386+
1387+
class T_ticket_update : T_Base() {
1388+
companion object : T_Base_companion() {
1389+
override fun register_subfields() {
1390+
add_field("fee", T_asset)
1391+
add_field("ticket", Tm_protocol_id_type(EBitsharesObjectType.ebot_ticket))
1392+
add_field("account", Tm_protocol_id_type(EBitsharesObjectType.ebot_account))
1393+
add_field("target_type", T_varint32) // see struct unsigned_int
1394+
add_field("amount_for_new_target", Tm_optional(T_asset))
1395+
add_field("extensions", Tm_set(T_future_extensions))
1396+
}
1397+
}
1398+
}
1399+
13731400
class T_operation : T_Base() {
13741401
companion object : T_Base_companion() {
13751402
override fun to_byte_buffer(io: BinSerializer, opdata: Any?) {
@@ -1439,6 +1466,8 @@ class T_operation : T_Base() {
14391466
EBitsharesOperations.ebo_htlc_create.value -> T_htlc_create
14401467
EBitsharesOperations.ebo_htlc_redeem.value -> T_htlc_redeem
14411468
EBitsharesOperations.ebo_htlc_extend.value -> T_htlc_extend
1469+
EBitsharesOperations.ebo_ticket_create.value -> T_ticket_create
1470+
EBitsharesOperations.ebo_ticket_update.value -> T_ticket_update
14421471
else -> {
14431472
assert(false)
14441473
return T_transfer

android/app/src/main/java/bitshares/OrgUtils.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bitshares
22

33
import android.content.Context
44
import android.os.Looper
5+
import com.btsplusplus.fowallet.ActivityAssetOpStakeVote
56
import com.btsplusplus.fowallet.BuildConfig
67
import com.btsplusplus.fowallet.NativeInterface
78
import com.btsplusplus.fowallet.R
@@ -1070,6 +1071,13 @@ class OrgUtils {
10701071
EBitsharesOperations.ebo_htlc_refund.value -> {
10711072
container.put(opdata.getString("to"), true)
10721073
}
1074+
EBitsharesOperations.ebo_ticket_create.value -> {
1075+
container.put(opdata.getString("account"), true)
1076+
container.put(opdata.getJSONObject("amount").getString("asset_id"), true)
1077+
}
1078+
EBitsharesOperations.ebo_ticket_update.value -> {
1079+
container.put(opdata.getString("account"), true)
1080+
}
10731081
else -> {
10741082
}
10751083
}
@@ -1439,6 +1447,18 @@ class OrgUtils {
14391447
val to = chainMgr.getChainObjectByID(opdata.getString("to")).getString("name")
14401448
desc = String.format(R.string.kOpDesc_htlc_refund.xmlstring(ctx), to, opdata.getString("htlc_id"))
14411449
}
1450+
EBitsharesOperations.ebo_ticket_create.value -> {
1451+
name = R.string.kOpType_ticket_create.xmlstring(ctx)
1452+
val account = chainMgr.getChainObjectByID(opdata.getString("account")).getString("name")
1453+
val str_amount = formatAssetAmountItem(opdata.getJSONObject("amount"))
1454+
desc = String.format(R.string.kOpDesc_ticket_create.xmlstring(ctx),
1455+
account, str_amount, ActivityAssetOpStakeVote.getTicketTypeDesc(opdata.getInt("target_type"), ctx))
1456+
}
1457+
EBitsharesOperations.ebo_ticket_update.value -> {
1458+
name = R.string.kOpType_ticket_update.xmlstring(ctx)
1459+
val account = chainMgr.getChainObjectByID(opdata.getString("account")).getString("name")
1460+
desc = String.format(R.string.kOpDesc_ticket_update.xmlstring(ctx), account, opdata.getString("ticket"))
1461+
}
14421462
else -> {
14431463
}
14441464
}

android/app/src/main/java/bitshares/bts_chain_config.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ enum class EBitsharesAssetOpKind(val value: Int) {
4141
ebaok_reserve(102), // 资产销毁(仅UIA资产)
4242
ebaok_settle(103), // 资产清算(仅Smart资产)
4343
ebaok_call_order_update(104), // 调整债仓(仅Smart资产)
44+
ebaok_stake_vote(105), // 锁仓投票(仅BTS)
45+
ebaok_more(106), // 虚拟按钮:更多
4446
}
4547

4648
/**
@@ -117,6 +119,8 @@ enum class EBitsharesObjectType(val value: Int) {
117119
ebot_worker(14),
118120
ebot_balance(15),
119121
ebot_htlc(16),
122+
ebot_custom_authority(17), // 17
123+
ebot_ticket(18), // 18
120124
}
121125

122126
/**
@@ -177,6 +181,11 @@ enum class EBitsharesOperations(val value: Int) {
177181
ebo_htlc_redeemed(51), // VIRTUAL
178182
ebo_htlc_extend(52),
179183
ebo_htlc_refund(53), // VIRTUAL
184+
ebo_custom_authority_create(54),
185+
ebo_custom_authority_update(55),
186+
ebo_custom_authority_delete(56),
187+
ebo_ticket_create(57),
188+
ebo_ticket_update(58),
180189
}
181190

182191
/**

0 commit comments

Comments
 (0)