-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watchlist worker #227
base: main
Are you sure you want to change the base?
watchlist worker #227
Conversation
Please follow README.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow contributing standards
@vikiival added the kysely-codegen part and reorganized routes by files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~
I checked the ref issues and it not written correctly: Please let me know if something is unclear for you, I can expand |
Thanks! will fix them in this week |
@vikiival I've overhauled all APIs using a two-entity approach. Given our watchlist UI currently doesn't support multiple watchlists, I introduced a 'default' watchlist for simplicity. While it may seem like I've created many APIs, only a handful will be used in our UI's initial version:
|
watchlist/src/utils/address.ts
Outdated
export function isValidAddress(address: string) { | ||
try { | ||
decodeAddress(address) | ||
return true | ||
} catch (e) { | ||
return false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try is adress valid from the same package ;))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use isAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main problem I have is the default watchlist,
the name of default should be the same as the address :).
and therefore you do not need a ton of checks
Co-authored-by: Viki Val <[email protected]>
@vikiival Could you clarify this for me? Sorry I'm a bit confused how does setting the default watchlist's name as 'address' reduce the number of checks we need to perform? |
there should be no routes with 'default' watchlist. Default watchlist for user should have name = address E.g. My default watchlist should be
You are doing a magic in the code to 'handle' is default :) |
@vikiival Got it, how about this approach: The ID of default watchlist = address, rather than the name = address. This means I won't have to look up the ID by name every time I get URLs like /watchlists/5FFG7GHAR2F2x.../*. It helps me avoid having to write code like the example below: if (req.params.watchlistId === address) {
// it's user's default watchlist
const id = findWatchlistIdByName(address)
...
} |
Sounds good are you planning to continue on this one @newraina ? |
@vikiival sure, I can continue in next week |
@vikiival removed all routes associated with the 'default' watchlist. To achieve this, I introduced a new
|
Ref: #64
test: watchlist.0xxmmvv.workers.dev
APIs:
GET /watchlists
- list all watchlistsPOST /watchlists
- create watchlistGET /watchlists/:id
- get one watchlistPUT /watchlists/:id
- update one watchlist (only name can be updated for now)DELETE /watchlists/:id
- delete watchlistGET /watchlists/:id/chains/:chain_id/items
- list items in watchlistPOST /watchlists/:id/chains/:chain_id/items
- add to watchlistGET /watchlists/:id/chains/:chain_id/items/:item_id/exists
- check if item exists in watchlistDELETE /watchlists/:id/chains/:chain_id/items/:item_id
- remove from watchlistrequest headers:
x-auth-address
address of user