FuelLabs / fuel-connectors

https://connectors.fuel.network
Apache License 2.0
77 stars 34 forks source link

connectors spec change proposal #94

Open LuizAsFight opened 3 months ago

LuizAsFight commented 3 months ago

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:

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 supportedMethods) 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);
  }

petertonysmith94 commented 1 month ago

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

LuizAsFight commented 1 month ago

@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)

petertonysmith94 commented 1 month ago

@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.