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
765c55bf
Commit
765c55bf
authored
Dec 20, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete node api endpoint
parent
5f60fb91
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
10 additions
and
159 deletions
+10
-159
useApiQuery.tsx
lib/api/useApiQuery.tsx
+3
-2
useRedirectForInvalidAuthToken.tsx
lib/hooks/useRedirectForInvalidAuthToken.tsx
+2
-3
[id].ts
pages/api/account/api-keys/[id].ts
+0
-11
index.ts
pages/api/account/api-keys/index.ts
+0
-5
[id].ts
pages/api/account/custom-abis/[id].ts
+0
-11
index.ts
pages/api/account/custom-abis/index.ts
+0
-5
[id].ts
pages/api/account/private-tags/address/[id].ts
+0
-11
index.ts
pages/api/account/private-tags/address/index.ts
+0
-5
[id].ts
pages/api/account/private-tags/transaction/[id].ts
+0
-11
index.ts
pages/api/account/private-tags/transaction/index.ts
+0
-5
[id].ts
pages/api/account/public-tags/[id].ts
+0
-11
index.ts
pages/api/account/public-tags/index.ts
+0
-5
[id].ts
pages/api/account/watchlist/[id].ts
+0
-11
get-with-tokens.ts
pages/api/account/watchlist/get-with-tokens.ts
+0
-36
index.ts
pages/api/account/watchlist/index.ts
+0
-5
accountQueries.ts
types/client/accountQueries.ts
+0
-9
AddressFavoriteButton.tsx
ui/address/details/AddressFavoriteButton.tsx
+5
-13
No files found.
lib/api/useApiQuery.tsx
View file @
765c55bf
import
type
{
UseQueryOptions
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
type
{
UserInfo
,
CustomAbis
,
PublicTags
,
AddressTags
,
TransactionTags
,
ApiKeys
}
from
'
types/api/account
'
;
import
type
{
UserInfo
,
CustomAbis
,
PublicTags
,
AddressTags
,
TransactionTags
,
ApiKeys
,
WatchlistAddress
}
from
'
types/api/account
'
;
import
type
{
CsrfData
}
from
'
types/client/account
'
;
import
type
{
RESOURCES
,
ResourceError
}
from
'
./resources
'
;
...
...
@@ -31,4 +31,5 @@ export type ResourcePayload<Q extends keyof typeof RESOURCES> =
Q
extends
'
private_tags_address
'
?
AddressTags
:
Q
extends
'
private_tags_tx
'
?
TransactionTags
:
Q
extends
'
api_keys
'
?
ApiKeys
:
never
;
Q
extends
'
watchlist
'
?
Array
<
WatchlistAddress
>
:
never
;
lib/hooks/useRedirectForInvalidAuthToken.tsx
View file @
765c55bf
...
...
@@ -2,8 +2,7 @@ import * as Sentry from '@sentry/react';
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
{
QueryKeys
}
from
'
types/client/accountQueries
'
;
import
{
resourceKey
}
from
'
lib/api/resources
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useLoginUrl
from
'
lib/hooks/useLoginUrl
'
;
...
...
@@ -17,7 +16,7 @@ export interface ErrorType {
export
default
function
useRedirectForInvalidAuthToken
()
{
const
queryClient
=
useQueryClient
();
const
state
=
queryClient
.
getQueryState
<
unknown
,
ErrorType
>
([
QueryKeys
.
profile
]);
const
state
=
queryClient
.
getQueryState
<
unknown
,
ErrorType
>
([
resourceKey
(
'
user_info
'
)
]);
const
errorStatus
=
state
?.
error
?.
error
?.
status
;
const
loginUrl
=
useLoginUrl
();
...
...
pages/api/account/api-keys/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/api_keys/
${
req
.
query
.
id
}
`
;
};
const
apiKeysHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
apiKeysHandler
;
pages/api/account/api-keys/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
apiKeysHandler
=
handler
(()
=>
'
/account/v1/user/api_keys
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
apiKeysHandler
;
pages/api/account/custom-abis/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/custom_abis/
${
req
.
query
.
id
}
`
;
};
const
customAbiHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
customAbiHandler
;
pages/api/account/custom-abis/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
customAbiHandler
=
handler
(()
=>
'
/account/v1/user/custom_abis
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
customAbiHandler
;
pages/api/account/private-tags/address/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/tags/address/
${
req
.
query
.
id
}
`
;
};
const
addressEditHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
addressEditHandler
;
pages/api/account/private-tags/address/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
addressHandler
=
handler
(()
=>
'
/account/v1/user/tags/address
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
addressHandler
;
pages/api/account/private-tags/transaction/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/tags/transaction/
${
req
.
query
.
id
}
`
;
};
const
transactionEditHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
transactionEditHandler
;
pages/api/account/private-tags/transaction/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
transactionHandler
=
handler
(()
=>
'
/account/v1/user/tags/transaction
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
transactionHandler
;
pages/api/account/public-tags/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/public_tags/
${
req
.
query
.
id
}
`
;
};
const
publicTagsHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
publicTagsHandler
;
pages/api/account/public-tags/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
publicKeysHandler
=
handler
(()
=>
'
/account/v1/user/public_tags
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
publicKeysHandler
;
pages/api/account/watchlist/[id].ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/account/v1/user/watchlist/
${
req
.
query
.
id
}
`
;
};
const
addressEditHandler
=
handler
(
getUrl
,
[
'
DELETE
'
,
'
PUT
'
]);
export
default
addressEditHandler
;
pages/api/account/watchlist/get-with-tokens.ts
deleted
100644 → 0
View file @
5f60fb91
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'
next
'
;
import
type
{
WatchlistAddresses
}
from
'
types/api/account
'
;
import
type
{
Tokenlist
}
from
'
types/api/tokenlist
'
;
import
type
{
TWatchlistItem
}
from
'
types/client/account
'
;
import
fetchFactory
from
'
lib/api/fetch
'
;
import
getUrlWithNetwork
from
'
lib/api/getUrlWithNetwork
'
;
import
{
httpLogger
}
from
'
lib/api/logger
'
;
const
watchlistWithTokensHandler
=
async
(
_req
:
NextApiRequest
,
res
:
NextApiResponse
<
Array
<
TWatchlistItem
>>
)
=>
{
httpLogger
(
_req
,
res
);
const
fetch
=
fetchFactory
(
_req
);
const
url
=
getUrlWithNetwork
(
_req
,
'
/api/account/v1/user/watchlist
'
);
const
watchlistResponse
=
await
fetch
(
url
,
{
method
:
'
GET
'
});
const
watchlistData
=
await
watchlistResponse
.
json
()
as
WatchlistAddresses
;
if
(
watchlistResponse
.
status
!==
200
)
{
httpLogger
.
logger
.
error
({
err
:
{
statusText
:
'
Watchlist token error
'
,
status
:
500
},
url
:
_req
.
url
});
res
.
status
(
500
).
end
(
watchlistData
||
'
Unknown error
'
);
return
;
}
const
data
=
await
Promise
.
all
(
watchlistData
.
map
(
async
item
=>
{
const
tokens
=
await
fetch
(
`?module=account&action=tokenlist&address=
${
item
.
address_hash
}
`
);
const
tokensData
=
await
tokens
.
json
()
as
Tokenlist
;
return
({
...
item
,
tokens_count
:
Array
.
isArray
(
tokensData
.
result
)
?
tokensData
.
result
.
length
:
0
});
}));
res
.
status
(
200
).
json
(
data
);
};
export
default
watchlistWithTokensHandler
;
pages/api/account/watchlist/index.ts
deleted
100644 → 0
View file @
5f60fb91
import
handler
from
'
lib/api/handler
'
;
const
watchlistHandler
=
handler
(()
=>
'
/account/v1/user/watchlist
'
,
[
'
GET
'
,
'
POST
'
]);
export
default
watchlistHandler
;
types/client/accountQueries.ts
deleted
100644 → 0
View file @
5f60fb91
export
enum
QueryKeys
{
addressTags
=
'
address-tags
'
,
apiKeys
=
'
api-keys
'
,
customAbis
=
'
custom-abis
'
,
profile
=
'
profile
'
,
publicTags
=
'
public-tags
'
,
transactionTags
=
'
transaction-tags
'
,
watchlist
=
'
watchlist
'
,
}
ui/address/details/AddressFavoriteButton.tsx
View file @
765c55bf
import
{
Icon
,
chakra
,
Tooltip
,
IconButton
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
,
useQuery
Client
}
from
'
@tanstack/react-query
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
type
{
TWatchlist
}
from
'
types/client/account
'
;
import
{
QueryKeys
as
AccountQueryKeys
}
from
'
types/client/accountQueries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
starFilledIcon
from
'
icons/star_filled.svg
'
;
import
starOutlineIcon
from
'
icons/star_outline.svg
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
{
resourceKey
}
from
'
lib/api/resources
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useLoginUrl
from
'
lib/hooks/useLoginUrl
'
;
import
usePreventFocusAfterModalClosing
from
'
lib/hooks/usePreventFocusAfterModalClosing
'
;
import
WatchlistAddModal
from
'
ui/watchlist/AddressModal/AddressModal
'
;
...
...
@@ -27,19 +26,12 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
const
deleteModalProps
=
useDisclosure
();
const
queryClient
=
useQueryClient
();
const
router
=
useRouter
();
const
fetch
=
useFetch
();
const
profileData
=
queryClient
.
getQueryData
<
UserInfo
>
([
AccountQueryKeys
.
profile
]);
const
profileData
=
queryClient
.
getQueryData
<
UserInfo
>
([
resourceKey
(
'
user_info
'
)
]);
const
isAuth
=
Boolean
(
profileData
);
const
loginUrl
=
useLoginUrl
();
const
watchListQuery
=
useQuery
<
unknown
,
unknown
,
TWatchlist
>
(
[
AccountQueryKeys
.
watchlist
],
async
()
=>
fetch
(
'
/node-api/account/watchlist
'
),
{
enabled
:
isAdded
,
},
);
const
watchListQuery
=
useApiQuery
(
'
watchlist
'
,
{
queryOptions
:
{
enabled
:
isAdded
}
});
const
handleClick
=
React
.
useCallback
(()
=>
{
if
(
!
isAuth
)
{
...
...
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