@stellar-expert/ui-framework 1.15.3 → 1.15.4

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.
@@ -1,12 +1,19 @@
1
1
  import React from 'react'
2
2
  import {xdrParseClaimant} from '@stellar-expert/claimable-balance-utils'
3
3
  import {AccountAddress} from '../account/account-address'
4
+ import {CodeBlock} from '../controls/code-block'
4
5
 
5
6
  export const ClaimableBalanceClaimants = React.memo(function ClaimableBalanceClaimants({claimants}) {
6
- const parsed = claimants.map(xdrParseClaimant)
7
+ const parsed = claimants.map(c => {
8
+ if (c.destination && c.predicate)
9
+ return c
10
+ return xdrParseClaimant(c)
11
+ })
7
12
  return <>
8
13
  {parsed.map((c, i) => <span key={i + c.destination}>{i > 0 && ', '}
9
- <AccountAddress account={c.destination}/> {c.predicate}
14
+ <AccountAddress account={c.destination}/> {typeof c.predicate === 'string' ?
15
+ c.predicate :
16
+ <div className="block-indent"><CodeBlock>{JSON.stringify(c.predicate, null, 2)}</CodeBlock></div>}
10
17
  </span>)}
11
18
  </>
12
19
  })
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import {shortenString} from '@stellar-expert/formatter'
3
+ import {formatExplorerLink} from '../ledger/ledger-entry-href-formatter'
4
+
5
+ export function ClaimableBalanceId({balance}) {
6
+ if (!balance)
7
+ return null
8
+ return <>{' '}
9
+ <a href={formatExplorerLink('claimable-balance', balance)} target="_blank">
10
+ {shortenString(balance)}
11
+ </a>
12
+ </>
13
+ }
@@ -7,6 +7,7 @@ import {AccountAddress} from '../account/account-address'
7
7
  import {SignerKey} from '../account/signer-key'
8
8
  import {OfferLink, PoolLink} from '../ledger/ledger-entry-link'
9
9
  import {AssetLink} from '../asset/asset-link'
10
+ import {ClaimableBalanceId} from '../claimable-balance/claimable-balance-id'
10
11
  import {Amount} from '../asset/amount'
11
12
  import {CopyToClipboard} from '../interaction/copy-to-clipboard'
12
13
  import {ScVal} from '../contract/sc-val'
@@ -107,12 +108,12 @@ export function EffectDescription({effect, operation}) {
107
108
  case 'claimableBalanceCreated':
108
109
  return <>
109
110
  Account <AccountAddress account={effect.source}/> created claimable
110
- balance <ClaimableBalance effect={effect}/> <Amount asset={effect.asset} amount={effect.amount} adjust/>
111
+ balance <ClaimableBalanceId balance={effect.balance}/> <Amount asset={effect.asset} amount={effect.amount} adjust/>
111
112
  </>
112
113
  case 'claimableBalanceRemoved':
113
114
  return <>
114
115
  Account <AccountAddress account={effect.source}/> claimed claimable
115
- balance <ClaimableBalance effect={effect}/> <Amount asset={effect.asset} amount={effect.amount} adjust/>
116
+ balance <ClaimableBalanceId balance={effect.balance}/> <Amount asset={effect.asset} amount={effect.amount} adjust/>
116
117
  </>
117
118
  case 'accountSponsorshipCreated':
118
119
  case 'accountSponsorshipUpdated':
@@ -161,13 +162,14 @@ export function EffectDescription({effect, operation}) {
161
162
  case 'claimableBalanceSponsorshipCreated':
162
163
  case 'claimableBalanceSponsorshipUpdated':
163
164
  return <>
164
- Account <AccountAddress account={effect.sponsor}/> sponsored claimable balance <ClaimableBalance effect={effect}/>
165
+ Account <AccountAddress account={effect.sponsor}/> sponsored
166
+ claimable balance <ClaimableBalanceId balance={effect.balance}/>
165
167
  {effect.source !== effect.sponsor && <> for account <AccountAddress account={effect.source}/></>}
166
168
  </>
167
169
  case 'claimableBalanceSponsorshipRemoved':
168
170
  return <>
169
171
  Account <AccountAddress account={effect.prevSponsor}/> revoked claimable
170
- balance <ClaimableBalance effect={effect}/> sponsorship
172
+ balance <ClaimableBalanceId balance={effect.balance}/> sponsorship
171
173
  {effect.source !== effect.prevSponsor && <> for account <AccountAddress account={effect.source}/></>}
172
174
  </>
173
175
  case 'signerSponsorshipCreated':
@@ -327,15 +329,6 @@ function ContractCodeWasm({wasm}) {
327
329
  </>
328
330
  }
329
331
 
330
- function ClaimableBalance({effect}) {
331
- const {balance} = effect
332
- return <>
333
- {shortenString(balance)} <CopyToClipboard text={balance}/>{/*<InfoTooltip icon="icon-plus">
334
- <CopyToClipboard text={balance}>{balance}</CopyToClipboard>
335
- </InfoTooltip>*/}
336
- </>
337
- }
338
-
339
332
  function LedgerKeyHint({effect, children}) {
340
333
  if (!effect.keyHash)
341
334
  return children
@@ -1,7 +1,7 @@
1
1
  import {getCurrentStellarNetwork} from '../state/stellar-network-hooks'
2
2
 
3
3
  /**
4
- * @param {'account'|'asset'|'ledger'|'tx'|'op'|'offer'|'contract'} type
4
+ * @param {'account'|'asset'|'ledger'|'tx'|'op'|'offer'|'contract'|'liquidity-pool'|'claimable-balance'} type
5
5
  * @param {String|Number} id
6
6
  * @param {String} [network]
7
7
  * @return {String}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/ui-framework",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "description": "StellarExpert shared UI components library",
5
5
  "main": "index.js",
6
6
  "module": "./index.js",
@@ -14,12 +14,8 @@ import {formatExplorerLink} from '../ledger/ledger-entry-href-formatter'
14
14
  import {ClaimableBalanceClaimants} from '../claimable-balance/claimable-balance-claimants'
15
15
  import {CopyToClipboard} from '../interaction/copy-to-clipboard'
16
16
  import {useStellarNetwork} from '../state/stellar-network-hooks'
17
- import {ScVal} from '../contract/sc-val'
18
17
  import InvocationInfoView from '../contract/invocation-info-view'
19
-
20
- function formatBalanceId(balance) {
21
- return `${balance.substr(8, 4)}…${balance.substr(-4)}`
22
- }
18
+ import {ClaimableBalanceId} from '../claimable-balance/claimable-balance-id'
23
19
 
24
20
  function getAccountPredefinedDisplayName(address) {
25
21
  if (!window.predefinedAccountDisplayNames)
@@ -449,16 +445,19 @@ function BumpSequenceDescriptionView({op, compact}) {
449
445
  * @constructor
450
446
  */
451
447
  function CreateClaimableBalanceDescriptionView({op, compact}) {
452
- const {asset, amount, claimants} = op.operation
448
+ const {asset, amount, claimants, effects} = op.operation
449
+ const balanceId = effects.find(e => e.type === 'claimableBalanceCreated')?.balance
453
450
  if (op.isEphemeral)
454
451
  return <>
455
452
  <b>Create claimable balance</b> <Amount amount={amount} asset={AssetDescriptor.parse(asset)} issuer={!compact}/>
453
+ <ClaimableBalanceId balance={balanceId}/>
456
454
  <OpSourceAccount op={op}/>{' '}
457
455
  claimable by <ClaimableBalanceClaimants claimants={claimants}/>
458
456
 
459
457
  </>
460
458
  return <>
461
- <OpSourceAccount op={op}/> created claimable balance{' '}
459
+ <OpSourceAccount op={op}/> created claimable balance
460
+ <ClaimableBalanceId balance={balanceId}/>{' '}
462
461
  <Amount amount={amount} asset={AssetDescriptor.parse(asset)} issuer={!compact}/>{' '}
463
462
  claimable by <ClaimableBalanceClaimants claimants={claimants}/>
464
463
  </>
@@ -474,11 +473,11 @@ function ClaimClaimableBalanceDescriptionView({op, compact}) {
474
473
  const {balanceId} = op.operation
475
474
  if (op.isEphemeral)
476
475
  return <>
477
- <b>Claim balance</b> <code>{formatBalanceId(balanceId)}</code>
476
+ <b>Claim balance</b> <ClaimableBalanceId balance={balanceId}/>
478
477
  <OpSourceAccount op={op}/>
479
478
  </>
480
479
  return <>
481
- <OpSourceAccount op={op}/> claimed balance <code>{formatBalanceId(balanceId)}</code>
480
+ <OpSourceAccount op={op}/> claimed balance <ClaimableBalanceId balance={balanceId}/>
482
481
  </>
483
482
  }
484
483
 
@@ -619,11 +618,11 @@ function RevokeClaimableBalanceSponsorshipDescriptionView({op, compact}) {
619
618
  const {balanceId} = op.operation
620
619
  if (op.isEphemeral)
621
620
  return <>
622
- <b>Revoke sponsorship</b> on claimable balance <code>{formatBalanceId(balanceId)}</code>
621
+ <b>Revoke sponsorship</b> on claimable balance <ClaimableBalanceId balance={balanceId}/>
623
622
  <OpSourceAccount op={op}/>
624
623
  </>
625
624
  return <>
626
- <OpSourceAccount op={op}/> revoked sponsorship on claimable balance <code>{formatBalanceId(balanceId)}</code>
625
+ <OpSourceAccount op={op}/> revoked sponsorship on claimable balance <ClaimableBalanceId balance={balanceId}/>
627
626
  </>
628
627
  }
629
628
 
@@ -674,10 +673,10 @@ function ClawbackClaimableBalanceDescriptionView({op, compact}) {
674
673
  const {balanceId} = op.operation
675
674
  if (op.isEphemeral)
676
675
  return <>
677
- <b>Clawback claimable balance</b> <code>{formatBalanceId(balanceId)}</code><OpSourceAccount op={op}/>
676
+ <b>Clawback claimable balance</b> <ClaimableBalanceId balance={balanceId}/><OpSourceAccount op={op}/>
678
677
  </>
679
678
  return <>
680
- <OpSourceAccount op={op}/> clawedback claimable balance <code>{formatBalanceId(balanceId)}</code>
679
+ <OpSourceAccount op={op}/> clawedback claimable balance <ClaimableBalanceId balance={balanceId}/>
681
680
  </>
682
681
  }
683
682