scs / substrate-api-client

Library for connecting to substrate API over WebSockets
Apache License 2.0
260 stars 122 forks source link

When can the `fixme: make generic` be done? #119

Closed wuminzhe closed 1 year ago

wuminzhe commented 3 years ago

@brenzi

brenzi commented 3 years ago

We currently have no plans to make api-client more generic. What exactly would you need to do?

wuminzhe commented 3 years ago

We want to connect to different substrate chain with different types.

clangenb commented 3 years ago

We currently don't have any resources to push that forward, although it should not be that much work. ~ 5-10 hours depending on skill level.

If you feel confident, I could support you in accomplishing that. Do you only need the balance for now, or are other runtime types also affected?

If not, we could simply make the api-client generic over the balance.

Regardless, as more generic types might be wanted by the community in the future, it might make sense to add a more future-proof concept. We could make the api-client generic over a trait Config - inspired by the runtime's config traits - which defines the current set of generics for the client. With the current setup, this would be something like:

pub Trait Config: {
   type Pair: Pair
   type MultiSignature: From<Pair::Signature>
   type Balance: Codec + Copy + Eq // Maybe just use parity's 'Member' trait
}

Then we could even add a default implementation in the api-client that reflects the node-templates' types, such that people that use the default type, don't need to implement anything.

wuminzhe commented 3 years ago

@clangenb We need different runtime types, not only balance. So I think Trait Config is what we want. We will try to contribute the codes.

clangenb commented 3 years ago

Ok, cool. You can reach out to me, whenever you have questions! 👍

wuminzhe commented 3 years ago

Ok, cool. You can reach out to me, whenever you have questions! 👍

Thank you

haerdib commented 1 year ago

Will be done in course of fixing #267