-
Notifications
You must be signed in to change notification settings - Fork 16
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
wip: manage token page #1309
base: main
Are you sure you want to change the base?
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. |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why move this file here?
return null; | ||
} | ||
|
||
const pmFeature = getNetworkFeature( |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 () => { |
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.
explicit query keys
<ScreenContainer | ||
headerChildren={<BrandText>Launchpad ERC 20</BrandText>} | ||
forceNetworkFeatures={[NetworkFeature.LaunchpadERC20]} | ||
forceNetworkKind={NetworkKind.Gno} |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why invalidate all networks
component={LaunchpadERC20ManageTokenScreen} | ||
options={{ | ||
header: () => null, | ||
title: screenTitle("Launchpad ERC20 Manage Token"), |
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.
title: screenTitle("Launchpad ERC20 Manage Token"), | |
title: screenTitle("Manage Fungible Token"), |
@@ -43,6 +44,7 @@ export type RootStackParamList = { | |||
LaunchpadERC20: undefined; | |||
LaunchpadERC20Tokens?: { network?: string }; | |||
LaunchpadERC20CreateToken: { step?: number }; | |||
LaunchpadERC20ManageToken: { network?: string; token: Token }; |
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.
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