Skip to content
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

Configuration for the hooks package #95

Open
Tracked by #208
sekaiking opened this issue Nov 2, 2021 · 2 comments
Open
Tracked by #208

Configuration for the hooks package #95

sekaiking opened this issue Nov 2, 2021 · 2 comments
Labels
@cura/hooks p1 When done with p0.

Comments

@sekaiking
Copy link
Contributor

If we wanna change the hooks package configuration we have to edit near-utils.js manually before the package is deployed. And it can't be edited afterward.

The main concern for now is switching between NEAR networks for mainnet and testnet from wherever the hooks are called anywhere from the web.

The near endpoints would still be defined inside the package, the user would just need to choose which network to use, like this

switch(config.network){
  case 'mainnet':
  // use mainnet endpoints
  case 'testnet':
  // use testnet endpoints
  default: 
  // use testnet endpoints
}

This is what a solution could be like https://github.com/ourzora/nft-hooks#configuration

@bestatigen
Copy link
Collaborator

Hi,

We need to extend the config:

function getConfig() {
    let config = {
        networkId: 'testnet',
        nodeUrl: 'https://rpc.testnet.near.org',
        walletUrl: 'https://wallet.testnet.near.org',
        helperUrl: 'https://helper.testnet.near.org',
    }

    return config
}

with something like this:
https://github.com/near-examples/guest-book/blob/435f5b46df999568e3e4ffff4f2ffe5ef2ecb922/src/config.js.

Once the information of the network is there then I agree on something like you linked from Zora, but maybe without taking it too far for now. In the sense that we can listen to network changes in useNearHooks or start with simply passing the network to setupNear. That should be enough, cause then the smart contract calls go to the network you set up in the near.tsx. Does that make sense @achrafismyname ?

@sekaiking
Copy link
Contributor Author

Thanks @devey for responding. Yes I got that, but I was thinking about the hooks that doesn't require authentication, specially in the NFTE component. If someone used the NFTE component, he has no way to switch network.

I was going to use useNearHooks for this, but what I didn't like about it is that a Provider is always required, which seemed to me a bit unnecessary in cases where we don't need authentication and default config works for us.
But I guess, it's the only solution because it will solve #102 too .

@sekaiking sekaiking mentioned this issue Jan 3, 2022
4 tasks
@bestatigen bestatigen added the p1 When done with p0. label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@cura/hooks p1 When done with p0.
Projects
None yet
Development

No branches or pull requests

2 participants