@@ -79,6 +79,8 @@ class WalletPlugin
79
79
" WALLET_CONFIRM_TRANSACTION" -> walletConfirmTransaction(args, callbackContext)
80
80
" WALLET_CONVERT" -> walletConvert(args, callbackContext)
81
81
" CONVERSION_TRANSACTIONS_SIZE" -> conversionTransactionsSize(args, callbackContext)
82
+ " CONVERSION_TRANSACTIONS_GET" -> conversionTransactionsGet(args, callbackContext)
83
+ " CONVERSION_IGNORED" -> conversionIgnored(args, callbackContext)
82
84
" PENDING_TRANSACTIONS_SIZE" -> pendingTransactionsSize(args, callbackContext)
83
85
" PENDING_TRANSACTIONS_GET" -> pendingTransactionsGet(args, callbackContext)
84
86
" BLOCK_DATE_FROM_SYSTEM_TIME" -> blockDateFromSystemTime(args, callbackContext)
@@ -90,7 +92,11 @@ class WalletPlugin
90
92
" SETTINGS_DELETE" -> settingsDelete(args, callbackContext)
91
93
" PROPOSAL_DELETE" -> proposalDelete(args, callbackContext)
92
94
" PENDING_TRANSACTIONS_DELETE" -> pendingTransactionsDelete(args, callbackContext)
93
- else -> return false
95
+ " CONVERSION_DELETE" -> conversionDelete(args, callbackContext)
96
+ else -> {
97
+ Log .w(TAG , " not found: $action " )
98
+ return false
99
+ }
94
100
}
95
101
return true
96
102
}
@@ -393,7 +399,7 @@ class WalletPlugin
393
399
)
394
400
val conversionId = nextConversionId.incrementAndGet()
395
401
conversionPool[conversionId] = conversion!!
396
- callbackContext.success(conversionId)
402
+ callbackContext.success(conversionId.toString() )
397
403
} catch (e: Exception ) {
398
404
callbackContext.error(e.message)
399
405
}
@@ -530,37 +536,37 @@ class WalletPlugin
530
536
}
531
537
}
532
538
533
- // @ExperimentalUnsignedTypes
534
- // @Throws(JSONException::class)
535
- // private fun conversionTransactionsGet(args: CordovaArgs, callbackContext: CallbackContext) {
536
- // val conversionId = args.getInt(0)
537
- // val index = args.getInt(1)
538
- // val conversion = conversionPool[conversionId]
539
- // try {
540
- // val transaction: ByteArray = conversion?.fragments?.get(index).serialize().toUbyteArray() .toByteArray()
541
- // callbackContext.success(transaction)
542
- // } catch (e: Exception) {
543
- // callbackContext.error(e.message)
544
- // }
545
- // }
546
-
547
- // @ExperimentalUnsignedTypes
548
- // @Throws(JSONException::class)
549
- // private fun conversionIgnored(args: CordovaArgs, callbackContext: CallbackContext) {
550
- // val conversionId = args.getInt(0)
551
- // val conversion = conversionPool[conversionId]
552
-
553
- // try {
554
- // val value = conversion?.ignoredValue
555
- // val count = conversion?.ignoredCount
556
-
557
- // val json = JSONObject().put("value", value).put("ignored", count)
558
- // callbackContext.success(json)
559
-
560
- // } catch (e: Exception) {
561
- // callbackContext.error(e.message)
562
- // }
563
- // }
539
+ @ExperimentalUnsignedTypes
540
+ @Throws(JSONException ::class )
541
+ private fun conversionTransactionsGet (args : CordovaArgs , callbackContext : CallbackContext ) {
542
+ val conversionId = args.getInt(0 )
543
+ val index = args.getInt(1 )
544
+ val conversion = conversionPool[conversionId]
545
+ try {
546
+ val transaction: ByteArray? = conversion?.fragments?.get(index)? .serialize()?.toUByteArray()? .toByteArray()
547
+ callbackContext.success(transaction)
548
+ } catch (e: Exception ) {
549
+ callbackContext.error(e.message)
550
+ }
551
+ }
552
+
553
+ @ExperimentalUnsignedTypes
554
+ @Throws(JSONException ::class )
555
+ private fun conversionIgnored (args : CordovaArgs , callbackContext : CallbackContext ) {
556
+ val conversionId = args.getInt(0 )
557
+ val conversion = conversionPool[conversionId]
558
+
559
+ try {
560
+ val value = conversion?.ignoredValue
561
+ val count = conversion?.ignoredCount
562
+
563
+ val json = JSONObject ().put(" value" , value).put(" ignored" , count)
564
+ callbackContext.success(json)
565
+
566
+ } catch (e: Exception ) {
567
+ callbackContext.error(e.message)
568
+ }
569
+ }
564
570
565
571
@ExperimentalUnsignedTypes
566
572
@Throws(JSONException ::class )
@@ -610,6 +616,18 @@ class WalletPlugin
610
616
}
611
617
}
612
618
619
+ @ExperimentalUnsignedTypes
620
+ @Throws(JSONException ::class )
621
+ private fun conversionDelete (args : CordovaArgs , callbackContext : CallbackContext ) {
622
+ val cid: Int = args.getInt(0 )
623
+ try {
624
+ conversionPool.remove(cid)
625
+ callbackContext.success()
626
+ } catch (e: Exception ) {
627
+ callbackContext.error(e.message)
628
+ }
629
+ }
630
+
613
631
companion object {
614
632
const val TAG = " WALLET"
615
633
}
0 commit comments