@@ -44,19 +44,20 @@ const allowedOperations = [
44
44
"rmvproducer" ,
45
45
"updtrevision" ,
46
46
"bidname" ,
47
- "bidrefund"
47
+ "bidrefund" ,
48
+ "ramtransfer" ,
48
49
] ;
49
50
50
51
/**
51
52
* Convert an array of operations into a readable format
52
- * @param {Object } operation
53
- * @returns
53
+ * @param {Object } operation
54
+ * @returns
54
55
*/
55
- export default async function beautify ( operation ) {
56
+ export default async function beautify ( operation ) {
56
57
if ( ! operation || ! operation . name ) {
57
58
return ;
58
59
}
59
-
60
+
60
61
const opType = operation . name ;
61
62
62
63
if ( ! allowedOperations . includes ( opType ) ) {
@@ -74,9 +75,9 @@ export default async function beautify (operation) {
74
75
if ( opType === "transfer" ) {
75
76
/**
76
77
* Transferring tokens action.
77
- *
78
+ *
78
79
* @details Transfer tokens from account to account.
79
- *
80
+ *
80
81
* @param from - the account to transfer from,
81
82
* @param to - the account to be transferred to,
82
83
* @param quantity - the quantity of tokens to be transferred,
@@ -92,7 +93,6 @@ export default async function beautify (operation) {
92
93
{ key : "quantity" , params : { quantity : quantity } } ,
93
94
{ key : "memo" , params : { memo : memo ?? "" } } ,
94
95
] ;
95
-
96
96
} else if ( opType === "setalimits" ) {
97
97
/**
98
98
* Set account limits action.
@@ -169,7 +169,10 @@ export default async function beautify (operation) {
169
169
*/
170
170
const feature_digest = operation . data . feature_digest ;
171
171
currentOperation [ "rows" ] = [
172
- { key : "feature_digest" , params : { feature_digest : feature_digest } } ,
172
+ {
173
+ key : "feature_digest" ,
174
+ params : { feature_digest : feature_digest } ,
175
+ } ,
173
176
] ;
174
177
} else if ( opType === "delegatebw" ) {
175
178
// functions defined in delegate_bandwidth.cpp
@@ -197,11 +200,16 @@ export default async function beautify (operation) {
197
200
currentOperation [ "rows" ] = [
198
201
{ key : "from" , params : { from : from } } ,
199
202
{ key : "receiver" , params : { receiver : receiver } } ,
200
- { key : "stake_net_quantity" , params : { stake_net_quantity : stake_net_quantity } } ,
201
- { key : "stake_cpu_quantity" , params : { stake_cpu_quantity : stake_cpu_quantity } } ,
203
+ {
204
+ key : "stake_net_quantity" ,
205
+ params : { stake_net_quantity : stake_net_quantity } ,
206
+ } ,
207
+ {
208
+ key : "stake_cpu_quantity" ,
209
+ params : { stake_cpu_quantity : stake_cpu_quantity } ,
210
+ } ,
202
211
{ key : "transfer" , params : { transfer : transfer } } ,
203
212
] ;
204
-
205
213
} else if ( opType === "setrex" ) {
206
214
/**
207
215
* Setrex action.
@@ -333,9 +341,7 @@ export default async function beautify (operation) {
333
341
* @pre Order cannot be cancelled once it's been filled.
334
342
*/
335
343
const owner = operation . data . owner ;
336
- currentOperation [ "rows" ] = [
337
- { key : "owner" , params : { owner : owner } } ,
338
- ] ;
344
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
339
345
} else if ( opType === "rentcpu" ) {
340
346
/**
341
347
* Rentcpu action.
@@ -469,7 +475,7 @@ export default async function beautify (operation) {
469
475
{ key : "from" , params : { from : from } } ,
470
476
{ key : "loan_num" , params : { loan_num : loan_num } } ,
471
477
{ key : "amount" , params : { amount : amount } } ,
472
- ] ;
478
+ ] ;
473
479
} else if ( opType === "updaterex" ) {
474
480
/**
475
481
* Updaterex action.
@@ -478,11 +484,9 @@ export default async function beautify (operation) {
478
484
*
479
485
* @param owner - REX owner account.
480
486
*/
481
-
487
+
482
488
const owner = operation . data . owner ;
483
- currentOperation [ "rows" ] = [
484
- { key : "owner" , params : { owner : owner } } ,
485
- ] ;
489
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
486
490
} else if ( opType === "rexexec" ) {
487
491
/**
488
492
* Rexexec action.
@@ -509,9 +513,7 @@ export default async function beautify (operation) {
509
513
* @param owner - REX owner account name.
510
514
*/
511
515
const owner = operation . data . owner ;
512
- currentOperation [ "rows" ] = [
513
- { key : "owner" , params : { owner : owner } } ,
514
- ] ;
516
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
515
517
} else if ( opType === "mvtosavings" ) {
516
518
/**
517
519
* Mvtosavings action.
@@ -561,9 +563,7 @@ export default async function beautify (operation) {
561
563
* REX fund entry is deleted.
562
564
*/
563
565
const owner = operation . data . owner ;
564
- currentOperation [ "rows" ] = [
565
- { key : "owner" , params : { owner : owner } } ,
566
- ] ;
566
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
567
567
} else if ( opType === "undelegatebw" ) {
568
568
/**
569
569
* Undelegate bandwitdh action.
@@ -601,8 +601,14 @@ export default async function beautify (operation) {
601
601
currentOperation [ "rows" ] = [
602
602
{ key : "from" , params : { from : from } } ,
603
603
{ key : "receiver" , params : { receiver : receiver } } ,
604
- { key : "unstake_net_quantity" , params : { unstake_net_quantity : unstake_net_quantity } } ,
605
- { key : "unstake_cpu_quantity" , params : { unstake_cpu_quantity : unstake_cpu_quantity } } ,
604
+ {
605
+ key : "unstake_net_quantity" ,
606
+ params : { unstake_net_quantity : unstake_net_quantity } ,
607
+ } ,
608
+ {
609
+ key : "unstake_cpu_quantity" ,
610
+ params : { unstake_cpu_quantity : unstake_cpu_quantity } ,
611
+ } ,
606
612
] ;
607
613
} else if ( opType === "buyram" ) {
608
614
/**
@@ -669,9 +675,7 @@ export default async function beautify (operation) {
669
675
* @param owner - the owner of the tokens claimed.
670
676
*/
671
677
const owner = operation . data . owner ;
672
- currentOperation [ "rows" ] = [
673
- { key : "owner" , params : { owner : owner } } ,
674
- ] ;
678
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
675
679
} else if ( opType === "regproducer" ) {
676
680
// functions defined in voting.cpp
677
681
@@ -711,7 +715,7 @@ export default async function beautify (operation) {
711
715
const producer = operation . data . producer ;
712
716
currentOperation [ "rows" ] = [
713
717
{ key : "producer" , params : { producer : producer } } ,
714
- ] ;
718
+ ] ;
715
719
} else if ( opType === "setram" ) {
716
720
/**
717
721
* Set ram action.
@@ -735,7 +739,10 @@ export default async function beautify (operation) {
735
739
*/
736
740
const bytes_per_block = operation . data . bytes_per_block ;
737
741
currentOperation [ "rows" ] = [
738
- { key : "bytes_per_block" , params : { bytes_per_block : bytes_per_block } } ,
742
+ {
743
+ key : "bytes_per_block" ,
744
+ params : { bytes_per_block : bytes_per_block } ,
745
+ } ,
739
746
] ;
740
747
} else if ( opType === "voteproducer" ) {
741
748
/**
@@ -770,7 +777,7 @@ export default async function beautify (operation) {
770
777
{ key : "voter" , params : { voter : voter } } ,
771
778
{ key : "proxy" , params : { proxy : proxy } } ,
772
779
{ key : "producers" , params : { producers : producers } } ,
773
- ] ;
780
+ ] ;
774
781
} else if ( opType === "regproxy" ) {
775
782
/**
776
783
* Register proxy action.
@@ -803,7 +810,10 @@ export default async function beautify (operation) {
803
810
*/
804
811
const params = JSON . stringify ( operation . data . params , null , 2 ) ;
805
812
currentOperation [ "rows" ] = [
806
- { key : "params" , params : { params : JSON . stringify ( params , null , 2 ) } } ,
813
+ {
814
+ key : "params" ,
815
+ params : { params : JSON . stringify ( params , null , 2 ) } ,
816
+ } ,
807
817
] ;
808
818
} else if ( opType === "claimrewards" ) {
809
819
// functions defined in producer_pay.cpp
@@ -814,9 +824,7 @@ export default async function beautify (operation) {
814
824
* @param owner - producer account claiming per-block and per-vote rewards.
815
825
*/
816
826
const owner = operation . data . owner ;
817
- currentOperation [ "rows" ] = [
818
- { key : "owner" , params : { owner : owner } } ,
819
- ] ;
827
+ currentOperation [ "rows" ] = [ { key : "owner" , params : { owner : owner } } ] ;
820
828
} else if ( opType === "setpriv" ) {
821
829
/**
822
830
* Set privilege status for an account.
@@ -898,7 +906,25 @@ export default async function beautify (operation) {
898
906
{ key : "bidder" , params : { bidder : bidder } } ,
899
907
{ key : "newname" , params : { newname : newname } } ,
900
908
] ;
909
+ } else if ( opType === "ramtransfer" ) {
910
+ /**
911
+ * Ram transfer action.
912
+ *
913
+ * @details Allows an account `from` to transfer ram to another account `to`.
914
+ *
915
+ * @param from - the account sending ram,
916
+ * @param to - the account receiving ram,
917
+ * @param bytes - the amount of ram to be sent.
918
+ */
919
+ const from = operation . data . from ;
920
+ const to = operation . data . to ;
921
+ const bytes = operation . data . bytes ;
922
+ currentOperation [ "rows" ] = [
923
+ { key : "from" , params : { from : from } } ,
924
+ { key : "to" , params : { to : to } } ,
925
+ { key : "bytes" , params : { bytes : bytes } } ,
926
+ ] ;
901
927
}
902
928
903
929
return currentOperation ;
904
- }
930
+ }
0 commit comments