Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
062f9b3f
Commit
062f9b3f
authored
Oct 13, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more token transfer types
parent
693b0717
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
42 deletions
+63
-42
tokenTransfer.ts
types/api/tokenTransfer.ts
+17
-3
TokenTransfer.tsx
ui/tx/TokenTransfer.tsx
+21
-16
TxDetails.tsx
ui/tx/TxDetails.tsx
+25
-23
No files found.
types/api/tokenTransfer.ts
View file @
062f9b3f
...
@@ -2,25 +2,39 @@ import type { AddressParam } from './addressParams';
...
@@ -2,25 +2,39 @@ import type { AddressParam } from './addressParams';
export
type
TokenTransfer
=
(
export
type
TokenTransfer
=
(
{
{
t
ype
:
'
token_transfer
'
;
t
oken_type
:
'
ERC-20
'
;
total
:
{
total
:
{
value
:
string
;
value
:
string
;
};
};
}
|
}
|
{
{
t
ype
:
'
token_minting
'
;
t
oken_type
:
'
ERC-721
'
;
total
:
{
total
:
{
token_id
:
string
;
token_id
:
string
;
};
};
}
|
{
token_type
:
'
ERC-1155
'
;
total
:
{
value
:
string
;
token_id
:
string
;
};
}
|
{
token_type
:
'
ERC-1155_batch
'
;
total
:
Array
<
{
value
:
string
;
token_id
:
string
;
}
>
;
}
}
)
&
TokenTransferBase
)
&
TokenTransferBase
interface
TokenTransferBase
{
interface
TokenTransferBase
{
type
:
'
token_transfer
'
|
'
token_burning
'
|
'
token_spawning
'
|
'
token_minting
'
;
txHash
:
string
;
txHash
:
string
;
from
:
AddressParam
;
from
:
AddressParam
;
to
:
AddressParam
;
to
:
AddressParam
;
token_address
:
string
;
token_address
:
string
;
token_symbol
:
string
;
token_symbol
:
string
;
token_type
:
string
;
exchange_rate
:
string
;
exchange_rate
:
string
;
}
}
ui/tx/TokenTransfer.tsx
View file @
062f9b3f
...
@@ -5,41 +5,46 @@ import type { TokenTransfer as TTokenTransfer } from 'types/api/tokenTransfer';
...
@@ -5,41 +5,46 @@ import type { TokenTransfer as TTokenTransfer } from 'types/api/tokenTransfer';
import
rightArrowIcon
from
'
icons/arrows/east.svg
'
;
import
rightArrowIcon
from
'
icons/arrows/east.svg
'
;
import
{
space
}
from
'
lib/html-entities
'
;
import
{
space
}
from
'
lib/html-entities
'
;
import
useLink
from
'
lib/link/useL
ink
'
;
import
link
from
'
lib/link/l
ink
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
CurrencyValue
from
'
ui/shared/CurrencyValue
'
;
import
CurrencyValue
from
'
ui/shared/CurrencyValue
'
;
import
TokenSnippet
from
'
ui/shared/TokenSnippet
'
;
import
TokenSnippet
from
'
ui/shared/TokenSnippet
'
;
type
Props
=
TTokenTransfer
type
Props
=
TTokenTransfer
const
TokenTransfer
=
({
from
,
to
,
total
,
exchange_rate
:
exchangeRate
,
type
,
...
token
}:
Props
)
=>
{
const
TokenTransfer
=
(
props
:
Props
)
=>
{
const
link
=
useLink
();
const
content
=
(()
=>
{
const
content
=
(()
=>
{
switch
(
type
)
{
switch
(
props
.
token_
type
)
{
case
'
token_transfer
'
:
case
'
ERC-20
'
:
return
(
return
(
<
CurrencyValue
value=
{
total
.
value
}
unit=
"ether"
exchangeRate=
{
exchangeRate
}
fontWeight=
{
600
}
/>
<
Text
fontWeight=
{
500
}
as=
"span"
>
For:
{
space
}
<
CurrencyValue
value=
{
props
.
total
.
value
}
unit=
"ether"
exchangeRate=
{
props
.
exchange_rate
}
fontWeight=
{
600
}
/>
</
Text
>
);
);
case
'
token_minting
'
:
{
case
'
ERC-721
'
:
{
const
url
=
link
(
'
token_instance_item
'
,
{
hash
:
token
.
token_address
,
id
:
total
.
token_id
});
const
url
=
link
(
'
token_instance_item
'
,
{
hash
:
props
.
token_address
,
id
:
props
.
total
.
token_id
});
return
<
Text
as=
"span"
>
Token ID [
<
Link
href=
{
url
}
>
{
total
.
token_id
}
</
Link
>
]
</
Text
>;
return
(
<
Text
fontWeight=
{
500
}
as=
"span"
>
For token ID:
{
space
}
<
Link
href=
{
url
}
fontWeight=
{
600
}
>
{
props
.
total
.
token_id
}
</
Link
>
</
Text
>
);
}
}
default
:
return
null
;
}
}
})();
})();
return
(
return
(
<
Flex
alignItems=
"center"
flexWrap=
"wrap"
columnGap=
{
3
}
rowGap=
{
3
}
>
<
Flex
alignItems=
"center"
flexWrap=
"wrap"
columnGap=
{
3
}
rowGap=
{
3
}
>
<
Flex
alignItems=
"center"
>
<
Flex
alignItems=
"center"
>
<
AddressLink
fontWeight=
"500"
hash=
{
from
.
hash
}
truncation=
"constant"
/>
<
AddressLink
fontWeight=
"500"
hash=
{
props
.
from
.
hash
}
truncation=
"constant"
/>
<
Icon
as=
{
rightArrowIcon
}
boxSize=
{
6
}
mx=
{
2
}
color=
"gray.500"
/>
<
Icon
as=
{
rightArrowIcon
}
boxSize=
{
6
}
mx=
{
2
}
color=
"gray.500"
/>
<
AddressLink
fontWeight=
"500"
hash=
{
to
.
hash
}
truncation=
"constant"
/>
<
AddressLink
fontWeight=
"500"
hash=
{
props
.
to
.
hash
}
truncation=
"constant"
/>
</
Flex
>
</
Flex
>
<
Text
fontWeight=
{
500
}
as=
"span"
>
For:
{
space
}
{
content
}
{
content
}
<
TokenSnippet
symbol=
{
props
.
token_symbol
}
hash=
{
props
.
token_address
}
name=
"Foo"
/>
</
Text
>
<
TokenSnippet
symbol=
{
token
.
token_symbol
}
hash=
{
token
.
token_address
}
name=
"Foo"
/>
</
Flex
>
</
Flex
>
);
);
};
};
...
...
ui/tx/TxDetails.tsx
View file @
062f9b3f
...
@@ -35,6 +35,13 @@ import TxRevertReason from 'ui/tx/details/TxRevertReason';
...
@@ -35,6 +35,13 @@ import TxRevertReason from 'ui/tx/details/TxRevertReason';
import
TokenTransfer
from
'
ui/tx/TokenTransfer
'
;
import
TokenTransfer
from
'
ui/tx/TokenTransfer
'
;
import
TxDecodedInputData
from
'
ui/tx/TxDecodedInputData
'
;
import
TxDecodedInputData
from
'
ui/tx/TxDecodedInputData
'
;
const
TOKEN_TRANSFERS
=
[
{
title
:
'
Tokens Transferred
'
,
hint
:
'
List of tokens transferred in the transaction.
'
,
type
:
'
token_transfer
'
},
{
title
:
'
Tokens Minted
'
,
hint
:
'
List of tokens minted in the transaction.
'
,
type
:
'
token_minting
'
},
{
title
:
'
Tokens Burnt
'
,
hint
:
'
List of tokens burnt in the transaction.
'
,
type
:
'
token_burning
'
},
{
title
:
'
Tokens Created
'
,
hint
:
'
List of tokens created in the transaction.
'
,
type
:
'
token_spawning
'
},
];
const
TxDetails
=
()
=>
{
const
TxDetails
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
...
@@ -65,9 +72,6 @@ const TxDetails = () => {
...
@@ -65,9 +72,6 @@ const TxDetails = () => {
return
<
DataFetchAlert
/>;
return
<
DataFetchAlert
/>;
}
}
const
transferredTokens
=
data
.
token_transfers
?.
filter
(({
type
})
=>
type
===
'
token_transfer
'
)
||
[];
const
mintedTokens
=
data
.
token_transfers
?.
filter
(({
type
})
=>
type
===
'
token_minting
'
)
||
[];
return
(
return
(
<
Grid
columnGap=
{
8
}
rowGap=
{
{
base
:
3
,
lg
:
3
}
}
templateColumns=
{
{
base
:
'
minmax(0, 1fr)
'
,
lg
:
'
auto minmax(0, 1fr)
'
}
}
>
<
Grid
columnGap=
{
8
}
rowGap=
{
{
base
:
3
,
lg
:
3
}
}
templateColumns=
{
{
base
:
'
minmax(0, 1fr)
'
,
lg
:
'
auto minmax(0, 1fr)
'
}
}
>
<
DetailsInfoItem
<
DetailsInfoItem
...
@@ -157,26 +161,24 @@ const TxDetails = () => {
...
@@ -157,26 +161,24 @@ const TxDetails = () => {
</Tooltip> */
}
</Tooltip> */
}
{
/* <TokenSnippet symbol="UP" name="User Pay" hash="0xA17ed5dFc62D0a3E74D69a0503AE9FdA65d9f212" ml={ 3 }/> */
}
{
/* <TokenSnippet symbol="UP" name="User Pay" hash="0xA17ed5dFc62D0a3E74D69a0503AE9FdA65d9f212" ml={ 3 }/> */
}
</
DetailsInfoItem
>
</
DetailsInfoItem
>
{
transferredTokens
.
length
>
0
&&
(
{
TOKEN_TRANSFERS
.
map
(({
title
,
hint
,
type
})
=>
{
<
DetailsInfoItem
const
items
=
data
.
token_transfers
?.
filter
((
token
)
=>
token
.
type
===
type
)
||
[];
title=
"Token transferred"
if
(
items
.
length
===
0
)
{
hint=
"List of token transferred in the transaction."
return
null
;
>
}
<
Flex
flexDirection=
"column"
alignItems=
"flex-start"
rowGap=
{
5
}
w=
"100%"
>
return
(
{
transferredTokens
.
map
((
item
,
index
)
=>
<
TokenTransfer
key=
{
index
}
{
...
item
}
/>)
}
<
DetailsInfoItem
</
Flex
>
key=
{
type
}
</
DetailsInfoItem
>
title=
{
title
}
)
}
hint=
{
hint
}
{
mintedTokens
.
length
>
0
&&
(
>
<
DetailsInfoItem
<
Flex
flexDirection=
"column"
alignItems=
"flex-start"
rowGap=
{
5
}
w=
"100%"
>
title=
"Token Minted"
{
items
.
map
((
item
,
index
)
=>
<
TokenTransfer
key=
{
index
}
{
...
item
}
/>)
}
hint=
"List of token minted in the transaction."
</
Flex
>
>
</
DetailsInfoItem
>
<
Flex
flexDirection=
"column"
alignItems=
"flex-start"
rowGap=
{
5
}
w=
"100%"
>
);
{
mintedTokens
.
map
((
item
,
index
)
=>
<
TokenTransfer
key=
{
index
}
{
...
item
}
/>)
}
})
}
</
Flex
>
</
DetailsInfoItem
>
)
}
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
mt=
{
{
base
:
3
,
lg
:
8
}
}
/>
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
mt=
{
{
base
:
3
,
lg
:
8
}
}
/>
<
DetailsInfoItem
<
DetailsInfoItem
title=
"Value"
title=
"Value"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment