wip: manage token page#1309
Conversation
✅ Deploy Preview for testitori ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for teritori-dapp ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
n0izn0iz
left a comment
There was a problem hiding this comment.
the screens prefix could use a rename but we can do that in a later PR
| func GetUserTokensJSON(user string) string { | ||
| userAddr := std.Address(user) | ||
| var nodes []*json.Node | ||
| tokens.Iterate("", "", func(key string, value interface{}) bool { | ||
| token, _ := value.(*Token) | ||
| if token.admin.Owner() == userAddr { | ||
| nodes = append(nodes, token.ToJSON()) | ||
| } | ||
| return false | ||
| }) | ||
| return json.ArrayNode("", nodes).String() | ||
| } |
There was a problem hiding this comment.
we should index tokens by owner instead of iterating through all tokens here
| @@ -14,6 +14,18 @@ export const zodToken = z.object({ | |||
|
|
|||
There was a problem hiding this comment.
why move this file here?
| return null; | ||
| } | ||
|
|
||
| const pmFeature = getNetworkFeature( |
There was a problem hiding this comment.
| const pmFeature = getNetworkFeature( | |
| const launchpadFeature = getNetworkFeature( |
| const selectedWallet = useSelectedWallet(); | ||
| const caller = selectedWallet?.address; | ||
| const { data: tokens } = useUserTokens(networkId, caller || ""); |
There was a problem hiding this comment.
| const selectedWallet = useSelectedWallet(); | |
| const caller = selectedWallet?.address; | |
| const { data: tokens } = useUserTokens(networkId, caller || ""); | |
| const selectedWallet = useSelectedWallet(); | |
| const { data: tokens } = useUserTokens(selectedWallet?.userId); |
|
|
||
| export const useLastAirdrops = (networkId: string) => { | ||
| return useQuery(["lastAirdrops"], async () => { | ||
| return useQuery(["lastAirdrops", networkId], async () => { |
There was a problem hiding this comment.
| return useQuery(["lastAirdrops", networkId], async () => { | |
| return useQuery(["erc20LaunchpadLastAirdrops", networkId], async () => { |
we should use very explicit query keys prefixes to avoid conflicts in the future as these kind of conflicts are hard to pinpoint
| import { zodToken } from "@/utils/types/types"; | ||
|
|
||
| export const useUserTokens = (networkId: string, addr: string) => { | ||
| return useQuery(["userTokens", addr, networkId], async () => { |
| <ScreenContainer | ||
| headerChildren={<BrandText>Launchpad ERC 20</BrandText>} | ||
| forceNetworkFeatures={[NetworkFeature.LaunchpadERC20]} | ||
| forceNetworkKind={NetworkKind.Gno} |
There was a problem hiding this comment.
| forceNetworkKind={NetworkKind.Gno} |
don't need to force the network kind since you force based on features
| await queryClient.invalidateQueries(["lastTokens"]); | ||
| await queryClient.invalidateQueries(["userTokens"]); |
There was a problem hiding this comment.
why invalidate all networks
| component={LaunchpadERC20ManageTokenScreen} | ||
| options={{ | ||
| header: () => null, | ||
| title: screenTitle("Launchpad ERC20 Manage Token"), |
There was a problem hiding this comment.
| title: screenTitle("Launchpad ERC20 Manage Token"), | |
| title: screenTitle("Manage Fungible Token"), |
| LaunchpadERC20: undefined; | ||
| LaunchpadERC20Tokens?: { network?: string }; | ||
| LaunchpadERC20CreateToken: { step?: number }; | ||
| LaunchpadERC20ManageToken: { network?: string; token: Token }; |
There was a problem hiding this comment.
| LaunchpadERC20ManageToken: { network?: string; token: Token }; | |
| LaunchpadERC20ManageToken: { token: string }; |
we shouldn't use a networkId and a token object as screen params but instead a network-prefixed id that identifies this token (see getNetworkObjectId/parseNetworkObjectId) so we have a proper permalink
WIP
Need review & help to ensure application of best pratices