Releases: onflow/flow-go-sdk
Version 0.6.0
💥 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
💥 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 theflow.TransactionStatus
enum.- Note: transaction expiry is not yet supported by the emulator.
Version 0.4.1
🐛 Bug Fixes
- Patch the following Access API client methods to support versions of the Access API that do not include a
Timestamp
field inBlock
andBlockHeader
responses: (#47)GetLatestBlock
,GetBlockAtHeight
,GetBlockByID
GetLatestBlockHeader
,GetBlockHeaderAtHeight
,GetBlockHeaderByID
Version 0.4.0
💥 Breaking Changes
Cadence
- Cadence has been upgraded to
v0.4.0
: https://github.com/onflow/cadence/releases/tag/v0.4.0
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
andEmulator
) 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 toflow.EmptyAddress
flow.ZeroID
was renamed toflow.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 theSigAlgo
field based on the provided public key. (#35)flow.BlockHeader
now includes aTimestamp
field. (#42)- The
flow.Mainnet
,flow.Testnet
andflow.Emulator
ChainID
constants were introduced to differentiate between different networks.
⚙️ Installing & Upgrading
go get github.com/onflow/flow-go-sdk@v0.4.0
Version 0.4.0 (Beta 1)
⚠️ 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
Compatible Emulator version: v0.1.1
🐛 Bug Fixes
- Fix
GetAccount
to returnAccountKey
values with correctID
field. Previously the ID for each key was set to zero.
⬆️ Upgrade
go get github.com/onflow/flow-go-sdk@v0.1.1
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