Migration Guide v0.25.0
The Go SDK version 0.25.0 introduced breaking changes in the API and package naming. Changes were required to make the implementation of the new HTTP access node API available.
We will list all the changes and provide examples on how to migrate.
- Renamed package: client -> access: the
clientpackage was renamed to
accesswhich now includes both
grpcpackage containing previously only gRPC implementation and also
httppackage containing the new HTTP API implementation.
- Removed package: convert: the
convertpackage was removed and all its functions were moved to each of the corresponding
httppackages. The methods were also changed to not be exported, so you can no longer use them outside the
- New clients: new clients were added each implementing the functions from the client interface and exposing a factory for creating them.
- New Client Interface: new client interface was created which is now network agnostic, meaning it
doesn't any more expose additional options in the API that were used to pass gRPC specific options. You can
still pass those options but you must use the network specific client as shown in the example bellow.
The interface also changed some functions:
Close() errorwas added
Creating a Client
Creating a client for communicating with the access node has changed since it's now possible to pick and choose between HTTP and gRPC communication protocols.
_10// initialize a gRPC emulator client_10flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure())
_10// common client interface_10var flowClient access.Client_10_10// initialize an http emulator client_10flowClient, err := http.NewClient(http.EmulatorHost)_10_10// initialize a gPRC emulator client_10flowClient, err = grpc.NewClient(grpc.EmulatorHost)
Using the gRPC Client with Options
Using the client is in most cases the same except for the advance case of passing additional options to the gRPC client which is no longer possible in the base client, you must use a network specific client as shown in the advanced example:
_10// initialize a gRPC emulator client_10flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure())_10latestBlock, err := flowClient.GetLatestBlock(ctx, true, MaxCallSendMsgSize(100))
_10// initialize a grpc network specific client_10flowClient, err := NewBaseClient(_10grpc.EmulatorHost,_10grpc.WithTransportCredentials(insecure.NewCredentials()),_10)_10latestBlock, err := flowClient.GetLatestBlock(ctx, true, MaxCallSendMsgSize(100))