@stellar-expert/ui-framework 1.16.7 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CLAUDE.md +35 -0
  2. package/README.md +1125 -3
  3. package/account/account-address.js +127 -127
  4. package/account/available-balance.js +22 -22
  5. package/account/identicon.js +90 -90
  6. package/account/signer-key.js +65 -64
  7. package/api/explorer-api-hooks.js +209 -202
  8. package/api/explorer-api-paginated-list-hooks.js +441 -440
  9. package/api/explorer-batch-info-loader.js +111 -85
  10. package/api/explorer-tx-api.js +28 -28
  11. package/api/ledger-stream.js +15 -0
  12. package/asset/amount.js +56 -56
  13. package/asset/asset-icon.js +41 -41
  14. package/asset/asset-issuer.js +21 -21
  15. package/asset/asset-link.js +107 -107
  16. package/asset/asset-list-hooks.js +59 -59
  17. package/asset/asset-meta-hooks.js +88 -88
  18. package/asset/asset-selector.js +72 -71
  19. package/basic-styles/base.scss +50 -50
  20. package/basic-styles/grid.scss +1 -1
  21. package/basic-styles/table.scss +1 -1
  22. package/claimable-balance/claimable-balance-claimants.js +5 -0
  23. package/contract/contract-api.js +15 -0
  24. package/contract/invocation-info-view.js +10 -2
  25. package/contract/sc-val.js +24 -0
  26. package/controls/button-group.js +25 -19
  27. package/controls/button-group.scss +46 -46
  28. package/controls/button.js +93 -78
  29. package/controls/button.scss +173 -173
  30. package/controls/code-block.js +42 -34
  31. package/controls/code-block.scss +71 -71
  32. package/controls/dropdown.js +318 -287
  33. package/controls/dropdown.scss +159 -159
  34. package/controls/external-link.js +10 -4
  35. package/controls/info-tooltip.js +23 -16
  36. package/controls/slider.js +29 -19
  37. package/controls/tabs.js +94 -94
  38. package/controls/tabs.scss +70 -70
  39. package/controls/tooltip.js +244 -240
  40. package/controls/tooltip.scss +116 -116
  41. package/controls/update-highlighter.js +32 -27
  42. package/controls/update-highlighter.scss +7 -7
  43. package/date/date-selector.js +56 -54
  44. package/date/elapsed-time.js +28 -21
  45. package/dex/price-dynamic.js +53 -44
  46. package/dex/price-dynamic.scss +33 -33
  47. package/directory/directory-hooks.js +109 -97
  48. package/effect/effect-description.js +5 -3
  49. package/errors/error-boundary.js +110 -97
  50. package/horizon/horizon-account-helpers.js +104 -104
  51. package/horizon/horizon-ledger-helpers.js +35 -35
  52. package/horizon/horizon-trades-helper.js +88 -88
  53. package/horizon/horizon-transaction-helpers.js +36 -36
  54. package/index.d.ts +1241 -0
  55. package/interaction/accordion.js +43 -35
  56. package/interaction/autofocus.js +13 -9
  57. package/interaction/block-select.js +64 -53
  58. package/interaction/block-select.scss +21 -21
  59. package/interaction/copy-to-clipboard.js +25 -18
  60. package/interaction/inline-progress.js +20 -15
  61. package/interaction/qr-code.js +34 -34
  62. package/interaction/responsive.js +20 -20
  63. package/interaction/spoiler.js +52 -39
  64. package/interaction/spoiler.scss +6 -6
  65. package/interaction/theme-selector.js +13 -10
  66. package/ledger/ledger-entry-href-formatter.js +4 -3
  67. package/ledger/ledger-entry-link.js +93 -58
  68. package/ledger/ledger-info-parser.js +28 -0
  69. package/meta/page-meta-tags.js +243 -238
  70. package/module/dynamic-module.js +47 -47
  71. package/package.json +3 -2
  72. package/state/on-screen-hooks.js +22 -22
  73. package/state/page-visibility-helpers.js +29 -16
  74. package/state/page-visibility-hooks.js +13 -11
  75. package/state/screen-orientation-hooks.js +19 -15
  76. package/state/state-hooks.js +76 -76
  77. package/state/stellar-network-hooks.js +56 -44
  78. package/state/theme.js +29 -28
  79. package/stellar/key-type.js +92 -91
  80. package/stellar/ledger-generic-id.js +39 -39
  81. package/stellar/signature-hint-utils.js +65 -65
  82. package/toast/toast-notifications-block.js +59 -59
  83. package/toast/toast-notifications.scss +1 -1
  84. package/tx/op-description-view.js +84 -81
  85. package/tx/op-icon.js +98 -98
  86. package/tx/parser/op-balance-changes.js +66 -66
  87. package/tx/parser/op-descriptor.js +51 -48
  88. package/tx/parser/tx-details-parser.js +81 -81
  89. package/tx/parser/tx-matcher.js +371 -371
  90. package/tx/parser/type-filter-matcher.js +126 -126
  91. package/tx/tx-list-hooks.js +32 -18
  92. package/tx/tx-operations-list.js +117 -116
@@ -17,15 +17,25 @@ import {useStellarNetwork} from '../state/stellar-network-hooks'
17
17
  import InvocationInfoView from '../contract/invocation-info-view'
18
18
  import {ClaimableBalanceId} from '../claimable-balance/claimable-balance-id'
19
19
 
20
- function getAccountPredefinedDisplayName(address) {
21
- if (!window.predefinedAccountDisplayNames)
22
- return undefined
23
- return window.predefinedAccountDisplayNames[address]
24
- }
20
+ /**
21
+ * Detailed operation description within a transaction
22
+ * @param {OperationDescriptor} op
23
+ * @param {boolean} [compact]
24
+ * @constructor
25
+ */
26
+ export const OpDescriptionView = React.memo(function OpDescriptionView({op, compact = false}) {
27
+ const render = typeMapping[op.operation.type]
28
+ if (!render) {
29
+ console.warn(`No operation text type mapping for operation ${op.operation.type}`)
30
+ return null
31
+ }
32
+ return React.createElement(render, {op, compact})
33
+ })
25
34
 
26
35
  /**
36
+ * Renders operation source account
27
37
  * @param {OperationDescriptor} op
28
- * @param {Boolean} compact
38
+ * @param {boolean} compact
29
39
  * @constructor
30
40
  */
31
41
  function OpSourceAccount({op, compact}) {
@@ -48,8 +58,9 @@ function OpSourceAccount({op, compact}) {
48
58
 
49
59
 
50
60
  /**
61
+ * CreateAccount operation (type 0)
51
62
  * @param {OperationDescriptor} op
52
- * @param {Boolean} compact
63
+ * @param {boolean} compact
53
64
  * @constructor
54
65
  */
55
66
  function CreateAccountDescriptionView({op, compact}) {
@@ -65,9 +76,9 @@ function CreateAccountDescriptionView({op, compact}) {
65
76
  }
66
77
 
67
78
  /**
68
- * Type: 1
79
+ * Payment operation (type 1)
69
80
  * @param {OperationDescriptor} op
70
- * @param {Boolean} compact
81
+ * @param {boolean} compact
71
82
  * @constructor
72
83
  */
73
84
  function PaymentDescriptionView({op, compact}) {
@@ -83,9 +94,9 @@ function PaymentDescriptionView({op, compact}) {
83
94
  }
84
95
 
85
96
  /**
86
- * Type: 2, 13
97
+ * Description view for PathPayment operations (types 2, 13)
87
98
  * @param {OperationDescriptor} op
88
- * @param {Boolean} compact
99
+ * @param {boolean} compact
89
100
  * @constructor
90
101
  */
91
102
  function PathPaymentDescriptionView({op, compact}) {
@@ -155,9 +166,9 @@ function PathPaymentDescriptionView({op, compact}) {
155
166
  }
156
167
 
157
168
  /**
158
- * Type: 3, 4, 12
169
+ * Description view for ManageSellOffer/ManageBuyOffer/CreatePassiveSellOffer operations (types 3, 4, 12)
159
170
  * @param {OperationDescriptor} op
160
- * @param {Boolean} compact
171
+ * @param {boolean} compact
161
172
  * @constructor
162
173
  */
163
174
  function ManageOfferDescriptionView({op, compact}) {
@@ -232,9 +243,9 @@ function AccountFlags({flags}) {
232
243
  }
233
244
 
234
245
  /**
235
- * Type: 5
246
+ * SetOptions operation (type 5)
236
247
  * @param {OperationDescriptor} op
237
- * @param {Boolean} compact
248
+ * @param {boolean} compact
238
249
  * @constructor
239
250
  */
240
251
  function SetOptionsDescriptionView({op, compact}) {
@@ -305,9 +316,9 @@ function SetOptionsDescriptionView({op, compact}) {
305
316
  }
306
317
 
307
318
  /**
308
- * Type: 6
319
+ * ChangeTrust operation (type 6)
309
320
  * @param {OperationDescriptor} op
310
- * @param {Boolean} compact
321
+ * @param {boolean} compact
311
322
  * @constructor
312
323
  */
313
324
  function ChangeTrustDescriptionView({op, compact}) {
@@ -338,9 +349,9 @@ function ChangeTrustDescriptionView({op, compact}) {
338
349
  }
339
350
 
340
351
  /**
341
- * Type: 7
352
+ * AllowTrust operation (type 7)
342
353
  * @param {OperationDescriptor} op
343
- * @param {Boolean} compact
354
+ * @param {boolean} compact
344
355
  * @constructor
345
356
  */
346
357
  function AllowTrustDescriptionView({op, compact}) {
@@ -360,9 +371,9 @@ function AllowTrustDescriptionView({op, compact}) {
360
371
  }
361
372
 
362
373
  /**
363
- * Type: 8
374
+ * AccountMerge operation (type 8)
364
375
  * @param {OperationDescriptor} op
365
- * @param {Boolean} compact
376
+ * @param {boolean} compact
366
377
  * @constructor
367
378
  */
368
379
  function MergeAccountDescriptionView({op, compact}) {
@@ -378,9 +389,9 @@ function MergeAccountDescriptionView({op, compact}) {
378
389
  }
379
390
 
380
391
  /**
381
- * Type: 9
392
+ * Inflation operation (type 9)
382
393
  * @param {OperationDescriptor} op
383
- * @param {Boolean} compact
394
+ * @param {boolean} compact
384
395
  * @constructor
385
396
  */
386
397
  function InflationDescriptionView({op, compact}) {
@@ -394,9 +405,9 @@ function InflationDescriptionView({op, compact}) {
394
405
  }
395
406
 
396
407
  /**
397
- * Type: 10
408
+ * ManageData operation (type 10)
398
409
  * @param {OperationDescriptor} op
399
- * @param {Boolean} compact
410
+ * @param {boolean} compact
400
411
  * @constructor
401
412
  */
402
413
  function ManageDataDescriptionView({op, compact}) {
@@ -422,9 +433,9 @@ function ManageDataDescriptionView({op, compact}) {
422
433
  }
423
434
 
424
435
  /**
425
- * Type: 11
436
+ * BumpSequence operation (type 11)
426
437
  * @param {OperationDescriptor} op
427
- * @param {Boolean} compact
438
+ * @param {boolean} compact
428
439
  * @constructor
429
440
  */
430
441
  function BumpSequenceDescriptionView({op, compact}) {
@@ -439,9 +450,9 @@ function BumpSequenceDescriptionView({op, compact}) {
439
450
  }
440
451
 
441
452
  /**
442
- * Type: 14
453
+ * CreateClaimableBalance operation (type 14)
443
454
  * @param {OperationDescriptor} op
444
- * @param {Boolean} compact
455
+ * @param {boolean} compact
445
456
  * @constructor
446
457
  */
447
458
  function CreateClaimableBalanceDescriptionView({op, compact}) {
@@ -464,9 +475,9 @@ function CreateClaimableBalanceDescriptionView({op, compact}) {
464
475
  }
465
476
 
466
477
  /**
467
- * Type: 15
478
+ * ClaimClaimableBalance operation (type 15)
468
479
  * @param {OperationDescriptor} op
469
- * @param {Boolean} compact
480
+ * @param {boolean} compact
470
481
  * @constructor
471
482
  */
472
483
  function ClaimClaimableBalanceDescriptionView({op, compact}) {
@@ -482,9 +493,9 @@ function ClaimClaimableBalanceDescriptionView({op, compact}) {
482
493
  }
483
494
 
484
495
  /**
485
- * Type: 16
496
+ * BeginSponsoringFutureReserves operation (type 16)
486
497
  * @param {OperationDescriptor} op
487
- * @param {Boolean} compact
498
+ * @param {boolean} compact
488
499
  * @constructor
489
500
  */
490
501
  function BeginSponsoringFutureReservesDescriptionView({op, compact}) {
@@ -499,9 +510,9 @@ function BeginSponsoringFutureReservesDescriptionView({op, compact}) {
499
510
  }
500
511
 
501
512
  /**
502
- * Type: 17
513
+ * EndSponsoringFutureReserves operation (type 17)
503
514
  * @param {OperationDescriptor} op
504
- * @param {Boolean} compact
515
+ * @param {boolean} compact
505
516
  * @constructor
506
517
  */
507
518
  function EndSponsoringFutureReservesDescriptionView({op, compact}) {
@@ -515,9 +526,9 @@ function EndSponsoringFutureReservesDescriptionView({op, compact}) {
515
526
  }
516
527
 
517
528
  /**
518
- * Type: 18
529
+ * RevokeAccountSponsorship operation (type 18)
519
530
  * @param {OperationDescriptor} op
520
- * @param {Boolean} compact
531
+ * @param {boolean} compact
521
532
  * @constructor
522
533
  */
523
534
  function RevokeAccountSponsorshipDescriptionView({op, compact}) {
@@ -532,9 +543,9 @@ function RevokeAccountSponsorshipDescriptionView({op, compact}) {
532
543
  }
533
544
 
534
545
  /**
535
- * Type: 18
546
+ * RevokeSignerSponsorship operation (type 18)
536
547
  * @param {OperationDescriptor} op
537
- * @param {Boolean} compact
548
+ * @param {boolean} compact
538
549
  * @constructor
539
550
  */
540
551
  function RevokeSignerSponsorshipDescriptionView({op, compact}) {
@@ -552,9 +563,9 @@ function RevokeSignerSponsorshipDescriptionView({op, compact}) {
552
563
  }
553
564
 
554
565
  /**
555
- * Type: 18
566
+ * RevokeTrustlineSponsorship operation (type 18)
556
567
  * @param {OperationDescriptor} op
557
- * @param {Boolean} compact
568
+ * @param {boolean} compact
558
569
  * @constructor
559
570
  */
560
571
  function RevokeTrustlineSponsorshipDescriptionView({op, compact}) {
@@ -571,9 +582,9 @@ function RevokeTrustlineSponsorshipDescriptionView({op, compact}) {
571
582
  }
572
583
 
573
584
  /**
574
- * Type: 18
585
+ * RevokeOfferSponsorship operation (type 18)
575
586
  * @param {OperationDescriptor} op
576
- * @param {Boolean} compact
587
+ * @param {boolean} compact
577
588
  * @constructor
578
589
  */
579
590
  function RevokeOfferSponsorshipDescriptionView({op, compact}) {
@@ -590,9 +601,9 @@ function RevokeOfferSponsorshipDescriptionView({op, compact}) {
590
601
  }
591
602
 
592
603
  /**
593
- * Type: 18
604
+ * RevokeDataSponsorship operation (type 18)
594
605
  * @param {OperationDescriptor} op
595
- * @param {Boolean} compact
606
+ * @param {boolean} compact
596
607
  * @constructor
597
608
  */
598
609
  function RevokeDataSponsorshipDescriptionView({op, compact}) {
@@ -609,9 +620,9 @@ function RevokeDataSponsorshipDescriptionView({op, compact}) {
609
620
  }
610
621
 
611
622
  /**
612
- * Type: 18
623
+ * RevokeClaimableBalanceSponsorship operation (type 18)
613
624
  * @param {OperationDescriptor} op
614
- * @param {Boolean} compact
625
+ * @param {boolean} compact
615
626
  * @constructor
616
627
  */
617
628
  function RevokeClaimableBalanceSponsorshipDescriptionView({op, compact}) {
@@ -627,9 +638,9 @@ function RevokeClaimableBalanceSponsorshipDescriptionView({op, compact}) {
627
638
  }
628
639
 
629
640
  /**
630
- * Type: 18
641
+ * RevokeLiquidityPoolSponsorship operation (type 18)
631
642
  * @param {OperationDescriptor} op
632
- * @param {Boolean} compact
643
+ * @param {boolean} compact
633
644
  * @constructor
634
645
  */
635
646
  function RevokeLiquidityPoolSponsorshipDescriptionView({op, compact}) {
@@ -645,9 +656,9 @@ function RevokeLiquidityPoolSponsorshipDescriptionView({op, compact}) {
645
656
  }
646
657
 
647
658
  /**
648
- * Type: 19
659
+ * Clawback operation (type 19)
649
660
  * @param {OperationDescriptor} op
650
- * @param {Boolean} compact
661
+ * @param {boolean} compact
651
662
  * @constructor
652
663
  */
653
664
  function ClawbackDescriptionView({op, compact}) {
@@ -664,9 +675,9 @@ function ClawbackDescriptionView({op, compact}) {
664
675
  }
665
676
 
666
677
  /**
667
- * Type: 20
678
+ * ClawbackClaimableBalance operation (type 20)
668
679
  * @param {OperationDescriptor} op
669
- * @param {Boolean} compact
680
+ * @param {boolean} compact
670
681
  * @constructor
671
682
  */
672
683
  function ClawbackClaimableBalanceDescriptionView({op, compact}) {
@@ -681,9 +692,9 @@ function ClawbackClaimableBalanceDescriptionView({op, compact}) {
681
692
  }
682
693
 
683
694
  /**
684
- * Type: 21
695
+ * SetTrustLineFlags operation (type 21)
685
696
  * @param {OperationDescriptor} op
686
- * @param {Boolean} compact
697
+ * @param {boolean} compact
687
698
  * @constructor
688
699
  */
689
700
  function SetTrustLineFlagsDescriptionView({op, compact}) {
@@ -714,9 +725,9 @@ function SetTrustLineFlagsDescriptionView({op, compact}) {
714
725
  }
715
726
 
716
727
  /**
717
- * Type: 22
728
+ * LiquidityPoolDeposit operation (type 22)
718
729
  * @param {OperationDescriptor} op
719
- * @param {Boolean} compact
730
+ * @param {boolean} compact
720
731
  * @constructor
721
732
  */
722
733
  function DepositLiquidityDescriptionView({op, compact}) {
@@ -739,9 +750,9 @@ function DepositLiquidityDescriptionView({op, compact}) {
739
750
  }
740
751
 
741
752
  /**
742
- * Type: 23
753
+ * LiquidityPoolWithdraw operation (type 23)
743
754
  * @param {OperationDescriptor} op
744
- * @param {Boolean} compact
755
+ * @param {boolean} compact
745
756
  * @constructor
746
757
  */
747
758
  function WithdrawLiquidityDescriptionView({op, compact}) {
@@ -764,9 +775,9 @@ function WithdrawLiquidityDescriptionView({op, compact}) {
764
775
  }
765
776
 
766
777
  /**
767
- * Type: 24
778
+ * InvokeHostFunction operation (type 24) — Soroban contract calls
768
779
  * @param {OperationDescriptor} op
769
- * @param {Boolean} compact
780
+ * @param {boolean} compact
770
781
  * @constructor
771
782
  */
772
783
  function InvokeHostFunctionView({op, compact}) {
@@ -856,9 +867,9 @@ function InvokeHostFunctionView({op, compact}) {
856
867
  }
857
868
 
858
869
  /**
859
- * Type: 25
870
+ * ExtendFootprintTTL operation (type 25)
860
871
  * @param {OperationDescriptor} op
861
- * @param {Boolean} compact
872
+ * @param {boolean} compact
862
873
  * @constructor
863
874
  */
864
875
  function ExtendFootprintTTLView({op}) {
@@ -874,9 +885,9 @@ function ExtendFootprintTTLView({op}) {
874
885
  }
875
886
 
876
887
  /**
877
- * Type: 26
888
+ * RestoreFootprint operation (type 26)
878
889
  * @param {OperationDescriptor} op
879
- * @param {Boolean} compact
890
+ * @param {boolean} compact
880
891
  * @constructor
881
892
  */
882
893
  function RestoreFootprintView({op}) {
@@ -890,6 +901,13 @@ function RestoreFootprintView({op}) {
890
901
  </>
891
902
  }
892
903
 
904
+
905
+ function getAccountPredefinedDisplayName(address) {
906
+ if (!window.predefinedAccountDisplayNames)
907
+ return undefined
908
+ return window.predefinedAccountDisplayNames[address]
909
+ }
910
+
893
911
  const typeMapping = {
894
912
  createAccount: CreateAccountDescriptionView,
895
913
  payment: PaymentDescriptionView,
@@ -924,19 +942,4 @@ const typeMapping = {
924
942
  invokeHostFunction: InvokeHostFunctionView,
925
943
  extendFootprintTtl: ExtendFootprintTTLView,
926
944
  restoreFootprint: RestoreFootprintView
927
- }
928
-
929
- /**
930
- * Text description of a tx operation
931
- * @param {OperationDescriptor} op
932
- * @param {Boolean} [compact]
933
- * @constructor
934
- */
935
- export const OpDescriptionView = React.memo(function OpDescriptionView({op, compact = false}) {
936
- const render = typeMapping[op.operation.type]
937
- if (!render) {
938
- console.warn(`No operation text type mapping for operation ${op.operation.type}`)
939
- return null
940
- }
941
- return React.createElement(render, {op, compact})
942
- })
945
+ }
package/tx/op-icon.js CHANGED
@@ -1,99 +1,99 @@
1
- import React from 'react'
2
- import cn from 'classnames'
3
-
4
- const opIconMapping = {
5
- feeCharge: 'send-circle',
6
- createAccount: 'hexagon-add',
7
- payment: 'send-circle',
8
- paymentReceive: 'receive-circle',
9
- pathPaymentStrictReceive: 'swap',
10
- manageSellOffer: 'dex-offer',
11
- createPassiveSellOffer: 'dex-offer',
12
- setOptions: 'hexagon-set-options',
13
- changeTrust: 'trustlines',
14
- changeTrustAdd: 'create-trustline',
15
- changeTrustRemove: 'remove-trustline',
16
- changeTrustUpdate: 'trustline-flags',
17
- allowTrust: 'trustline-flags',
18
- accountMerge: 'hexagon-remove',
19
- accountMergeReceive: 'receive-circle',
20
- inflation: 'hexagon-inflation',
21
- manageData: 'grid',
22
- manageDataAdd: 'grid-add',
23
- manageDataRemove: 'grid-remove',
24
- bumpSequence: 'upload',
25
- manageBuyOffer: 'dex-offer',
26
- pathPaymentStrictSend: 'swap',
27
- createClaimableBalance: 'shutdown-circle',
28
- claimClaimableBalance: 'icon-ok',
29
- claimClaimableBalanceReceive: 'receive-circle',
30
- beginSponsoringFutureReserves: 'sponsor',
31
- endSponsoringFutureReserves: 'sponsor',
32
- revoke: 'revoke',
33
- revokeAccountSponsorship: 'revoke',
34
- revokeTrustlineSponsorship: 'revoke',
35
- revokeOfferSponsorship: 'revoke',
36
- revokeDataSponsorship: 'revoke',
37
- revokeClaimableBalanceSponsorship: 'revoke',
38
- revokeLiquidityPoolSponsorship: 'revoke',
39
- revokeSignerSponsorship: 'revoke',
40
- clawback: 'clawback',
41
- clawbackReceive: 'send-circle',
42
- clawbackClaimableBalance: 'icon-ok',
43
- setTrustLineFlags: 'trustline-flags',
44
- liquidityPoolDeposit: 'droplet',
45
- liquidityPoolWithdraw: 'droplet-half',
46
- invokeHostFunction: 'flash',
47
- extendFootprintTtl: 'upload',
48
- restoreFootprint: 'upload'
49
- }
50
-
51
- /**
52
- * Transaction operation icon
53
- * @param {OperationDescriptor|'feeCharge'} op - Operation descriptor
54
- * @param {Boolean} failed - Whether the transaction failed during execution
55
- * @constructor
56
- */
57
- export const OpIcon = React.memo(function OpIcon({op, failed = false}) {
58
- let type
59
- let title
60
- if (op === 'feeCharge') {
61
- type = 'feeCharge'
62
- title = 'Transaction fees charge'
63
- } else {
64
- const {operation} = op
65
- title = type = operation.type
66
- title = title[0].toUpperCase() + title.substring(1) + ' operation'
67
- switch (type) {
68
- case 'payment':
69
- case 'accountMerge':
70
- case 'claimClaimableBalance':
71
- case 'clawback':
72
- if (!op.context?.account?.includes(operation.source)) {
73
- type += 'Receive'
74
- }
75
- break
76
- case 'manageData':
77
- if (operation.effects.some(e => e.type === 'dataEntryCreated')) {
78
- type += 'Add'
79
- } else if (operation.effects.some(e => e.type === 'dataEntryRemoved')) {
80
- type += 'Remove'
81
- }
82
- break
83
- case 'changeTrust':
84
- if (operation.limit > 0) {
85
- type += 'Add'
86
- } else {
87
- type += 'Remove'
88
- }
89
- break
90
- }
91
- }
92
- if (failed) {
93
- title += ' - Transaction failed'
94
- }
95
- const icon = opIconMapping[type]
96
- return <div className={cn('op-icon', {failed})} title={title}>
97
- <i className={`icon-${icon}`}/>
98
- </div>
1
+ import React from 'react'
2
+ import cn from 'classnames'
3
+
4
+ const opIconMapping = {
5
+ feeCharge: 'send-circle',
6
+ createAccount: 'hexagon-add',
7
+ payment: 'send-circle',
8
+ paymentReceive: 'receive-circle',
9
+ pathPaymentStrictReceive: 'swap',
10
+ manageSellOffer: 'dex-offer',
11
+ createPassiveSellOffer: 'dex-offer',
12
+ setOptions: 'hexagon-set-options',
13
+ changeTrust: 'trustlines',
14
+ changeTrustAdd: 'create-trustline',
15
+ changeTrustRemove: 'remove-trustline',
16
+ changeTrustUpdate: 'trustline-flags',
17
+ allowTrust: 'trustline-flags',
18
+ accountMerge: 'hexagon-remove',
19
+ accountMergeReceive: 'receive-circle',
20
+ inflation: 'hexagon-inflation',
21
+ manageData: 'grid',
22
+ manageDataAdd: 'grid-add',
23
+ manageDataRemove: 'grid-remove',
24
+ bumpSequence: 'upload',
25
+ manageBuyOffer: 'dex-offer',
26
+ pathPaymentStrictSend: 'swap',
27
+ createClaimableBalance: 'shutdown-circle',
28
+ claimClaimableBalance: 'icon-ok',
29
+ claimClaimableBalanceReceive: 'receive-circle',
30
+ beginSponsoringFutureReserves: 'sponsor',
31
+ endSponsoringFutureReserves: 'sponsor',
32
+ revoke: 'revoke',
33
+ revokeAccountSponsorship: 'revoke',
34
+ revokeTrustlineSponsorship: 'revoke',
35
+ revokeOfferSponsorship: 'revoke',
36
+ revokeDataSponsorship: 'revoke',
37
+ revokeClaimableBalanceSponsorship: 'revoke',
38
+ revokeLiquidityPoolSponsorship: 'revoke',
39
+ revokeSignerSponsorship: 'revoke',
40
+ clawback: 'clawback',
41
+ clawbackReceive: 'send-circle',
42
+ clawbackClaimableBalance: 'icon-ok',
43
+ setTrustLineFlags: 'trustline-flags',
44
+ liquidityPoolDeposit: 'droplet',
45
+ liquidityPoolWithdraw: 'droplet-half',
46
+ invokeHostFunction: 'flash',
47
+ extendFootprintTtl: 'upload',
48
+ restoreFootprint: 'upload'
49
+ }
50
+
51
+ /**
52
+ * Transaction operation icon
53
+ * @param {OperationDescriptor|'feeCharge'} op - Operation descriptor
54
+ * @param {boolean} failed - Whether the transaction failed during execution
55
+ * @constructor
56
+ */
57
+ export const OpIcon = React.memo(function OpIcon({op, failed = false}) {
58
+ let type
59
+ let title
60
+ if (op === 'feeCharge') {
61
+ type = 'feeCharge'
62
+ title = 'Transaction fees charge'
63
+ } else {
64
+ const {operation} = op
65
+ title = type = operation.type
66
+ title = title[0].toUpperCase() + title.substring(1) + ' operation'
67
+ switch (type) {
68
+ case 'payment':
69
+ case 'accountMerge':
70
+ case 'claimClaimableBalance':
71
+ case 'clawback':
72
+ if (!op.context?.account?.includes(operation.source)) {
73
+ type += 'Receive'
74
+ }
75
+ break
76
+ case 'manageData':
77
+ if (operation.effects.some(e => e.type === 'dataEntryCreated')) {
78
+ type += 'Add'
79
+ } else if (operation.effects.some(e => e.type === 'dataEntryRemoved')) {
80
+ type += 'Remove'
81
+ }
82
+ break
83
+ case 'changeTrust':
84
+ if (operation.limit > 0) {
85
+ type += 'Add'
86
+ } else {
87
+ type += 'Remove'
88
+ }
89
+ break
90
+ }
91
+ }
92
+ if (failed) {
93
+ title += ' - Transaction failed'
94
+ }
95
+ const icon = opIconMapping[type]
96
+ return <div className={cn('op-icon', {failed})} title={title}>
97
+ <i className={`icon-${icon}`}/>
98
+ </div>
99
99
  })