Skip to main content
Version: Current

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 client package was renamed to access which now includes both grpc package containing previously only gRPC implementation and also http package containing the new HTTP API implementation.
  • Removed package: convert: the convert package was removed and all its functions were moved to each of the corresponding grpc or http packages. The methods were also changed to not be exported, so you can no longer use them outside the convert package.
  • 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:
    • GetCollectionByID renamed to GetCollection
    • Close() error was added

Migration

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.

Previous versions:


_10
// initialize a gRPC emulator client
_10
flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure())

Version 0.25.0:


_10
// common client interface
_10
var flowClient access.Client
_10
_10
// initialize an http emulator client
_10
flowClient, err := http.NewClient(http.EmulatorHost)
_10
_10
// initialize a gPRC emulator client
_10
flowClient, 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:

Previous versions:


_10
// initialize a gRPC emulator client
_10
flowClient, err := client.New("127.0.0.1:3569", grpc.WithInsecure())
_10
latestBlock, err := flowClient.GetLatestBlock(ctx, true, MaxCallSendMsgSize(100))

Version 0.25.0:


_10
// initialize a grpc network specific client
_10
flowClient, err := NewBaseClient(
_10
grpc.EmulatorHost,
_10
grpc.WithTransportCredentials(insecure.NewCredentials()),
_10
)
_10
latestBlock, err := flowClient.GetLatestBlock(ctx, true, MaxCallSendMsgSize(100))