curaOS / source

Start a solid foundation of tools for creators+builders.
https://cura.run
15 stars 13 forks source link

Configuration for the hooks package #95

Open sekaiking opened 2 years ago

sekaiking commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 .