@stellar-expert/ui-framework 1.9.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 (124) hide show
  1. package/.npmrc +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/account/account-address.js +127 -0
  5. package/account/account-address.scss +20 -0
  6. package/account/available-balance.js +21 -0
  7. package/account/identicon.js +91 -0
  8. package/account/identicon.scss +6 -0
  9. package/account/signer-key.js +65 -0
  10. package/api/api-cache.js +5 -0
  11. package/api/explorer-api-call.js +37 -0
  12. package/api/explorer-api-hooks.js +202 -0
  13. package/api/explorer-api-paginated-list-hooks.js +439 -0
  14. package/api/explorer-batch-info-loader.js +85 -0
  15. package/api/explorer-tx-api.js +29 -0
  16. package/asset/amount.js +53 -0
  17. package/asset/asset-icon.js +34 -0
  18. package/asset/asset-issuer.js +22 -0
  19. package/asset/asset-link.js +93 -0
  20. package/asset/asset-link.scss +26 -0
  21. package/asset/asset-list-hooks.js +60 -0
  22. package/asset/asset-meta-hooks.js +78 -0
  23. package/asset/asset-selector.js +72 -0
  24. package/asset/asset-selector.scss +41 -0
  25. package/basic-styles/base.scss +53 -0
  26. package/basic-styles/form.scss +90 -0
  27. package/basic-styles/grid.scss +388 -0
  28. package/basic-styles/link.scss +17 -0
  29. package/basic-styles/lists.scss +68 -0
  30. package/basic-styles/loader.scss +22 -0
  31. package/basic-styles/responsive.scss +29 -0
  32. package/basic-styles/scrollbars.scss +19 -0
  33. package/basic-styles/spacing.scss +50 -0
  34. package/basic-styles/table.scss +104 -0
  35. package/basic-styles/themes.scss +59 -0
  36. package/basic-styles/typography.scss +191 -0
  37. package/basic-styles/variables.scss +26 -0
  38. package/claimable-balance/claimable-balance-claimants.js +12 -0
  39. package/contract/sc-val.js +70 -0
  40. package/contract/wasm-section-parser.js +159 -0
  41. package/contract/wasm-section-reader.js +79 -0
  42. package/contract/xdr-reader.js +148 -0
  43. package/controls/active-icon.scss +23 -0
  44. package/controls/button-group.js +20 -0
  45. package/controls/button-group.scss +48 -0
  46. package/controls/button.js +74 -0
  47. package/controls/button.scss +148 -0
  48. package/controls/code-block.js +35 -0
  49. package/controls/code-block.scss +74 -0
  50. package/controls/dropdown.js +281 -0
  51. package/controls/dropdown.scss +161 -0
  52. package/controls/external-link.js +5 -0
  53. package/controls/info-tooltip.js +17 -0
  54. package/controls/info-tooltip.scss +4 -0
  55. package/controls/slider.js +20 -0
  56. package/controls/slider.scss +22 -0
  57. package/controls/tabs.js +94 -0
  58. package/controls/tabs.scss +73 -0
  59. package/controls/tooltip.js +214 -0
  60. package/controls/tooltip.scss +97 -0
  61. package/controls/update-highlighter.js +28 -0
  62. package/controls/update-highlighter.scss +10 -0
  63. package/date/date-selector.js +44 -0
  64. package/date/elapsed-time.js +22 -0
  65. package/date/utc-timestamp.js +23 -0
  66. package/dex/price-dynamic.js +45 -0
  67. package/dex/price-dynamic.scss +36 -0
  68. package/directory/directory-hooks.js +89 -0
  69. package/effect/effect-description.js +289 -0
  70. package/effect/op-effects-view.js +11 -0
  71. package/effect/op-effects.scss +8 -0
  72. package/errors/error-boundary.js +98 -0
  73. package/fonts/font.scss +23 -0
  74. package/fonts/icons/config.json +1858 -0
  75. package/fonts/icons/icons-embedded.scss +644 -0
  76. package/horizon/horizon-account-helpers.js +104 -0
  77. package/horizon/horizon-client-helpers.js +52 -0
  78. package/horizon/horizon-ledger-helpers.js +36 -0
  79. package/horizon/horizon-orderbook-helpers.js +14 -0
  80. package/horizon/horizon-trades-helper.js +89 -0
  81. package/horizon/horizon-transaction-helpers.js +36 -0
  82. package/index.js +85 -0
  83. package/index.scss +16 -0
  84. package/interaction/autofocus.js +9 -0
  85. package/interaction/block-select.js +54 -0
  86. package/interaction/block-select.scss +24 -0
  87. package/interaction/copy-to-clipboard.js +19 -0
  88. package/interaction/inline-progress.js +16 -0
  89. package/interaction/qr-code.js +45 -0
  90. package/interaction/responsive.js +21 -0
  91. package/interaction/spoiler.js +40 -0
  92. package/interaction/spoiler.scss +9 -0
  93. package/interaction/theme-selector.js +11 -0
  94. package/ledger/ledger-entry-href-formatter.js +22 -0
  95. package/ledger/ledger-entry-link.js +59 -0
  96. package/meta/page-meta-tags.js +229 -0
  97. package/module/dynamic-module.js +48 -0
  98. package/package.json +41 -0
  99. package/state/on-screen-hooks.js +23 -0
  100. package/state/page-visibility-helpers.js +17 -0
  101. package/state/page-visibility-hooks.js +12 -0
  102. package/state/screen-orientation-hooks.js +16 -0
  103. package/state/state-hooks.js +77 -0
  104. package/state/stellar-network-hooks.js +45 -0
  105. package/state/theme.js +29 -0
  106. package/stellar/key-type.js +92 -0
  107. package/stellar/ledger-generic-id.js +40 -0
  108. package/stellar/signature-hint-utils.js +65 -0
  109. package/toast/toast-notification-instance.js +43 -0
  110. package/toast/toast-notification.js +46 -0
  111. package/toast/toast-notifications-block.js +55 -0
  112. package/toast/toast-notifications.scss +166 -0
  113. package/tx/op-accounting-changes.js +27 -0
  114. package/tx/op-description-view.js +925 -0
  115. package/tx/op-description.scss +98 -0
  116. package/tx/op-icon.js +93 -0
  117. package/tx/parser/op-balance-changes.js +62 -0
  118. package/tx/parser/op-descriptor.js +49 -0
  119. package/tx/parser/tx-details-parser.js +75 -0
  120. package/tx/parser/tx-matcher.js +372 -0
  121. package/tx/parser/type-filter-matcher.js +127 -0
  122. package/tx/tx-fee-effect.js +14 -0
  123. package/tx/tx-list-hooks.js +19 -0
  124. package/tx/tx-operations-list.js +105 -0
@@ -0,0 +1,98 @@
1
+ .op-container {
2
+ position: relative;
3
+
4
+ + .op-container {
5
+ padding-top: 0.4em;
6
+ }
7
+
8
+ .op-layout {
9
+ display: flex;
10
+ flex-wrap: nowrap;
11
+ align-items: center;
12
+
13
+ > :nth-child(2) {
14
+ flex-grow: 4;
15
+ }
16
+ }
17
+
18
+ .op-icon {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ align-self: flex-start;
23
+ position: relative;
24
+ min-width: 2.4em;
25
+ max-width: 2.4em;
26
+ width: 2.4em;
27
+ height: 2.4em;
28
+ margin-right: 0.3em;
29
+ text-align: center;
30
+ color: var(--color-bg);
31
+ background: var(--color-primary);
32
+ border-radius: 50%;
33
+
34
+ &:before {
35
+ content: '';
36
+ display: block;
37
+ border-bottom: 1px solid var(--color-text);
38
+ opacity: 0.2;
39
+ position: absolute;
40
+ width: 0.36em;
41
+ left: -0.36em;
42
+ top: 1.22em;
43
+ }
44
+
45
+ i {
46
+ line-height: 1;
47
+ font-size: 1.6em;
48
+ display: block;
49
+ }
50
+ }
51
+
52
+ .accounting-effects {
53
+ text-align: right;
54
+ padding-left: 0.5em;
55
+ font-size: 1rem;
56
+ }
57
+
58
+ /*group brackets*/
59
+
60
+ &:before {
61
+ content: '';
62
+ display: block;
63
+ position: absolute;
64
+ border-left: 1px solid var(--color-text);
65
+ opacity: 0.2;
66
+ height: 100%;
67
+ width: 0.4em;
68
+ left: -0.4em;
69
+ top: 0;
70
+ }
71
+
72
+ &:last-child:before {
73
+ height: 1.65em;
74
+ }
75
+
76
+ &:first-child:before {
77
+ top: auto;
78
+ bottom: 0;
79
+ height: calc(100% - 1.25em);
80
+ }
81
+
82
+ &:only-child {
83
+ &:before {
84
+ display: none;
85
+ }
86
+
87
+ .op-icon:before {
88
+ display: none;
89
+ }
90
+ }
91
+ }
92
+
93
+ .tx-effects-toggle {
94
+ float: right;
95
+ position: relative;
96
+ z-index: 1;
97
+ margin-top: 0.6em;
98
+ }
package/tx/op-icon.js ADDED
@@ -0,0 +1,93 @@
1
+ import React from 'react'
2
+
3
+ const opIconMapping = {
4
+ feeCharge: 'send-circle',
5
+ createAccount: 'hexagon-add',
6
+ payment: 'send-circle',
7
+ paymentReceive: 'receive-circle',
8
+ pathPaymentStrictReceive: 'swap',
9
+ manageSellOffer: 'dex-offer',
10
+ createPassiveSellOffer: 'dex-offer',
11
+ setOptions: 'hexagon-set-options',
12
+ changeTrust: 'trustlines',
13
+ changeTrustAdd: 'create-trustline',
14
+ changeTrustRemove: 'remove-trustline',
15
+ changeTrustUpdate: 'trustline-flags',
16
+ allowTrust: 'trustline-flags',
17
+ accountMerge: 'hexagon-remove',
18
+ accountMergeReceive: 'receive-circle',
19
+ inflation: 'hexagon-inflation',
20
+ manageData: 'grid',
21
+ manageDataAdd: 'grid-add',
22
+ manageDataRemove: 'grid-remove',
23
+ bumpSequence: 'upload',
24
+ manageBuyOffer: 'dex-offer',
25
+ pathPaymentStrictSend: 'swap',
26
+ createClaimableBalance: 'shutdown-circle',
27
+ claimClaimableBalance: 'icon-ok',
28
+ claimClaimableBalanceReceive: 'receive-circle',
29
+ beginSponsoringFutureReserves: 'sponsor',
30
+ endSponsoringFutureReserves: 'sponsor',
31
+ revoke: 'revoke',
32
+ revokeAccountSponsorship: 'revoke',
33
+ revokeTrustlineSponsorship: 'revoke',
34
+ revokeOfferSponsorship: 'revoke',
35
+ revokeDataSponsorship: 'revoke',
36
+ revokeClaimableBalanceSponsorship: 'revoke',
37
+ revokeLiquidityPoolSponsorship: 'revoke',
38
+ revokeSignerSponsorship: 'revoke',
39
+ clawback: 'clawback',
40
+ clawbackReceive: 'send-circle',
41
+ clawbackClaimableBalance: 'icon-ok',
42
+ setTrustLineFlags: 'trustline-flags',
43
+ liquidityPoolDeposit: 'droplet',
44
+ liquidityPoolWithdraw: 'droplet-half',
45
+ invokeHostFunction: 'flash',
46
+ bumpFootprintExpiration: 'upload',
47
+ restoreFootprint: 'upload'
48
+ }
49
+
50
+ /**
51
+ * Transaction operation icon
52
+ * @param {OperationDescriptor|'feeCharge'} op - Operation descriptor
53
+ * @constructor
54
+ */
55
+ export const OpIcon = React.memo(function OpIcon({op}) {
56
+ let type
57
+ if (op === 'feeCharge') {
58
+ type = 'feeCharge'
59
+ } else {
60
+ const {operation} = op
61
+ type = operation.type
62
+ switch (type) {
63
+ case 'payment':
64
+ case 'accountMerge':
65
+ case 'claimClaimableBalance':
66
+ case 'clawback':
67
+ if (!op.context?.account?.includes(operation.source)) {
68
+ type += 'Receive'
69
+ }
70
+ break
71
+ case 'manageData':
72
+ if (operation.effects.some(e => e.type === 'dataEntryCreated')) {
73
+ type += 'Add'
74
+ } else if (operation.effects.some(e => e.type === 'dataEntryRemoved')) {
75
+ type += 'Remove'
76
+ }
77
+ break
78
+ case 'changeTrust':
79
+ if (operation.limit > 0) {
80
+ type += 'Add'
81
+ } else {
82
+ type += 'Remove'
83
+ }
84
+ break
85
+ }
86
+ }
87
+
88
+
89
+ const icon = opIconMapping[type]
90
+ return <div className="op-icon">
91
+ <i className={`icon-${icon}`}/>
92
+ </div>
93
+ })
@@ -0,0 +1,62 @@
1
+ const manageOfferOpTypes = ['manageSellOffer', 'manageBuyOffer', 'createPassiveSellOffer']
2
+
3
+ /**
4
+ * Calculate operation resulting balance changes
5
+ * @param {{}} op - Operation descriptor
6
+ * @return {[{amount: *, source, type: string, asset},{amount: *, source, type: string, asset}]|{length}|*|*[]}
7
+ */
8
+ export function retrieveOpBalanceChanges(op) {
9
+ const {effects} = op.operation
10
+ const changes = effects.filter(e => e.source === op.context && (e.type === 'accountDebited' || e.type === 'accountCredited'))
11
+ if (changes.length) {
12
+ changes.sort((a, b) => a.type - b.type)
13
+ return changes
14
+ }
15
+
16
+ /*if (manageOfferOpTypes.includes(op.operation.type)) {
17
+ const debitedAmounts = []
18
+ const creditedAmounts = []
19
+ let sourceAsset
20
+ let destAsset
21
+
22
+ for (let e of effects) {
23
+ if (![e.seller, e.source].includes(op.context) || e.type !== 'trade')
24
+ continue
25
+ let {amount} = e
26
+ sourceAsset = e.asset[1]
27
+ destAsset = e.asset[0]
28
+ if (e.seller === op.context) {
29
+ amount = amount.slice().reverse()
30
+ sourceAsset = e.asset[1]
31
+ destAsset = e.asset[0]
32
+ }
33
+ debitedAmounts.push(amount[1])
34
+ creditedAmounts.push(amount[0])
35
+ }
36
+ const res = []
37
+ if (debitedAmounts.length) {
38
+ res.push({
39
+ type: 'accountDebited',
40
+ source: op.context,
41
+ asset: sourceAsset,
42
+ amount: sumAmounts(debitedAmounts)
43
+ })
44
+ }
45
+
46
+ if (creditedAmounts.length) {
47
+ res.push({
48
+ type: 'accountCredited',
49
+ source: op.context,
50
+ asset: destAsset,
51
+ amount: sumAmounts(creditedAmounts)
52
+ })
53
+ }
54
+ return res
55
+ }*/
56
+ return []
57
+ }
58
+ /*
59
+
60
+ function sumAmounts(amounts) {
61
+ return amounts.reduce((prev, v) => prev.add(v), new Bignumber(0))
62
+ }*/
@@ -0,0 +1,49 @@
1
+ export default class OperationDescriptor {
2
+ /**
3
+ * @type {BaseOperation} - Operation properties
4
+ * @readonly
5
+ */
6
+ operation
7
+ /**
8
+ * @type {String} - Parent transaction hash
9
+ * @readonly
10
+ */
11
+ txHash
12
+ /**
13
+ * @type {Number} - Application order
14
+ * @readonly
15
+ */
16
+ order
17
+ /**
18
+ * @type {Boolean} - True for unsubmitted|unsuccessful transactions
19
+ * @readonly
20
+ */
21
+ isEphemeral
22
+ /**
23
+ * @type {Boolean} - Whether the enclosing transaction has been successfully executed
24
+ * @readonly
25
+ */
26
+ successful
27
+
28
+ /**
29
+ * Prepare descriptors for transaction operations
30
+ * @param {BaseOperation[]} operations
31
+ * @param {String} txHash
32
+ * @param {Boolean} isEphemeral
33
+ * @param {Boolean} successful
34
+ * @return {OperationDescriptor[]}
35
+ */
36
+ static parseOperations(operations, txHash, isEphemeral, successful) {
37
+ return operations.map((operation, i) => {
38
+ const op = new OperationDescriptor()
39
+ Object.assign(op, {
40
+ txHash,
41
+ order: i,
42
+ operation,
43
+ isEphemeral,
44
+ successful
45
+ })
46
+ return op
47
+ })
48
+ }
49
+ }
@@ -0,0 +1,75 @@
1
+ import {parseTxOperationsMeta} from '@stellar-expert/tx-meta-effects-parser'
2
+ import OperationDescriptor from './op-descriptor'
3
+ import TxMatcher from './tx-matcher'
4
+
5
+ /**
6
+ * @typedef {Object} ParsedTxDetails - Parsed transaction
7
+ * @property {OperationDescriptor[]} operations - Parsed operation descriptors
8
+ * @property {Transaction|FeeBumpTransaction} tx - Parsed transaction
9
+ * @property {String} txHash - Transaction hash
10
+ * @property {String} context - Account address, asset name, offer id
11
+ * @property {String} contextType - Resolved context type
12
+ * @property {Boolean} isEphemeral - True if transaction has not been submitted or rejected
13
+ * @property {Boolean} unmatched - Whether transaction matches context and filter
14
+ * @property {Boolean} [successful] - Whether the transaction has been executed successfully or failed during execution
15
+ * @property {{}[]} [effects] - Transaction-level effects (including fee charges)
16
+ * @property {String} [createdAt] - Ledger application timestamp
17
+ */
18
+
19
+ /**
20
+ * @typedef {Object} TxFiltersContext
21
+ * @property {String[]} [type]
22
+ * @property {String[]} [account]
23
+ * @property {String[]} [source]
24
+ * @property {String[]} [destination]
25
+ * @property {String[]} [asset]
26
+ * @property {String[]} [src_asset]
27
+ * @property {String[]} [dest_asset]
28
+ * @property {String[]} [offer]
29
+ * @property {String[]} [pool]
30
+ */
31
+
32
+ /**
33
+ * Parse tx details from raw envelope, result, and meta
34
+ * @param {String} network - Network passphrase or identifier
35
+ * @param {String} tx - Base64-encoded tx envelope xdr
36
+ * @param {String} [result] - Base64-encoded tx envelope result
37
+ * @param {String} [meta] - Base64-encoded tx envelope meta
38
+ * @param {String} [id] - Unique trasnaction id
39
+ * @param {TxFiltersContext} [context] - Filters applied to transactions search
40
+ * @param {String} [createdAt] - Ledger execution timestamp
41
+ * @param {Boolean} [skipUnrelated] - Ledger execution timestamp
42
+ * @return {ParsedTxDetails}
43
+ */
44
+ export function parseTxDetails({network, txEnvelope, result, meta, id, context, createdAt, skipUnrelated}) {
45
+ const {tx, effects, operations, isEphemeral, failed} = parseTxOperationsMeta({network, tx: txEnvelope, meta, result})
46
+ const txHash = tx.hash().toString('hex')
47
+ const txMatcher = new TxMatcher(context, skipUnrelated)
48
+ const parsedOps = OperationDescriptor.parseOperations(operations, txHash, isEphemeral, !isEphemeral && !failed)
49
+ .filter(od => txMatcher.matchOperation(od))
50
+
51
+ const res = {
52
+ operations: parsedOps,
53
+ tx,
54
+ txHash,
55
+ context,
56
+ isEphemeral,
57
+ unmatched: !parsedOps.length
58
+ }
59
+ if (!isEphemeral) {
60
+ res.effects = effects
61
+ }
62
+ if (createdAt) {
63
+ res.createdAt = createdAt
64
+ }
65
+ if (!isEphemeral) {
66
+ res.successful = !failed
67
+ }
68
+ if (id !== undefined) {
69
+ res.id = id
70
+ }
71
+ for (let op of parsedOps) {
72
+ op.tx = res
73
+ }
74
+ return res
75
+ }