aptos-labs / aptos-go-sdk

Aptos Go SDK
https://aptos.dev/sdks/go-sdk
Apache License 2.0
10 stars 14 forks source link

[Feature Request] Export clients as a interface #94

Open KimSeogyu opened 3 weeks ago

KimSeogyu commented 3 weeks ago

🚀 Feature Request Description

I suggest export Client, NodeClient (and more..) as a interface, not as a struct.

gregnazario commented 2 weeks ago

I'm fairly new to Go, could you give me the reason why?

KimSeogyu commented 1 week ago

I'm fairly new to Go, could you give me the reason why?

I'm a backend developer working with the aptos-go-sdk. I often apply mock implementations to completely separate the business logic from the blockchain during unit testing. The problem with the current approach of exporting clients as structs rather than interfaces is that the user has to manually implement an interface that mirrors all the methods of the aptos-go-sdk structure, which is required to insert either the actual aptos-go-sdk structure or a mock implementation. To simplify this process, we believe it is more efficient to export the client as an interface rather than a struct.

gregnazario commented 1 day ago

I'm fairly new to Go, could you give me the reason why?

I'm a backend developer working with the aptos-go-sdk. I often apply mock implementations to completely separate the business logic from the blockchain during unit testing. The problem with the current approach of exporting clients as structs rather than interfaces is that the user has to manually implement an interface that mirrors all the methods of the aptos-go-sdk structure, which is required to insert either the actual aptos-go-sdk structure or a mock implementation. To simplify this process, we believe it is more efficient to export the client as an interface rather than a struct.

Seems valid. Feel free to put up a pull request, or I will get to it eventually.