@stellar-expert/ui-framework 1.9.10 → 1.10.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.
@@ -1,289 +1,289 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import {AuthRequiredFlag, AuthRevocableFlag, AuthImmutableFlag, AuthClawbackEnabledFlag} from '@stellar/stellar-base'
4
- import {AssetDescriptor} from '@stellar-expert/asset-descriptor'
5
- import {shortenString, formatWithAutoPrecision} from '@stellar-expert/formatter'
6
- import {AccountAddress} from '../account/account-address'
7
- import {SignerKey} from '../account/signer-key'
8
- import {OfferLink, PoolLink} from '../ledger/ledger-entry-link'
9
- import {AssetLink} from '../asset/asset-link'
10
- import {Amount} from '../asset/amount'
11
- import {CopyToClipboard} from '../interaction/copy-to-clipboard'
12
- import {ScVal} from '../contract/sc-val'
13
-
14
- export function EffectDescription({effect}) {
15
- switch (effect.type) {
16
- case 'accountCreated':
17
- return <>Account <AccountAddress account={effect.account}/> created</>
18
- case 'accountRemoved':
19
- return <>Account <AccountAddress account={effect.source}/> removed</>
20
- case 'accountCredited':
21
- return <><Amount asset={effect.asset} amount={effect.amount} adjust/> credited to
22
- account <AccountAddress account={effect.source}/></>
23
- case 'accountDebited':
24
- return <><Amount asset={effect.asset} amount={effect.amount} adjust/> debited from
25
- account <AccountAddress account={effect.source}/></>
26
- case 'accountThresholdsUpdated':
27
- return <>Account <AccountAddress account={effect.source}/> set thresholds to {effect.thresholds.join('/')}</>
28
- case 'accountHomeDomainUpdated':
29
- return <>
30
- Account <AccountAddress account={effect.source}/> set home domain to{' '}
31
- <a href={'https://' + effect.home_domain} target="_blank" rel="noreferrer noopener">{effect.home_domain}</a>
32
- </>
33
- case 'accountFlagsUpdated':
34
- return <>Account <AccountAddress account={effect.source}/> updated authorization
35
- flags: {decodeAccountAuthFlags(effect.flags).join(', ')}</>
36
- case 'accountInflationDestinationUpdated':
37
- return <>Account <AccountAddress account={effect.source}/> set inflation destination
38
- to <AccountAddress account={effect.inflationDestination}/></>
39
- case 'accountSignerCreated':
40
- return <>Account <AccountAddress account={effect.source}/> added
41
- signer <AccountAddress account={effect.signer}/>(w:{effect.weight})</>
42
- case 'accountSignerUpdated':
43
- return <>Account <AccountAddress account={effect.source}/> updated
44
- signer <AccountAddress account={effect.signer}/>(w:{effect.weight})</>
45
- case 'accountSignerRemoved':
46
- return <>Account <AccountAddress account={effect.source}/> removed
47
- signer <AccountAddress account={effect.signer}/></>
48
- case 'trustlineCreated':
49
- return <>
50
- Account <AccountAddress account={effect.source}/> established trustline to <AssetLink asset={effect.asset}/> with
51
- limit <Amount asset={effect.asset} amount={effect.limit} issuer={false} icon={false} adjust/>
52
- </>
53
- case 'trustlineUpdated':
54
- return <>
55
- Account <AccountAddress account={effect.source}/> updated trustline to <AssetLink asset={effect.asset}/> with
56
- limit <Amount asset={effect.asset} amount={effect.limit} issuer={false} icon={false} adjust/>
57
- </>
58
- case 'trustlineRemoved':
59
- return <>Account <AccountAddress account={effect.source}/> removed trustline to <AssetLink asset={effect.asset}/></>
60
- case 'trustlineAuthorizationUpdated':
61
- return <>
62
- Account <AccountAddress account={effect.source}/> updated <AssetLink asset={effect.asset}/> trustline authorization
63
- flags ({decodeTrustlineFlags(effect.flags)}) for <AccountAddress account={effect.trustor}/>
64
- </>
65
- case 'assetMinted':
66
- return <><Amount asset={effect.asset} amount={effect.amount} adjust/> minted</>
67
- case 'assetBurned':
68
- return <>Account <AccountAddress account={effect.source}/> burned <Amount asset={effect.asset} amount={effect.amount} adjust/></>
69
- case 'offerCreated':
70
- return <OfferChange effect={effect} action="created"/>
71
- case 'offerUpdated':
72
- return <OfferChange effect={effect} action="updated"/>
73
- case 'offerRemoved':
74
- return <>DEX offer <OfferLink offer={effect.offer}/> removed</>
75
- case 'trade':
76
- return <span>
77
- Account <AccountAddress account={effect.source}/> exchanged{' '}
78
- <span className="nowrap">
79
- <Amount asset={effect.asset[0]} amount={effect.amount[0]} adjust/>{' '}
80
- <span className="icon icon-shuffle color-primary"/>{' '}
81
- <Amount asset={effect.asset[1]} amount={effect.amount[1]} adjust/>
82
- </span>{' '}
83
- {effect.pool ?
84
- <>(pool <PoolLink pool={effect.pool}/>)</> :
85
- <>(DEX offer <OfferLink offer={effect.offer}/> by <AccountAddress account={effect.seller}/>)</>}
86
- </span>
87
- case 'sequenceBumped':
88
- return <>Account <AccountAddress account={effect.source}/> bumped sequence to {effect.sequence}</>
89
- case 'dataEntryCreated':
90
- case 'dataEntryUpdated':
91
- return <>
92
- Account <AccountAddress account={effect.source}/> {effect.type === 'dataEntryCreated' ? 'created' : 'updated'} data entry
93
- <span className="word-break condensed text-small"><code>"{effect.name}"</code> = <code>"{effect.value}"</code></span>
94
- </>
95
- case 'dataEntryRemoved':
96
- return <>
97
- Account <AccountAddress account={effect.source}/> removed data entry
98
- <span className="word-break condensed text-small"><code>"{effect.name}"</code></span>
99
- </>
100
- case 'claimableBalanceCreated':
101
- return <>
102
- Account <AccountAddress account={effect.source}/> created claimable
103
- balance {shortenString(effect.balance)} <Amount asset={effect.asset} amount={effect.amount} adjust/>
104
- </>
105
- case 'claimableBalanceRemoved':
106
- return <>
107
- Account <AccountAddress account={effect.source}/> claimed claimable
108
- balance {shortenString(effect.balance)} <Amount asset={effect.asset} amount={effect.amount} adjust/>
109
- </>
110
- case 'accountSponsorshipCreated':
111
- case 'accountSponsorshipUpdated':
112
- return <>
113
- Account <AccountAddress account={effect.sponsor}/> sponsored account base reserve
114
- for <AccountAddress account={effect.account}/>
115
- </>
116
- case 'accountSponsorshipRemoved':
117
- return <>
118
- Account <AccountAddress account={effect.prevSponsor}/> revoked account sponsorship
119
- for <AccountAddress account={effect.account}/>
120
- </>
121
- case 'trustlineSponsorshipCreated':
122
- case 'trustlineSponsorshipUpdated':
123
- return <>
124
- Account <AccountAddress account={effect.sponsor}/> sponsored <AssetLink asset={effect.asset}/> trustline reserve
125
- for <AccountAddress account={effect.account}/>
126
- </>
127
- case 'trustlineSponsorshipRemoved':
128
- return <>
129
- Account <AccountAddress account={effect.prevSponsor}/> revoked <AssetLink asset={effect.asset}/> trustline sponsorship
130
- for <AccountAddress account={effect.account}/>
131
- </>
132
- case 'offerSponsorshipCreated':
133
- case 'offerSponsorshipUpdated':
134
- return <>
135
- Account <AccountAddress account={effect.sponsor}/> sponsored offer <OfferLink offer={effect.offer}/> reserve
136
- for <AccountAddress account={effect.account}/>
137
- </>
138
- case 'offerSponsorshipRemoved':
139
- return <>
140
- Account <AccountAddress account={effect.prevSponsor}/> revoked offer <OfferLink offer={effect.offer}/> sponsorship
141
- for <AccountAddress account={effect.account}/>
142
- </>
143
- case 'dataSponsorshipCreated':
144
- case 'dataSponsorshipUpdated':
145
- return <>
146
- Account <AccountAddress account={effect.sponsor}/> sponsored "{shortenString(effect.name)}" data reserve
147
- for <AccountAddress account={effect.account}/>
148
- </>
149
- case 'dataSponsorshipRemoved':
150
- return <>
151
- Account <AccountAddress account={effect.prevSponsor}/> revoked "{shortenString(effect.name)}" data sponsorship
152
- for <AccountAddress account={effect.account}/>
153
- </>
154
- case 'claimableBalanceSponsorshipCreated':
155
- case 'claimableBalanceSponsorshipUpdated':
156
- return <>
157
- Account <AccountAddress account={effect.sponsor}/> sponsored claimable balance {shortenString(effect.balance)}
158
- {effect.source !== effect.sponsor && <> for account <AccountAddress account={effect.source}/></>}
159
- </>
160
- case 'claimableBalanceSponsorshipRemoved':
161
- return <>
162
- Account <AccountAddress account={effect.prevSponsor}/> revoked claimable balance {shortenString(effect.balance)} sponsorship
163
- {effect.source !== effect.prevSponsor && <> for account <AccountAddress account={effect.source}/></>}
164
- </>
165
- case 'signerSponsorshipCreated':
166
- case 'signerSponsorshipUpdated':
167
- return <>
168
- Account <AccountAddress account={effect.sponsor}/> sponsored signer <SignerKey account={effect.signer}/>{' '}
169
- for account <AccountAddress account={effect.account}/>
170
- </>
171
- case 'signerSponsorshipRemoved':
172
- return <>
173
- Account <AccountAddress account={effect.prevSponsor}/> revoked signer <SignerKey account={effect.signer}/> sponsorship{' '}
174
- for account <AccountAddress account={effect.account}/>
175
- </>
176
- case 'liquidityPoolDeposited':
177
- return <>
178
- <span className="nowrap">
179
- <Amount asset={effect.assets[0].asset} amount={effect.assets[0].amount} adjust/>{' '}
180
- and <Amount asset={effect.assets[1].asset} amount={effect.assets[1].amount} adjust/>
181
- </span>{' '}
182
- deposited to liquidity <span className="nowrap">pool <AssetLink asset={effect.pool}/></span>{' '}
183
- <i className="icon icon-shuffle"/> <span className="nowrap">{formatWithAutoPrecision(effect.shares)} pool shares</span>
184
- </>
185
- case 'liquidityPoolWithdrew':
186
- return <>
187
- {formatWithAutoPrecision(effect.shares)} pool shares <i className="icon icon-shuffle"/>{' '}
188
- <span className="nowrap">
189
- <Amount asset={effect.assets[0].asset} amount={effect.assets[0].amount} adjust/>{' '}
190
- and <Amount asset={effect.assets[1].asset} amount={effect.assets[1].amount} adjust/>
191
- </span>{' '}
192
- withdrawn from <span className="nowrap"><AssetLink asset={effect.pool}/> pool</span>
193
- </>
194
- case 'liquidityPoolCreated':
195
- return <>Liquidity pool <AssetLink asset={effect.pool}/> created</>
196
- case 'liquidityPoolUpdated':
197
- return <>Liquidity pool <AssetLink asset={effect.pool}/> updated / {' '}
198
- <span className="nowrap">
199
- <Amount asset={effect.reserves[0].asset} amount={effect.reserves[0].amount} adjust/> <i className="icon-plus"/>{' '}
200
- <Amount asset={effect.reserves[1].asset} amount={effect.reserves[1].amount} adjust/></span> /{' '}
201
- <span className="nowrap">{formatWithAutoPrecision(effect.shares)} pool shares</span>,{' '}
202
- <span className="nowrap">{effect.accounts} accounts</span></>
203
- case 'liquidityPoolRemoved':
204
- return <>Liquidity pool <AssetLink asset={effect.pool}/> removed</>
205
- case 'inflation':
206
- return <>Inflation distribution initialized</>
207
- case 'contractCodeUploaded':
208
- return <>Contract code <ContractCodeWasm wasm={effect.wasm}/> uploaded</>
209
- case 'contractCreated':
210
- return <>Contract <AccountAddress account={effect.contract}/> created <ContractDetails effect={effect}/></>
211
- case 'contractInvoked':
212
- return <>{effect.depth > 0 &&
213
- <i className="icon-level-down text-tiny color-primary" style={{paddingLeft: (effect.depth - 1) + 'em'}}/>}
214
- Contract <AccountAddress account={effect.contract}/>{' '} function <code>{effect.function}</code> invoked
215
- {!!effect.rawArgs && <> with arguments <ScVal value={effect.rawArgs}/></>}</>
216
- case 'contractEvent':
217
- return <>Contract <AccountAddress account={effect.contract}/> raised event <ScVal value={effect.rawTopics}/>{' '}
218
- with data <ScVal value={effect.rawData}/></>
219
- case 'contractDataCreated':
220
- case 'contractDataUpdated':
221
- return <>Contract <AccountAddress account={effect.owner}/> {effect.type === 'contractDataCreated' ? 'created ' : 'updated '}
222
- data <ScVal value={effect.key}/> with value <ScVal value={effect.value}/>
223
- </>
224
- case 'contractDataRemoved':
225
- return <>Contract <AccountAddress account={effect.owner}/> removed data <ScVal value={effect.key}/></>
226
- case 'feeCharged':
227
- return <><Amount asset="XLM" amount={effect.charged} adjust/> fee charged from <AccountAddress account={effect.source}/> (
228
- bid <Amount asset="XLM" amount={effect.bid} adjust/>)</>
229
- }
230
- return <><i className="icon-warning color-warning"/> Effect {effect.type} not supported</>
231
- }
232
-
233
- EffectDescription.propTypes = {
234
- effect: PropTypes.object.isRequired
235
- }
236
-
237
- function decodeAccountAuthFlags(flags) {
238
- const res = []
239
- if ((flags & AuthRequiredFlag) === AuthRequiredFlag) {
240
- res.push('REQUIRED')
241
- }
242
- if ((flags & AuthRevocableFlag) === AuthRevocableFlag) {
243
- res.push('REVOCABLE')
244
- }
245
- if ((flags & AuthImmutableFlag) === AuthImmutableFlag) {
246
- res.push('IMMUTABLE')
247
- }
248
- if ((flags & AuthClawbackEnabledFlag) === AuthClawbackEnabledFlag) {
249
- res.push('CLAWBACK_ENABLED')
250
- }
251
- return res
252
- }
253
-
254
- function decodeTrustlineFlags(flags) {
255
- if ((flags & 2) === 2)
256
- return 'FROZEN'
257
- if ((flags & 1) === 1)
258
- return 'AUTHORIZED'
259
- return 'UNAUTHORIZED'
260
- }
261
-
262
- function OfferChange({effect, action}) {
263
- return <>DEX offer <OfferLink offer={effect.offer}/> {action} /{' '}
264
- <span className="nowrap">
265
- <Amount asset={effect.asset[0]} amount={effect.amount} adjust/> <i className="icon icon-shuffle color-primary"/>{' '}
266
- <AssetLink asset={effect.asset[1]}/>
267
- </span> at <span className="nowrap">
268
- {formatWithAutoPrecision(parseFloat(effect.price))}{' '}
269
- {AssetDescriptor.parse(effect.asset[1]).toCurrency()}/{AssetDescriptor.parse(effect.asset[0]).toCurrency()}
270
- </span>
271
- </>
272
- }
273
-
274
- function ContractDetails({effect}) {
275
- switch (effect.kind) {
276
- case 'wasm':
277
- return <>from WASM <ContractCodeWasm wasm={effect.wasmHash}/></>
278
- case 'fromAddress':
279
- return <>from issuer <AccountAddress account={effect.issuer}/> with salt <ContractCodeWasm wasm={effect.salt}/></>
280
- case 'fromAsset':
281
- return <>from asset <AssetLink asset={effect.asset}/></>
282
- default:
283
- return <span className="dimme">(contract type not supported)</span>
284
- }
285
- }
286
-
287
- function ContractCodeWasm({wasm}) {
288
- return <><code title={wasm}>{shortenString(wasm, 16)}</code><CopyToClipboard text={wasm}/>)</>
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import {AuthRequiredFlag, AuthRevocableFlag, AuthImmutableFlag, AuthClawbackEnabledFlag} from '@stellar/stellar-base'
4
+ import {AssetDescriptor} from '@stellar-expert/asset-descriptor'
5
+ import {shortenString, formatWithAutoPrecision} from '@stellar-expert/formatter'
6
+ import {AccountAddress} from '../account/account-address'
7
+ import {SignerKey} from '../account/signer-key'
8
+ import {OfferLink, PoolLink} from '../ledger/ledger-entry-link'
9
+ import {AssetLink} from '../asset/asset-link'
10
+ import {Amount} from '../asset/amount'
11
+ import {CopyToClipboard} from '../interaction/copy-to-clipboard'
12
+ import {ScVal} from '../contract/sc-val'
13
+
14
+ export function EffectDescription({effect}) {
15
+ switch (effect.type) {
16
+ case 'accountCreated':
17
+ return <>Account <AccountAddress account={effect.account}/> created</>
18
+ case 'accountRemoved':
19
+ return <>Account <AccountAddress account={effect.source}/> removed</>
20
+ case 'accountCredited':
21
+ return <><Amount asset={effect.asset} amount={effect.amount} adjust/> credited to
22
+ account <AccountAddress account={effect.source}/></>
23
+ case 'accountDebited':
24
+ return <><Amount asset={effect.asset} amount={effect.amount} adjust/> debited from
25
+ account <AccountAddress account={effect.source}/></>
26
+ case 'accountThresholdsUpdated':
27
+ return <>Account <AccountAddress account={effect.source}/> set thresholds to {effect.thresholds.join('/')}</>
28
+ case 'accountHomeDomainUpdated':
29
+ return <>
30
+ Account <AccountAddress account={effect.source}/> set home domain to{' '}
31
+ <a href={'https://' + effect.home_domain} target="_blank" rel="noreferrer noopener">{effect.home_domain}</a>
32
+ </>
33
+ case 'accountFlagsUpdated':
34
+ return <>Account <AccountAddress account={effect.source}/> updated authorization
35
+ flags: {decodeAccountAuthFlags(effect.flags).join(', ')}</>
36
+ case 'accountInflationDestinationUpdated':
37
+ return <>Account <AccountAddress account={effect.source}/> set inflation destination
38
+ to <AccountAddress account={effect.inflationDestination}/></>
39
+ case 'accountSignerCreated':
40
+ return <>Account <AccountAddress account={effect.source}/> added
41
+ signer <AccountAddress account={effect.signer}/>(w:{effect.weight})</>
42
+ case 'accountSignerUpdated':
43
+ return <>Account <AccountAddress account={effect.source}/> updated
44
+ signer <AccountAddress account={effect.signer}/>(w:{effect.weight})</>
45
+ case 'accountSignerRemoved':
46
+ return <>Account <AccountAddress account={effect.source}/> removed
47
+ signer <AccountAddress account={effect.signer}/></>
48
+ case 'trustlineCreated':
49
+ return <>
50
+ Account <AccountAddress account={effect.source}/> established trustline to <AssetLink asset={effect.asset}/> with
51
+ limit <Amount asset={effect.asset} amount={effect.limit} issuer={false} icon={false} adjust/>
52
+ </>
53
+ case 'trustlineUpdated':
54
+ return <>
55
+ Account <AccountAddress account={effect.source}/> updated trustline to <AssetLink asset={effect.asset}/> with
56
+ limit <Amount asset={effect.asset} amount={effect.limit} issuer={false} icon={false} adjust/>
57
+ </>
58
+ case 'trustlineRemoved':
59
+ return <>Account <AccountAddress account={effect.source}/> removed trustline to <AssetLink asset={effect.asset}/></>
60
+ case 'trustlineAuthorizationUpdated':
61
+ return <>
62
+ Account <AccountAddress account={effect.source}/> updated <AssetLink asset={effect.asset}/> trustline authorization
63
+ flags ({decodeTrustlineFlags(effect.flags)}) for <AccountAddress account={effect.trustor}/>
64
+ </>
65
+ case 'assetMinted':
66
+ return <><Amount asset={effect.asset} amount={effect.amount} adjust/> minted</>
67
+ case 'assetBurned':
68
+ return <>Account <AccountAddress account={effect.source}/> burned <Amount asset={effect.asset} amount={effect.amount} adjust/></>
69
+ case 'offerCreated':
70
+ return <OfferChange effect={effect} action="created"/>
71
+ case 'offerUpdated':
72
+ return <OfferChange effect={effect} action="updated"/>
73
+ case 'offerRemoved':
74
+ return <>DEX offer <OfferLink offer={effect.offer}/> removed</>
75
+ case 'trade':
76
+ return <span>
77
+ Account <AccountAddress account={effect.source}/> exchanged{' '}
78
+ <span className="nowrap">
79
+ <Amount asset={effect.asset[0]} amount={effect.amount[0]} adjust/>{' '}
80
+ <span className="icon icon-shuffle color-primary"/>{' '}
81
+ <Amount asset={effect.asset[1]} amount={effect.amount[1]} adjust/>
82
+ </span>{' '}
83
+ {effect.pool ?
84
+ <>(pool <PoolLink pool={effect.pool}/>)</> :
85
+ <>(DEX offer <OfferLink offer={effect.offer}/> by <AccountAddress account={effect.seller}/>)</>}
86
+ </span>
87
+ case 'sequenceBumped':
88
+ return <>Account <AccountAddress account={effect.source}/> bumped sequence to {effect.sequence}</>
89
+ case 'dataEntryCreated':
90
+ case 'dataEntryUpdated':
91
+ return <>
92
+ Account <AccountAddress account={effect.source}/> {effect.type === 'dataEntryCreated' ? 'created' : 'updated'} data entry
93
+ <span className="word-break condensed text-small"><code>"{effect.name}"</code> = <code>"{effect.value}"</code></span>
94
+ </>
95
+ case 'dataEntryRemoved':
96
+ return <>
97
+ Account <AccountAddress account={effect.source}/> removed data entry
98
+ <span className="word-break condensed text-small"><code>"{effect.name}"</code></span>
99
+ </>
100
+ case 'claimableBalanceCreated':
101
+ return <>
102
+ Account <AccountAddress account={effect.source}/> created claimable
103
+ balance {shortenString(effect.balance)} <Amount asset={effect.asset} amount={effect.amount} adjust/>
104
+ </>
105
+ case 'claimableBalanceRemoved':
106
+ return <>
107
+ Account <AccountAddress account={effect.source}/> claimed claimable
108
+ balance {shortenString(effect.balance)} <Amount asset={effect.asset} amount={effect.amount} adjust/>
109
+ </>
110
+ case 'accountSponsorshipCreated':
111
+ case 'accountSponsorshipUpdated':
112
+ return <>
113
+ Account <AccountAddress account={effect.sponsor}/> sponsored account base reserve
114
+ for <AccountAddress account={effect.account}/>
115
+ </>
116
+ case 'accountSponsorshipRemoved':
117
+ return <>
118
+ Account <AccountAddress account={effect.prevSponsor}/> revoked account sponsorship
119
+ for <AccountAddress account={effect.account}/>
120
+ </>
121
+ case 'trustlineSponsorshipCreated':
122
+ case 'trustlineSponsorshipUpdated':
123
+ return <>
124
+ Account <AccountAddress account={effect.sponsor}/> sponsored <AssetLink asset={effect.asset}/> trustline reserve
125
+ for <AccountAddress account={effect.account}/>
126
+ </>
127
+ case 'trustlineSponsorshipRemoved':
128
+ return <>
129
+ Account <AccountAddress account={effect.prevSponsor}/> revoked <AssetLink asset={effect.asset}/> trustline sponsorship
130
+ for <AccountAddress account={effect.account}/>
131
+ </>
132
+ case 'offerSponsorshipCreated':
133
+ case 'offerSponsorshipUpdated':
134
+ return <>
135
+ Account <AccountAddress account={effect.sponsor}/> sponsored offer <OfferLink offer={effect.offer}/> reserve
136
+ for <AccountAddress account={effect.account}/>
137
+ </>
138
+ case 'offerSponsorshipRemoved':
139
+ return <>
140
+ Account <AccountAddress account={effect.prevSponsor}/> revoked offer <OfferLink offer={effect.offer}/> sponsorship
141
+ for <AccountAddress account={effect.account}/>
142
+ </>
143
+ case 'dataSponsorshipCreated':
144
+ case 'dataSponsorshipUpdated':
145
+ return <>
146
+ Account <AccountAddress account={effect.sponsor}/> sponsored "{shortenString(effect.name)}" data reserve
147
+ for <AccountAddress account={effect.account}/>
148
+ </>
149
+ case 'dataSponsorshipRemoved':
150
+ return <>
151
+ Account <AccountAddress account={effect.prevSponsor}/> revoked "{shortenString(effect.name)}" data sponsorship
152
+ for <AccountAddress account={effect.account}/>
153
+ </>
154
+ case 'claimableBalanceSponsorshipCreated':
155
+ case 'claimableBalanceSponsorshipUpdated':
156
+ return <>
157
+ Account <AccountAddress account={effect.sponsor}/> sponsored claimable balance {shortenString(effect.balance)}
158
+ {effect.source !== effect.sponsor && <> for account <AccountAddress account={effect.source}/></>}
159
+ </>
160
+ case 'claimableBalanceSponsorshipRemoved':
161
+ return <>
162
+ Account <AccountAddress account={effect.prevSponsor}/> revoked claimable balance {shortenString(effect.balance)} sponsorship
163
+ {effect.source !== effect.prevSponsor && <> for account <AccountAddress account={effect.source}/></>}
164
+ </>
165
+ case 'signerSponsorshipCreated':
166
+ case 'signerSponsorshipUpdated':
167
+ return <>
168
+ Account <AccountAddress account={effect.sponsor}/> sponsored signer <SignerKey account={effect.signer}/>{' '}
169
+ for account <AccountAddress account={effect.account}/>
170
+ </>
171
+ case 'signerSponsorshipRemoved':
172
+ return <>
173
+ Account <AccountAddress account={effect.prevSponsor}/> revoked signer <SignerKey account={effect.signer}/> sponsorship{' '}
174
+ for account <AccountAddress account={effect.account}/>
175
+ </>
176
+ case 'liquidityPoolDeposited':
177
+ return <>
178
+ <span className="nowrap">
179
+ <Amount asset={effect.assets[0].asset} amount={effect.assets[0].amount} adjust/>{' '}
180
+ and <Amount asset={effect.assets[1].asset} amount={effect.assets[1].amount} adjust/>
181
+ </span>{' '}
182
+ deposited to liquidity <span className="nowrap">pool <AssetLink asset={effect.pool}/></span>{' '}
183
+ <i className="icon icon-shuffle"/> <span className="nowrap">{formatWithAutoPrecision(effect.shares)} pool shares</span>
184
+ </>
185
+ case 'liquidityPoolWithdrew':
186
+ return <>
187
+ {formatWithAutoPrecision(effect.shares)} pool shares <i className="icon icon-shuffle"/>{' '}
188
+ <span className="nowrap">
189
+ <Amount asset={effect.assets[0].asset} amount={effect.assets[0].amount} adjust/>{' '}
190
+ and <Amount asset={effect.assets[1].asset} amount={effect.assets[1].amount} adjust/>
191
+ </span>{' '}
192
+ withdrawn from <span className="nowrap"><AssetLink asset={effect.pool}/> pool</span>
193
+ </>
194
+ case 'liquidityPoolCreated':
195
+ return <>Liquidity pool <AssetLink asset={effect.pool}/> created</>
196
+ case 'liquidityPoolUpdated':
197
+ return <>Liquidity pool <AssetLink asset={effect.pool}/> updated / {' '}
198
+ <span className="nowrap">
199
+ <Amount asset={effect.reserves[0].asset} amount={effect.reserves[0].amount} adjust/> <i className="icon-plus"/>{' '}
200
+ <Amount asset={effect.reserves[1].asset} amount={effect.reserves[1].amount} adjust/></span> /{' '}
201
+ <span className="nowrap">{formatWithAutoPrecision(effect.shares)} pool shares</span>,{' '}
202
+ <span className="nowrap">{effect.accounts} accounts</span></>
203
+ case 'liquidityPoolRemoved':
204
+ return <>Liquidity pool <AssetLink asset={effect.pool}/> removed</>
205
+ case 'inflation':
206
+ return <>Inflation distribution initialized</>
207
+ case 'contractCodeUploaded':
208
+ return <>Contract code <ContractCodeWasm wasm={effect.wasm}/> uploaded</>
209
+ case 'contractCreated':
210
+ return <>Contract <AccountAddress account={effect.contract}/> created <ContractDetails effect={effect}/></>
211
+ case 'contractInvoked':
212
+ return <>{effect.depth > 0 &&
213
+ <i className="icon-level-down text-tiny color-primary" style={{paddingLeft: (effect.depth - 1) + 'em'}}/>}
214
+ Contract <AccountAddress account={effect.contract}/>{' '} function <code>{effect.function}</code> invoked
215
+ {!!effect.rawArgs && <> with arguments <ScVal value={effect.rawArgs}/></>}</>
216
+ case 'contractEvent':
217
+ return <>Contract <AccountAddress account={effect.contract}/> raised event <ScVal value={effect.rawTopics}/>{' '}
218
+ with data <ScVal value={effect.rawData}/></>
219
+ case 'contractDataCreated':
220
+ case 'contractDataUpdated':
221
+ return <>Contract <AccountAddress account={effect.owner}/> {effect.type === 'contractDataCreated' ? 'created ' : 'updated '}
222
+ data <ScVal value={effect.key}/> with value <ScVal value={effect.value}/>
223
+ </>
224
+ case 'contractDataRemoved':
225
+ return <>Contract <AccountAddress account={effect.owner}/> removed data <ScVal value={effect.key}/></>
226
+ case 'feeCharged':
227
+ return <><Amount asset="XLM" amount={effect.charged} adjust/> fee charged from <AccountAddress account={effect.source}/> (
228
+ bid <Amount asset="XLM" amount={effect.bid} adjust/>)</>
229
+ }
230
+ return <><i className="icon-warning color-warning"/> Effect {effect.type} not supported</>
231
+ }
232
+
233
+ EffectDescription.propTypes = {
234
+ effect: PropTypes.object.isRequired
235
+ }
236
+
237
+ function decodeAccountAuthFlags(flags) {
238
+ const res = []
239
+ if ((flags & AuthRequiredFlag) === AuthRequiredFlag) {
240
+ res.push('REQUIRED')
241
+ }
242
+ if ((flags & AuthRevocableFlag) === AuthRevocableFlag) {
243
+ res.push('REVOCABLE')
244
+ }
245
+ if ((flags & AuthImmutableFlag) === AuthImmutableFlag) {
246
+ res.push('IMMUTABLE')
247
+ }
248
+ if ((flags & AuthClawbackEnabledFlag) === AuthClawbackEnabledFlag) {
249
+ res.push('CLAWBACK_ENABLED')
250
+ }
251
+ return res
252
+ }
253
+
254
+ function decodeTrustlineFlags(flags) {
255
+ if ((flags & 2) === 2)
256
+ return 'FROZEN'
257
+ if ((flags & 1) === 1)
258
+ return 'AUTHORIZED'
259
+ return 'UNAUTHORIZED'
260
+ }
261
+
262
+ function OfferChange({effect, action}) {
263
+ return <>DEX offer <OfferLink offer={effect.offer}/> {action} /{' '}
264
+ <span className="nowrap">
265
+ <Amount asset={effect.asset[0]} amount={effect.amount} adjust/> <i className="icon icon-shuffle color-primary"/>{' '}
266
+ <AssetLink asset={effect.asset[1]}/>
267
+ </span> at <span className="nowrap">
268
+ {formatWithAutoPrecision(parseFloat(effect.price))}{' '}
269
+ {AssetDescriptor.parse(effect.asset[1]).toCurrency()}/{AssetDescriptor.parse(effect.asset[0]).toCurrency()}
270
+ </span>
271
+ </>
272
+ }
273
+
274
+ function ContractDetails({effect}) {
275
+ switch (effect.kind) {
276
+ case 'wasm':
277
+ return <>from WASM <ContractCodeWasm wasm={effect.wasmHash}/></>
278
+ case 'fromAddress':
279
+ return <>from issuer <AccountAddress account={effect.issuer}/> with salt <ContractCodeWasm wasm={effect.salt}/></>
280
+ case 'fromAsset':
281
+ return <>from asset <AssetLink asset={effect.asset}/></>
282
+ default:
283
+ return <span className="dimme">(contract type not supported)</span>
284
+ }
285
+ }
286
+
287
+ function ContractCodeWasm({wasm}) {
288
+ return <><code title={wasm}>{shortenString(wasm, 16)}</code><CopyToClipboard text={wasm}/></>
289
289
  }
@@ -1,8 +1,8 @@
1
- .op-effects {
2
- padding: 0.2em 0 0 2.6em;
3
- line-height: 1.8;
4
-
5
- .icon-puzzle {
6
- margin-left: -1.4em;
7
- }
1
+ .op-effects {
2
+ padding: 0.2em 0 0 2.6em;
3
+ line-height: 1.8;
4
+
5
+ .icon-puzzle {
6
+ margin-left: -1.4em;
7
+ }
8
8
  }