Skip to content

Releases: onflow/flow-go-sdk

Version 0.6.0

25 Jun 00:35
Compare
Choose a tag to compare

💥 Breaking Changes

RPC errors

This release introduces a dedicated client.RPCError type for errors returned by the Access API. (#62)

client.RPCError implements the interface defined in the status.FromError function from the google.golang.org/grpc/status package:

import "google.golang.org/grpc/status"

res, err := c.GetTransactionResult(...)
if err != nil {
  s, ok := status.FromError(err)
  ...
}

client.RPCError can also be unwrapped to produce the original gRPC error:

grpcErr := errors.Unwrap(rpcErr)

Removed crypto.KeyType enum

The crypto.KeyType enum was removed because it is no longer required by the rest of the SDK. (#58)

Version 0.5.0

15 Jun 21:44
Compare
Choose a tag to compare

💥 Breaking Changes

Script arguments

Added support for script arguments, which allows Cadence values to be passed as arguments to ExecuteScript calls. This change affects the following functions on client.Client:

  • ExecuteScriptAtLatestBlock
  • ExecuteScriptAtBlockID
  • ExecuteScriptAtBlockHeight

Each of these functions now takes an additional argument of type []cadence.Value. For scripts that do not require any arguments, simply pass nil:

result, _ := c.ExecuteScriptAtLatestBlock(ctx, myBlockID, myScript, nil)

Note: script arguments are not yet supported in the emulator.

🐛 Bug Fixes

  • Added thread safety to the flow.Transaction#ID function. This fixes a previous race condition that would occur when generating transaction IDs from multiple routines.

⭐ Features

  • Added flow.TransactionStatusExpired status to the flow.TransactionStatus enum.
    • Note: transaction expiry is not yet supported by the emulator.

Version 0.4.1

05 Jun 00:54
Compare
Choose a tag to compare

🐛 Bug Fixes

  • Patch the following Access API client methods to support versions of the Access API that do not include a Timestamp field in Block and BlockHeader responses: (#47)
    • GetLatestBlock, GetBlockAtHeight, GetBlockByID
    • GetLatestBlockHeader, GetBlockHeaderAtHeight, GetBlockHeaderByID

Version 0.4.0

03 Jun 17:43
Compare
Choose a tag to compare

address

💥 Breaking Changes

Cadence

The AuthAccount constructor signature has changed from this:

AuthAccount(publicKeys: [[Int]], code: [Int])

to this:

let account = AuthAccount(payer: AuthAccount)

This allows for another account that isn't the transaction payer to pay for the creation of a new account.

The constructor also no longer takes publicKeys and code arguments -- these fields must be provided via the addPublicKey and setCode methods.

Example

This transaction:

transaction {
  prepare() {
    let acct = AuthAccount(keys: keys, code: code)
  }
}

now becomes this:

transaction {
  prepare(signer: AuthAccount) {
    let acct = AuthAccount(payer: signer)
    for key in keys {
      acct.addPublicKey(key)
    }
    acct.setCode(code)
  }
}

This also means that the account creation transaction requires an authorizer. For cases where you were previously signing with a single payer, you can make this change to use the same payer to pay the transaction fee and account creation fee.

// Old code

tx := flow.NewTransaction().
    SetScript(createAccount).
    SetPayer(payerAddress)
  
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)
// New code

tx := flow.NewTransaction().
    SetScript(createAccount).
    SetPayer(payerAddress).
    AddAuthorizer(payerAddress) // add payerAddress as an authorizer
  
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)

Account Addresses

Changes introduced in #36 and #41.

  • Address length has changed from 20 bytes to 8 bytes (64 bits).
  • Address generation no longer follows a monotonic sequence; addresses are now generated in a deterministic but non-monotonic sequence.
  • Each network (Mainnet, Testnet and Emulator) uses different parameters for address generation, meaning that addresses are not compatible across networks.

AddressGenerator

The flow.AddressGenerator struct can be used to generate addresses for a specific network. Here's an example:

gen := flow.NewAddressGenerator(flow.Mainnet)

// get the current address
addressA := gen.Address()

// increment state
gen.Next()

// get the next address
addressB := gen.Address()

// skip to index 42
gen.SetIndex(42)

addressC := gen.Address()

// check if an address is valid for a network
if !addressC.IsValid(flow.Testnet) {
    fmt.Println("Invalid testnet address!")
}

Other Breaking Changes

  • flow.ZeroAddress was renamed to flow.EmptyAddress
  • flow.ZeroID was renamed to flow.EmptyID

⭐ Features

  • Transactions now support Cadence arguments, which can be used with parameterized scripts to create reusable transactions. (#43) Example
  • flow.AccountKey#SetPublicKey now automatically sets the SigAlgo field based on the provided public key. (#35)
  • flow.BlockHeader now includes a Timestamp field. (#42)
  • The flow.Mainnet, flow.Testnet and flow.Emulator ChainID constants were introduced to differentiate between different networks.

⚙️ Installing & Upgrading

go get github.com/onflow/[email protected]

Version 0.4.0 (Beta 1)

26 May 19:34
Compare
Choose a tag to compare
Pre-release

⚠️ Breaking Changes

Cadence

Upgrade to Cadence v0.4.0-beta1: https://github.com/onflow/cadence/releases/tag/v0.4.0-beta1

The AuthAccount constructor signature has changed from this:

AuthAccount(publicKeys: [[Int]], code: [Int])

to this:

let account = AuthAccount(payer: AuthAccount)

This allows for another account that isn't the transaction payer to pay for the creation of a new account.

The constructor also no longer takes publicKeys and code arguments -- these fields must be provided via the addPublicKey and setCode methods.

Example

This transaction:

transaction {
	prepare() {
		let acct = AuthAccount(keys: keys, code: code)
	}
}

now becomes this:

transaction {
	prepare(signer: AuthAccount) {
		let acct = AuthAccount(payer: signer)
		for key in keys {
				acct.addPublicKey(key)
		}
		acct.setCode(code)
	}
}

This also means that the account creation transaction requires an authorizer. For cases where you were previously signing with a single payer, you can make this change to use the same payer to pay the transaction fee and account creation fee.

// Old code

tx := flow.NewTransaction().
  SetScript(createAccount).
  SetPayer(payerAddress)
  
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)
// New code

tx := flow.NewTransaction().
  SetScript(createAccount).
  SetPayer(payerAddress).
  AddAuthorizer(payerAddress) // add payerAddress as an authorizer
  
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)

Version 0.1.1

01 May 04:16
Compare
Choose a tag to compare

key

Compatible Emulator version: v0.1.1

🐛 Bug Fixes

  • Fix GetAccount to return AccountKey values with correct ID field. Previously the ID for each key was set to zero.

⬆️ Upgrade

go get github.com/onflow/[email protected]

This update is compatible with the latest emulator release, which is included in the Flow CLI. To upgrade the CLI, follow these steps.

If you're running the emulator with Docker, simply bump your image version:

gcr.io/dl-flow/emulator:v0.1.1