FuelLabs/fuel-connectors

connectors spec change proposal

Opened this issue · 3 comments

this is a proposal is for improving the spec below
https://github.com/FuelLabs/fuel-connectors/wiki

step 1 - add a new section:


Supported Methods

Include on FuelConnectors interface a way to provide the methods that this connector supports

This enables improvements on UX for the Connectors UI by:

  • Easily provide for UI what are the methods that this connector supports
  • Allowing UI to hide the connectors that don't support the method that the user wants to call

step 2 - include in Connector method list


| Method | Description | Params | Return |

| --- | --- | --- | --- |
| unsupportedMethods | Return the names of methods that the current connector don't support. | | string[] |

step 3 - add to Fuel SDK method list


| Method | Description | Params | Return |

| --- | --- | --- | --- | | isMethodSupported | Return a boolean representing if the method is supported by this connector (inside of unsupportedMethods) | method name | boolean | | getSupportedConnectors | Return an array of the supported connectors for the inputted method name | method name | boolean |

step 4 (optional) - create a way to block methods that are not supported when they are called

This is open for discussion.
One option is to add overrides for each connector function, executing first the isMethodSupported
For this we would need to add to Fuel SDK method list overriding methods from Fuel Connector


  async sendTransaction(_address: string, _transaction: TransactionRequestLike) {
    if (!this.isMethodSupported('sendTransaction')) {
      throw new Error(`Method not supported by connector "${this.name}"`);
    }

    return super.sendTransaction(_address, _transaction);
  }

Hey @LuizAsFight - is there any movement on this one?

@petertonysmith94 I am asking for some opinions, we should move this soon.

What you think of the idea? I changed the supportedMethods prop to be unsupportedMethods, the reasoning is that normally connectors will support most of the methods, so I am doing the dev inform only the exception (methods not supported)

@LuizAsFight I can share my opinions :)

The addition of unsupportedMethods to the connectors, seems reasonable to me.

I get the rational behind the isMethodSupported and getSupportedConnectors methods. Just wondering whether they need to go onto the Fuel SDK, or could they sit externally as helper functions?

The final step 4 could easily be added to the callMethod function.