Skip to content

wip: manage token page#1309

Draft
mvallenet wants to merge 14 commits into
mainfrom
gno-launchpad-erc20-manage-token
Draft

wip: manage token page#1309
mvallenet wants to merge 14 commits into
mainfrom
gno-launchpad-erc20-manage-token

Conversation

@mvallenet

Copy link
Copy Markdown
Member

WIP

Need review & help to ensure application of best pratices

@netlify

netlify Bot commented Oct 17, 2024

Copy link
Copy Markdown

Deploy Preview for testitori ready!

Name Link
🔨 Latest commit a0b7eff
🔍 Latest deploy log https://app.netlify.com/sites/testitori/deploys/671799276dadd70008343118
😎 Deploy Preview https://deploy-preview-1309--testitori.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented Oct 17, 2024

Copy link
Copy Markdown

Deploy Preview for teritori-dapp ready!

Name Link
🔨 Latest commit a0b7eff
🔍 Latest deploy log https://app.netlify.com/sites/teritori-dapp/deploys/671799270abc3300081e3bc0
😎 Deploy Preview https://deploy-preview-1309--teritori-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@n0izn0iz n0izn0iz left a comment

Copy link
Copy Markdown
Collaborator

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

Comment on lines +193 to +204
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()
}

Copy link
Copy Markdown
Collaborator

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({

Copy link
Copy Markdown
Collaborator

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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const pmFeature = getNetworkFeature(
const launchpadFeature = getNetworkFeature(

Comment on lines +31 to +33
const selectedWallet = useSelectedWallet();
const caller = selectedWallet?.address;
const { data: tokens } = useUserTokens(networkId, caller || "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 () => {

Copy link
Copy Markdown
Collaborator

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}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
forceNetworkKind={NetworkKind.Gno}

don't need to force the network kind since you force based on features

Comment on lines 119 to +120
await queryClient.invalidateQueries(["lastTokens"]);
await queryClient.invalidateQueries(["userTokens"]);

Copy link
Copy Markdown
Collaborator

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"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: screenTitle("Launchpad ERC20 Manage Token"),
title: screenTitle("Manage Fungible Token"),

LaunchpadERC20: undefined;
LaunchpadERC20Tokens?: { network?: string };
LaunchpadERC20CreateToken: { step?: number };
LaunchpadERC20ManageToken: { network?: string; token: Token };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants