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
8e46f14d
Commit
8e46f14d
authored
Nov 04, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
page setup
parent
9b929ffb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
0 deletions
+86
-0
token-transfers.ts
pages/api/transactions/[id]/token-transfers.ts
+11
-0
tokenTransfer.ts
types/api/tokenTransfer.ts
+6
-0
queries.ts
types/client/queries.ts
+1
-0
Transaction.tsx
ui/pages/Transaction.tsx
+2
-0
TokenTransfer.tsx
ui/shared/TokenTransfer/TokenTransfer.tsx
+37
-0
TxTokenTransfer.tsx
ui/tx/TxTokenTransfer.tsx
+29
-0
No files found.
pages/api/transactions/[id]/token-transfers.ts
0 → 100644
View file @
8e46f14d
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/v2/transactions/
${
req
.
query
.
id
}
/token-transfers`
;
};
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
export
default
requestHandler
;
types/api/tokenTransfer.ts
View file @
8e46f14d
import
type
{
AddressParam
}
from
'
./addressParams
'
;
import
type
{
PaginationParams
}
from
'
./pagination
'
;
import
type
{
TokenInfoGeneric
}
from
'
./tokenInfo
'
;
export
type
Erc20TotalPayload
=
{
...
...
@@ -37,3 +38,8 @@ interface TokenTransferBase {
from
:
AddressParam
;
to
:
AddressParam
;
}
export
interface
TokenTransferResponse
{
items
:
Array
<
TokenTransfer
>
;
next_page_params
:
PaginationParams
|
null
;
}
types/client/queries.ts
View file @
8e46f14d
...
...
@@ -6,6 +6,7 @@ export enum QueryKeys {
txInternals
=
'
tx-internals
'
,
txLog
=
'
tx-log
'
,
txRawTrace
=
'
tx-raw-trace
'
,
txTokenTransfers
=
'
tx-token-transfers
'
,
blockTxs
=
'
block-transactions
'
,
block
=
'
block
'
,
blocks
=
'
blocks
'
,
...
...
ui/pages/Transaction.tsx
View file @
8e46f14d
...
...
@@ -18,10 +18,12 @@ import TxDetails from 'ui/tx/TxDetails';
import
TxInternals
from
'
ui/tx/TxInternals
'
;
import
TxLogs
from
'
ui/tx/TxLogs
'
;
import
TxRawTrace
from
'
ui/tx/TxRawTrace
'
;
import
TxTokenTransfer
from
'
ui/tx/TxTokenTransfer
'
;
// import TxState from 'ui/tx/TxState';
const
TABS
:
Array
<
RoutedTab
>
=
[
{
id
:
'
index
'
,
title
:
'
Details
'
,
component
:
<
TxDetails
/>
},
{
id
:
'
token_transfers
'
,
title
:
'
Token transfers
'
,
component
:
<
TxTokenTransfer
/>
},
{
id
:
'
internal
'
,
title
:
'
Internal txn
'
,
component
:
<
TxInternals
/>
},
{
id
:
'
logs
'
,
title
:
'
Logs
'
,
component
:
<
TxLogs
/>
},
// will be implemented later, api is not ready
...
...
ui/shared/TokenTransfer/TokenTransfer.tsx
0 → 100644
View file @
8e46f14d
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
type
{
QueryKey
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
TokenTransferResponse
}
from
'
types/api/tokenTransfer
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
interface
Props
{
isLoading
?:
boolean
;
isDisabled
?:
boolean
;
path
:
string
;
queryKey
:
QueryKey
;
}
const
TokenTransfer
=
({
isLoading
:
isLoadingProp
,
isDisabled
,
queryKey
,
path
}:
Props
)
=>
{
const
{
isError
,
isLoading
}
=
useQuery
<
unknown
,
unknown
,
TokenTransferResponse
>
(
queryKey
,
async
()
=>
await
fetch
(
path
),
{
enabled
:
!
isDisabled
,
},
);
if
(
isLoading
||
isLoadingProp
)
{
return
<
span
>
Loading...
</
span
>;
}
if
(
isError
)
{
return
<
DataFetchAlert
/>;
}
return
<
Box
>
TokenTransfer
</
Box
>;
};
export
default
React
.
memo
(
TokenTransfer
);
ui/tx/TxTokenTransfer.tsx
0 → 100644
View file @
8e46f14d
import
React
from
'
react
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
SECOND
}
from
'
lib/consts
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
TokenTransfer
from
'
ui/shared/TokenTransfer/TokenTransfer
'
;
import
TxPendingAlert
from
'
ui/tx/TxPendingAlert
'
;
import
TxSocketAlert
from
'
ui/tx/TxSocketAlert
'
;
import
useFetchTxInfo
from
'
ui/tx/useFetchTxInfo
'
;
const
TxTokenTransfer
=
()
=>
{
const
{
isError
,
isLoading
,
data
,
socketStatus
}
=
useFetchTxInfo
({
updateDelay
:
5
*
SECOND
});
if
(
!
isLoading
&&
!
isError
&&
!
data
.
status
)
{
return
socketStatus
?
<
TxSocketAlert
status=
{
socketStatus
}
/>
:
<
TxPendingAlert
/>;
}
if
(
isError
)
{
return
<
DataFetchAlert
/>;
}
const
queryKey
=
[
QueryKeys
.
txTokenTransfers
,
data
?.
hash
];
const
path
=
`/node-api/transactions/
${
data
?.
hash
}
/token-transfers`
;
return
<
TokenTransfer
isLoading=
{
isLoading
}
isDisabled=
{
!
data
?.
status
||
!
data
?.
hash
}
path=
{
path
}
queryKey=
{
queryKey
}
/>;
};
export
default
TxTokenTransfer
;
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