Repository: onflow/flow-cli
Pull request #1595 (2024-05-14 21:35:15)

Upgrade flowkit


______

For contributor use:

- [ ] Targeted PR against `master` branch
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work
- [ ] Code follows the [standards mentioned here](https://github.com/onflow/flow-cli/blob/master/CONTRIBUTING.md#styleguides)
- [ ] Updated relevant documentation
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Added appropriate labels



Patch:
diff --git a/go.mod b/go.mod
index 1e6d0245..bc92ef36 100644
--- a/go.mod
+++ b/go.mod
@@ -11,18 +11,18 @@ require (
 	github.com/logrusorgru/aurora/v4 v4.0.0
 	github.com/manifoldco/promptui v0.9.0
 	github.com/onflow/cadence v1.0.0-preview.25
-	github.com/onflow/cadence-tools/languageserver v1.0.0-preview.14
+	github.com/onflow/cadence-tools/languageserver v1.0.0-preview.15
 	github.com/onflow/cadence-tools/lint v1.0.0-preview.17
 	github.com/onflow/cadence-tools/test v1.0.0-preview.15
 	github.com/onflow/contract-updater/lib/go/templates v1.0.1
 	github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1
-	github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.13
+	github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.14
 	github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240429192223-e696a8e439b5
 	github.com/onflow/flow-emulator v1.0.0-preview.22
 	github.com/onflow/flow-evm-gateway v0.9.0
 	github.com/onflow/flow-go v0.34.0-crescendo-preview.18
 	github.com/onflow/flow-go-sdk v1.0.0-preview.25
-	github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.18
+	github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.19
 	github.com/onflow/go-ethereum v1.13.4
 	github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48
 	github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
diff --git a/go.sum b/go.sum
index 21d90620..a5c372bd 100644
--- a/go.sum
+++ b/go.sum
@@ -2062,8 +2062,8 @@ github.com/onflow/atree v0.7.0-rc.1/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ
 github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
 github.com/onflow/cadence v1.0.0-preview.25 h1:kSmWjxmg9PS+bsk8C3j1NUTkFAl/jNrintVhlh6miM0=
 github.com/onflow/cadence v1.0.0-preview.25/go.mod h1:fGhLBbuEmv5rh48qv0ZS0tUz53gxWsHpB4dPsF09h6E=
-github.com/onflow/cadence-tools/languageserver v1.0.0-preview.14 h1:bG9ecxcEDkiO7EpTo6DVDrGZhVuSVgyoEFdW1aJmHPY=
-github.com/onflow/cadence-tools/languageserver v1.0.0-preview.14/go.mod h1:36/d7Znj05df08Gu0wsOTzLS+DeBQ4/8cD6kORKchZ4=
+github.com/onflow/cadence-tools/languageserver v1.0.0-preview.15 h1:h653h3MxWyH2ZrB40FPMuXUn1a8pwi6PCwOGlenEdu8=
+github.com/onflow/cadence-tools/languageserver v1.0.0-preview.15/go.mod h1:yMyhrH0p/BuDm6xLY1MzOPAECjNot6PpPCOB4lpj/cc=
 github.com/onflow/cadence-tools/lint v1.0.0-preview.17 h1:ERfb0IeO0vrT2Gs7p9jPeDUYIf8P9wa1foyBQCLz1Bs=
 github.com/onflow/cadence-tools/lint v1.0.0-preview.17/go.mod h1:li3nUOoTFQDvqsGlJxu7CPvyeBbV6PQTrZ8T0UROiwM=
 github.com/onflow/cadence-tools/test v1.0.0-preview.15 h1:hBDDNBz3V3VntriqokY+/GqYb1/Iw/9+pRhiOQ39tEc=
@@ -2075,8 +2075,8 @@ github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A=
 github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
 github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 h1:IqdUzdqFCSW0klWmA3J9c17ZyQTab9SWcWSLouX6o0Q=
 github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw=
-github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.13 h1:/3oNbdEsi98SWlSzmabe1DXfy4OCUSC1Gwe9vFX6anY=
-github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.13/go.mod h1:C820Ndv7HLTnn4q+fBvg/i6at8bmIyQK6V81Pzuo4b4=
+github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.14 h1:Q0MEdGnWAOt8tZXCbLvX4LW5aWka1FsTEh0ZxG8tJCc=
+github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.14/go.mod h1:e5v8Mjec2fPjpNSMx1Yt3kRvAfLWIjAguWt2Rpyrevs=
 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240429192223-e696a8e439b5 h1:by3a+8p2kUUjnxfbRYRd78bDEeXAc3PK2LzyBEQqkV4=
 github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240429192223-e696a8e439b5/go.mod h1:+4JWLclBOT+emyBh6NAZSEbqEwzHcWHpIbfsXmRASgY=
 github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240429192223-e696a8e439b5 h1:6Cg0h+8Iyy/Nnefk5j0gdeVoMTNpUooAMjyV8sk6zoA=
@@ -2101,8 +2101,8 @@ github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140/g
 github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
 github.com/onflow/flow/protobuf/go/flow v0.4.1-0.20240412170550-911321113030 h1:I+aosSiJny88O4p3nPbCiUcp/UqN6AepvO6uj82bjH0=
 github.com/onflow/flow/protobuf/go/flow v0.4.1-0.20240412170550-911321113030/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
-github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.18 h1:vgQ1SpQ9mpTX+c6x1hm71DmaLnHoMr3kIG479Ye0ll4=
-github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.18/go.mod h1:uQiVIHhm6dXrXDM9SQG00FIaEQgh+TdVvM+ortvpF+M=
+github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.19 h1:oKiXykcwVvs/J5CTtKkdzaieTitCYDXdoBPMBBe1Mb0=
+github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.19/go.mod h1:uQiVIHhm6dXrXDM9SQG00FIaEQgh+TdVvM+ortvpF+M=
 github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc=
 github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY=
 github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo=
diff --git a/internal/accounts/create-interactive.go b/internal/accounts/create-interactive.go
index f2deaebd..113ed74d 100644
--- a/internal/accounts/create-interactive.go
+++ b/internal/accounts/create-interactive.go
@@ -52,7 +52,7 @@ func createInteractive(state *flowkit.State) (*accountResult, error) {
 	log := output.NewStdoutLogger(output.InfoLog)
 	name := util.AccountNamePrompt(state.Accounts().Names())
 	networkName, selectedNetwork := util.CreateAccountNetworkPrompt()
-	privateFile := accounts.PrivateKeyFile(name)
+	privateFile := accounts.PrivateKeyFile(name, "")
 
 	// create new gateway based on chosen network
 	gw, err := gateway.NewGrpcGateway(selectedNetwork)
diff --git a/internal/config/init.go b/internal/config/init.go
index ba968ead..3439764f 100644
--- a/internal/config/init.go
+++ b/internal/config/init.go
@@ -22,6 +22,8 @@ import (
 	"bytes"
 	"fmt"
 
+	"github.com/onflow/flowkit/v2/accounts"
+
 	"github.com/onflow/flow-go-sdk/crypto"
 	"github.com/spf13/cobra"
 
@@ -71,11 +73,18 @@ func Initialise(
 		return nil, fmt.Errorf("invalid hash algorithm: %s", InitFlag.ServiceKeyHashAlgo)
 	}
 
-	state, err := flowkit.Init(readerWriter, sigAlgo, hashAlgo)
+	state, err := flowkit.Init(readerWriter)
+	if err != nil {
+		return nil, err
+	}
+
+	emulatorAccount, err := accounts.NewEmulatorAccount(readerWriter, crypto.ECDSA_P256, crypto.SHA3_256, "")
 	if err != nil {
 		return nil, err
 	}
 
+	state.Accounts().AddOrUpdate(emulatorAccount)
+
 	if InitFlag.ServicePrivateKey != "" {
 		privateKey, err := crypto.DecodePrivateKeyHex(sigAlgo, InitFlag.ServicePrivateKey)
 		if err != nil {
diff --git a/internal/dependencymanager/install.go b/internal/dependencymanager/install.go
index ebc71c9e..ecb3a0e2 100644
--- a/internal/dependencymanager/install.go
+++ b/internal/dependencymanager/install.go
@@ -20,6 +20,7 @@ package dependencymanager
 
 import (
 	"fmt"
+
 	"github.com/onflow/flow-cli/internal/util"
 
 	"github.com/spf13/cobra"
diff --git a/internal/emulator/start.go b/internal/emulator/start.go
index bdc673fa..df122ab8 100644
--- a/internal/emulator/start.go
+++ b/internal/emulator/start.go
@@ -62,7 +62,7 @@ func configuredServiceKey(
 			hashAlgo = emulator.DefaultServiceKeyHashAlgo
 		}
 
-		state, err = flowkit.Init(loader, sigAlgo, hashAlgo)
+		state, err = flowkit.Init(loader)
 		if err != nil {
 			exitf(1, err.Error())
 		} else {


Test patch:
diff --git a/internal/cadence/lint_test.go b/internal/cadence/lint_test.go
index 81c2585a..850e9557 100644
--- a/internal/cadence/lint_test.go
+++ b/internal/cadence/lint_test.go
@@ -24,7 +24,6 @@ import (
 	"github.com/onflow/cadence/runtime/ast"
 	"github.com/onflow/cadence/runtime/common"
 	"github.com/onflow/cadence/tools/analysis"
-	"github.com/onflow/flow-go-sdk/crypto"
 	"github.com/onflow/flowkit/v2"
 	"github.com/onflow/flowkit/v2/config"
 	"github.com/spf13/afero"
@@ -311,7 +310,7 @@ func setupMockState(t *testing.T) *flowkit.State {
 	}`), 0644)
 
 	rw := afero.Afero{Fs: mockFs}
-	state, err := flowkit.Init(rw, crypto.ECDSA_P256, crypto.SHA3_256)
+	state, err := flowkit.Init(rw)
 	require.NoError(t, err)
 
 	// Mock flowkit contracts
diff --git a/internal/super/flix_test.go b/internal/super/flix_test.go
index ac9acc8a..2e98c997 100644
--- a/internal/super/flix_test.go
+++ b/internal/super/flix_test.go
@@ -27,7 +27,6 @@ import (
 	"github.com/stretchr/testify/mock"
 
 	"github.com/onflow/flixkit-go/flixkit"
-	"github.com/onflow/flow-go-sdk/crypto"
 
 	"github.com/onflow/flowkit/v2"
 	"github.com/onflow/flowkit/v2/config"
@@ -221,7 +220,7 @@ func Test_GenerateFlixPrefill(t *testing.T) {
 	var rw = afero.Afero{Fs: mockFS}
 	err := rw.WriteFile(cadenceFile, []byte(CADENCE_SCRIPT), 0644)
 	assert.NoError(t, err)
-	state, _ := flowkit.Init(rw, crypto.ECDSA_P256, crypto.SHA3_256)
+	state, _ := flowkit.Init(rw)
 
 	mockFlixService := new(MockFlixService)
 	ctx := context.Background()
diff --git a/internal/util/test.go b/internal/util/test.go
index c688515c..634af4f9 100644
--- a/internal/util/test.go
+++ b/internal/util/test.go
@@ -21,8 +21,10 @@ package util
 import (
 	"testing"
 
-	"github.com/onflow/flow-go-sdk"
 	"github.com/onflow/flow-go-sdk/crypto"
+	"github.com/onflow/flowkit/v2/accounts"
+
+	"github.com/onflow/flow-go-sdk"
 	"github.com/stretchr/testify/require"
 
 	"github.com/onflow/flowkit/v2"
@@ -39,8 +41,11 @@ var TestID = flow.HexToID("24993fc99f81641c45c0afa307e683b4f08d407d90041aa9439f4
 func TestMocks(t *testing.T) (*mocks.MockServices, *flowkit.State, flowkit.ReaderWriter) {
 	services := mocks.DefaultMockServices()
 	rw, _ := tests.ReaderWriter()
-	state, err := flowkit.Init(rw, crypto.ECDSA_P256, crypto.SHA3_256)
+	state, err := flowkit.Init(rw)
 	require.NoError(t, err)
 
+	emulatorAccount, _ := accounts.NewEmulatorAccount(rw, crypto.ECDSA_P256, crypto.SHA3_256, "")
+	state.Accounts().AddOrUpdate(emulatorAccount)
+
 	return services, state, rw
 }