HopersNFT / hopers-frontend

https://hopers-frontend.vercel.app
0 stars 6 forks source link

Issue on useContract.js #43

Closed Tocard closed 1 year ago

Tocard commented 1 year ago

Hey,

I'm not a front-end guys and not familiar with node/js whatever. Not pretenting to know better than you, just trying to help

There is an issue with rpc spam in this file.

image

the exact portion of code who are doing that is located here

const getQueryClient = async (
    config: {
        [key: string]: string;
    },
    forceRefresh = false
): Promise<CosmWasmClient> => {
    const rpcEndpoint: string = config["rpcEndpoint"];
    const queryingClientConnection = {
        client: await CosmWasmClient.connect(rpcEndpoint),
        rpcEndpoint,
    };

    return queryingClientConnection.client;
};

If you change it that way

const getQueryClient = async (
    config: {
        [key: string]: string;
    },
    forceRefresh = false
): Promise<CosmWasmClient> => {
    const rpcEndpoint: string = "https://juno-rpc.polkachu.com";
    const queryingClientConnection = {
        client: await CosmWasmClient.connect(rpcEndpoint),
        rpcEndpoint,
    };

    return queryingClientConnection.client;
};

image

Anyway, the client should not be created each time a component acces this code

sheriff-rango commented 1 year ago

Thanks for letting me know. I will check it and let you know the result.

badmingtoncedric commented 1 year ago

Hi, To complete the previous analyze, I would add my comment and try to guide you on the right way.

To beginning, I'm sorry to say that but your source code is really dirty, hard to understand and containing lot of problems and a bad management of redux states.. I don't want to offense you with my comment but I lost 3h on your code to try to find a simple way to fix the problem without success.

You can check the useFetch.ts file to start debug and use the redux addon to see uneccessary dispatch calls. I tried to make a hotfix but in the state of the code I can't do nothing without a huge refactorizing of many files (all the redux store mechanism must be rewrited) imho.

security note: please use an .env file to store and import your API Key (and renew it ASAP because it's hardcoded in your source code)

Dizz02 commented 1 year ago

No one is offended web3invest. Actually we appreciate your feedback and help you are bringing on the table. We want the best for users and the community. We are open for any suggestions you may have. let's work together as a team for the good sake of the network

badmingtoncedric commented 1 year ago

A bug bounty will be nice 😇 , I try to launch a masternodes french ecosystem so you’re welcome to participate with a donation ❤️

For the future, if I can help you, I’ll do my best 👍 I’m open work, partnership or any interesting and valuable ideas. 🤝

Best Regards