From f5697c0338dce727de1967ab96bafa241505701c Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:43:00 -0800 Subject: [PATCH 01/21] Bump version to 1.12.0 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 285cea5d1..13a15bd96 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.11.0 \ No newline at end of file +v1.12.0 \ No newline at end of file From 5f29b18f2ba755b6fe0463f635962dbe96a5b47d Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Fri, 26 Jan 2024 14:27:51 -0800 Subject: [PATCH 02/21] Default to "file" location type for emulator-account key in flow.json (#1337) --- flowkit/accounts/account.go | 26 ++++++++++++++++++++---- flowkit/accounts/keys.go | 15 +++++++++++++- flowkit/accounts/keys_test.go | 5 ++++- flowkit/state.go | 8 ++++---- flowkit/transactions/transaction_test.go | 3 ++- internal/accounts/create-interactive.go | 4 ++-- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/flowkit/accounts/account.go b/flowkit/accounts/account.go index bc2c9612a..6902db65c 100644 --- a/flowkit/accounts/account.go +++ b/flowkit/accounts/account.go @@ -36,6 +36,11 @@ type Account struct { Key Key } +// PrivateKeyFile returns the private key file name for an account. +func PrivateKeyFile(name string) string { + return fmt.Sprintf("%s.pkey", name) +} + func FromConfig(conf *config.Config) (Accounts, error) { var accounts Accounts for _, accountConf := range conf.Accounts { @@ -85,22 +90,35 @@ func toConfig(account Account) config.Account { } } -func NewEmulatorAccount(sigAlgo crypto.SignatureAlgorithm, hashAlgo crypto.HashAlgorithm) (*Account, error) { +// defaultEmulatorPrivateKeyFile returns the default emulator private key file name. +func defaultEmulatorPrivateKeyFile() string { + return PrivateKeyFile("emulator-account") +} + +func NewEmulatorAccount( + rw config.ReaderWriter, + sigAlgo crypto.SignatureAlgorithm, + hashAlgo crypto.HashAlgorithm, +) (*Account, error) { seed := make([]byte, crypto.MinSeedLength) _, err := rand.Read(seed) if err != nil { - return nil, fmt.Errorf("failed to generate random seed: %v", err) + return nil, fmt.Errorf("failed to generate random seed: %w", err) } privateKey, err := crypto.GeneratePrivateKey(sigAlgo, seed) if err != nil { - return nil, fmt.Errorf("failed to generate emulator service key: %v", err) + return nil, fmt.Errorf("failed to generate emulator service key: %w", err) + } + + if err := rw.WriteFile(defaultEmulatorPrivateKeyFile(), []byte(privateKey.String()), 0644); err != nil { + return nil, fmt.Errorf("failed to write private key file: %w", err) } return &Account{ Name: config.DefaultEmulator.ServiceAccount, Address: flow.ServiceAddress(flow.Emulator), - Key: NewHexKeyFromPrivateKey(0, hashAlgo, privateKey), + Key: NewFileKey(defaultEmulatorPrivateKeyFile(), 0, sigAlgo, hashAlgo, rw), }, nil } diff --git a/flowkit/accounts/keys.go b/flowkit/accounts/keys.go index cac4481f3..ddfb425ea 100644 --- a/flowkit/accounts/keys.go +++ b/flowkit/accounts/keys.go @@ -301,6 +301,7 @@ func NewFileKey( index int, sigAlgo crypto.SignatureAlgorithm, hashAlgo crypto.HashAlgorithm, + rw config.ReaderWriter, ) *FileKey { return &FileKey{ baseKey: &baseKey{ @@ -309,6 +310,7 @@ func NewFileKey( sigAlgo: sigAlgo, hashAlgo: hashAlgo, }, + rw: rw, location: location, } } @@ -319,6 +321,7 @@ func NewFileKey( type FileKey struct { *baseKey privateKey crypto.PrivateKey + rw config.ReaderWriter location string } @@ -333,10 +336,20 @@ func (f *FileKey) Signer(ctx context.Context) (crypto.Signer, error) { func (f *FileKey) PrivateKey() (*crypto.PrivateKey, error) { if f.privateKey == nil { // lazy load the key - key, err := os.ReadFile(f.location) // TODO(sideninja) change to use the state ReaderWriter + // if reader writer is provided, use it to read the file + var ( + key []byte + err error + ) + if f.rw != nil { + key, err = f.rw.ReadFile(f.location) + } else { + key, err = os.ReadFile(f.location) + } if err != nil { return nil, fmt.Errorf("could not load the key for the account from provided location %s: %w", f.location, err) } + pkey, err := crypto.DecodePrivateKeyHex(f.sigAlgo, strings.TrimPrefix(string(key), "0x")) if err != nil { return nil, fmt.Errorf("could not decode the key from provided location %s: %w", f.location, err) diff --git a/flowkit/accounts/keys_test.go b/flowkit/accounts/keys_test.go index 550c6b8bd..c991c3fe6 100644 --- a/flowkit/accounts/keys_test.go +++ b/flowkit/accounts/keys_test.go @@ -24,6 +24,8 @@ import ( "github.com/stretchr/testify/assert" + "github.com/onflow/flow-cli/flowkit/tests" + "github.com/onflow/flow-cli/flowkit/config" ) @@ -59,7 +61,8 @@ func Test_File_key(t *testing.T) { cKey := fileKey.ToConfig() assert.Equal(t, cKey, confKey) - key := NewFileKey(confKey.Location, confKey.Index, confKey.SigAlgo, confKey.HashAlgo) + rw, _ := tests.ReaderWriter() + key := NewFileKey(confKey.Location, confKey.Index, confKey.SigAlgo, confKey.HashAlgo, rw) assert.Equal(t, confKey, key.ToConfig()) } diff --git a/flowkit/state.go b/flowkit/state.go index 94993cc3f..8bf62d75c 100644 --- a/flowkit/state.go +++ b/flowkit/state.go @@ -267,21 +267,21 @@ func Load(configFilePaths []string, readerWriter ReaderWriter) (*State, error) { // Init initializes a new Flow project. func Init( - readerWriter ReaderWriter, + rw ReaderWriter, sigAlgo crypto.SignatureAlgorithm, hashAlgo crypto.HashAlgorithm, ) (*State, error) { - emulatorServiceAccount, err := accounts.NewEmulatorAccount(sigAlgo, hashAlgo) + emulatorServiceAccount, err := accounts.NewEmulatorAccount(rw, sigAlgo, hashAlgo) if err != nil { return nil, err } - loader := config.NewLoader(readerWriter) + loader := config.NewLoader(rw) loader.AddConfigParser(json.NewParser()) return &State{ confLoader: loader, - readerWriter: readerWriter, + readerWriter: rw, conf: config.Default(), accounts: &accounts.Accounts{*emulatorServiceAccount}, }, nil diff --git a/flowkit/transactions/transaction_test.go b/flowkit/transactions/transaction_test.go index 8025c03d4..44d446195 100644 --- a/flowkit/transactions/transaction_test.go +++ b/flowkit/transactions/transaction_test.go @@ -75,7 +75,8 @@ func TestNew(t *testing.T) { assert.Equal(t, addr.String(), tx.FlowTransaction().ProposalKey.Address.String()) assert.Equal(t, proposer.Keys[index].Index, tx.FlowTransaction().ProposalKey.KeyIndex) - sig, _ := accounts.NewEmulatorAccount(crypto.ECDSA_P256, crypto.SHA3_256) + rw, _ := tests.ReaderWriter() + sig, _ := accounts.NewEmulatorAccount(rw, crypto.ECDSA_P256, crypto.SHA3_256) sig.Address = flow.HexToAddress("0x01") err = tx.SetSigner(sig) assert.NoError(t, err) diff --git a/internal/accounts/create-interactive.go b/internal/accounts/create-interactive.go index 95f300da3..3d8aa2b2b 100644 --- a/internal/accounts/create-interactive.go +++ b/internal/accounts/create-interactive.go @@ -51,7 +51,7 @@ func createInteractive(state *flowkit.State) (*accountResult, error) { log := output.NewStdoutLogger(output.InfoLog) name := util.AccountNamePrompt(state.Accounts().Names()) networkName, selectedNetwork := util.CreateAccountNetworkPrompt() - privateFile := fmt.Sprintf("%s.pkey", name) + privateFile := accounts.PrivateKeyFile(name) // create new gateway based on chosen network gw, err := gateway.NewGrpcGateway(selectedNetwork) @@ -159,7 +159,7 @@ func createNetworkAccount( return &accounts.Account{ Name: name, Address: *address[0], - Key: accounts.NewFileKey(privateFile, 0, defaultSignAlgo, defaultHashAlgo), + Key: accounts.NewFileKey(privateFile, 0, defaultSignAlgo, defaultHashAlgo, state.ReaderWriter()), }, nil } From a975cd468401b871f81a72efa0f89286dafeb7d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:13:23 +0000 Subject: [PATCH 03/21] Bump google.golang.org/grpc from 1.60.1 to 1.61.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.1 to 1.61.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.60.1...v1.61.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 26 +++++++++++++------------- go.sum | 58 ++++++++++++++++++++++++++++------------------------------ 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/go.mod b/go.mod index 144303b26..3c9dd8ade 100644 --- a/go.mod +++ b/go.mod @@ -28,14 +28,14 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 golang.org/x/exp v0.0.0-20230321023759-10a507213a29 - google.golang.org/grpc v1.60.1 + google.golang.org/grpc v1.61.0 ) require ( - cloud.google.com/go/compute v1.23.0 // indirect + cloud.google.com/go/compute v1.23.3 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.2 // indirect - cloud.google.com/go/kms v1.15.2 // indirect + cloud.google.com/go/iam v1.1.5 // indirect + cloud.google.com/go/kms v1.15.5 // indirect dario.cat/mergo v1.0.0 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect @@ -98,9 +98,9 @@ require ( github.com/google/go-dap v0.11.0 // indirect github.com/google/go-github v17.0.0+incompatible // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.4 // indirect + github.com/google/s2a-go v0.1.7 // indirect + github.com/google/uuid v1.4.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect @@ -234,19 +234,19 @@ require ( golang.org/x/crypto v0.16.0 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.13.0 // indirect - golang.org/x/sync v0.4.0 // indirect + golang.org/x/oauth2 v0.14.0 // indirect + golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.13.0 // indirect - google.golang.org/api v0.128.0 // indirect + google.golang.org/api v0.149.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect diff --git a/go.sum b/go.sum index 424ea12b5..33e49e59b 100644 --- a/go.sum +++ b/go.sum @@ -27,24 +27,24 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME= +cloud.google.com/go v0.110.10 h1:LXy9GEO+timppncPIAZoOj3l58LIU9k+kn48AN7IO3Y= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= +cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v1.1.2 h1:gacbrBdWcoVmGLozRuStX45YKvJtzIjJdAolzUs1sm4= -cloud.google.com/go/iam v1.1.2/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= +cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI= +cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= cloud.google.com/go/kms v1.0.0/go.mod h1:nhUehi+w7zht2XrUfvTRNpxrfayBHqP4lu2NSywui/0= -cloud.google.com/go/kms v1.15.2 h1:lh6qra6oC4AyWe5fUUUBe/S27k12OHAleOOOw6KakdE= -cloud.google.com/go/kms v1.15.2/go.mod h1:3hopT4+7ooWRCjc2DxgnpESFxhIraaI2IpAVUEhbT/w= +cloud.google.com/go/kms v1.15.5 h1:pj1sRfut2eRbD9pFRjNnPNg/CzJPuQAzUujMIM1vVeM= +cloud.google.com/go/kms v1.15.5/go.mod h1:cU2H5jnp6G2TDpUGZyqTCoy1n16fbubHZjmVXSMtwDI= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -496,15 +496,15 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= +github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.4 h1:uGy6JWR/uMIILU8wbf+OkstIrNiMjGpEIyhx8f6W7s4= -github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= +github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -1263,7 +1263,6 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= @@ -1391,8 +1390,8 @@ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0= +golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1406,8 +1405,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1653,8 +1652,8 @@ google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= -google.golang.org/api v0.128.0 h1:RjPESny5CnQRn9V6siglged+DZCgfu9l6mO9dkX9VOg= -google.golang.org/api v0.128.0/go.mod h1:Y611qgqaE92On/7g65MQgxYul3c0rEB894kniWLY750= +google.golang.org/api v0.149.0 h1:b2CqT6kG+zqJIVKRQ3ELJVLN1PwHZ6DJ3dW8yl82rgY= +google.golang.org/api v0.149.0/go.mod h1:Mwn1B7JTXrzXtnvmzQE2BD6bYZQ8DShKZDZbeN9I7qI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1731,13 +1730,13 @@ google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211007155348-82e027067bd4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= -google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= -google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc h1:g3hIDl0jRNd9PPTs2uBzYuaD5mQuwOkZY0vSc0LR32o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= +google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= +google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= +google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20231030173426-d783a09b4405 h1:o4S3HvTUEXgRsNSUQsALDVog0O9F/U1JJlHmmUN8Uas= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1771,9 +1770,8 @@ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= +google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= From 5c48fe3f91ca2cf811d422db3705503bae5f3a0c Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:37:01 -0800 Subject: [PATCH 04/21] Fix command message for config add --- internal/dependencymanager/add.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index b972e99a1..72eaedb7e 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -68,7 +68,7 @@ func add( } logger.Info("✅ Dependency installation complete. Check your flow.json") - logger.Info("Ensure you add any required dependencies to your 'deployments' section. This can be done using the 'flow add config deployment' command.") + logger.Info("Ensure you add any required dependencies to your 'deployments' section. This can be done using the 'flow config add deployment' command.") logger.Info("Note: Core contracts do not need to be added to deployments. For reference, see this URL: https://github.com/onflow/flow-core-contracts") return nil, nil From 4159ac6bfc92fe82cb975176023856a20998d93a Mon Sep 17 00:00:00 2001 From: Tom Haile Date: Wed, 31 Jan 2024 16:20:40 -0600 Subject: [PATCH 05/21] update to use newest version of flixkit-go --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 3c9dd8ade..d1991a187 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/onflow/cadence-tools/languageserver v0.33.3 github.com/onflow/cadence-tools/test v0.14.5 github.com/onflow/fcl-dev-wallet v0.7.4 - github.com/onflow/flixkit-go v1.1.0 - github.com/onflow/flow-cli/flowkit v1.6.1-0.20231110211255-b41f57a8b8c7 + github.com/onflow/flixkit-go v1.1.1 + github.com/onflow/flow-cli/flowkit v1.11.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f github.com/onflow/flow-emulator v0.59.0 github.com/onflow/flow-go-sdk v0.41.17 diff --git a/go.sum b/go.sum index 33e49e59b..be177c5c1 100644 --- a/go.sum +++ b/go.sum @@ -875,8 +875,8 @@ github.com/onflow/cadence-tools/test v0.14.5 h1:u1kYkotKdwKEf9c3h65mI3VMevBkHY+7 github.com/onflow/cadence-tools/test v0.14.5/go.mod h1:ix09Bb3GQ/fZMNpSR8E+vSFItGF54fzP9gFxU7AsOIw= github.com/onflow/fcl-dev-wallet v0.7.4 h1:vI6t3U0AO88R/Iitn5KsnniSpbN9Lqsqwvi9EJT4C0k= github.com/onflow/fcl-dev-wallet v0.7.4/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= -github.com/onflow/flixkit-go v1.1.0 h1:yju2lotk2LQBXUwb0rZeOtVbHW2KVSzzRRu/3rPtzok= -github.com/onflow/flixkit-go v1.1.0/go.mod h1:KGL7oMu4uzt7s0qsNkaqGBYIt+Z38Qbf0JG56qK/Sg0= +github.com/onflow/flixkit-go v1.1.1 h1:ARgLsfWxc3LjgUHUAELildY5lxJ6kA4gVfAS2+ZRaCE= +github.com/onflow/flixkit-go v1.1.1/go.mod h1:XkbRPv6drM8uQpvdKgZ5stShtOlOMiQ6Fy86D0EsW5U= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= From fb33480dc407cc7377f49e30ffc693727aff4441 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:03:14 -0800 Subject: [PATCH 06/21] Update version to v.1.13.0 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 13a15bd96..e58d236a7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.12.0 \ No newline at end of file +v1.13.0 \ No newline at end of file From 8f0c1f13c44c9e938f295699de49f5c85a4716e5 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Thu, 1 Feb 2024 13:30:24 -0800 Subject: [PATCH 07/21] update to use flowkit externally --- go.mod | 5 ++--- go.sum | 4 ++++ internal/accounts/accounts_test.go | 6 +++--- internal/accounts/contract-add.go | 6 +++--- internal/accounts/contract-remove.go | 4 ++-- internal/accounts/create-interactive.go | 10 +++++----- internal/accounts/create.go | 6 +++--- internal/accounts/fund.go | 4 ++-- internal/accounts/get.go | 4 ++-- internal/accounts/staking-info.go | 4 ++-- internal/blocks/blocks_test.go | 4 ++-- internal/blocks/get.go | 4 ++-- internal/collections/get.go | 4 ++-- internal/command/command.go | 8 ++++---- internal/command/global_flags.go | 2 +- internal/command/result.go | 4 ++-- internal/config/add-account.go | 8 ++++---- internal/config/add-contract.go | 6 +++--- internal/config/add-deployment.go | 6 +++--- internal/config/add-network.go | 6 +++--- internal/config/init.go | 6 +++--- internal/config/remove-account.go | 4 ++-- internal/config/remove-contract.go | 4 ++-- internal/config/remove-deployment.go | 4 ++-- internal/config/remove-network.go | 4 ++-- internal/dependencymanager/add.go | 4 ++-- internal/dependencymanager/dependencyinstaller.go | 10 +++++----- .../dependencymanager/dependencyinstaller_test.go | 10 +++++----- internal/dependencymanager/install.go | 4 ++-- internal/emulator/snapshot.go | 4 ++-- internal/emulator/start.go | 4 ++-- internal/events/events_test.go | 4 ++-- internal/events/get.go | 4 ++-- internal/keys/decode.go | 4 ++-- internal/keys/derive.go | 4 ++-- internal/keys/generate.go | 4 ++-- internal/keys/keys.go | 2 +- internal/project/deploy.go | 8 ++++---- internal/project/project_test.go | 6 +++--- internal/quick/run.go | 4 ++-- internal/scripts/execute.go | 6 +++--- internal/scripts/scripts_test.go | 4 ++-- internal/signatures/generate.go | 6 +++--- internal/signatures/verify.go | 4 ++-- internal/snapshot/save.go | 4 ++-- internal/status/status.go | 4 ++-- internal/super/dev.go | 4 ++-- internal/super/files.go | 2 +- internal/super/flix.go | 6 +++--- internal/super/flix_test.go | 10 +++++----- internal/super/generate.go | 6 +++--- internal/super/generate_test.go | 2 +- internal/super/output.go | 6 +++--- internal/super/project.go | 8 ++++---- internal/super/setup.go | 4 ++-- internal/test/test.go | 6 +++--- internal/test/test_test.go | 4 ++-- internal/tools/flowser.go | 6 +++--- internal/tools/wallet.go | 4 ++-- internal/transactions/build.go | 8 ++++---- internal/transactions/decode.go | 6 +++--- internal/transactions/get.go | 4 ++-- internal/transactions/send-signed.go | 6 +++--- internal/transactions/send.go | 10 +++++----- internal/transactions/sign.go | 8 ++++---- internal/transactions/transactions.go | 2 +- internal/transactions/transactions_test.go | 12 ++++++------ internal/util/prompt.go | 4 ++-- internal/util/test.go | 8 ++++---- internal/util/util.go | 2 +- 70 files changed, 186 insertions(+), 183 deletions(-) diff --git a/go.mod b/go.mod index d1991a187..e4f405376 100644 --- a/go.mod +++ b/go.mod @@ -13,10 +13,10 @@ require ( github.com/onflow/cadence-tools/test v0.14.5 github.com/onflow/fcl-dev-wallet v0.7.4 github.com/onflow/flixkit-go v1.1.1 - github.com/onflow/flow-cli/flowkit v1.11.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f github.com/onflow/flow-emulator v0.59.0 github.com/onflow/flow-go-sdk v0.41.17 + github.com/onflow/flowkit v1.13.0 github.com/onflowser/flowser/v3 v3.1.3 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/pkg/errors v0.9.1 @@ -168,6 +168,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.6.0 // indirect github.com/onflow/cadence-tools/lint v0.14.1 // indirect + github.com/onflow/flow-cli/flowkit v1.11.0 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/flow-go v0.32.4-0.20231211231711-1aba0828ca33 // indirect @@ -260,7 +261,5 @@ require ( nhooyr.io/websocket v1.8.7 // indirect ) -replace github.com/onflow/flow-cli/flowkit => ./flowkit - // this is a woraround for the flow-go/crypto cross compliation issue replace github.com/onflow/flow-go/crypto => github.com/onflow/flow-go/crypto v0.24.9 diff --git a/go.sum b/go.sum index be177c5c1..f6228df2e 100644 --- a/go.sum +++ b/go.sum @@ -877,6 +877,8 @@ github.com/onflow/fcl-dev-wallet v0.7.4 h1:vI6t3U0AO88R/Iitn5KsnniSpbN9Lqsqwvi9E github.com/onflow/fcl-dev-wallet v0.7.4/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= github.com/onflow/flixkit-go v1.1.1 h1:ARgLsfWxc3LjgUHUAELildY5lxJ6kA4gVfAS2+ZRaCE= github.com/onflow/flixkit-go v1.1.1/go.mod h1:XkbRPv6drM8uQpvdKgZ5stShtOlOMiQ6Fy86D0EsW5U= +github.com/onflow/flow-cli/flowkit v1.11.0 h1:RSfKlla/l+ZJwqAmlvA5HPFbQ6ia2wzKSG0kJ8fqVa0= +github.com/onflow/flow-cli/flowkit v1.11.0/go.mod h1:aH4shan7Ggxd0GIXZD2S4kYMemNfzP1rLWvzKnb6K3g= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= @@ -897,6 +899,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9j github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231124194313-106cc495def6 h1:KMN+OEVaw7KAgxL3p8ux7CMuyTvacAlYTbasOqowh4M= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231124194313-106cc495def6/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flowkit v1.13.0 h1:a8XIDxz/k54nw2UAN3BxVeXnflwUzZaxocSxhA5IFiw= +github.com/onflow/flowkit v1.13.0/go.mod h1:V1vMr/51HpLT8oWw/zoFsLs33ibG8FNeoNbA5SGTHf8= github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead h1:2j1Unqs76Z1b95Gu4C3Y28hzNUHBix7wL490e61SMSw= github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead/go.mod h1:E3ScfQb5XcWJCIAdtIeEnr5i5l2y60GT0BTXeIHseWg= github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= diff --git a/internal/accounts/accounts_test.go b/internal/accounts/accounts_test.go index c6db069dd..999d59871 100644 --- a/internal/accounts/accounts_test.go +++ b/internal/accounts/accounts_test.go @@ -23,7 +23,7 @@ import ( "strings" "testing" - "github.com/onflow/flow-cli/flowkit/accounts" + "github.com/onflow/flowkit/accounts" "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" @@ -31,10 +31,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/tests" ) func Test_DeployContract(t *testing.T) { diff --git a/internal/accounts/contract-add.go b/internal/accounts/contract-add.go index 084b91716..88407872d 100644 --- a/internal/accounts/contract-add.go +++ b/internal/accounts/contract-add.go @@ -28,10 +28,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/arguments" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/arguments" + "github.com/onflow/flowkit/output" ) type deployContractFlags struct { diff --git a/internal/accounts/contract-remove.go b/internal/accounts/contract-remove.go index a6839febd..84ebc8b44 100644 --- a/internal/accounts/contract-remove.go +++ b/internal/accounts/contract-remove.go @@ -26,9 +26,9 @@ import ( "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRemoveContract struct { diff --git a/internal/accounts/create-interactive.go b/internal/accounts/create-interactive.go index 3d8aa2b2b..2fee793fd 100644 --- a/internal/accounts/create-interactive.go +++ b/internal/accounts/create-interactive.go @@ -35,12 +35,12 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/accounts" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/gateway" + "github.com/onflow/flowkit/output" ) // createInteractive is used when user calls a default account create command without any provided values. diff --git a/internal/accounts/create.go b/internal/accounts/create.go index 436321fad..90ff7168f 100644 --- a/internal/accounts/create.go +++ b/internal/accounts/create.go @@ -23,14 +23,14 @@ import ( "fmt" "strings" - "github.com/onflow/flow-cli/flowkit/accounts" + "github.com/onflow/flowkit/accounts" "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsCreate struct { diff --git a/internal/accounts/fund.go b/internal/accounts/fund.go index 4f161a20c..177aacd33 100644 --- a/internal/accounts/fund.go +++ b/internal/accounts/fund.go @@ -27,9 +27,9 @@ import ( "github.com/pkg/browser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsFund struct { diff --git a/internal/accounts/get.go b/internal/accounts/get.go index 9c9c5b8cd..2bb7d1397 100644 --- a/internal/accounts/get.go +++ b/internal/accounts/get.go @@ -25,9 +25,9 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsGet struct { diff --git a/internal/accounts/staking-info.go b/internal/accounts/staking-info.go index 4ef3013ba..ba9b9252a 100644 --- a/internal/accounts/staking-info.go +++ b/internal/accounts/staking-info.go @@ -28,10 +28,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsStakingInfo struct{} diff --git a/internal/blocks/blocks_test.go b/internal/blocks/blocks_test.go index 04f6dd12d..af9236df8 100644 --- a/internal/blocks/blocks_test.go +++ b/internal/blocks/blocks_test.go @@ -26,10 +26,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/tests" ) func Test_GetBlock(t *testing.T) { diff --git a/internal/blocks/get.go b/internal/blocks/get.go index de384fd27..1776a2cba 100644 --- a/internal/blocks/get.go +++ b/internal/blocks/get.go @@ -24,9 +24,9 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsBlocks struct { diff --git a/internal/collections/get.go b/internal/collections/get.go index 72370444a..ce81d0792 100644 --- a/internal/collections/get.go +++ b/internal/collections/get.go @@ -25,9 +25,9 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsCollections struct{} diff --git a/internal/command/command.go b/internal/command/command.go index f1dcd81ca..0beab2c5a 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -39,12 +39,12 @@ import ( "github.com/spf13/cobra" "github.com/onflow/flow-cli/build" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/settings" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/gateway" + "github.com/onflow/flowkit/output" ) // run the command with arguments. diff --git a/internal/command/global_flags.go b/internal/command/global_flags.go index 33ecc0a9f..15077a531 100644 --- a/internal/command/global_flags.go +++ b/internal/command/global_flags.go @@ -25,8 +25,8 @@ import ( "github.com/psiemens/sconfig" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit/config" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/config" ) // Flags initialized to default values. diff --git a/internal/command/result.go b/internal/command/result.go index ed9be9266..0e4ba3f37 100644 --- a/internal/command/result.go +++ b/internal/command/result.go @@ -30,8 +30,8 @@ import ( "github.com/spf13/afero" "golang.org/x/exp/maps" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) // Result interface describes all the formats for the result output. diff --git a/internal/config/add-account.go b/internal/config/add-account.go index c3255292c..d9eabbca1 100644 --- a/internal/config/add-account.go +++ b/internal/config/add-account.go @@ -22,17 +22,17 @@ import ( "fmt" "strconv" - "github.com/onflow/flow-cli/flowkit/accounts" + "github.com/onflow/flowkit/accounts" "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsAddAccount struct { diff --git a/internal/config/add-contract.go b/internal/config/add-contract.go index 2191a7ac2..bf831c94c 100644 --- a/internal/config/add-contract.go +++ b/internal/config/add-contract.go @@ -24,11 +24,11 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsAddContract struct { diff --git a/internal/config/add-deployment.go b/internal/config/add-deployment.go index b642dc7a5..8f4864a34 100644 --- a/internal/config/add-deployment.go +++ b/internal/config/add-deployment.go @@ -23,11 +23,11 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsAddDeployment struct { diff --git a/internal/config/add-network.go b/internal/config/add-network.go index 832ee1d7e..4e0464c71 100644 --- a/internal/config/add-network.go +++ b/internal/config/add-network.go @@ -24,11 +24,11 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsAddNetwork struct { diff --git a/internal/config/init.go b/internal/config/init.go index c726004fe..17abd0cc0 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -25,11 +25,11 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsInit struct { diff --git a/internal/config/remove-account.go b/internal/config/remove-account.go index a2b42f36b..335fb1c05 100644 --- a/internal/config/remove-account.go +++ b/internal/config/remove-account.go @@ -21,10 +21,10 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRemoveAccount struct{} diff --git a/internal/config/remove-contract.go b/internal/config/remove-contract.go index fd7236566..43ac131f6 100644 --- a/internal/config/remove-contract.go +++ b/internal/config/remove-contract.go @@ -21,10 +21,10 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRemoveContract struct{} diff --git a/internal/config/remove-deployment.go b/internal/config/remove-deployment.go index 6a8c0daf1..18769d7b3 100644 --- a/internal/config/remove-deployment.go +++ b/internal/config/remove-deployment.go @@ -21,10 +21,10 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRemoveDeployment struct{} diff --git a/internal/config/remove-network.go b/internal/config/remove-network.go index 48f2d956f..e135b53cb 100644 --- a/internal/config/remove-network.go +++ b/internal/config/remove-network.go @@ -21,10 +21,10 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRemoveNetwork struct{} diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index 72eaedb7e..79a601715 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type addFlagsCollection struct { diff --git a/internal/dependencymanager/dependencyinstaller.go b/internal/dependencymanager/dependencyinstaller.go index 0be79d74b..b2581255b 100644 --- a/internal/dependencymanager/dependencyinstaller.go +++ b/internal/dependencymanager/dependencyinstaller.go @@ -28,16 +28,16 @@ import ( "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flow-cli/flowkit/gateway" + "github.com/onflow/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/project" + "github.com/onflow/flowkit/project" flowsdk "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-cli/flowkit/config" + "github.com/onflow/flowkit/config" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type DependencyInstaller struct { diff --git a/internal/dependencymanager/dependencyinstaller_test.go b/internal/dependencymanager/dependencyinstaller_test.go index 9a7e1ac59..abeda12d2 100644 --- a/internal/dependencymanager/dependencyinstaller_test.go +++ b/internal/dependencymanager/dependencyinstaller_test.go @@ -26,12 +26,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/gateway/mocks" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/gateway" + "github.com/onflow/flowkit/gateway/mocks" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/tests" ) func TestDependencyInstallerInstall(t *testing.T) { diff --git a/internal/dependencymanager/install.go b/internal/dependencymanager/install.go index cd16effb9..4eb17be18 100644 --- a/internal/dependencymanager/install.go +++ b/internal/dependencymanager/install.go @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type installFlagsCollection struct{} diff --git a/internal/emulator/snapshot.go b/internal/emulator/snapshot.go index 5855e403d..2b506270c 100644 --- a/internal/emulator/snapshot.go +++ b/internal/emulator/snapshot.go @@ -29,10 +29,10 @@ import ( "github.com/spf13/cobra" "golang.org/x/exp/slices" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type SnapshotFlag struct{} diff --git a/internal/emulator/start.go b/internal/emulator/start.go index d0661b088..fb0b949e7 100644 --- a/internal/emulator/start.go +++ b/internal/emulator/start.go @@ -30,10 +30,10 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" ) var Cmd *cobra.Command diff --git a/internal/events/events_test.go b/internal/events/events_test.go index 02c6fa7d4..0f109d998 100644 --- a/internal/events/events_test.go +++ b/internal/events/events_test.go @@ -28,10 +28,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/tests" ) func Test_Get(t *testing.T) { diff --git a/internal/events/get.go b/internal/events/get.go index f6f0a6bcc..3770a0525 100644 --- a/internal/events/get.go +++ b/internal/events/get.go @@ -24,9 +24,9 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsEvents struct { diff --git a/internal/keys/decode.go b/internal/keys/decode.go index 98057289a..a861f3b18 100644 --- a/internal/keys/decode.go +++ b/internal/keys/decode.go @@ -27,9 +27,9 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsDecode struct { diff --git a/internal/keys/derive.go b/internal/keys/derive.go index 453be91cd..5bf17bae4 100644 --- a/internal/keys/derive.go +++ b/internal/keys/derive.go @@ -24,9 +24,9 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsDerive struct { diff --git a/internal/keys/generate.go b/internal/keys/generate.go index fd5078a61..98dcd34a2 100644 --- a/internal/keys/generate.go +++ b/internal/keys/generate.go @@ -25,9 +25,9 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsGenerate struct { diff --git a/internal/keys/keys.go b/internal/keys/keys.go index 9ef0114ff..4fb32513e 100644 --- a/internal/keys/keys.go +++ b/internal/keys/keys.go @@ -26,8 +26,8 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/output" ) var Cmd = &cobra.Command{ diff --git a/internal/project/deploy.go b/internal/project/deploy.go index e545a6210..5571e60bb 100644 --- a/internal/project/deploy.go +++ b/internal/project/deploy.go @@ -27,12 +27,12 @@ import ( "github.com/spf13/cobra" "golang.org/x/exp/slices" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/project" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/project" ) type flagsDeploy struct { diff --git a/internal/project/project_test.go b/internal/project/project_test.go index e61a76ee0..c72d689d2 100644 --- a/internal/project/project_test.go +++ b/internal/project/project_test.go @@ -25,11 +25,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/accounts" + "github.com/onflow/flowkit/config" ) func Test_ProjectDeploy(t *testing.T) { diff --git a/internal/quick/run.go b/internal/quick/run.go index 3954ebd8a..c8c98d007 100644 --- a/internal/quick/run.go +++ b/internal/quick/run.go @@ -23,9 +23,9 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsRun struct { diff --git a/internal/scripts/execute.go b/internal/scripts/execute.go index 050518951..c32952e3a 100644 --- a/internal/scripts/execute.go +++ b/internal/scripts/execute.go @@ -26,10 +26,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/arguments" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/arguments" + "github.com/onflow/flowkit/output" ) type Flags struct { diff --git a/internal/scripts/scripts_test.go b/internal/scripts/scripts_test.go index baa191f3d..d5f83ff63 100644 --- a/internal/scripts/scripts_test.go +++ b/internal/scripts/scripts_test.go @@ -26,10 +26,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/tests" ) func Test_Execute(t *testing.T) { diff --git a/internal/signatures/generate.go b/internal/signatures/generate.go index 4d4fefb0c..9fe538d76 100644 --- a/internal/signatures/generate.go +++ b/internal/signatures/generate.go @@ -23,14 +23,14 @@ import ( "context" "fmt" - "github.com/onflow/flow-cli/flowkit/accounts" + "github.com/onflow/flowkit/accounts" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsGenerate struct { diff --git a/internal/signatures/verify.go b/internal/signatures/verify.go index 841346ccf..c9635299b 100644 --- a/internal/signatures/verify.go +++ b/internal/signatures/verify.go @@ -27,10 +27,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsVerify struct { diff --git a/internal/snapshot/save.go b/internal/snapshot/save.go index 3007b80ca..9fc877185 100644 --- a/internal/snapshot/save.go +++ b/internal/snapshot/save.go @@ -24,9 +24,9 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) var saveCommand = &command.Command{ diff --git a/internal/status/status.go b/internal/status/status.go index 60f6c6608..3adbe8f6d 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -24,10 +24,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsStatus struct { diff --git a/internal/super/dev.go b/internal/super/dev.go index 29ab1f068..f224e62c3 100644 --- a/internal/super/dev.go +++ b/internal/super/dev.go @@ -27,9 +27,9 @@ import ( "github.com/onflow/cadence/runtime/parser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsDev struct{} diff --git a/internal/super/files.go b/internal/super/files.go index d1388bfa2..77780e2d9 100644 --- a/internal/super/files.go +++ b/internal/super/files.go @@ -28,7 +28,7 @@ import ( "github.com/pkg/errors" "github.com/radovskyb/watcher" - "github.com/onflow/flow-cli/flowkit/config" + "github.com/onflow/flowkit/config" ) const ( diff --git a/internal/super/flix.go b/internal/super/flix.go index 418b2d126..e96f68554 100644 --- a/internal/super/flix.go +++ b/internal/super/flix.go @@ -28,12 +28,12 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/scripts" "github.com/onflow/flow-cli/internal/transactions" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flixFlags struct { diff --git a/internal/super/flix_test.go b/internal/super/flix_test.go index be6d33692..926e835a7 100644 --- a/internal/super/flix_test.go +++ b/internal/super/flix_test.go @@ -29,13 +29,13 @@ import ( "github.com/onflow/flixkit-go/flixkit" "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/mocks" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/mocks" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/tests" ) type MockFlixService struct { diff --git a/internal/super/generate.go b/internal/super/generate.go index bd8041ff9..fbb27486d 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -23,12 +23,12 @@ import ( "path/filepath" "strings" - "github.com/onflow/flow-cli/flowkit/config" + "github.com/onflow/flowkit/config" - "github.com/onflow/flow-cli/flowkit" + "github.com/onflow/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit/output" "github.com/spf13/cobra" ) diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index 84d56a298..6183fbf6a 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/onflow/flow-cli/flowkit/output" + "github.com/onflow/flowkit/output" ) func TestGenerateNewContract(t *testing.T) { diff --git a/internal/super/output.go b/internal/super/output.go index 064a84d34..f8bf5e41c 100644 --- a/internal/super/output.go +++ b/internal/super/output.go @@ -31,9 +31,9 @@ import ( "golang.org/x/exp/maps" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" - flowkitProject "github.com/onflow/flow-cli/flowkit/project" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" + flowkitProject "github.com/onflow/flowkit/project" ) func printDeployment(deployed []*flowkitProject.Contract, err error, contractPathNames map[string]string) { diff --git a/internal/super/project.go b/internal/super/project.go index d8729fd51..c8225ef34 100644 --- a/internal/super/project.go +++ b/internal/super/project.go @@ -25,11 +25,11 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/pkg/errors" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - flowkitProject "github.com/onflow/flow-cli/flowkit/project" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/accounts" + "github.com/onflow/flowkit/config" + flowkitProject "github.com/onflow/flowkit/project" ) var emulator = config.EmulatorNetwork.Name diff --git a/internal/super/setup.go b/internal/super/setup.go index fd25a1841..e66175efa 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -32,10 +32,10 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsSetup struct { diff --git a/internal/test/test.go b/internal/test/test.go index 84d96cb6c..d16ac4471 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -32,11 +32,11 @@ import ( "github.com/onflow/cadence/runtime/common" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) // The key where meta information for a test report in JSON diff --git a/internal/test/test_test.go b/internal/test/test_test.go index 0f61be418..2f8e7a719 100644 --- a/internal/test/test_test.go +++ b/internal/test/test_test.go @@ -30,9 +30,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/tests" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/tests" ) func TestExecutingTests(t *testing.T) { diff --git a/internal/tools/flowser.go b/internal/tools/flowser.go index 5257bb8d6..dca2fcf4f 100644 --- a/internal/tools/flowser.go +++ b/internal/tools/flowser.go @@ -26,12 +26,12 @@ import ( "github.com/onflowser/flowser/v3/pkg/flowser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/settings" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) type flagsFlowser struct{} diff --git a/internal/tools/wallet.go b/internal/tools/wallet.go index 97a0762c7..2fdc27520 100644 --- a/internal/tools/wallet.go +++ b/internal/tools/wallet.go @@ -25,9 +25,9 @@ import ( devWallet "github.com/onflow/fcl-dev-wallet/go/wallet" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsWallet struct { diff --git a/internal/transactions/build.go b/internal/transactions/build.go index 8ca2cf5a0..843675de3 100644 --- a/internal/transactions/build.go +++ b/internal/transactions/build.go @@ -26,12 +26,12 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/arguments" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/transactions" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/arguments" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/transactions" ) type flagsBuild struct { diff --git a/internal/transactions/decode.go b/internal/transactions/decode.go index fa809bf16..b2c455069 100644 --- a/internal/transactions/decode.go +++ b/internal/transactions/decode.go @@ -21,13 +21,13 @@ package transactions import ( "fmt" - "github.com/onflow/flow-cli/flowkit/transactions" + "github.com/onflow/flowkit/transactions" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsDecode struct { diff --git a/internal/transactions/get.go b/internal/transactions/get.go index d2379fc00..b7e55b703 100644 --- a/internal/transactions/get.go +++ b/internal/transactions/get.go @@ -25,9 +25,9 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsGet struct { diff --git a/internal/transactions/send-signed.go b/internal/transactions/send-signed.go index d39d84612..d28a0e8bc 100644 --- a/internal/transactions/send-signed.go +++ b/internal/transactions/send-signed.go @@ -22,14 +22,14 @@ import ( "context" "fmt" - "github.com/onflow/flow-cli/flowkit/transactions" + "github.com/onflow/flowkit/transactions" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsSendSigned struct { diff --git a/internal/transactions/send.go b/internal/transactions/send.go index ac18309c7..7339c8218 100644 --- a/internal/transactions/send.go +++ b/internal/transactions/send.go @@ -25,12 +25,12 @@ import ( "github.com/onflow/cadence" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/arguments" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/transactions" "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/accounts" + "github.com/onflow/flowkit/arguments" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/transactions" ) type Flags struct { diff --git a/internal/transactions/sign.go b/internal/transactions/sign.go index bf3c25e99..91f0e861a 100644 --- a/internal/transactions/sign.go +++ b/internal/transactions/sign.go @@ -27,17 +27,17 @@ import ( "net/http" "sort" - "github.com/onflow/flow-cli/flowkit/transactions" + "github.com/onflow/flowkit/transactions" - "github.com/onflow/flow-cli/flowkit/accounts" + "github.com/onflow/flowkit/accounts" flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/output" ) type flagsSign struct { diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index ed9f0e3cc..5278d6f09 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -27,10 +27,10 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/flowkit/output" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/events" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit/output" ) var Cmd = &cobra.Command{ diff --git a/internal/transactions/transactions_test.go b/internal/transactions/transactions_test.go index e4dcd3c84..981207221 100644 --- a/internal/transactions/transactions_test.go +++ b/internal/transactions/transactions_test.go @@ -29,14 +29,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/tests" - "github.com/onflow/flow-cli/flowkit/transactions" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/util" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/accounts" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/tests" + "github.com/onflow/flowkit/transactions" ) func Test_Build(t *testing.T) { diff --git a/internal/util/prompt.go b/internal/util/prompt.go index 392aa8d34..cffb1c49f 100644 --- a/internal/util/prompt.go +++ b/internal/util/prompt.go @@ -33,8 +33,8 @@ import ( "golang.org/x/exp/maps" "golang.org/x/exp/slices" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/output" + "github.com/onflow/flowkit/config" + "github.com/onflow/flowkit/output" ) func ApproveTransactionForSigningPrompt(transaction *flow.Transaction) bool { diff --git a/internal/util/test.go b/internal/util/test.go index 17e408c6b..9f5be3727 100644 --- a/internal/util/test.go +++ b/internal/util/test.go @@ -25,10 +25,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/mocks" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/tests" + "github.com/onflow/flowkit" + "github.com/onflow/flowkit/mocks" + "github.com/onflow/flowkit/output" + "github.com/onflow/flowkit/tests" ) var NoLogger = output.NewStdoutLogger(output.NoneLog) diff --git a/internal/util/util.go b/internal/util/util.go index f928ded19..beec1a411 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -30,7 +30,7 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-cli/flowkit" + "github.com/onflow/flowkit" ) const EnvPrefix = "FLOW" From f1bcd08d61bf1f20a41b1005158662d094004c65 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Thu, 1 Feb 2024 16:02:03 -0800 Subject: [PATCH 08/21] linter --- internal/accounts/accounts_test.go | 5 +++-- internal/accounts/contract-add.go | 3 ++- internal/accounts/contract-remove.go | 3 ++- internal/accounts/create-interactive.go | 3 ++- internal/accounts/create.go | 3 ++- internal/accounts/fund.go | 3 ++- internal/accounts/get.go | 3 ++- internal/accounts/staking-info.go | 5 +++-- internal/blocks/blocks_test.go | 5 +++-- internal/blocks/get.go | 3 ++- internal/collections/get.go | 3 ++- internal/command/command.go | 7 ++++--- internal/command/global_flags.go | 3 ++- internal/config/add-account.go | 5 +++-- internal/config/add-contract.go | 5 +++-- internal/config/add-deployment.go | 5 +++-- internal/config/add-network.go | 5 +++-- internal/config/init.go | 5 +++-- internal/config/remove-account.go | 5 +++-- internal/config/remove-contract.go | 5 +++-- internal/config/remove-deployment.go | 5 +++-- internal/config/remove-network.go | 5 +++-- internal/dependencymanager/add.go | 3 ++- internal/dependencymanager/dependencyinstaller_test.go | 3 ++- internal/dependencymanager/install.go | 3 ++- internal/emulator/snapshot.go | 5 +++-- internal/emulator/start.go | 5 +++-- internal/events/events_test.go | 5 +++-- internal/events/get.go | 3 ++- internal/keys/decode.go | 3 ++- internal/keys/derive.go | 3 ++- internal/keys/generate.go | 3 ++- internal/keys/keys.go | 3 ++- internal/project/deploy.go | 5 +++-- internal/project/project_test.go | 5 +++-- internal/quick/run.go | 3 ++- internal/scripts/execute.go | 3 ++- internal/scripts/scripts_test.go | 5 +++-- internal/signatures/generate.go | 5 +++-- internal/signatures/verify.go | 5 +++-- internal/snapshot/save.go | 3 ++- internal/status/status.go | 5 +++-- internal/super/dev.go | 3 ++- internal/super/flix.go | 7 ++++--- internal/super/flix_test.go | 5 +++-- internal/super/generate.go | 3 ++- internal/super/project.go | 3 ++- internal/super/setup.go | 5 +++-- internal/test/test.go | 5 +++-- internal/test/test_test.go | 3 ++- internal/tools/flowser.go | 7 ++++--- internal/tools/wallet.go | 3 ++- internal/transactions/build.go | 5 +++-- internal/transactions/decode.go | 3 ++- internal/transactions/get.go | 3 ++- internal/transactions/send-signed.go | 5 +++-- internal/transactions/send.go | 3 ++- internal/transactions/sign.go | 5 +++-- internal/transactions/transactions.go | 3 ++- internal/transactions/transactions_test.go | 5 +++-- 60 files changed, 154 insertions(+), 94 deletions(-) diff --git a/internal/accounts/accounts_test.go b/internal/accounts/accounts_test.go index 999d59871..0874588ca 100644 --- a/internal/accounts/accounts_test.go +++ b/internal/accounts/accounts_test.go @@ -31,10 +31,11 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_DeployContract(t *testing.T) { diff --git a/internal/accounts/contract-add.go b/internal/accounts/contract-add.go index 88407872d..29061d525 100644 --- a/internal/accounts/contract-add.go +++ b/internal/accounts/contract-add.go @@ -28,10 +28,11 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/arguments" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type deployContractFlags struct { diff --git a/internal/accounts/contract-remove.go b/internal/accounts/contract-remove.go index 84ebc8b44..d4ba049b4 100644 --- a/internal/accounts/contract-remove.go +++ b/internal/accounts/contract-remove.go @@ -26,9 +26,10 @@ import ( "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsRemoveContract struct { diff --git a/internal/accounts/create-interactive.go b/internal/accounts/create-interactive.go index 2fee793fd..a173ebf7a 100644 --- a/internal/accounts/create-interactive.go +++ b/internal/accounts/create-interactive.go @@ -35,12 +35,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/accounts" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/gateway" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/util" ) // createInteractive is used when user calls a default account create command without any provided values. diff --git a/internal/accounts/create.go b/internal/accounts/create.go index 90ff7168f..45029e242 100644 --- a/internal/accounts/create.go +++ b/internal/accounts/create.go @@ -28,9 +28,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsCreate struct { diff --git a/internal/accounts/fund.go b/internal/accounts/fund.go index 177aacd33..3dbdbbd72 100644 --- a/internal/accounts/fund.go +++ b/internal/accounts/fund.go @@ -27,9 +27,10 @@ import ( "github.com/pkg/browser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsFund struct { diff --git a/internal/accounts/get.go b/internal/accounts/get.go index 2bb7d1397..1c3443380 100644 --- a/internal/accounts/get.go +++ b/internal/accounts/get.go @@ -25,9 +25,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsGet struct { diff --git a/internal/accounts/staking-info.go b/internal/accounts/staking-info.go index ba9b9252a..e946f1cad 100644 --- a/internal/accounts/staking-info.go +++ b/internal/accounts/staking-info.go @@ -28,10 +28,11 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsStakingInfo struct{} diff --git a/internal/blocks/blocks_test.go b/internal/blocks/blocks_test.go index af9236df8..f8a68cf6f 100644 --- a/internal/blocks/blocks_test.go +++ b/internal/blocks/blocks_test.go @@ -26,10 +26,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_GetBlock(t *testing.T) { diff --git a/internal/blocks/get.go b/internal/blocks/get.go index 1776a2cba..a638363e1 100644 --- a/internal/blocks/get.go +++ b/internal/blocks/get.go @@ -24,9 +24,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsBlocks struct { diff --git a/internal/collections/get.go b/internal/collections/get.go index ce81d0792..bef980b64 100644 --- a/internal/collections/get.go +++ b/internal/collections/get.go @@ -25,9 +25,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsCollections struct{} diff --git a/internal/command/command.go b/internal/command/command.go index 0beab2c5a..478066558 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -38,13 +38,14 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/build" - "github.com/onflow/flow-cli/internal/settings" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/gateway" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/build" + "github.com/onflow/flow-cli/internal/settings" + "github.com/onflow/flow-cli/internal/util" ) // run the command with arguments. diff --git a/internal/command/global_flags.go b/internal/command/global_flags.go index 15077a531..0ce586709 100644 --- a/internal/command/global_flags.go +++ b/internal/command/global_flags.go @@ -25,8 +25,9 @@ import ( "github.com/psiemens/sconfig" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit/config" + + "github.com/onflow/flow-cli/internal/util" ) // Flags initialized to default values. diff --git a/internal/config/add-account.go b/internal/config/add-account.go index d9eabbca1..6ac9b657c 100644 --- a/internal/config/add-account.go +++ b/internal/config/add-account.go @@ -28,11 +28,12 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsAddAccount struct { diff --git a/internal/config/add-contract.go b/internal/config/add-contract.go index bf831c94c..176113345 100644 --- a/internal/config/add-contract.go +++ b/internal/config/add-contract.go @@ -24,11 +24,12 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsAddContract struct { diff --git a/internal/config/add-deployment.go b/internal/config/add-deployment.go index 8f4864a34..e1f0059c9 100644 --- a/internal/config/add-deployment.go +++ b/internal/config/add-deployment.go @@ -23,11 +23,12 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsAddDeployment struct { diff --git a/internal/config/add-network.go b/internal/config/add-network.go index 4e0464c71..8605020df 100644 --- a/internal/config/add-network.go +++ b/internal/config/add-network.go @@ -24,11 +24,12 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsAddNetwork struct { diff --git a/internal/config/init.go b/internal/config/init.go index 17abd0cc0..68dda9f0c 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -25,11 +25,12 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsInit struct { diff --git a/internal/config/remove-account.go b/internal/config/remove-account.go index 335fb1c05..29250051d 100644 --- a/internal/config/remove-account.go +++ b/internal/config/remove-account.go @@ -21,10 +21,11 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsRemoveAccount struct{} diff --git a/internal/config/remove-contract.go b/internal/config/remove-contract.go index 43ac131f6..c2a50e81a 100644 --- a/internal/config/remove-contract.go +++ b/internal/config/remove-contract.go @@ -21,10 +21,11 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsRemoveContract struct{} diff --git a/internal/config/remove-deployment.go b/internal/config/remove-deployment.go index 18769d7b3..e2c85bc15 100644 --- a/internal/config/remove-deployment.go +++ b/internal/config/remove-deployment.go @@ -21,10 +21,11 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsRemoveDeployment struct{} diff --git a/internal/config/remove-network.go b/internal/config/remove-network.go index e135b53cb..391f523bc 100644 --- a/internal/config/remove-network.go +++ b/internal/config/remove-network.go @@ -21,10 +21,11 @@ package config import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsRemoveNetwork struct{} diff --git a/internal/dependencymanager/add.go b/internal/dependencymanager/add.go index 79a601715..30bc66e7b 100644 --- a/internal/dependencymanager/add.go +++ b/internal/dependencymanager/add.go @@ -23,9 +23,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type addFlagsCollection struct { diff --git a/internal/dependencymanager/dependencyinstaller_test.go b/internal/dependencymanager/dependencyinstaller_test.go index abeda12d2..ecacc944c 100644 --- a/internal/dependencymanager/dependencyinstaller_test.go +++ b/internal/dependencymanager/dependencyinstaller_test.go @@ -26,12 +26,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/gateway" "github.com/onflow/flowkit/gateway/mocks" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/util" ) func TestDependencyInstallerInstall(t *testing.T) { diff --git a/internal/dependencymanager/install.go b/internal/dependencymanager/install.go index 4eb17be18..f1a49fea1 100644 --- a/internal/dependencymanager/install.go +++ b/internal/dependencymanager/install.go @@ -23,9 +23,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type installFlagsCollection struct{} diff --git a/internal/emulator/snapshot.go b/internal/emulator/snapshot.go index 2b506270c..f9f87fb2c 100644 --- a/internal/emulator/snapshot.go +++ b/internal/emulator/snapshot.go @@ -29,10 +29,11 @@ import ( "github.com/spf13/cobra" "golang.org/x/exp/slices" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type SnapshotFlag struct{} diff --git a/internal/emulator/start.go b/internal/emulator/start.go index fb0b949e7..1608d42c5 100644 --- a/internal/emulator/start.go +++ b/internal/emulator/start.go @@ -30,10 +30,11 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) var Cmd *cobra.Command diff --git a/internal/events/events_test.go b/internal/events/events_test.go index 0f109d998..9ab4f3a08 100644 --- a/internal/events/events_test.go +++ b/internal/events/events_test.go @@ -28,10 +28,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_Get(t *testing.T) { diff --git a/internal/events/get.go b/internal/events/get.go index 3770a0525..f4b8fc48f 100644 --- a/internal/events/get.go +++ b/internal/events/get.go @@ -24,9 +24,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsEvents struct { diff --git a/internal/keys/decode.go b/internal/keys/decode.go index a861f3b18..aa9ae83ef 100644 --- a/internal/keys/decode.go +++ b/internal/keys/decode.go @@ -27,9 +27,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsDecode struct { diff --git a/internal/keys/derive.go b/internal/keys/derive.go index 5bf17bae4..43f2ac699 100644 --- a/internal/keys/derive.go +++ b/internal/keys/derive.go @@ -24,9 +24,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsDerive struct { diff --git a/internal/keys/generate.go b/internal/keys/generate.go index 98dcd34a2..2254dcd5f 100644 --- a/internal/keys/generate.go +++ b/internal/keys/generate.go @@ -25,9 +25,10 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsGenerate struct { diff --git a/internal/keys/keys.go b/internal/keys/keys.go index 4fb32513e..d441f1306 100644 --- a/internal/keys/keys.go +++ b/internal/keys/keys.go @@ -26,8 +26,9 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/util" ) var Cmd = &cobra.Command{ diff --git a/internal/project/deploy.go b/internal/project/deploy.go index 5571e60bb..33818b97b 100644 --- a/internal/project/deploy.go +++ b/internal/project/deploy.go @@ -27,12 +27,13 @@ import ( "github.com/spf13/cobra" "golang.org/x/exp/slices" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/project" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsDeploy struct { diff --git a/internal/project/project_test.go b/internal/project/project_test.go index c72d689d2..3fea28fbb 100644 --- a/internal/project/project_test.go +++ b/internal/project/project_test.go @@ -25,11 +25,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/accounts" "github.com/onflow/flowkit/config" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_ProjectDeploy(t *testing.T) { diff --git a/internal/quick/run.go b/internal/quick/run.go index c8c98d007..213cb69d2 100644 --- a/internal/quick/run.go +++ b/internal/quick/run.go @@ -23,9 +23,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsRun struct { diff --git a/internal/scripts/execute.go b/internal/scripts/execute.go index c32952e3a..51486d41e 100644 --- a/internal/scripts/execute.go +++ b/internal/scripts/execute.go @@ -26,10 +26,11 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/arguments" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type Flags struct { diff --git a/internal/scripts/scripts_test.go b/internal/scripts/scripts_test.go index d5f83ff63..5d8ae4f10 100644 --- a/internal/scripts/scripts_test.go +++ b/internal/scripts/scripts_test.go @@ -26,10 +26,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_Execute(t *testing.T) { diff --git a/internal/signatures/generate.go b/internal/signatures/generate.go index 9fe538d76..1e9658d45 100644 --- a/internal/signatures/generate.go +++ b/internal/signatures/generate.go @@ -27,10 +27,11 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsGenerate struct { diff --git a/internal/signatures/verify.go b/internal/signatures/verify.go index c9635299b..1cf04c42d 100644 --- a/internal/signatures/verify.go +++ b/internal/signatures/verify.go @@ -27,10 +27,11 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsVerify struct { diff --git a/internal/snapshot/save.go b/internal/snapshot/save.go index 9fc877185..3a7f7e2cc 100644 --- a/internal/snapshot/save.go +++ b/internal/snapshot/save.go @@ -24,9 +24,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) var saveCommand = &command.Command{ diff --git a/internal/status/status.go b/internal/status/status.go index 3adbe8f6d..646635839 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -24,10 +24,11 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsStatus struct { diff --git a/internal/super/dev.go b/internal/super/dev.go index f224e62c3..c6b1d0c6c 100644 --- a/internal/super/dev.go +++ b/internal/super/dev.go @@ -27,9 +27,10 @@ import ( "github.com/onflow/cadence/runtime/parser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsDev struct{} diff --git a/internal/super/flix.go b/internal/super/flix.go index e96f68554..edb92a6f2 100644 --- a/internal/super/flix.go +++ b/internal/super/flix.go @@ -28,12 +28,13 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/scripts" - "github.com/onflow/flow-cli/internal/transactions" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/scripts" + "github.com/onflow/flow-cli/internal/transactions" ) type flixFlags struct { diff --git a/internal/super/flix_test.go b/internal/super/flix_test.go index 926e835a7..b8215c140 100644 --- a/internal/super/flix_test.go +++ b/internal/super/flix_test.go @@ -29,13 +29,14 @@ import ( "github.com/onflow/flixkit-go/flixkit" "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/mocks" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type MockFlixService struct { diff --git a/internal/super/generate.go b/internal/super/generate.go index fbb27486d..b60f4ca09 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -27,9 +27,10 @@ import ( "github.com/onflow/flowkit" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit/output" + "github.com/onflow/flow-cli/internal/command" + "github.com/spf13/cobra" ) diff --git a/internal/super/project.go b/internal/super/project.go index c8225ef34..c2ad5e3fb 100644 --- a/internal/super/project.go +++ b/internal/super/project.go @@ -25,11 +25,12 @@ import ( "github.com/onflow/flow-go-sdk/crypto" "github.com/pkg/errors" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/accounts" "github.com/onflow/flowkit/config" flowkitProject "github.com/onflow/flowkit/project" + + "github.com/onflow/flow-cli/internal/util" ) var emulator = config.EmulatorNetwork.Name diff --git a/internal/super/setup.go b/internal/super/setup.go index e66175efa..b44daa6dc 100644 --- a/internal/super/setup.go +++ b/internal/super/setup.go @@ -32,10 +32,11 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsSetup struct { diff --git a/internal/test/test.go b/internal/test/test.go index d16ac4471..3b1ad4300 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -32,11 +32,12 @@ import ( "github.com/onflow/cadence/runtime/common" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) // The key where meta information for a test report in JSON diff --git a/internal/test/test_test.go b/internal/test/test_test.go index 2f8e7a719..756204921 100644 --- a/internal/test/test_test.go +++ b/internal/test/test_test.go @@ -30,9 +30,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/tests" + + "github.com/onflow/flow-cli/internal/util" ) func TestExecutingTests(t *testing.T) { diff --git a/internal/tools/flowser.go b/internal/tools/flowser.go index dca2fcf4f..64ebea21c 100644 --- a/internal/tools/flowser.go +++ b/internal/tools/flowser.go @@ -26,12 +26,13 @@ import ( "github.com/onflowser/flowser/v3/pkg/flowser" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/settings" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/settings" + "github.com/onflow/flow-cli/internal/util" ) type flagsFlowser struct{} diff --git a/internal/tools/wallet.go b/internal/tools/wallet.go index 2fdc27520..73d1289ef 100644 --- a/internal/tools/wallet.go +++ b/internal/tools/wallet.go @@ -25,9 +25,10 @@ import ( devWallet "github.com/onflow/fcl-dev-wallet/go/wallet" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsWallet struct { diff --git a/internal/transactions/build.go b/internal/transactions/build.go index 843675de3..70e4a73ec 100644 --- a/internal/transactions/build.go +++ b/internal/transactions/build.go @@ -26,12 +26,13 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/arguments" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/transactions" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsBuild struct { diff --git a/internal/transactions/decode.go b/internal/transactions/decode.go index b2c455069..428948d4c 100644 --- a/internal/transactions/decode.go +++ b/internal/transactions/decode.go @@ -25,9 +25,10 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsDecode struct { diff --git a/internal/transactions/get.go b/internal/transactions/get.go index b7e55b703..82972908a 100644 --- a/internal/transactions/get.go +++ b/internal/transactions/get.go @@ -25,9 +25,10 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" ) type flagsGet struct { diff --git a/internal/transactions/send-signed.go b/internal/transactions/send-signed.go index d28a0e8bc..ccaae4953 100644 --- a/internal/transactions/send-signed.go +++ b/internal/transactions/send-signed.go @@ -26,10 +26,11 @@ import ( "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsSendSigned struct { diff --git a/internal/transactions/send.go b/internal/transactions/send.go index 7339c8218..8b2df6755 100644 --- a/internal/transactions/send.go +++ b/internal/transactions/send.go @@ -25,12 +25,13 @@ import ( "github.com/onflow/cadence" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flowkit" "github.com/onflow/flowkit/accounts" "github.com/onflow/flowkit/arguments" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/transactions" + + "github.com/onflow/flow-cli/internal/command" ) type Flags struct { diff --git a/internal/transactions/sign.go b/internal/transactions/sign.go index 91f0e861a..4c49cfd76 100644 --- a/internal/transactions/sign.go +++ b/internal/transactions/sign.go @@ -34,10 +34,11 @@ import ( flowsdk "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/output" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) type flagsSign struct { diff --git a/internal/transactions/transactions.go b/internal/transactions/transactions.go index 5278d6f09..445851d99 100644 --- a/internal/transactions/transactions.go +++ b/internal/transactions/transactions.go @@ -27,10 +27,11 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/spf13/cobra" + "github.com/onflow/flowkit/output" + "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/events" "github.com/onflow/flow-cli/internal/util" - "github.com/onflow/flowkit/output" ) var Cmd = &cobra.Command{ diff --git a/internal/transactions/transactions_test.go b/internal/transactions/transactions_test.go index 981207221..3f45b9425 100644 --- a/internal/transactions/transactions_test.go +++ b/internal/transactions/transactions_test.go @@ -29,14 +29,15 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/onflow/flow-cli/internal/command" - "github.com/onflow/flow-cli/internal/util" "github.com/onflow/flowkit" "github.com/onflow/flowkit/accounts" "github.com/onflow/flowkit/config" "github.com/onflow/flowkit/output" "github.com/onflow/flowkit/tests" "github.com/onflow/flowkit/transactions" + + "github.com/onflow/flow-cli/internal/command" + "github.com/onflow/flow-cli/internal/util" ) func Test_Build(t *testing.T) { From c5c072dcaf187356e5a62fc72107383041efdcb9 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Thu, 1 Feb 2024 16:13:09 -0800 Subject: [PATCH 09/21] remove workflow, update readme --- .github/workflows/flowkit-release.yml | 18 ------------------ flowkit/README.md | 17 ++--------------- 2 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/flowkit-release.yml diff --git a/.github/workflows/flowkit-release.yml b/.github/workflows/flowkit-release.yml deleted file mode 100644 index 6e6858996..000000000 --- a/.github/workflows/flowkit-release.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Flowkit Release - -on: - release: - types: [published] - -jobs: - flowkit-release: - if: "!github.event.release.prerelease" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: tag flowkit release - env: - FLOWKIT_RELEASE_TAG: flowkit/${{ github.event.release.tag_name }} - run: | - git tag "$FLOWKIT_RELEASE_TAG" - git push origin "$FLOWKIT_RELEASE_TAG" diff --git a/flowkit/README.md b/flowkit/README.md index dc8ed2f0a..490a69f45 100644 --- a/flowkit/README.md +++ b/flowkit/README.md @@ -1,16 +1,3 @@ -## Flowkit Package Design -Flowkit is a core package used by the CLI commands. It features APIs for interacting with the Flow network -in the context of flow.json configuration values. Flowkit is defined by the [interface here](services.go). - -Flowkit contains multiple subpackages, the most important ones are: -- **config**: parsing and storing of flow.json values, as well as validation, -- **gateway**: implementation of Flow AN methods, uses emulator as well as Go SDK to communicate with ANs, -- **project**: stateful operations on top of flow.json, which allows resolving imports in contracts used in deployments - -It is important we define clear boundaries between flowkit and other CLI packages. If we are in doubt where certain -methods should be implemented we must ask ourselves if the method provides value for any other consumers of the -pacakge or only provides utility for CLI usage, if it's only providing utility for CLI then it should be added inside -the internal package, instead of flowkit. If in doubt better to add things to internal package and then move to flowkit -if such need is identified. - +## Flowkit +Note: This module has been deprecated. The latest supported version is v1.13.0. The module migrated since to github.com/onflow/flowkit. Please use the new module github.com/onflow/flowkit instead. Version v1.13.0 is equivalent to version v1.13.0 on the new module. From 9452097641955297147642f813fb733627864cc3 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Thu, 1 Feb 2024 16:13:53 -0800 Subject: [PATCH 10/21] delete all of flowkit --- Makefile | 2 +- flowkit/CHANGELOG.md | 285 --- flowkit/accounts/account.go | 192 -- flowkit/accounts/account_test.go | 128 -- flowkit/accounts/keys.go | 456 ----- flowkit/accounts/keys_test.go | 91 - flowkit/arguments/arguments.go | 149 -- flowkit/arguments/arguments_test.go | 254 --- flowkit/cmd/flow-schema/flow-schema.go | 69 - flowkit/config/account.go | 103 -- flowkit/config/account_test.go | 119 -- flowkit/config/config.go | 121 -- flowkit/config/config_test.go | 342 ---- flowkit/config/contract.go | 208 --- flowkit/config/contract_test.go | 111 -- flowkit/config/dependency.go | 79 - flowkit/config/dependency_test.go | 44 - flowkit/config/deployment.go | 123 -- flowkit/config/deployment_test.go | 155 -- flowkit/config/emulator.go | 60 - flowkit/config/emulator_test.go | 75 - flowkit/config/json/account.go | 485 ----- flowkit/config/json/account_test.go | 567 ------ flowkit/config/json/config.go | 155 -- flowkit/config/json/config_test.go | 257 --- flowkit/config/json/contract.go | 157 -- flowkit/config/json/contract_test.go | 187 -- flowkit/config/json/dependency.go | 181 -- flowkit/config/json/dependency_test.go | 77 - flowkit/config/json/deploy.go | 198 -- flowkit/config/json/deploy_test.go | 153 -- flowkit/config/json/emulator.go | 70 - flowkit/config/json/emulator_test.go | 76 - flowkit/config/json/network.go | 169 -- flowkit/config/json/network_test.go | 155 -- flowkit/config/json/schema.go | 44 - flowkit/config/loader.go | 225 --- flowkit/config/loader_test.go | 464 ----- flowkit/config/network.go | 97 - flowkit/config/network_test.go | 79 - flowkit/config/processor.go | 49 - flowkit/config/processor_test.go | 71 - flowkit/events.go | 77 - flowkit/events_test.go | 56 - flowkit/flowkit.go | 1057 ----------- flowkit/flowkit_test.go | 2086 ---------------------- flowkit/gateway/emulator.go | 335 ---- flowkit/gateway/gateway.go | 47 - flowkit/gateway/grpc.go | 206 --- flowkit/gateway/mocks/Gateway.go | 515 ------ flowkit/gateway/mocks/gateway_mock.go | 125 -- flowkit/go.mod | 207 --- flowkit/go.sum | 1475 --------------- flowkit/mocks/Services.go | 708 -------- flowkit/mocks/services_mock.go | 223 --- flowkit/output/colors.go | 61 - flowkit/output/emoji.go | 61 - flowkit/output/logger.go | 98 - flowkit/output/spinner.go | 79 - flowkit/project/contract.go | 67 - flowkit/project/contract_test.go | 54 - flowkit/project/deployment.go | 253 --- flowkit/project/deployment_test.go | 213 --- flowkit/project/imports.go | 89 - flowkit/project/imports_test.go | 138 -- flowkit/project/program.go | 155 -- flowkit/project/program_test.go | 216 --- flowkit/schema.json | 357 ---- flowkit/services.go | 123 -- flowkit/state.go | 307 ---- flowkit/state_test.go | 894 ---------- flowkit/tests/resources.go | 660 ------- flowkit/tests/testnet_test.go | 205 --- flowkit/transactions/transaction.go | 426 ----- flowkit/transactions/transaction_test.go | 88 - 75 files changed, 1 insertion(+), 18742 deletions(-) delete mode 100644 flowkit/CHANGELOG.md delete mode 100644 flowkit/accounts/account.go delete mode 100644 flowkit/accounts/account_test.go delete mode 100644 flowkit/accounts/keys.go delete mode 100644 flowkit/accounts/keys_test.go delete mode 100644 flowkit/arguments/arguments.go delete mode 100644 flowkit/arguments/arguments_test.go delete mode 100644 flowkit/cmd/flow-schema/flow-schema.go delete mode 100644 flowkit/config/account.go delete mode 100644 flowkit/config/account_test.go delete mode 100644 flowkit/config/config.go delete mode 100644 flowkit/config/config_test.go delete mode 100644 flowkit/config/contract.go delete mode 100644 flowkit/config/contract_test.go delete mode 100644 flowkit/config/dependency.go delete mode 100644 flowkit/config/dependency_test.go delete mode 100644 flowkit/config/deployment.go delete mode 100644 flowkit/config/deployment_test.go delete mode 100644 flowkit/config/emulator.go delete mode 100644 flowkit/config/emulator_test.go delete mode 100644 flowkit/config/json/account.go delete mode 100644 flowkit/config/json/account_test.go delete mode 100644 flowkit/config/json/config.go delete mode 100644 flowkit/config/json/config_test.go delete mode 100644 flowkit/config/json/contract.go delete mode 100644 flowkit/config/json/contract_test.go delete mode 100644 flowkit/config/json/dependency.go delete mode 100644 flowkit/config/json/dependency_test.go delete mode 100644 flowkit/config/json/deploy.go delete mode 100644 flowkit/config/json/deploy_test.go delete mode 100644 flowkit/config/json/emulator.go delete mode 100644 flowkit/config/json/emulator_test.go delete mode 100644 flowkit/config/json/network.go delete mode 100644 flowkit/config/json/network_test.go delete mode 100644 flowkit/config/json/schema.go delete mode 100644 flowkit/config/loader.go delete mode 100644 flowkit/config/loader_test.go delete mode 100644 flowkit/config/network.go delete mode 100644 flowkit/config/network_test.go delete mode 100644 flowkit/config/processor.go delete mode 100644 flowkit/config/processor_test.go delete mode 100644 flowkit/events.go delete mode 100644 flowkit/events_test.go delete mode 100644 flowkit/flowkit.go delete mode 100644 flowkit/flowkit_test.go delete mode 100644 flowkit/gateway/emulator.go delete mode 100644 flowkit/gateway/gateway.go delete mode 100644 flowkit/gateway/grpc.go delete mode 100644 flowkit/gateway/mocks/Gateway.go delete mode 100644 flowkit/gateway/mocks/gateway_mock.go delete mode 100644 flowkit/go.mod delete mode 100644 flowkit/go.sum delete mode 100644 flowkit/mocks/Services.go delete mode 100644 flowkit/mocks/services_mock.go delete mode 100644 flowkit/output/colors.go delete mode 100644 flowkit/output/emoji.go delete mode 100644 flowkit/output/logger.go delete mode 100644 flowkit/output/spinner.go delete mode 100644 flowkit/project/contract.go delete mode 100644 flowkit/project/contract_test.go delete mode 100644 flowkit/project/deployment.go delete mode 100644 flowkit/project/deployment_test.go delete mode 100644 flowkit/project/imports.go delete mode 100644 flowkit/project/imports_test.go delete mode 100644 flowkit/project/program.go delete mode 100644 flowkit/project/program_test.go delete mode 100644 flowkit/schema.json delete mode 100644 flowkit/services.go delete mode 100644 flowkit/state.go delete mode 100644 flowkit/state_test.go delete mode 100644 flowkit/tests/resources.go delete mode 100644 flowkit/tests/testnet_test.go delete mode 100644 flowkit/transactions/transaction.go delete mode 100644 flowkit/transactions/transaction_test.go diff --git a/Makefile b/Makefile index 73e549e27..47b4c6dfd 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ $(BINARY): GO111MODULE=on go build \ -trimpath \ -ldflags \ - "-X github.com/onflow/flow-cli/build.commit=$(COMMIT) -X github.com/onflow/flow-cli/build.semver=$(VERSION) -X github.com/onflow/flow-cli/flowkit/util.MIXPANEL_PROJECT_TOKEN=${MIXPANEL_PROJECT_TOKEN} -X github.com/onflow/flow-cli/internal/accounts.accountToken=${ACCOUNT_TOKEN}"\ + "-X github.com/onflow/flow-cli/build.commit=$(COMMIT) -X github.com/onflow/flow-cli/build.semver=$(VERSION) -X github.com/onflow/flow-cli/internal/accounts.accountToken=${ACCOUNT_TOKEN}"\ -o $(BINARY) ./cmd/flow .PHONY: versioned-binaries diff --git a/flowkit/CHANGELOG.md b/flowkit/CHANGELOG.md deleted file mode 100644 index 10ba8dac1..000000000 --- a/flowkit/CHANGELOG.md +++ /dev/null @@ -1,285 +0,0 @@ -# Flowkit Changelog - -All notable changes to flowkit APIs will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## Unreleased - -## 1.0.0 - -### Changed - -Flowkit package was tagged as v1.0.0 and is now considered stable. -It was also moved and renamed from `github.com/onflow/pkg/flowkit` to `github.com/onflow/flowkit` (dropped `pkg`). -Please note that when you update to this version you will need to update your imports and -use the command: `go get github.com/onflow/flowkit@latest` and you will have to manually change all -imports from `github.com/onflow/pkg/flowkit` to `github.com/onflow/flowkit` (a simple find and replace might do). - - ---- - -Flowkit package APIs completely undergo major changes. APIs that were previously accessed via services were moved -under a single interface defined in [services.go](services.go). Accessing those methods must be done on a -flowkit instance. - -Example previously: -```go -services := services.NewServices(gateway, state, logger) -account, err := services.Accounts.Get(address) -``` -changed to: -```go -services := flowkit.NewFlowkit(state, *network, clientGateway, logger) -account, err := services.GetAccount(context.Background(), address) -``` - -Each of the APIs now require context as the first argument. -We can find a definition of the flowkit interface here: -```go -Network() config.Network -Ping() error -Gateway() gateway.Gateway -SetLogger(output.Logger) - -// GetAccount fetches account on the Flow network. -GetAccount(context.Context, flow.Address) (*flow.Account, error) - -// CreateAccount on the Flow network with the provided keys and using the signer for creation transaction. -// Returns the newly created account as well as the ID of the transaction that created the account. -// -// Keys is a slice but only one can be passed as well. If the transaction fails or there are other issues an error is returned. -CreateAccount(context.Context, *Account, []AccountPublicKey) (*flow.Account, flow.Identifier, error) - -// AddContract to the Flow account provided and return the transaction ID. -// -// If the contract already exists on the account the operation will fail and error will be returned. -// Use UpdateContract method for such usage. -AddContract(context.Context, *Account, *Script, bool) (flow.Identifier, bool, error) - -// RemoveContract from the provided account by its name. -// -// If removal is successful transaction ID is returned. -RemoveContract(context.Context, *Account, string) (flow.Identifier, error) - -// GetBlock by the query from Flow blockchain. Query can define a block by ID, block by height or require the latest block. -GetBlock(context.Context, BlockQuery) (*flow.Block, error) - -// GetCollection by the ID from Flow network. -GetCollection(context.Context, flow.Identifier) (*flow.Collection, error) - -// GetEvents from Flow network by their event name in the specified height interval defined by start and end inclusive. -// Optional worker defines parameters for how many concurrent workers do we want to fetch our events, -// and how many blocks between the provided interval each worker fetches. -// -// Providing worker value will produce faster response as the interval will be scanned concurrently. This parameter is optional, -// if not provided only a single worker will be used. -GetEvents(context.Context, []string, uint64, uint64, *EventWorker) ([]flow.BlockEvents, error) - -// GenerateKey using the signature algorithm and optional seed. If seed is not provided a random safe seed will be generated. -GenerateKey(context.Context, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, error) - -// GenerateMnemonicKey will generate a new key with the signature algorithm and optional derivation path. -// -// If the derivation path is not provided a default "m/44'/539'/0'/0/0" will be used. -GenerateMnemonicKey(context.Context, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, string, error) - -DerivePrivateKeyFromMnemonic(context.Context, string, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, error) - -// DeployProject contracts to the Flow network or update if already exists and update is set to true. -// -// Retrieve all the contracts for specified network, sort them for deployment deploy one by one and replace -// the imports in the contract source, so it corresponds to the account name the contract was deployed to. -DeployProject(context.Context, bool) ([]*project.Contract, error) - -// ExecuteScript on the Flow network and return the Cadence value as a result. -ExecuteScript(context.Context, *Script) (cadence.Value, error) - -// GetTransactionByID from the Flow network including the transaction result. Using the waitSeal we can wait for the transaction to be sealed. -GetTransactionByID(context.Context, flow.Identifier, bool) (*flow.Transaction, *flow.TransactionResult, error) - -GetTransactionsByBlockID(context.Context, flow.Identifier) ([]*flow.Transaction, []*flow.TransactionResult, error) - -// BuildTransaction builds a new transaction type for later signing and submitting to the network. -// -// TransactionAddressesRoles type defines the address for each role (payer, proposer, authorizers) and the script defines the transaction content. -BuildTransaction(context.Context, *TransactionAddressesRoles, int, *Script, uint64) (*Transaction, error) - -// SignTransactionPayload will use the signer account provided and the payload raw byte content to sign it. -// -// The payload should be RLP encoded transaction payload and is suggested to be used in pair with BuildTransaction function. -SignTransactionPayload(context.Context, *Account, []byte) (*Transaction, error) - -// SendSignedTransaction will send a prebuilt and signed transaction to the Flow network. -// -// You can build the transaction using the BuildTransaction method and then sign it using the SignTranscation method. -SendSignedTransaction(context.Context, *Transaction) (*flow.Transaction, *flow.TransactionResult, error) - -// SendTransaction will build and send a transaction to the Flow network, using the accounts provided for each role and -// contain the script. Transaction as well as transaction result will be returned in case the transaction is successfully submitted. -SendTransaction(context.Context, *TransactionAccountRoles, *Script, uint64) (*flow.Transaction, *flow.TransactionResult, error) -``` - -Passing network parameter is no longer required as the network is initialized using the `NewFlowkit` initializer. - ---- - -The `ScriptQuery` was moved to `flowkit` package and addded `Latest` field. It is also now passed by value instead of -by pointer. You can use `LatestScriptQuery` convenience variable to pass usage of latest block for script execution. - ----- - -The `TransactionAccountRoles` and `TransactionAddressesRoles` are no longer passed to transaction functions as -pointer but as value since they are always required. - ---- - -The `flowkit.NewScript` method was removed and you should use `flowkit.Script{}` struct directly for initialization. -Also getter and setters were removed to favour direct property access. - ---- - -The `config.Contracts.ByName(name string) *Contract` changed to return an error if contract -was not found whereas before it returned a nil value. - ---- - -The `Account` type and helper methods as well as `AccountKey` interface and all the implementations -were moved to `accounts` package. - ---- - -The `AccountKey`, `HexAccountKey`, `KmsAccountKey`, `Bip44AccountKey` were renamed to `Key`, `HexKey`, `KMSKey`, `BIP44Key` to avoid stutter in the naming, -as well as all the factory methods were renamed to remove the `account` word. - ---- - -The `Transaction` was moved to `transactions` package as well as all the factory methods. -All the factory methods were renamed to drop the `transaction` word. - ---- - -The `TransactionAddressesRoles` was moved to `transactions` package and renamed to drop the -`transaction` word to `AddressRoles` the same holds true for `TransactionAccountRoles`. - ---- - -The `ParseArgumentsJSON` and `ParseArgumentsWithoutType` were moved to a `arguments` package and renamed -to `ParseJSON` and `ParseWithoutType` correspondingly. - ---- - -Renamed transaction function from `transaction.SetGasLimit` to `transaction.SetComputeLimit`. - ---- - -The `flowkit.Account` getter methods for `account.Address()`, `account.Name()` was removed and the variable -was exported so you can use `account.Address`, `account.Name` directly. - ---- - -The function `state.DeploymentContractsByNetwork(network string)` changed to accept network type like so: -`state.DeploymentContractsByNetwork(network config.Network)`, there are also predefined network types in config -you can access using `config.EmulatorNetwork`, `config.TestnetNetwork`, `config.MainnetNetwork`. - ---- - -The config functions for getting default networks was removed and replaced with variables. -For example the method `config.DefaultMainnetNetwork()` was replaced with `config.MainnetNetwork` variable. - - -### Added - ----- -An `AccountPublicKey` type was added used in flowkit `CreateAccount` API, you can find the definition in [flowkit.go](flowkit.go). - ---- - -A `BlockQuery` was added for querying blocks using the flowkit `GetBlock` API. You can find the definition in [flowkit.go](flowkit.go). -You can use `NewBlockQuery` factory method to pass in raw string, which should be either equal to `"latest"`, height or block ID. - ---- - -Added predefined common networks in config: -```go - EmptyNetwork = Network{} - EmulatorNetwork = Network{ - Name: "emulator", - Host: "127.0.0.1:3569", - } - TestnetNetwork = Network{ - Name: "testnet", - Host: "access.devnet.nodes.onflow.org:9000", - } - SandboxNetwork = Network{ - Name: "sandboxnet", - Host: "access.sandboxnet.nodes.onflow.org:9000", - } - MainnetNetwork = Network{ - Name: "mainnet", - Host: "access.mainnet.nodes.onflow.org:9000", - } - DefaultNetworks = Networks{ - EmulatorNetwork, - TestnetNetwork, - SandboxNetwork, - MainnetNetwork, - } -``` - -### Removed - ---- - -The `GetBlock` API doesn't return the `[]flow.BlockEvents, []*flow.Collection` anymore, you should use `GetCollection` and -`GetEvents` API. - ---- - -The `GetLatestBlockHeight` method was removed, you should instead use `GetBlock(LatestBlockQuery)`. - ---- - -The `flowkit.Exist(path string)` was removed, the `config.Exist(path string)` should be used. - -## v0.46.2 - -### Changed - ---- -The `Network` property was removed from `Contract` type. The network is now included in -the `Aliases` on the contract. We also removed having multiple contracts by same name just to -accommodate multiple aliases. Now there's only one contract identified by name, -and if there are multiple network aliases they are contained in the `Aliases` list. -- Package: `config` -- Type: `Contracts` - ---- -A method `Contracts.AddOrUpdate(name, contract)` was changed to not include the name, as it's -already part of the contract you are adding. -- Method: `AddOrUpdate` -- Package: `config` -- Type: `Contracts` - ---- -Don't return error if contract by name not found but rather just a `nil`. -- Method: `ByName` -- Package: `config` -- Type: `Contracts` - -### Added - ---- - -New type `Aliases` was added to `Contracts`. -Aliases contain new functions to get the aliases by network and add new aliases. -- Package: `config` -- Type: `Contracts` - - ---- - -`WithLogger` now takes zerolog instead of Logrus since that is what flow-emulator has changed to. -- Package: `gateway` -- Type: `EmulatorGateway` diff --git a/flowkit/accounts/account.go b/flowkit/accounts/account.go deleted file mode 100644 index 6902db65c..000000000 --- a/flowkit/accounts/account.go +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package accounts - -import ( - "crypto/rand" - "fmt" - "strings" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - - "github.com/onflow/flow-cli/flowkit/config" -) - -// Account is defined by an address and name and contains an Key which can be used for signing. -type Account struct { - Name string - Address flow.Address - Key Key -} - -// PrivateKeyFile returns the private key file name for an account. -func PrivateKeyFile(name string) string { - return fmt.Sprintf("%s.pkey", name) -} - -func FromConfig(conf *config.Config) (Accounts, error) { - var accounts Accounts - for _, accountConf := range conf.Accounts { - acc, err := fromConfig(accountConf) - if err != nil { - return nil, err - } - accounts = append(accounts, *acc) - } - - return accounts, nil -} - -func ToConfig(accounts Accounts) config.Accounts { - accountConfs := make([]config.Account, 0) - - for _, account := range accounts { - accountConfs = append(accountConfs, toConfig(account)) - } - - return accountConfs -} - -func fromConfig(account config.Account) (*Account, error) { - key, err := keyFromConfig(account.Key) - if err != nil { - return nil, err - } - - return &Account{ - Name: account.Name, - Address: account.Address, - Key: key, - }, nil -} - -func toConfig(account Account) config.Account { - var key config.AccountKey - if account.Key != nil { - key = account.Key.ToConfig() - } - - return config.Account{ - Name: account.Name, - Address: account.Address, - Key: key, - } -} - -// defaultEmulatorPrivateKeyFile returns the default emulator private key file name. -func defaultEmulatorPrivateKeyFile() string { - return PrivateKeyFile("emulator-account") -} - -func NewEmulatorAccount( - rw config.ReaderWriter, - sigAlgo crypto.SignatureAlgorithm, - hashAlgo crypto.HashAlgorithm, -) (*Account, error) { - seed := make([]byte, crypto.MinSeedLength) - _, err := rand.Read(seed) - if err != nil { - return nil, fmt.Errorf("failed to generate random seed: %w", err) - } - - privateKey, err := crypto.GeneratePrivateKey(sigAlgo, seed) - if err != nil { - return nil, fmt.Errorf("failed to generate emulator service key: %w", err) - } - - if err := rw.WriteFile(defaultEmulatorPrivateKeyFile(), []byte(privateKey.String()), 0644); err != nil { - return nil, fmt.Errorf("failed to write private key file: %w", err) - } - - return &Account{ - Name: config.DefaultEmulator.ServiceAccount, - Address: flow.ServiceAddress(flow.Emulator), - Key: NewFileKey(defaultEmulatorPrivateKeyFile(), 0, sigAlgo, hashAlgo, rw), - }, nil -} - -// Accounts is a collection of account. -type Accounts []Account - -// Remove an account. -func (a *Accounts) Remove(name string) error { - account, err := a.ByName(name) - if err != nil { - return err - } - - if account == nil { - return fmt.Errorf("account named %s does not exist in configuration", name) - } - - for i, acc := range *a { - if acc.Name == name { - *a = append((*a)[0:i], (*a)[i+1:]...) // remove item - } - } - - return nil -} - -func (a *Accounts) String() string { - return strings.Join(a.Names(), ",") -} - -func (a *Accounts) Names() []string { - accNames := make([]string, 0) - for _, acc := range *a { - accNames = append(accNames, acc.Name) - } - return accNames -} - -// ByAddress get an account by address. -func (a Accounts) ByAddress(address flow.Address) (*Account, error) { - for i := range a { - if a[i].Address == address { - return &a[i], nil - } - } - - return nil, fmt.Errorf("could not find account with address %s in the configuration", address) -} - -// ByName get an account by name or returns and error if no account found -func (a Accounts) ByName(name string) (*Account, error) { - for i := range a { - if a[i].Name == name { - return &a[i], nil - } - } - - return nil, fmt.Errorf("could not find account with name %s in the configuration", name) -} - -// AddOrUpdate add account if missing or updates if present. -func (a *Accounts) AddOrUpdate(account *Account) { - for i, acc := range *a { - if acc.Name == account.Name { - (*a)[i] = acc - return - } - } - - *a = append(*a, *account) -} diff --git a/flowkit/accounts/account_test.go b/flowkit/accounts/account_test.go deleted file mode 100644 index c4c684e8e..000000000 --- a/flowkit/accounts/account_test.go +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package accounts - -import ( - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" -) - -func Test_Accounts(t *testing.T) { - - t.Run("List accounts", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - Account{Name: "charlie"}, - Account{Name: "dave"}, - } - - assert.Equal(t, "alice,bob,charlie,dave", accs.String()) - assert.Equal(t, []string{"alice", "bob", "charlie", "dave"}, accs.Names()) - }) - - t.Run("Get by name", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - } - - a, err := accs.ByName("alice") - assert.NoError(t, err) - assert.Equal(t, "alice", a.Name) - assert.Equal(t, "0000000000000000", a.Address.String()) - }) - - t.Run("Change address", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - } - - a, err := accs.ByName("alice") - assert.NoError(t, err) - newAddr := flow.HexToAddress("0x02") - a.Address = newAddr - // change gets reflected in the collection - a2, _ := accs.ByName("alice") - assert.Equal(t, "0000000000000002", a2.Address.String()) - }) - - t.Run("Get by address", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - } - - a, _ := accs.ByName("alice") - newAddr := flow.HexToAddress("0x02") - a.Address = newAddr - - a2, err := accs.ByAddress(newAddr) - assert.NoError(t, err) - assert.Equal(t, "alice", a2.Name) - }) - - t.Run("Update", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - } - - accs.AddOrUpdate(&Account{Name: "mike"}) - assert.Equal(t, "alice,bob,mike", accs.String()) - - m1, err := accs.ByName("mike") - assert.NoError(t, err) - assert.Equal(t, "0000000000000000", m1.Address.String()) - - m1.Address = flow.HexToAddress("0x02") - accs.AddOrUpdate(m1) - m2, err := accs.ByName("mike") - assert.NoError(t, err) - assert.Equal(t, "0000000000000002", m2.Address.String()) - }) - - t.Run("Remove", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - Account{Name: "bob"}, - Account{Name: "mike"}, - } - - err := accs.Remove("mike") - assert.NoError(t, err) - assert.Equal(t, "alice,bob", accs.String()) - }) - - t.Run("Fail not found", func(t *testing.T) { - accs := Accounts{ - Account{Name: "alice"}, - } - - _, err := accs.ByName("bob") - assert.EqualError(t, err, "could not find account with name bob in the configuration") - - _, err = accs.ByAddress(flow.HexToAddress("0x01")) - assert.EqualError(t, err, "could not find account with address 0000000000000001 in the configuration") - }) - -} diff --git a/flowkit/accounts/keys.go b/flowkit/accounts/keys.go deleted file mode 100644 index ddfb425ea..000000000 --- a/flowkit/accounts/keys.go +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package accounts - -import ( - "context" - "encoding/hex" - "fmt" - "os" - "os/exec" - "regexp" - "strings" - - goeth "github.com/ethereum/go-ethereum/accounts" - "github.com/lmars/go-slip10" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-go-sdk/crypto/cloudkms" - "github.com/tyler-smith/go-bip39" - - "github.com/onflow/flow-cli/flowkit/config" -) - -// PublicKey contains public account key information. -type PublicKey struct { - Public crypto.PublicKey - Weight int - SigAlgo crypto.SignatureAlgorithm - HashAlgo crypto.HashAlgorithm -} - -// Key defines functions any key representation must implement. -type Key interface { - // Type returns the key type (hex, kms, file...) - Type() config.KeyType - // Index returns the key index on the account - Index() int - // SigAlgo returns signature algorithm used for signing - SigAlgo() crypto.SignatureAlgorithm - // HashAlgo returns hash algorithm used for signing - HashAlgo() crypto.HashAlgorithm - // Signer is used when we want to sign a transaction, using the Sign() function - Signer(ctx context.Context) (crypto.Signer, error) - // ToConfig converts the key to the storable key format - ToConfig() config.AccountKey - // Validate key - Validate() error - // PrivateKey returns the private key if possible, - // depends on the key type - PrivateKey() (*crypto.PrivateKey, error) -} - -var _ Key = &HexKey{} - -var _ Key = &KMSKey{} - -var _ Key = &BIP44Key{} - -func keyFromConfig(accountKeyConf config.AccountKey) (Key, error) { - switch accountKeyConf.Type { - case config.KeyTypeHex: - return hexKeyFromConfig(accountKeyConf) - case config.KeyTypeBip44: - return bip44KeyFromConfig(accountKeyConf) - case config.KeyTypeGoogleKMS: - return kmsKeyFromConfig(accountKeyConf) - case config.KeyTypeFile: - return fileKeyFromConfig(accountKeyConf) - } - - return nil, fmt.Errorf(`invalid key type: "%s"`, accountKeyConf.Type) -} - -type baseKey struct { - keyType config.KeyType - index int - sigAlgo crypto.SignatureAlgorithm - hashAlgo crypto.HashAlgorithm -} - -func baseKeyFromConfig(accountKeyConf config.AccountKey) *baseKey { - return &baseKey{ - keyType: accountKeyConf.Type, - index: accountKeyConf.Index, - sigAlgo: accountKeyConf.SigAlgo, - hashAlgo: accountKeyConf.HashAlgo, - } -} - -func (a *baseKey) Type() config.KeyType { - return a.keyType -} - -func (a *baseKey) SigAlgo() crypto.SignatureAlgorithm { - if a.sigAlgo == crypto.UnknownSignatureAlgorithm { - return crypto.ECDSA_P256 // default value - } - return a.sigAlgo -} - -func (a *baseKey) HashAlgo() crypto.HashAlgorithm { - if a.hashAlgo == crypto.UnknownHashAlgorithm { - return crypto.SHA3_256 // default value - } - return a.hashAlgo -} - -func (a *baseKey) Index() int { - return a.index // default to 0 -} - -func (a *baseKey) Validate() error { - return nil -} - -// KMSKey implements Gcloud KMS system for signing. -type KMSKey struct { - *baseKey - kmsKey cloudkms.Key -} - -// ToConfig convert account key to configuration. -func (a *KMSKey) ToConfig() config.AccountKey { - return config.AccountKey{ - Type: a.keyType, - Index: a.index, - SigAlgo: a.sigAlgo, - HashAlgo: a.hashAlgo, - ResourceID: a.kmsKey.ResourceID(), - } -} - -func (a *KMSKey) Signer(ctx context.Context) (crypto.Signer, error) { - kmsClient, err := cloudkms.NewClient(ctx) - if err != nil { - return nil, err - } - - accountKMSSigner, err := kmsClient.SignerForKey( - ctx, - a.kmsKey, - ) - if err != nil { - return nil, err - } - - return accountKMSSigner, nil -} - -func (a *KMSKey) Validate() error { - return gcloudApplicationSignin(a.kmsKey.ResourceID()) -} - -func (a *KMSKey) PrivateKey() (*crypto.PrivateKey, error) { - return nil, fmt.Errorf("private key not accessible") -} - -// gcloudApplicationSignin signs in as an application user using gcloud command line tool -// currently assumes gcloud is already installed on the machine -// will by default pop a browser window to sign in -func gcloudApplicationSignin(resourceID string) error { - googleAppCreds := os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") - if len(googleAppCreds) > 0 { - return nil - } - - kms, err := cloudkms.KeyFromResourceID(resourceID) - if err != nil { - return err - } - - proj := kms.ProjectID - if len(proj) == 0 { - return fmt.Errorf( - "could not get GOOGLE_APPLICATION_CREDENTIALS, no google service account JSON provided but private key type is KMS", - ) - } - - loginCmd := exec.Command("gcloud", "auth", "application-default", "login", fmt.Sprintf("--project=%s", proj)) - - output, err := loginCmd.CombinedOutput() - if err != nil { - return fmt.Errorf("Failed to run %q: %s\n", loginCmd.String(), err) - } - - squareBracketRegex := regexp.MustCompile(`(?s)\[(.*)\]`) - regexResult := squareBracketRegex.FindAllStringSubmatch(string(output), -1) - // Should only be one value. Second index since first index contains the square brackets - googleApplicationCreds := regexResult[0][1] - - os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", googleApplicationCreds) - - return nil -} - -func kmsKeyFromConfig(key config.AccountKey) (Key, error) { - accountKMSKey, err := cloudkms.KeyFromResourceID(key.ResourceID) - if err != nil { - return nil, err - } - - return &KMSKey{ - baseKey: &baseKey{ - keyType: config.KeyTypeGoogleKMS, - index: key.Index, - sigAlgo: key.SigAlgo, - hashAlgo: key.HashAlgo, - }, - kmsKey: accountKMSKey, - }, nil -} - -// HexKey implements account key in hex representation. -type HexKey struct { - *baseKey - privateKey crypto.PrivateKey -} - -func NewHexKeyFromPrivateKey( - index int, - hashAlgo crypto.HashAlgorithm, - privateKey crypto.PrivateKey, -) *HexKey { - return &HexKey{ - baseKey: &baseKey{ - keyType: config.KeyTypeHex, - index: index, - sigAlgo: privateKey.Algorithm(), - hashAlgo: hashAlgo, - }, - privateKey: privateKey, - } -} - -func hexKeyFromConfig(accountKey config.AccountKey) (*HexKey, error) { - return &HexKey{ - baseKey: baseKeyFromConfig(accountKey), - privateKey: accountKey.PrivateKey, - }, nil -} - -func (a *HexKey) Signer(ctx context.Context) (crypto.Signer, error) { - return crypto.NewInMemorySigner(a.privateKey, a.HashAlgo()) -} - -func (a *HexKey) PrivateKey() (*crypto.PrivateKey, error) { - return &a.privateKey, nil -} - -func (a *HexKey) ToConfig() config.AccountKey { - return config.AccountKey{ - Type: a.keyType, - Index: a.index, - SigAlgo: a.sigAlgo, - HashAlgo: a.hashAlgo, - PrivateKey: a.privateKey, - } -} - -func (a *HexKey) Validate() error { - _, err := crypto.DecodePrivateKeyHex(a.sigAlgo, a.privateKeyHex()) - if err != nil { - return fmt.Errorf("invalid private key: %w", err) - } - - return nil -} - -func (a *HexKey) privateKeyHex() string { - return hex.EncodeToString(a.privateKey.Encode()) -} - -// fileKeyFromConfig creates a hex account key from a file location -func fileKeyFromConfig(accountKey config.AccountKey) (*FileKey, error) { - return &FileKey{ - baseKey: baseKeyFromConfig(accountKey), - location: accountKey.Location, - }, nil -} - -// NewFileKey creates a new account key that is stored to a separate file in the provided location. -// -// This type of the key is a more secure way of storing accounts. The config only includes the location and not the key. -func NewFileKey( - location string, - index int, - sigAlgo crypto.SignatureAlgorithm, - hashAlgo crypto.HashAlgorithm, - rw config.ReaderWriter, -) *FileKey { - return &FileKey{ - baseKey: &baseKey{ - keyType: config.KeyTypeFile, - index: index, - sigAlgo: sigAlgo, - hashAlgo: hashAlgo, - }, - rw: rw, - location: location, - } -} - -// FileKey represents a key that is saved in a seperate file and will be lazy-loaded. -// -// The FileKey stores location of the file where private key is stored in hex-encoded format. -type FileKey struct { - *baseKey - privateKey crypto.PrivateKey - rw config.ReaderWriter - location string -} - -func (f *FileKey) Signer(ctx context.Context) (crypto.Signer, error) { - key, err := f.PrivateKey() - if err != nil { - return nil, err - } - - return crypto.NewInMemorySigner(*key, f.HashAlgo()) -} - -func (f *FileKey) PrivateKey() (*crypto.PrivateKey, error) { - if f.privateKey == nil { // lazy load the key - // if reader writer is provided, use it to read the file - var ( - key []byte - err error - ) - if f.rw != nil { - key, err = f.rw.ReadFile(f.location) - } else { - key, err = os.ReadFile(f.location) - } - if err != nil { - return nil, fmt.Errorf("could not load the key for the account from provided location %s: %w", f.location, err) - } - - pkey, err := crypto.DecodePrivateKeyHex(f.sigAlgo, strings.TrimPrefix(string(key), "0x")) - if err != nil { - return nil, fmt.Errorf("could not decode the key from provided location %s: %w", f.location, err) - } - f.privateKey = pkey - } - return &f.privateKey, nil -} - -func (f *FileKey) ToConfig() config.AccountKey { - return config.AccountKey{ - Type: config.KeyTypeFile, - SigAlgo: f.sigAlgo, - HashAlgo: f.hashAlgo, - Location: f.location, - } -} - -// BIP44Key implements https://github.com/onflow/flow/blob/master/flips/20201125-bip-44-multi-account.md -type BIP44Key struct { - *baseKey - privateKey crypto.PrivateKey - mnemonic string - derivationPath string -} - -func bip44KeyFromConfig(key config.AccountKey) (Key, error) { - return &BIP44Key{ - baseKey: &baseKey{ - keyType: config.KeyTypeBip44, - index: key.Index, - sigAlgo: key.SigAlgo, - hashAlgo: key.HashAlgo, - }, - derivationPath: key.DerivationPath, - mnemonic: key.Mnemonic, - }, nil -} - -func (a *BIP44Key) Signer(ctx context.Context) (crypto.Signer, error) { - pkey, err := a.PrivateKey() - if err != nil { - return nil, err - } - - return crypto.NewInMemorySigner(*pkey, a.HashAlgo()) -} - -func (a *BIP44Key) PrivateKey() (*crypto.PrivateKey, error) { - if a.privateKey == nil { // lazy load - err := a.Validate() - if err != nil { - return nil, err - } - } - return &a.privateKey, nil -} - -func (a *BIP44Key) ToConfig() config.AccountKey { - return config.AccountKey{ - Type: a.keyType, - Index: a.index, - SigAlgo: a.sigAlgo, - HashAlgo: a.hashAlgo, - PrivateKey: a.privateKey, - Mnemonic: a.mnemonic, - DerivationPath: a.derivationPath, - } -} - -func (a *BIP44Key) Validate() error { - - if !bip39.IsMnemonicValid(a.mnemonic) { - return fmt.Errorf("invalid mnemonic defined for account in flow.json") - } - - derivationPath, err := goeth.ParseDerivationPath(a.derivationPath) - if err != nil { - return fmt.Errorf("invalid derivation path defined for account in flow.json") - } - - seed := bip39.NewSeed(a.mnemonic, "") - curve := slip10.CurveBitcoin - if a.sigAlgo == crypto.ECDSA_P256 { - curve = slip10.CurveP256 - } - accountKey, err := slip10.NewMasterKeyWithCurve(seed, curve) - if err != nil { - return err - } - - for _, n := range derivationPath { - accountKey, err = accountKey.NewChildKey(n) - - if err != nil { - return err - } - } - a.privateKey, err = crypto.DecodePrivateKey(a.SigAlgo(), accountKey.Key) - if err != nil { - return err - } - return nil -} diff --git a/flowkit/accounts/keys_test.go b/flowkit/accounts/keys_test.go deleted file mode 100644 index c991c3fe6..000000000 --- a/flowkit/accounts/keys_test.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package accounts - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit/tests" - - "github.com/onflow/flow-cli/flowkit/config" -) - -func Test_KMS_Keys(t *testing.T) { - confKey := config.AccountKey{ - Type: config.KeyTypeGoogleKMS, - Index: 0, - SigAlgo: config.DefaultSigAlgo, - HashAlgo: config.DefaultHashAlgo, - ResourceID: "projects/my-project/locations/global/keyRings/flow/cryptoKeys/my-account/cryptoKeyVersions/1", - } - - kmsKey, err := kmsKeyFromConfig(confKey) - assert.NoError(t, err) - - _, err = kmsKey.PrivateKey() - assert.EqualError(t, err, "private key not accessible") - assert.Equal(t, confKey, kmsKey.ToConfig()) -} - -func Test_File_key(t *testing.T) { - confKey := config.AccountKey{ - Type: config.KeyTypeFile, - Index: 0, - SigAlgo: config.DefaultSigAlgo, - HashAlgo: config.DefaultHashAlgo, - Location: "./test.pkey", - } - - fileKey, err := fileKeyFromConfig(confKey) - assert.NoError(t, err) - - cKey := fileKey.ToConfig() - assert.Equal(t, cKey, confKey) - - rw, _ := tests.ReaderWriter() - key := NewFileKey(confKey.Location, confKey.Index, confKey.SigAlgo, confKey.HashAlgo, rw) - assert.Equal(t, confKey, key.ToConfig()) -} - -func Test_BIP44(t *testing.T) { - confKey := config.AccountKey{ - Type: config.KeyTypeBip44, - Index: 0, - SigAlgo: config.DefaultSigAlgo, - HashAlgo: config.DefaultHashAlgo, - Mnemonic: "version field tornado move level pretty inject stereo ten catalog salon swallow", - DerivationPath: "m/44'/539'/0'/0/0", - } - - key, err := bip44KeyFromConfig(confKey) - assert.NoError(t, err) - - const pubKey = "0x2d6daea8b0ba5b1d5935f7846ccdd7e6f9f981e34d3c0a02a927cc79c837eba56c0f9a979195e41143495b72314ffcab60da6b7031060c80dc12f01f7f2096be" - assert.Equal(t, confKey, key.ToConfig()) - pkey, err := key.PrivateKey() - assert.NoError(t, err) - assert.Equal(t, pubKey, (*pkey).PublicKey().String()) - - sig, err := key.Signer(context.Background()) - assert.NoError(t, err) - assert.Equal(t, pubKey, sig.PublicKey().String()) -} diff --git a/flowkit/arguments/arguments.go b/flowkit/arguments/arguments.go deleted file mode 100644 index f1c753ea0..000000000 --- a/flowkit/arguments/arguments.go +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package arguments - -import ( - "encoding/json" - "fmt" - "strings" - - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/runtime/ast" - "github.com/onflow/cadence/runtime/cmd" - "github.com/onflow/cadence/runtime/common" - "github.com/onflow/cadence/runtime/interpreter" - "github.com/onflow/cadence/runtime/sema" -) - -type cadenceArgument struct { - Value cadence.Value -} - -func (v *cadenceArgument) MarshalJSON() ([]byte, error) { - return jsoncdc.Encode(v.Value) -} - -func (v *cadenceArgument) UnmarshalJSON(b []byte) (err error) { - v.Value, err = jsoncdc.Decode(nil, b) - if err != nil { - return err - } - return nil -} - -// ParseJSON parses string representing JSON array with Cadence arguments. -// -// Cadence arguments must be defined in the JSON-Cadence format https://developers.flow.com/cadence/json-cadence-spec -func ParseJSON(args string) ([]cadence.Value, error) { - var arg []cadenceArgument - b := []byte(args) - err := json.Unmarshal(b, &arg) - - if err != nil { - return nil, err - } - - cadenceArgs := make([]cadence.Value, len(arg)) - for i, arg := range arg { - cadenceArgs[i] = arg.Value - } - return cadenceArgs, nil -} - -// ParseWithoutType parses arguments passed as string slice based on the Cadence code. -// -// Using the Cadence code required arguments are computed and then extracted from passed slice of arguments. -// The fileName argument is optional and can be empty if not present. -func ParseWithoutType(args []string, code []byte, fileName string) (scriptArgs []cadence.Value, err error) { - - resultArgs := make([]cadence.Value, 0, len(args)) - - codes := map[common.Location][]byte{} - location := common.StringLocation(fileName) - program, must := cmd.PrepareProgram(code, location, codes) - checker, _ := cmd.PrepareChecker(program, location, codes, nil, must) - - var parameterList []*ast.Parameter - - functionDeclaration := sema.FunctionEntryPointDeclaration(program) - if functionDeclaration != nil { - if functionDeclaration.ParameterList != nil { - parameterList = functionDeclaration.ParameterList.Parameters - } - } - - transactionDeclaration := program.TransactionDeclarations() - if len(transactionDeclaration) == 1 { - if transactionDeclaration[0].ParameterList != nil { - parameterList = transactionDeclaration[0].ParameterList.Parameters - } - } - - contractDeclaration := program.SoleContractDeclaration() - if contractDeclaration != nil { - contractInitializer := contractDeclaration.Members.Initializers() - if len(contractInitializer) == 1 { - if contractInitializer[0].FunctionDeclaration.ParameterList != nil { - parameterList = contractInitializer[0].FunctionDeclaration.ParameterList.Parameters - } - } - } - - if parameterList == nil { - return resultArgs, nil - } - - if len(parameterList) != len(args) { - return nil, fmt.Errorf("argument count is %d, expected %d", len(args), len(parameterList)) - } - - inter, err := interpreter.NewInterpreter(nil, nil, &interpreter.Config{}) - if err != nil { - return nil, err - } - - for index, argumentString := range args { - astType := parameterList[index].TypeAnnotation.Type - semaType := checker.ConvertType(astType) - - if semaType == sema.StringType { - if !strings.HasPrefix(argumentString, "\"") { - argumentString = ast.QuoteString(argumentString) - } - } else if _, ok := semaType.(*sema.AddressType); ok { - if !strings.HasPrefix(argumentString, "0x") { - argumentString = fmt.Sprintf("0x%s", argumentString) - } - } - - value, err := runtime.ParseLiteral(argumentString, semaType, inter) - if err != nil { - return nil, fmt.Errorf( - "argument `%s` is not expected type `%s`", - parameterList[index].Identifier, - semaType.QualifiedString(), - ) - } - - resultArgs = append(resultArgs, value) - } - return resultArgs, nil -} diff --git a/flowkit/arguments/arguments_test.go b/flowkit/arguments/arguments_test.go deleted file mode 100644 index 8917625fa..000000000 --- a/flowkit/arguments/arguments_test.go +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package arguments - -import ( - "fmt" - "testing" - - "github.com/onflow/cadence" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func Test_ParseWithoutType(t *testing.T) { - t.Parallel() - - t.Run("types", func(t *testing.T) { - t.Parallel() - - type testCase struct { - Name string - Literal string - InvalidLiteral string - Value cadence.Value - Type cadence.Type - } - - testCases := []testCase{ - { - Name: "Address", - Value: cadence.NewAddress([8]byte{0, 0, 0, 0, 0, 0, 0, 1}), - Type: cadence.AddressType{}, - }, - { - Name: "Bool", - Value: cadence.NewBool(true), - Type: cadence.BoolType{}, - }, - { - Name: "Int", - Value: cadence.NewInt(-42), - Type: cadence.IntType{}, - }, - { - Name: "Int8", - Value: cadence.NewInt8(-42), - Type: cadence.Int8Type{}, - }, - { - Name: "Int16", - Value: cadence.NewInt16(-42), - Type: cadence.Int16Type{}, - }, - { - Name: "Int32", - Value: cadence.NewInt32(-42), - Type: cadence.Int32Type{}, - }, - { - Name: "Int64", - Value: cadence.NewInt64(-42), - Type: cadence.Int64Type{}, - }, - { - Name: "Int128", - Value: cadence.NewInt128(-42), - Type: cadence.Int128Type{}, - }, - { - Name: "UInt8", - Value: cadence.NewUInt8(42), - Type: cadence.UInt8Type{}, - }, - { - Name: "UInt16", - Value: cadence.NewUInt16(42), - Type: cadence.UInt16Type{}, - }, - { - Name: "UInt32", - Value: cadence.NewUInt32(42), - Type: cadence.UInt32Type{}, - }, - { - Name: "UInt64", - Value: cadence.NewUInt64(42), - Type: cadence.UInt64Type{}, - }, - { - Name: "UInt128", - Value: cadence.NewUInt128(42), - Type: cadence.UInt128Type{}, - }, - { - Name: "String", - Value: cadence.String("42"), - Type: cadence.StringType{}, - }, - { - Name: "String, no quoting", - Literal: `foo`, - Value: cadence.String("foo"), - Type: cadence.StringType{}, - }, - { - Name: "optional String, nil", - Value: cadence.NewOptional(nil), - Type: &cadence.OptionalType{ - Type: cadence.StringType{}, - }, - }, - { - Name: "optional String, value", - Value: cadence.NewOptional( - cadence.String("test"), - ), - Type: &cadence.OptionalType{ - Type: cadence.StringType{}, - }, - }, - // TODO: depends on https://github.com/onflow/cadence/pull/2469 - //{ - // Name: "doubly optional String, nil", - // Value: cadence.NewOptional( - // cadence.NewOptional(nil), - // ), - // Type: &cadence.OptionalType{ - // Type: &cadence.OptionalType{ - // Type: cadence.StringType{}, - // }, - // }, - //}, - { - Name: "variable-sized array", - Value: cadence.NewArray([]cadence.Value{ - cadence.String("42"), - }), - Type: &cadence.VariableSizedArrayType{ - ElementType: cadence.StringType{}, - }, - }, - { - Name: "constant-sized array", - Value: cadence.NewArray([]cadence.Value{ - cadence.String("42"), - }), - Type: &cadence.ConstantSizedArrayType{ - ElementType: cadence.StringType{}, - Size: 1, - }, - }, - { - Name: "identifier (invalid)", - InvalidLiteral: "foo", - Type: cadence.IntType{}, - }, - { - Name: "expression (invalid)", - InvalidLiteral: "1 + 1", - Type: cadence.IntType{}, - }, - } - - test := func(testCase testCase) { - t.Run(testCase.Name, func(t *testing.T) { - t.Parallel() - - literal := testCase.Literal - if testCase.Value != nil { - literal = testCase.Value.String() - } else if len(testCase.InvalidLiteral) > 0 { - literal = testCase.InvalidLiteral - } - - args, err := ParseWithoutType( - []string{literal}, - []byte(fmt.Sprintf( - `pub fun main(test: %s) {}`, - testCase.Type.ID(), - )), - "", - ) - if len(testCase.InvalidLiteral) > 0 { - require.Error(t, err) - } else { - require.NoError(t, err) - assert.Equal(t, - []cadence.Value{testCase.Value}, - args, - ) - } - }) - } - - for _, testCase := range testCases { - test(testCase) - } - }) - - t.Run("entrypoints", func(t *testing.T) { - t.Parallel() - - template := map[string]string{ - "script": `pub fun main(foo: String): Void {}`, - "contract": `pub contract Foo { init(foo: String) {} }`, - "transaction": `transaction(foo: String) {}`, - } - - test := func(name string, code string) { - t.Run(name, func(t *testing.T) { - t.Parallel() - - args, err := ParseWithoutType([]string{"hello"}, []byte(code), "") - assert.NoError(t, err) - assert.Len(t, args, 1) - v, _ := cadence.NewString("hello") - assert.Equal(t, []cadence.Value{v}, args) - }) - } - - for name, code := range template { - test(name, code) - } - }) -} - -func Test_ParseJSON(t *testing.T) { - t.Parallel() - - jsonInput := `[{"type": "String", "value": "Hello World"}]` - - values, err := ParseJSON(jsonInput) - require.NoError(t, err) - - require.Len(t, values, 1) - assert.Equal(t, `"Hello World"`, values[0].String()) - assert.Equal(t, "String", values[0].Type().ID()) -} diff --git a/flowkit/cmd/flow-schema/flow-schema.go b/flowkit/cmd/flow-schema/flow-schema.go deleted file mode 100644 index 8ebd8c2b4..000000000 --- a/flowkit/cmd/flow-schema/flow-schema.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "encoding/json" - "flag" - "fmt" - "os" - "strings" - - configJson "github.com/onflow/flow-cli/flowkit/config/json" -) - -func main() { - var verify bool - flag.BoolVar(&verify, "verify", false, "Verify the schema") - - flag.Parse() - path := flag.Arg(0) - - if path == "" { - fmt.Println("Path is required") - os.Exit(1) - } - - schema := configJson.GenerateSchema() - json, err := json.MarshalIndent(schema, "", " ") - - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - if verify { - fileContents, err := os.ReadFile(path) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - if normalizeNewlines(string(fileContents)) != normalizeNewlines(string(json)) { - fmt.Println("Schema is out of date - have you run `make generate-schema`?") - os.Exit(1) - } - } else { - os.WriteFile(path, json, 0644) - } -} - -func normalizeNewlines(s string) string { - return strings.ReplaceAll(s, "\r\n", "\n") -} diff --git a/flowkit/config/account.go b/flowkit/config/account.go deleted file mode 100644 index 673acbbf6..000000000 --- a/flowkit/config/account.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "golang.org/x/exp/slices" -) - -const ( - DefaultHashAlgo = crypto.SHA3_256 - DefaultSigAlgo = crypto.ECDSA_P256 -) - -// Account defines the configuration for a Flow account. -type Account struct { - Name string - Address flow.Address - Key AccountKey -} - -type Accounts []Account - -// AccountKey represents account key and all their possible configuration formats. -type AccountKey struct { - Type KeyType - Index int - SigAlgo crypto.SignatureAlgorithm - HashAlgo crypto.HashAlgorithm - ResourceID string - Mnemonic string - DerivationPath string - PrivateKey crypto.PrivateKey - Location string - Env string -} - -func NewDefaultAccountKey(pkey crypto.PrivateKey) AccountKey { - return AccountKey{ - Type: KeyTypeHex, - SigAlgo: DefaultSigAlgo, - HashAlgo: DefaultHashAlgo, - PrivateKey: pkey, - } -} - -func (a *AccountKey) IsDefault() bool { - return a.Index == 0 && - a.Type == KeyTypeHex && - a.SigAlgo == DefaultSigAlgo && - a.HashAlgo == DefaultHashAlgo -} - -// ByName get account by name or error if not found. -func (a *Accounts) ByName(name string) (*Account, error) { - for _, account := range *a { - if account.Name == name { - return &account, nil - } - } - - return nil, fmt.Errorf("account with name %s is not present in configuration", name) -} - -// AddOrUpdate add new or update if already present. -func (a *Accounts) AddOrUpdate(name string, account Account) { - for i, existingAccount := range *a { - if existingAccount.Name == name { - (*a)[i] = account - return - } - } - - *a = append(*a, account) -} - -// Remove account by name. -func (a *Accounts) Remove(name string) { - for i, account := range *a { - if account.Name == name { - *a = slices.Delete(*a, i, i+1) - } - } -} diff --git a/flowkit/config/account_test.go b/flowkit/config/account_test.go deleted file mode 100644 index 9ee8756d9..000000000 --- a/flowkit/config/account_test.go +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" -) - -func TestAccounts_ByName(t *testing.T) { - acc1 := Account{ - Name: "test1", - Address: flow.HexToAddress("0x1"), - } - - acc2 := Account{ - Name: "test2", - Address: flow.HexToAddress("0x2"), - } - - accounts := Accounts{acc1, acc2} - - t.Run("Account present in slice", func(t *testing.T) { - account, err := accounts.ByName("test1") - assert.Nil(t, err) - assert.Equal(t, &acc1, account) - }) - - t.Run("Account not present in slice", func(t *testing.T) { - account, err := accounts.ByName("test3") - assert.Error(t, err) - assert.Nil(t, account) - }) -} - -func TestAccounts_AddOrUpdate(t *testing.T) { - acc1 := Account{ - Name: "test1", - Address: flow.HexToAddress("0x1"), - } - - acc2 := Account{ - Name: "test2", - Address: flow.HexToAddress("0x2"), - } - - // Test case 1: add a new account - t.Run("Add new account", func(t *testing.T) { - accounts := Accounts{acc1, acc2} - acc3 := Account{ - Name: "test3", - Address: flow.HexToAddress("0x3"), - } - - accounts.AddOrUpdate("test3", acc3) - assert.Len(t, accounts, 3) - }) - - // Test case 2: update an existing account - t.Run("Update existing account", func(t *testing.T) { - accounts := Accounts{acc1, acc2} - - acc2Updated := Account{ - Name: "test2", - Address: flow.HexToAddress("0x4"), - } - - accounts.AddOrUpdate("test2", acc2Updated) - assert.Len(t, accounts, 2) - - account, err := accounts.ByName("test2") - assert.Nil(t, err) - assert.Equal(t, acc2Updated, *account) - }) -} - -func TestAccounts_Remove(t *testing.T) { - acc1 := Account{ - Name: "account1", - Address: flow.HexToAddress("01"), - } - acc2 := Account{ - Name: "account2", - Address: flow.HexToAddress("02"), - } - acc3 := Account{ - Name: "account3", - Address: flow.HexToAddress("03"), - } - - accounts := Accounts{acc1, acc2, acc3} - - accounts.Remove("account2") - assert.Equal(t, len(accounts), 2) - - _, err := accounts.ByName("account2") - assert.Error(t, err) - - accounts.Remove("account4") - assert.Equal(t, len(accounts), 2) -} diff --git a/flowkit/config/config.go b/flowkit/config/config.go deleted file mode 100644 index 3781ba32b..000000000 --- a/flowkit/config/config.go +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "errors" - "fmt" - "os" -) - -// Config contains all the configuration for CLI and implements getters and setters for properties. -// Config is agnostic to format from which it is built and it doesn't provide persistence functionality. -// -// Emulators contains all the emulator config -// Contracts contains all contracts definitions and their sources -// Networks defines all the Flow networks addresses -// Accounts defines Flow accounts and their addresses, private key and more properties -// Deployments describes which contracts should be deployed to which accounts -type Config struct { - Emulators Emulators - Contracts Contracts - Dependencies Dependencies - Networks Networks - Accounts Accounts - Deployments Deployments -} - -type KeyType string - -const ( - KeyTypeHex KeyType = "hex" - KeyTypeGoogleKMS KeyType = "google-kms" - KeyTypeBip44 KeyType = "bip44" - KeyTypeFile KeyType = "file" -) - -// Validate the configuration values. -func (c *Config) Validate() error { - for _, con := range c.Contracts { - for _, alias := range con.Aliases { - _, err := c.Networks.ByName(alias.Network) - if alias.Network != "" && err != nil { - return fmt.Errorf("contract %s alias contains nonexisting network %s", con.Name, alias.Network) - } - } - } - - for _, em := range c.Emulators { - if _, err := c.Accounts.ByName(em.ServiceAccount); err != nil { - return fmt.Errorf("emulator %s contains nonexisting service account %s", em.Name, em.ServiceAccount) - } - } - - for _, d := range c.Deployments { - if _, err := c.Networks.ByName(d.Network); err != nil { - return fmt.Errorf("deployment contains nonexisting network %s", d.Network) - } - - for _, con := range d.Contracts { - if _, err := c.Contracts.ByName(con.Name); err != nil { - return fmt.Errorf("deployment contains nonexisting contract %s", con.Name) - } - } - - if _, err := c.Accounts.ByName(d.Account); err != nil { - return fmt.Errorf("deployment contains nonexisting account %s", d.Account) - } - } - - return nil -} - -// Default returns the default configuration. -func Default() *Config { - return &Config{ - Emulators: DefaultEmulators, - Networks: DefaultNetworks, - } -} - -var ErrOutdatedFormat = errors.New("you are using old configuration format") - -const DefaultPath = "flow.json" - -func IsDefaultPath(paths []string) bool { - return len(paths) == 2 && paths[0] == GlobalPath() && paths[1] == DefaultPath -} - -// GlobalPath gets global path based on home dir. -func GlobalPath() string { - dirname, err := os.UserHomeDir() - if err != nil { - return "" - } - - return fmt.Sprintf("%s/%s", dirname, DefaultPath) -} - -// DefaultPaths determines default paths for configuration. -func DefaultPaths() []string { - return []string{ - GlobalPath(), - DefaultPath, - } -} diff --git a/flowkit/config/config_test.go b/flowkit/config/config_test.go deleted file mode 100644 index 40882b4a2..000000000 --- a/flowkit/config/config_test.go +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package config_test - -import ( - "testing" - - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit/config" -) - -func generateComplexConfig() config.Config { - var keys []crypto.PrivateKey - key, _ := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - keys = append(keys, key) - key, _ = crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "388e3fbdc654b765942610679bb3a66b74212149ab9482187067ee116d9a8118") - keys = append(keys, key) - key, _ = crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "27bbeba308e501f8485ddaab77e285c0bc0d611096a79b4f0b4ccc927c6dbf04") - keys = append(keys, key) - - return config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 9000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{{ - Name: "NonFungibleToken", - Location: "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - }, { - Name: "FungibleToken", - Location: "../hungry-kitties/cadence/contracts/FungibleToken.cdc", - }, { - Name: "Kibble", - Location: "./cadence/kibble/contracts/Kibble.cdc", - }, { - Name: "KittyItems", - Location: "./cadence/kittyItems/contracts/KittyItems.cdc", - }, { - Name: "KittyItemsMarket", - Location: "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", - Aliases: []config.Alias{{ - Network: "testnet", - Address: flow.HexToAddress("0x123123123"), - }}, - }, { - Name: "KittyItemsMarket", - Location: "0x123123123", - }}, - Deployments: config.Deployments{{ - Network: "emulator", - Account: "emulator-account", - Contracts: []config.ContractDeployment{ - {Name: "KittyItems", Args: []cadence.Value{}}, - {Name: "KittyItemsMarket", Args: []cadence.Value{}}, - }, - }, { - Network: "emulator", - Account: "account-4", - Contracts: []config.ContractDeployment{ - {Name: "FungibleToken", Args: []cadence.Value{}}, - {Name: "NonFungibleToken", Args: []cadence.Value{}}, - {Name: "Kibble", Args: []cadence.Value{}}, - {Name: "KittyItems", Args: []cadence.Value{}}, - {Name: "KittyItemsMarket", Args: []cadence.Value{}}, - }, - }, { - Network: "testnet", - Account: "account-2", - Contracts: []config.ContractDeployment{ - {Name: "FungibleToken", Args: []cadence.Value{}}, - {Name: "NonFungibleToken", Args: []cadence.Value{}}, - {Name: "Kibble", Args: []cadence.Value{}}, - {Name: "KittyItems", Args: []cadence.Value{}}, - }, - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys[0], - }, - }, { - Name: "account-2", - Address: flow.HexToAddress("2c1162386b0a245f"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys[1], - }, - }, { - Name: "account-4", - Address: flow.HexToAddress("f8d6e0586b0a20c1"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys[2], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }, { - Name: "testnet", - Host: "access.devnet.nodes.onflow.org:9000", - Key: "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", - }}, - } -} - -func Test_GetContractsForNetworkComplex(t *testing.T) { - conf := generateComplexConfig() - kitty, _ := conf.Contracts.ByName("KittyItems") - assert.NotNil(t, kitty) - - market, _ := conf.Contracts.ByName("KittyItemsMarket") - assert.NotNil(t, market) - - assert.Equal(t, "KittyItems", kitty.Name) - assert.Equal(t, "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", market.Location) -} - -func Test_GetContractsByNameAndNetworkComplex(t *testing.T) { - conf := generateComplexConfig() - market, _ := conf.Contracts.ByName("KittyItemsMarket") - assert.NotNil(t, market) - - assert.Equal(t, "0000000123123123", market.Aliases.ByNetwork("testnet").Address.String()) -} - -func Test_GetAccountByNameComplex(t *testing.T) { - conf := generateComplexConfig() - acc, err := conf.Accounts.ByName("account-4") - assert.NoError(t, err) - - assert.Equal(t, "f8d6e0586b0a20c1", acc.Address.String()) -} - -func Test_GetDeploymentsByNetworkComplex(t *testing.T) { - conf := generateComplexConfig() - deployment := conf.Deployments.ByAccountAndNetwork("account-2", "testnet") - - assert.Equal(t, - []config.ContractDeployment{ - {Name: "FungibleToken", Args: []cadence.Value{}}, - {Name: "NonFungibleToken", Args: []cadence.Value{}}, - {Name: "Kibble", Args: []cadence.Value{}}, - {Name: "KittyItems", Args: []cadence.Value{}}, - }, - deployment.Contracts, - ) -} - -func Test_GetNetworkByNameComplex(t *testing.T) { - conf := generateComplexConfig() - network, err := conf.Networks.ByName("emulator") - assert.NoError(t, err) - assert.Equal(t, "127.0.0.1.3569", network.Host) - - network, err = conf.Networks.ByName("testnet") - assert.NoError(t, err) - assert.Equal(t, network.Host, "access.devnet.nodes.onflow.org:9000") - assert.Equal(t, network.Key, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd") -} - -func TestConfig_Validate(t *testing.T) { - // Test valid configuration - cfg := &config.Config{ - Emulators: config.DefaultEmulators, - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - }}, - Networks: config.DefaultNetworks, - Accounts: config.Accounts{{ - Name: "MyAccount", - Address: flow.HexToAddress("0x01"), - }, { - Name: "emulator-account", - Address: flow.HexToAddress("0x02"), - }}, - Deployments: config.Deployments{{ - Network: "testnet", - Contracts: []config.ContractDeployment{{ - Name: "MyContract", - }}, - Account: "MyAccount", - }}, - } - - err := cfg.Validate() - assert.NoError(t, err, "config should be valid") - - cfg = &config.Config{ - Emulators: config.DefaultEmulators, - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - }}, - Networks: config.DefaultNetworks, - Accounts: config.Accounts{{ - Name: "MyAccount", - Address: flow.HexToAddress("0x01"), - }}, - Deployments: config.Deployments{{ - Network: "testnet", - Contracts: []config.ContractDeployment{{ - Name: "MyContract", - }}, - Account: "MyAccount", - }}, - } - - err = cfg.Validate() - assert.EqualError(t, err, "emulator default contains nonexisting service account emulator-account") - - cfg = &config.Config{ - Emulators: config.DefaultEmulators, - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - }}, - Networks: config.DefaultNetworks, - Accounts: config.Accounts{{ - Name: "MyAccount", - Address: flow.HexToAddress("0x01"), - }, { - Name: "emulator-account", - Address: flow.HexToAddress("0x02"), - }}, - Deployments: config.Deployments{{ - Network: "testnet", - Contracts: []config.ContractDeployment{{ - Name: "NonExistingContract", - }}, - Account: "MyAccount", - }}, - } - - err = cfg.Validate() - assert.EqualError(t, err, "deployment contains nonexisting contract NonExistingContract") - - cfg = &config.Config{ - Emulators: config.DefaultEmulators, - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - Aliases: config.Aliases{{ - Network: "non-existing", - Address: flow.HexToAddress("0x01"), - }}, - }}, - Networks: config.DefaultNetworks, - } - - err = cfg.Validate() - assert.EqualError(t, err, "contract MyContract alias contains nonexisting network non-existing") - - cfg = &config.Config{ - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - }}, - Deployments: config.Deployments{{ - Network: "no", - Contracts: []config.ContractDeployment{{ - Name: "NonExistingContract", - }}, - Account: "MyAccount", - }}, - Networks: config.DefaultNetworks, - } - - err = cfg.Validate() - assert.EqualError(t, err, "deployment contains nonexisting network no") - - cfg = &config.Config{ - Contracts: config.Contracts{{ - Name: "MyContract", - Location: "contracts/my-contract.cdc", - }}, - Deployments: config.Deployments{{ - Network: "testnet", - Contracts: []config.ContractDeployment{{ - Name: "MyContract", - }}, - Account: "no", - }}, - Networks: config.DefaultNetworks, - } - - err = cfg.Validate() - assert.EqualError(t, err, "deployment contains nonexisting account no") -} - -func Test_DefaultConfig(t *testing.T) { - cfg := config.Default() - assert.Len(t, cfg.Emulators, 1) - assert.Equal(t, cfg.Emulators[0].Name, "default") - assert.Equal(t, cfg.Emulators[0].ServiceAccount, "emulator-account") - assert.Len(t, cfg.Networks, 4) - assert.Equal(t, "emulator", cfg.Networks[0].Name) - assert.Equal(t, "testing", cfg.Networks[1].Name) - assert.Equal(t, "testnet", cfg.Networks[2].Name) - assert.Equal(t, "mainnet", cfg.Networks[3].Name) -} - -func Test_DefaultPath(t *testing.T) { - global := config.GlobalPath() - assert.True(t, config.IsDefaultPath([]string{global, "flow.json"})) - assert.False(t, config.IsDefaultPath([]string{"no.json"})) - - def := config.DefaultPaths() - assert.True(t, config.IsDefaultPath(def)) -} diff --git a/flowkit/config/contract.go b/flowkit/config/contract.go deleted file mode 100644 index bcfa883d7..000000000 --- a/flowkit/config/contract.go +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" - "path/filepath" - - "github.com/onflow/flow-go/fvm/systemcontracts" - flowGo "github.com/onflow/flow-go/model/flow" - - "github.com/onflow/flow-go-sdk" - "golang.org/x/exp/slices" -) - -// Contract defines the configuration for a Cadence contract. -type Contract struct { - Name string - Location string - Aliases Aliases - IsDependency bool -} - -// Alias defines an existing pre-deployed contract address for specific network. -type Alias struct { - Network string - Address flow.Address -} - -type Aliases []Alias - -func (a *Aliases) ByNetwork(network string) *Alias { - for _, alias := range *a { - if alias.Network == network { - return &alias - } - } - - return nil -} - -func (a *Aliases) Add(network string, address flow.Address) { - for _, alias := range *a { - if alias.Network == network { - return // already exists - } - } - *a = append(*a, Alias{ - Network: network, - Address: address, - }) -} - -type Contracts []Contract - -// IsAliased checks if contract has an alias. -func (c *Contract) IsAliased() bool { - return len(c.Aliases) > 0 -} - -// ByName get contract by name or return an error if it doesn't exist. -func (c *Contracts) ByName(name string) (*Contract, error) { - for i, contract := range *c { - if contract.Name == name { - return &(*c)[i], nil - } - } - - return nil, fmt.Errorf("contract %s does not exist", name) -} - -// AddOrUpdate add new or update if already present. -func (c *Contracts) AddOrUpdate(contract Contract) { - for i, existingContract := range *c { - if existingContract.Name == contract.Name { - (*c)[i] = contract - return - } - } - - *c = append(*c, contract) -} - -// Remove contract by its name. -func (c *Contracts) Remove(name string) error { - if _, err := c.ByName(name); err != nil { - return err - } - - for i, contract := range *c { - if contract.Name == name { - *c = slices.Delete(*c, i, i+1) - } - } - - return nil -} - -const dependencyManagerDirectory = "imports" - -const ( - networkEmulator = "emulator" - networkTestnet = "testnet" - networkMainnet = "mainnet" -) - -func supportedNetworks() []string { - return []string{ - networkEmulator, - networkTestnet, - networkMainnet, - } -} - -var networkToChainID = map[string]flowGo.ChainID{ - networkEmulator: flowGo.Emulator, - networkTestnet: flowGo.Testnet, - networkMainnet: flowGo.Mainnet, -} - -func isCoreContract(networkName, contractName, contractAddress string) bool { - sc := systemcontracts.SystemContractsForChain(networkToChainID[networkName]) - - for _, coreContract := range sc.All() { - if coreContract.Name == contractName && coreContract.Address.String() == contractAddress { - return true - } - } - - return false -} - -func getCoreContractByName(networkName, contractName string) *systemcontracts.SystemContract { - sc := systemcontracts.SystemContractsForChain(networkToChainID[networkName]) - - for i, coreContract := range sc.All() { - if coreContract.Name == contractName { - return &sc.All()[i] - } - } - - return nil -} - -// AddDependencyAsContract adds a dependency as a contract if it doesn't already exist. -func (c *Contracts) AddDependencyAsContract(dependency Dependency, networkName string) { - var aliases []Alias - - // If core contract found by name and address matches, then use all core contract aliases across networks - if isCoreContract(networkName, dependency.Source.ContractName, dependency.Source.Address.String()) { - for _, networkStr := range supportedNetworks() { - coreContract := getCoreContractByName(networkStr, dependency.Source.ContractName) - if coreContract != nil { - aliases = append(aliases, Alias{ - Network: networkStr, - Address: flow.HexToAddress(coreContract.Address.String()), - }) - } - } - } else { - aliases = append(aliases, dependency.Aliases...) - } - - // If no core contract match, then use the address in source as alias - if len(aliases) == 0 { - aliases = append(aliases, Alias{ - Network: dependency.Source.NetworkName, - Address: dependency.Source.Address, - }) - } - - contract := Contract{ - Name: dependency.Name, - Location: filepath.ToSlash(fmt.Sprintf("%s/%s/%s.cdc", dependencyManagerDirectory, dependency.Source.Address, dependency.Source.ContractName)), - Aliases: aliases, - IsDependency: true, - } - - if _, err := c.ByName(contract.Name); err != nil { - c.AddOrUpdate(contract) - } -} - -func (c *Contracts) DependencyContractByName(name string) *Contract { - for i, contract := range *c { - if contract.Name == name && contract.IsDependency { - return &(*c)[i] - } - } - - return nil -} diff --git a/flowkit/config/contract_test.go b/flowkit/config/contract_test.go deleted file mode 100644 index 2b9ab21f0..000000000 --- a/flowkit/config/contract_test.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" -) - -func TestAliases_Add(t *testing.T) { - aliases := Aliases{} - aliases.Add("testnet", flow.HexToAddress("0xabcdef")) - - alias := aliases.ByNetwork("testnet") - assert.NotNil(t, alias) -} - -func TestAliases_Add_Duplicate(t *testing.T) { - aliases := Aliases{} - aliases.Add("testnet", flow.HexToAddress("0xabcdef")) - aliases.Add("testnet", flow.HexToAddress("0x123456")) - - assert.Len(t, aliases, 1) -} - -func TestContracts_AddOrUpdate_Add(t *testing.T) { - contracts := Contracts{} - contracts.AddOrUpdate(Contract{Name: "mycontract", Location: "path/to/contract.cdc"}) - - assert.Len(t, contracts, 1) - - contract, err := contracts.ByName("mycontract") - assert.NoError(t, err) - assert.Equal(t, "path/to/contract.cdc", contract.Location) -} - -func TestContracts_AddOrUpdate_Update(t *testing.T) { - contracts := Contracts{ - Contract{Name: "mycontract", Location: "path/to/contract.cdc"}, - } - contracts.AddOrUpdate(Contract{Name: "mycontract", Location: "new/path/to/contract.cdc"}) - - assert.Len(t, contracts, 1) - - contract, err := contracts.ByName("mycontract") - assert.NoError(t, err) - assert.Equal(t, "new/path/to/contract.cdc", contract.Location) -} - -func TestContracts_Remove(t *testing.T) { - contracts := Contracts{ - Contract{Name: "mycontract", Location: "path/to/contract.cdc"}, - } - err := contracts.Remove("mycontract") - assert.NoError(t, err) - assert.Len(t, contracts, 0) -} - -func TestContracts_Remove_NotFound(t *testing.T) { - contracts := Contracts{ - Contract{Name: "mycontract1", Location: "path/to/contract.cdc"}, - Contract{Name: "mycontract2", Location: "path/to/contract.cdc"}, - Contract{Name: "mycontract3", Location: "path/to/contract.cdc"}, - } - err := contracts.Remove("mycontract2") - assert.NoError(t, err) - assert.Len(t, contracts, 2) - _, err = contracts.ByName("mycontract1") - assert.NoError(t, err) - _, err = contracts.ByName("mycontract3") - assert.NoError(t, err) - _, err = contracts.ByName("mycontract2") - assert.EqualError(t, err, "contract mycontract2 does not exist") -} - -func TestContracts_AddDependencyAsContract(t *testing.T) { - contracts := Contracts{} - contracts.AddDependencyAsContract(Dependency{ - Name: "testcontract", - Source: Source{ - NetworkName: "testnet", - Address: flow.HexToAddress("0x0000000000abcdef"), - ContractName: "TestContract", - }, - }, "testnet") - - assert.Len(t, contracts, 1) - - contract, err := contracts.ByName("testcontract") - assert.NoError(t, err) - assert.Equal(t, "imports/0000000000abcdef/TestContract.cdc", contract.Location) - assert.Len(t, contract.Aliases, 1) -} diff --git a/flowkit/config/dependency.go b/flowkit/config/dependency.go deleted file mode 100644 index 68c862a19..000000000 --- a/flowkit/config/dependency.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" - "strings" - - "github.com/onflow/flow-go-sdk" -) - -func ParseSourceString(s string) (network, address, contractName string, err error) { - parts := strings.Split(s, "://") - if len(parts) != 2 { - return "", "", "", fmt.Errorf("invalid dependency source format: %s", s) - } - network = parts[0] - - subParts := strings.Split(parts[1], ".") - if len(subParts) != 2 { - return "", "", "", fmt.Errorf("invalid dependency source format: %s", s) - } - address = subParts[0] - contractName = subParts[1] - - return network, address, contractName, nil -} - -type Source struct { - NetworkName string - Address flow.Address - ContractName string -} - -type Dependency struct { - Name string - Source Source - Hash string - Aliases Aliases -} - -type Dependencies []Dependency - -func (d *Dependencies) ByName(name string) *Dependency { - for i, dep := range *d { - if dep.Name == name { - return &(*d)[i] - } - } - - return nil -} - -func (d *Dependencies) AddOrUpdate(dep Dependency) { - for i, dependency := range *d { - if dependency.Name == dep.Name { - (*d)[i] = dep - return - } - } - - *d = append(*d, dep) -} diff --git a/flowkit/config/dependency_test.go b/flowkit/config/dependency_test.go deleted file mode 100644 index b3f00499f..000000000 --- a/flowkit/config/dependency_test.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestDependencies_ByName(t *testing.T) { - dependencies := Dependencies{ - Dependency{Name: "mydep"}, - } - - dep := dependencies.ByName("mydep") - assert.NotNil(t, dep) -} - -func TestDependencies_AddOrUpdate(t *testing.T) { - dependencies := Dependencies{} - dependencies.AddOrUpdate(Dependency{Name: "mydep"}) - - assert.Len(t, dependencies, 1) - - dep := dependencies.ByName("mydep") - assert.NotNil(t, dep) -} diff --git a/flowkit/config/deployment.go b/flowkit/config/deployment.go deleted file mode 100644 index 5fc78239d..000000000 --- a/flowkit/config/deployment.go +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" - - "github.com/onflow/cadence" - "golang.org/x/exp/slices" -) - -// ContractDeployment defines the deployment of the contract with possible args. -type ContractDeployment struct { - Name string - Args []cadence.Value -} - -// Deployment defines the configuration for a contract deployment. -type Deployment struct { - Network string // network name to deploy to - Account string // account name to which to deploy to - Contracts []ContractDeployment // contracts to deploy -} - -// AddContract to deployment list on the account name and network name. -func (d *Deployment) AddContract(contract ContractDeployment) { - for _, c := range d.Contracts { - if contract.Name == c.Name { - return // don't allow adding duplicates - } - } - - d.Contracts = append(d.Contracts, contract) -} - -// RemoveContract removes a specific contract by name from an existing deployment identified by account name and network name. -func (d *Deployment) RemoveContract(contractName string) { - for i, contract := range d.Contracts { - if contract.Name == contractName { - d.Contracts = slices.Delete(d.Contracts, i, i+1) - } - } -} - -type Deployments []Deployment - -// All returns a list of all deployments -func (d *Deployments) All() Deployments { - return *d -} - -// ByNetwork get all deployments by network. -func (d *Deployments) ByNetwork(network string) Deployments { - var deployments Deployments - - for _, deploy := range *d { - if deploy.Network == network { - deployments = append(deployments, deploy) - } - } - - return deployments -} - -// ByAccountAndNetwork get deploy by account and network. -func (d *Deployments) ByAccountAndNetwork(account string, network string) *Deployment { - for i, deploy := range *d { - if deploy.Network == network && deploy.Account == account { - return &(*d)[i] - } - } - - return nil -} - -// AddOrUpdate add new or update if already present. -func (d *Deployments) AddOrUpdate(deployment Deployment) { - for i, existingDeployment := range *d { - if existingDeployment.Account == deployment.Account && - existingDeployment.Network == deployment.Network { - (*d)[i] = deployment - return - } - } - - *d = append(*d, deployment) -} - -// Remove removes deployment by account and network. -func (d *Deployments) Remove(account string, network string) error { - deployment := d.ByAccountAndNetwork(account, network) - if deployment == nil { - return fmt.Errorf( - "deployment for account %s on network %s does not exist in configuration", - account, - network, - ) - } - - for i, deployment := range *d { - if deployment.Network == network && deployment.Account == account { - *d = slices.Delete(*d, i, i+1) - } - } - - return nil -} diff --git a/flowkit/config/deployment_test.go b/flowkit/config/deployment_test.go deleted file mode 100644 index 952f6edc8..000000000 --- a/flowkit/config/deployment_test.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/onflow/cadence" - "github.com/stretchr/testify/assert" -) - -func Test_Deployment(t *testing.T) { - contracts := []ContractDeployment{{ - Name: "contract-1", - Args: []cadence.Value{cadence.NewInt(5)}, - }, { - Name: "contract-2", - Args: []cadence.Value{cadence.NewInt(15)}, - }} - - t.Run("Adding deployments", func(t *testing.T) { - network := "test-network" - - deployments := &Deployments{} - deployments.AddOrUpdate(Deployment{ - Network: network, - Account: "test-account", - Contracts: []ContractDeployment{contracts[0]}, - }) - assert.Equal(t, []ContractDeployment{contracts[0]}, (*deployments)[0].Contracts) - - deployments.AddOrUpdate(Deployment{ - Network: network, - Account: "test-account", - Contracts: contracts, - }) - assert.Equal(t, contracts, (*deployments)[0].Contracts) - - deployments.AddOrUpdate(Deployment{ - Network: network, - Account: "test-account-2", - Contracts: []ContractDeployment{contracts[0]}, - }) - assert.Len(t, *deployments, 2) - assert.Equal(t, []ContractDeployment{contracts[0]}, (*deployments)[1].Contracts) - }) - - t.Run("Remove deployment", func(t *testing.T) { - deployments := &Deployments{ - Deployment{ - Network: "test-network", - Account: "test-account", - Contracts: []ContractDeployment{{ - Name: "contract-1", - Args: []cadence.Value{cadence.NewInt(5)}, - }, { - Name: "contract-2", - Args: []cadence.Value{cadence.NewInt(15)}, - }}, - }, - } - - err := deployments.Remove("test-account", "test-network") - assert.NoError(t, err) - assert.Len(t, *deployments, 0) - }) - - t.Run("Remove deployment contract", func(t *testing.T) { - copyContracts := make([]ContractDeployment, len(contracts)) - copy(copyContracts, contracts) - const acc = "test" - const net = "testnet" - - deployments := &Deployments{ - Deployment{ - Network: net, - Account: acc, - Contracts: copyContracts, - }, - } - - deployments.ByAccountAndNetwork(acc, net).RemoveContract(contracts[0].Name) - - assert.Len(t, *deployments, 1) - assert.Len(t, (*deployments)[0].Contracts, 1) - assert.Equal(t, (*deployments)[0].Contracts[0], contracts[1]) - }) - - t.Run("Deployment by network", func(t *testing.T) { - deployments := &Deployments{ - Deployment{ - Network: "net", - Account: "acc", - }, - Deployment{ - Network: "net", - Account: "acc2", - }, - Deployment{ - Network: "net2", - Account: "acc2", - }, - } - - network := deployments.ByNetwork("net") - assert.Len(t, network, 2) - assert.Equal(t, network[0].Account, "acc") - assert.Equal(t, network[1].Account, "acc2") - }) - - t.Run("Remove non-existing deployment", func(t *testing.T) { - deployments := &Deployments{ - Deployment{ - Network: "test", - Account: "acc", - }, - } - - err := deployments.Remove("acc", "no") - assert.EqualError(t, err, "deployment for account acc on network no does not exist in configuration") - }) - - t.Run("Add deployment contract", func(t *testing.T) { - const acc = "test" - const net = "testnet" - deployments := &Deployments{ - Deployment{Network: net, Account: acc}, - } - - deployments.ByAccountAndNetwork(acc, net).AddContract(contracts[0]) - deployments.ByAccountAndNetwork(acc, net).AddContract(contracts[1]) - - assert.Len(t, *deployments, 1) - assert.Len(t, (*deployments)[0].Contracts, 2) - assert.Equal(t, (*deployments)[0].Contracts[1], contracts[1]) - assert.Equal(t, (*deployments)[0].Contracts[0], contracts[0]) - }) - -} diff --git a/flowkit/config/emulator.go b/flowkit/config/emulator.go deleted file mode 100644 index d0d1c9b1a..000000000 --- a/flowkit/config/emulator.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -var ( - DefaultEmulator = Emulator{ - Name: "default", - ServiceAccount: "emulator-account", - Port: 3569, - } - DefaultEmulators = Emulators{DefaultEmulator} -) - -// Emulator defines the configuration for a Flow Emulator instance. -type Emulator struct { - Name string - Port int - ServiceAccount string -} - -type Emulators []Emulator - -// Default gets default emulator. -func (e *Emulators) Default() *Emulator { - for _, em := range *e { - if em.Name == DefaultEmulator.Name { - return &em - } - } - - return nil -} - -// AddOrUpdate add new or update if already present. -func (e *Emulators) AddOrUpdate(name string, emulator Emulator) { - for i, existingEmulator := range *e { - if existingEmulator.Name == name { - (*e)[i] = emulator - return - } - } - - *e = append(*e, emulator) -} diff --git a/flowkit/config/emulator_test.go b/flowkit/config/emulator_test.go deleted file mode 100644 index ba73466dc..000000000 --- a/flowkit/config/emulator_test.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Flow CLI -* -* Copyright 2019-2020 Dapper Labs, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestEmulatorsDefault(t *testing.T) { - emulators := Emulators{{ - Name: "emulator-1", - Port: 1234, - }, { - Name: "default", - Port: 3569, - ServiceAccount: "emulator-account", - }} - - expected := &Emulator{ - Name: "default", - ServiceAccount: "emulator-account", - Port: 3569, - } - - assert.Equal(t, expected, emulators.Default()) -} - -func TestEmulatorsAddOrUpdate(t *testing.T) { - emulator1 := Emulator{ - Name: "emulator-1", - Port: 1234, - } - emulator2 := Emulator{ - Name: "emulator-account", - Port: 3569, - ServiceAccount: "emulator-account", - } - - emulators := Emulators{emulator1} - - emulators.AddOrUpdate(emulator1.Name, emulator2) - - assert.Len(t, emulators, 1) - assert.Equal(t, emulator2, emulators[0]) - - emulators.AddOrUpdate("emulator-2", Emulator{ - Name: "emulator-2", - Port: 2345, - }) - - assert.Len(t, emulators, 2) - assert.Contains(t, emulators, emulator2) - assert.Contains(t, emulators, Emulator{ - Name: "emulator-2", - Port: 2345, - }) -} diff --git a/flowkit/config/json/account.go b/flowkit/config/json/account.go deleted file mode 100644 index cbf444a06..000000000 --- a/flowkit/config/json/account.go +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "regexp" - "strings" - - "github.com/invopop/jsonschema" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "golang.org/x/exp/slices" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonAccounts map[string]account - -const ( - defaultHashAlgo = crypto.SHA3_256 - defaultSigAlgo = crypto.ECDSA_P256 -) - -// transformAddress returns address based on address and chain id. -func transformAddress(address string) (flow.Address, error) { - // only allow service for emulator - if address == "service" { - return flow.ServiceAddress(flow.Emulator), nil - } - - if flow.HexToAddress(address) == flow.EmptyAddress { - return flow.EmptyAddress, fmt.Errorf("could not parse address: %s", address) - } - - return flow.HexToAddress(address), nil -} - -// transformSimpleToConfig transforms simple internal account to config account. -func transformSimpleToConfig(accountName string, a simpleAccount) (*config.Account, error) { - key := config.AccountKey{ - Type: config.KeyTypeHex, - SigAlgo: defaultSigAlgo, - HashAlgo: defaultHashAlgo, - } - - replaced, original, err := tryReplaceEnv(a.Key) - if err != nil { - return nil, err - } - if replaced != "" { - key.Env = original - a.Key = replaced - } - - pkey, err := crypto.DecodePrivateKeyHex( - config.DefaultSigAlgo, - strings.TrimPrefix(a.Key, "0x"), - ) - if err != nil { - return nil, fmt.Errorf("invalid private key for account: %s", accountName) - } - key.PrivateKey = pkey - - replacedAddress, _, err := tryReplaceEnv(a.Address) - if err != nil { - return nil, err - } - if replacedAddress != "" { - a.Address = replacedAddress - } - - address, err := transformAddress(a.Address) - if err != nil { - return nil, err - } - - return &config.Account{ - Name: accountName, - Address: address, - Key: key, - }, nil -} - -// tryReplaceEnv checks if value matches env regex, if it does it check whether the value was set in env, -// if not set then it errors, otherwise it replaces the value with set env variable, and also returns the original key. -func tryReplaceEnv(value string) (replaced string, original string, err error) { - envRegex, err := regexp.Compile(`^\$\{(\w+)\}|\$(\w+)$`) - if err != nil { - return "", "", err - } - - if !envRegex.MatchString(value) { - return - } - - found := envRegex.FindAllStringSubmatch(value, -1) - if len(found) == 0 { - return // should not happen - } - - envVar := found[0][1] - if found[0][2] != "" { // second regex - envVar = found[0][2] - } - if os.Getenv(envVar) == "" { - return "", "", fmt.Errorf("required environment variable %s not set", envVar) - } - - original = value - replaced = os.ExpandEnv(value) - - return -} - -// transformAdvancedToConfig transforms advanced internal account to config account. -func transformAdvancedToConfig(accountName string, a advancedAccount) (*config.Account, error) { - sigAlgo := config.DefaultSigAlgo // default to ecdsa as default - if a.Key.SigAlgo != "" { - sigAlgo = crypto.StringToSignatureAlgorithm(a.Key.SigAlgo) - } - - if sigAlgo == crypto.UnknownSignatureAlgorithm { - return nil, fmt.Errorf("invalid signature algorithm for account %s", accountName) - } - - hashAlgo := config.DefaultHashAlgo // default to sha3 as default - if a.Key.HashAlgo != "" { - hashAlgo = crypto.StringToHashAlgorithm(a.Key.HashAlgo) - } - - if hashAlgo == crypto.UnknownHashAlgorithm { - return nil, fmt.Errorf("invalid hash algorithm for account %s", accountName) - } - - validTypes := []config.KeyType{config.KeyTypeHex, config.KeyTypeFile, config.KeyTypeBip44, config.KeyTypeGoogleKMS} - if !slices.Contains(validTypes, a.Key.Type) { - return nil, fmt.Errorf("invalid key type for account %s", accountName) - } - - // check that only one is provided because the values are mutually exclusive - set := false - for _, v := range []string{a.Key.ResourceID, a.Key.PrivateKey, a.Key.Location} { - if v == "" { - continue - } - if set { - return nil, fmt.Errorf("can only provide one property (resource ID, private key, location) on account %s", accountName) - } - set = true - } - - address, err := transformAddress(a.Address) - if err != nil { - return nil, err - } - - key := config.AccountKey{ - Type: a.Key.Type, - Index: a.Key.Index, - SigAlgo: sigAlgo, - HashAlgo: hashAlgo, - } - - switch a.Key.Type { - case config.KeyTypeHex: - if a.Key.PrivateKey == "" { - return nil, fmt.Errorf("missing private key value for hex key type on account %s", accountName) - } - - replaced, original, err := tryReplaceEnv(a.Key.PrivateKey) - if err != nil { - return nil, err - } - if replaced != "" { - key.Env = original - a.Key.PrivateKey = replaced - } - - pKey, err := crypto.DecodePrivateKeyHex( - sigAlgo, - strings.TrimPrefix(a.Key.PrivateKey, "0x"), - ) - if err != nil { - return nil, err - } - - key.PrivateKey = pKey - case config.KeyTypeBip44: - if a.Key.Mnemonic == "" { - return nil, fmt.Errorf("missing mnemonic value for bip44 key type on account %s", accountName) - } - key.Mnemonic = a.Key.Mnemonic - key.DerivationPath = a.Key.DerivationPath - if key.DerivationPath == "" { - key.DerivationPath = "m/44'/539'/0'/0/0" - } - - case config.KeyTypeGoogleKMS: - if a.Key.ResourceID == "" { - return nil, fmt.Errorf("missing resource ID value for key on account %s", accountName) - } - key.ResourceID = a.Key.ResourceID - - case config.KeyTypeFile: - if a.Key.Location == "" { - return nil, fmt.Errorf("missing location to a file containing the private key value for the account %s", accountName) - } - key.Location = filepath.FromSlash(a.Key.Location) - } - - return &config.Account{ - Name: accountName, - Address: address, - Key: key, - }, nil -} - -// transformToConfig transforms json structures to config structure. -func (j jsonAccounts) transformToConfig() (config.Accounts, error) { - accounts := make(config.Accounts, 0) - - for accountName, a := range j { - var account *config.Account - var err error - if a.Simple.Address != "" { - account, err = transformSimpleToConfig(accountName, a.Simple) - if err != nil { - return nil, err - } - } else { // advanced format - account, err = transformAdvancedToConfig(accountName, a.Advanced) - if err != nil { - return nil, err - } - } - - accounts = append(accounts, *account) - } - - return accounts, nil -} - -// transformToJSON transforms config structure to json structures for saving. -func transformAccountsToJSON(accounts config.Accounts) jsonAccounts { - jsonAccounts := jsonAccounts{} - - for _, a := range accounts { - if a.Key.IsDefault() { - jsonAccounts[a.Name] = transformSimpleAccountToJSON(a) - } else { - jsonAccounts[a.Name] = transformAdvancedAccountToJSON(a) - } - } - - return jsonAccounts -} - -func transformSimpleAccountToJSON(a config.Account) account { - key := strings.TrimPrefix(a.Key.PrivateKey.String(), "0x") - if a.Key.Env != "" { - key = a.Key.Env // if we used env vars then use it when saving - } - - return account{ - Simple: simpleAccount{ - Address: a.Address.String(), - Key: key, - }, - } -} - -func transformAdvancedAccountToJSON(a config.Account) account { - return account{ - Advanced: advancedAccount{ - Address: a.Address.String(), - Key: transformAdvancedKeyToJSON(a.Key), - }, - } -} - -func transformAdvancedKeyToJSON(key config.AccountKey) advanceKey { - advancedKey := advanceKey{ - Type: key.Type, - } - - if key.Index != 0 { // only set if non-default - advancedKey.Index = key.Index - } - - if key.SigAlgo != config.DefaultSigAlgo { // only set if non-default - advancedKey.SigAlgo = key.SigAlgo.String() - } - - if key.HashAlgo != config.DefaultHashAlgo { // only set if non-default - advancedKey.HashAlgo = key.HashAlgo.String() - } - - switch key.Type { - case config.KeyTypeHex: - advancedKey.PrivateKey = strings.TrimPrefix(key.PrivateKey.String(), "0x") - if key.Env != "" { - advancedKey.PrivateKey = key.Env // if we used env vars then use it when saving - } - case config.KeyTypeBip44: - advancedKey.Mnemonic = key.Mnemonic - advancedKey.DerivationPath = key.DerivationPath - case config.KeyTypeGoogleKMS: - advancedKey.ResourceID = key.ResourceID - case config.KeyTypeFile: - advancedKey.Location = filepath.ToSlash(key.Location) - } - - return advancedKey -} - -type account struct { - Simple simpleAccount - Advanced advancedAccount -} - -type simpleAccount struct { - Address string `json:"address"` - Key string `json:"key"` -} - -type advancedAccount struct { - Address string `json:"address"` - Key advanceKey `json:"key"` -} - -type advanceKey struct { - Type config.KeyType `json:"type"` - Index int `json:"index,omitempty"` - SigAlgo string `json:"signatureAlgorithm,omitempty"` - HashAlgo string `json:"hashAlgorithm,omitempty"` - // hex key type - PrivateKey string `json:"privateKey,omitempty"` - // bip44 key type - Mnemonic string `json:"mnemonic,omitempty"` - DerivationPath string `json:"derivationPath,omitempty"` - // kms key type - ResourceID string `json:"resourceID,omitempty"` - // key location - Location string `json:"location,omitempty"` - // old key format - Context map[string]string `json:"context,omitempty"` -} - -// support for pre v0.22 formats -type simpleAccountPre022 struct { - Address string `json:"address"` - Keys string `json:"keys"` -} - -// support for pre v0.22 formats -type advanceAccountPre022 struct { - Address string `json:"address"` - Keys []advanceKey `json:"keys"` -} - -type formatType int - -const ( - simpleFormat formatType = 0 - advancedFormat formatType = 1 - simpleFormatPre022 formatType = 2 // pre v.022 format - advancedFormatPre022 formatType = 3 // pre v.022 format -) - -func decideFormat(b []byte) (formatType, error) { - var raw map[string]any - err := json.Unmarshal(b, &raw) - if err != nil { - return 0, err - } - - if raw["keys"] != nil { - switch raw["keys"].(type) { - case string: - return simpleFormatPre022, nil - default: - return advancedFormatPre022, nil - } - } - - switch raw["key"].(type) { - case string: - return simpleFormat, nil - default: - return advancedFormat, nil - } -} - -func (j *account) UnmarshalJSON(b []byte) error { - - format, err := decideFormat(b) - if err != nil { - return err - } - - switch format { - case simpleFormat: - var simple simpleAccount - err = json.Unmarshal(b, &simple) - j.Simple = simple - - case simpleFormatPre022: - var simpleOld simpleAccountPre022 - err = json.Unmarshal(b, &simpleOld) - j.Simple = simpleAccount{ - Address: simpleOld.Address, - Key: simpleOld.Keys, - } - - case advancedFormatPre022: - var advancedOld advanceAccountPre022 - err = json.Unmarshal(b, &advancedOld) - - j.Advanced = advancedAccount{ - Address: advancedOld.Address, - Key: advancedOld.Keys[0], - } - j.Advanced.Key.PrivateKey = advancedOld.Keys[0].Context["privateKey"] - - case advancedFormat: - var advanced advancedAccount - err = json.Unmarshal(b, &advanced) - j.Advanced = advanced - } - - return err -} - -func (j account) MarshalJSON() ([]byte, error) { - if j.Simple != (simpleAccount{}) { - return json.Marshal(j.Simple) - } - - return json.Marshal(j.Advanced) -} - -func (a account) JSONSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - OneOf: []*jsonschema.Schema{ - { - Ref: "#/$defs/simpleAccount", - }, - { - Ref: "#/$defs/advancedAccount", - }, - { - Ref: "#/$defs/simpleAccountPre022", - }, - { - Ref: "#/$defs/advanceAccountPre022", - }, - }, - Definitions: map[string]*jsonschema.Schema{ - "simpleAccount": jsonschema.Reflect(simpleAccount{}), - "advancedAccount": jsonschema.Reflect(advancedAccount{}), - "simpleAccountPre022": jsonschema.Reflect(simpleAccountPre022{}), - "advanceAccountPre022": jsonschema.Reflect(advanceAccountPre022{}), - }, - } -} diff --git a/flowkit/config/json/account_test.go b/flowkit/config/json/account_test.go deleted file mode 100644 index 0cb836828..000000000 --- a/flowkit/config/json/account_test.go +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package json - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit/config" -) - -func Test_ConfigAccountKeysSimple(t *testing.T) { - b := []byte(`{ - "test": { - "address": "service", - "key": "0x1fae488ce86422698f1c13468b137d62de488e7e978d7090396f7883a60abdcf" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("test") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, "f8d6e0586b0a20c7", account.Address.String()) - assert.Equal(t, "SHA3_256", key.HashAlgo.String()) - assert.Equal(t, 0, key.Index) - assert.Equal(t, "ECDSA_P256", key.SigAlgo.String()) - assert.Equal(t, "0x1fae488ce86422698f1c13468b137d62de488e7e978d7090396f7883a60abdcf", key.PrivateKey.String()) -} - -func Test_ConfigAccountKeysAdvancedHex(t *testing.T) { - b := []byte(`{ - "test": { - "address": "service", - "key": { - "type": "hex", - "index": 1, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA2_256", - "privateKey": "271cec6bb5221d12713759188166bdfa00079db5789c36b54dcf1d794d8d8cdf" - } - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("test") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, "f8d6e0586b0a20c7", account.Address.String()) - assert.Equal(t, "SHA2_256", key.HashAlgo.String()) - assert.Equal(t, 1, key.Index) - assert.Equal(t, "ECDSA_P256", key.SigAlgo.String()) - assert.Equal(t, "0x271cec6bb5221d12713759188166bdfa00079db5789c36b54dcf1d794d8d8cdf", key.PrivateKey.String()) - assert.Equal(t, "", key.ResourceID) -} - -func Test_ConfigAccountKeysAdvancedFile(t *testing.T) { - b := []byte(`{ - "test": { - "address": "service", - "key": { - "type": "file", - "location": "./test.pkey" - } - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("test") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, "f8d6e0586b0a20c7", account.Address.String()) - assert.Equal(t, "SHA3_256", key.HashAlgo.String()) - assert.Equal(t, "ECDSA_P256", key.SigAlgo.String()) - assert.Equal(t, filepath.FromSlash("./test.pkey"), key.Location) - assert.Equal(t, "", key.ResourceID) - - jsonAccs := transformAccountsToJSON(accounts) - assert.Equal(t, "./test.pkey", jsonAccs["test"].Advanced.Key.Location) - assert.Equal(t, "", jsonAccs["test"].Advanced.Key.PrivateKey) -} - -func Test_ConfigAccountKeysAdvancedKMS(t *testing.T) { - b := []byte(`{ - "test": { - "address": "service", - "key": { - "type": "google-kms", - "index": 1, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "resourceID": "projects/flow/locations/us/keyRings/foo/bar/cryptoKeyVersions/1" - } - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("test") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, "f8d6e0586b0a20c7", account.Address.String()) - assert.Equal(t, "SHA3_256", key.HashAlgo.String()) - assert.Equal(t, 1, key.Index) - assert.Equal(t, "ECDSA_P256", key.SigAlgo.String()) - assert.Equal(t, "projects/flow/locations/us/keyRings/foo/bar/cryptoKeyVersions/1", key.ResourceID) - assert.Nil(t, key.PrivateKey) -} - -func Test_ConfigAccountOldFormats(t *testing.T) { - b := []byte(`{ - "old-format-1": { - "address": "service", - "keys": [{ - "type": "hex", - "index": 1, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA2_256", - "context": { - "privateKey": "f988fd7a959d96d0e36ca13a240bbfc4a78098cc56cfd1fa6c918080c8a0f55c" - } - }] - }, - "old-format-2": { - "address": "service", - "keys": "271cec6bb5221d12713759188166bdfa00079db5789c36b54dcf1d794d8d8cdf" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("old-format-1") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, account.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, key.HashAlgo.String(), "SHA2_256") - assert.Equal(t, key.Index, 1) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0xf988fd7a959d96d0e36ca13a240bbfc4a78098cc56cfd1fa6c918080c8a0f55c") - - account, err = accounts.ByName("old-format-2") - assert.NoError(t, err) - key = account.Key - - assert.Equal(t, account.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0x271cec6bb5221d12713759188166bdfa00079db5789c36b54dcf1d794d8d8cdf") -} - -func Test_ConfigMultipleAccountsSimple(t *testing.T) { - b := []byte(`{ - "emulator-account": { - "address": "service", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - }, - "testnet-account": { - "address": "0x2c1162386b0a245f", - "key": "1234567890123456789012345678901234567890123456789012345678901234" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("emulator-account") - assert.NoError(t, err) - - key := account.Key - - assert.Equal(t, account.Name, "emulator-account") - assert.Equal(t, account.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0xdd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - - account, err = accounts.ByName("testnet-account") - assert.NoError(t, err) - key = account.Key - - assert.Equal(t, account.Address.String(), "2c1162386b0a245f") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0x1234567890123456789012345678901234567890123456789012345678901234") -} - -func Test_ConfigMultipleAccountsAdvanced(t *testing.T) { - b := []byte(`{ - "emulator-account": { - "address": "service", - "key": { - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "privateKey": "1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "testnet-account": { - "address": "1c1162386b0a245f", - "key": { - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "privateKey": "2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("emulator-account") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, account.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.NotNil(t, key.PrivateKey) - assert.Equal(t, key.PrivateKey.String(), "0x1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - - account, err = accounts.ByName("testnet-account") - assert.NoError(t, err) - key = account.Key - - assert.Equal(t, account.Address.String(), "1c1162386b0a245f") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.NotNil(t, key.PrivateKey) - assert.Equal(t, key.PrivateKey.String(), "0x2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") -} - -func Test_ConfigMixedAccounts(t *testing.T) { - b := []byte(`{ - "emulator-account": { - "address": "service", - "key": { - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "privateKey": "1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "testnet-account": { - "address": "3c1162386b0a245f", - "key": "2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := accounts.ByName("emulator-account") - assert.NoError(t, err) - key := account.Key - - assert.Equal(t, account.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0x1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - - account, err = accounts.ByName("testnet-account") - assert.NoError(t, err) - key = account.Key - - assert.Equal(t, account.Address.String(), "3c1162386b0a245f") - assert.Equal(t, key.HashAlgo.String(), "SHA3_256") - assert.Equal(t, key.Index, 0) - assert.Equal(t, key.SigAlgo.String(), "ECDSA_P256") - assert.Equal(t, key.PrivateKey.String(), "0x2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") -} - -func Test_ConfigAccountsMap(t *testing.T) { - b := []byte(`{ - "emulator-account": { - "address": "service", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - }, - "testnet-account": { - "address": "3c1162386b0a245f", - "key": "1234567890123456789012345678901234567890123456789012345678901234" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - emulatorAccount, err := accounts.ByName("emulator-account") - assert.NoError(t, err) - assert.Equal(t, emulatorAccount.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, emulatorAccount.Name, "emulator-account") -} - -func Test_ConfigAccountsMapWithEnvVars(t *testing.T) { - - os.Setenv("FLOW_EMULATOR_ADDRESS", "f8d6e0586b0a20c7") - os.Setenv("FLOW_EMULATOR_KEY", "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - - b := []byte(`{ - "emulator-account": { - "address": "$FLOW_EMULATOR_ADDRESS", - "key": "$FLOW_EMULATOR_KEY" - }, - "testnet-account": { - "address": "3c1162386b0a245f", - "key": "1234567890123456789012345678901234567890123456789012345678901234" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - emulatorAccount, err := accounts.ByName("emulator-account") - assert.NoError(t, err) - assert.Equal(t, emulatorAccount.Address.String(), "f8d6e0586b0a20c7") - assert.Equal(t, emulatorAccount.Key.PrivateKey.String(), "0xdd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - assert.Equal(t, emulatorAccount.Name, "emulator-account") -} - -func Test_TransformDefaultAccountToJSON(t *testing.T) { - privateKey, err := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - assert.NoError(t, err) - - account := config.Account{ - Name: "emulator-account", - Address: flow.HexToAddress("f8d6e0586b0a20c7"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: privateKey}, - } - accounts := []config.Account{account} - - j := transformAccountsToJSON(accounts) - result, err := json.Marshal(j) - assert.NoError(t, err) - - expected := []byte(`{"emulator-account":{"address":"f8d6e0586b0a20c7","key":"1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"}}`) - assert.Equal(t, string(expected), string(result)) -} - -func Test_TransformAccountToJSON(t *testing.T) { - b := []byte(`{"emulator-account":{"address":"f8d6e0586b0a20c7","key":{"type":"hex","index":1,"privateKey":"1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"}},"testnet-account":{"address":"3c1162386b0a245f","key":"2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"}}`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - j := transformAccountsToJSON(accounts) - x, _ := json.Marshal(j) - - assert.Equal(t, string(b), string(x)) -} - -func Test_TransformDefaultAccountToJSONAdvanced(t *testing.T) { - b := []byte(`{"emulator-account":{"address":"f8d6e0586b0a20c7","key":"1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"},"testnet-account":{"address":"3c1162386b0a245f","key":"2272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"}}`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - accounts, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - j := transformAccountsToJSON(accounts) - x, _ := json.Marshal(j) - - // our output format is shorted - improve test - assert.Equal(t, string(b), string(x)) -} - -func Test_SupportForOldFormatWithMultipleKeys(t *testing.T) { - b := []byte(`{ - "emulator-account": { - "address": "service", - "chain": "flow-emulator", - "keys": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - }, - "testnet-account": { - "address": "3c1162386b0a245f", - "chain": "testnet", - "keys": [ - { - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "context": { - "privateKey": "1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - },{ - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "context": { - "privateKey": "2332967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b44" - } - } - ] - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - conf, err := jsonAccounts.transformToConfig() - assert.NoError(t, err) - - account, err := conf.ByName("testnet-account") - assert.NoError(t, err) - key := account.Key - assert.Equal(t, key.PrivateKey.String(), "0x1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - - emulatorAccount, err := conf.ByName("emulator-account") - assert.NoError(t, err) - key = emulatorAccount.Key - assert.Equal(t, key.PrivateKey.String(), "0xdd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") -} - -func Test_ConfigInvalidKey(t *testing.T) { - b := []byte(`{ - "test": { - "address": "service", - "key": "z488ce86422698f1c13468b137d62de488e7e978d7090396f7883a60abdcf" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - _, err = jsonAccounts.transformToConfig() - assert.Equal(t, err.Error(), "invalid private key for account: test") -} - -func Test_ConfigInvalidAddress(t *testing.T) { - b := []byte(`{ - "test": { - "address": "zz", - "key": "2332967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b44" - } - }`) - - var jsonAccounts jsonAccounts - err := json.Unmarshal(b, &jsonAccounts) - assert.NoError(t, err) - - _, err = jsonAccounts.transformToConfig() - assert.Equal(t, err.Error(), "could not parse address: zz") -} - -func Test_ReplaceENV(t *testing.T) { - t.Run("Valid ENV set vars", func(t *testing.T) { - os.Setenv("TEST", "foo") - - tests := []string{"$TEST", "${TEST}"} - for _, test := range tests { - replaced, original, err := tryReplaceEnv(test) - assert.NoError(t, err) - assert.Equal(t, "foo", replaced) - assert.Equal(t, test, original) - } - }) - - t.Run("ENV not set", func(t *testing.T) { - _, _, err := tryReplaceEnv("$NOT_SET") - assert.EqualError(t, err, "required environment variable NOT_SET not set") - }) - - t.Run("Should not match", func(t *testing.T) { - tests := []string{"TEST", "${TEST", "$TEST}", "$$$$", "123"} - for i, test := range tests { - replaced, original, err := tryReplaceEnv(test) - assert.NoError(t, err, fmt.Sprintf("test #%d", i)) - assert.Equal(t, "", replaced) - assert.Equal(t, "", original) - } - }) -} diff --git a/flowkit/config/json/config.go b/flowkit/config/json/config.go deleted file mode 100644 index af2f96c8e..000000000 --- a/flowkit/config/json/config.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "fmt" - - "github.com/onflow/flow-cli/flowkit/config" -) - -// jsonConfig implements JSON format for persisting and parsing configuration. -type jsonConfig struct { - Emulators jsonEmulators `json:"emulators,omitempty"` - Contracts jsonContracts `json:"contracts,omitempty"` - Dependencies jsonDependencies `json:"dependencies,omitempty"` - Networks jsonNetworks `json:"networks,omitempty"` - Accounts jsonAccounts `json:"accounts,omitempty"` - Deployments jsonDeployments `json:"deployments,omitempty"` -} - -func (j *jsonConfig) transformToConfig() (*config.Config, error) { - emulators, err := j.Emulators.transformToConfig() - if err != nil { - return nil, err - } - - contracts, err := j.Contracts.transformToConfig() - if err != nil { - return nil, err - } - - dependencies, err := j.Dependencies.transformToConfig() - if err != nil { - return nil, err - } - - networks, err := j.Networks.transformToConfig() - if err != nil { - return nil, err - } - - accounts, err := j.Accounts.transformToConfig() - if err != nil { - return nil, err - } - - deployments, err := j.Deployments.transformToConfig() - if err != nil { - return nil, err - } - - conf := &config.Config{ - Emulators: emulators, - Contracts: contracts, - Dependencies: dependencies, - Networks: networks, - Accounts: accounts, - Deployments: deployments, - } - - // Add dependencies as contracts so they can be used in the project just like any other contract. - for _, dep := range dependencies { - conf.Contracts.AddDependencyAsContract(dep, dep.Source.NetworkName) - } - - return conf, nil -} - -func transformConfigToJSON(config *config.Config) jsonConfig { - return jsonConfig{ - Emulators: transformEmulatorsToJSON(config.Emulators), - Contracts: transformContractsToJSON(config.Contracts), - Dependencies: transformDependenciesToJSON(config.Dependencies, config.Contracts), - Networks: transformNetworksToJSON(config.Networks), - Accounts: transformAccountsToJSON(config.Accounts), - Deployments: transformDeploymentsToJSON(config.Deployments), - } -} - -type oldFormat struct { - Host any `json:"host"` - Accounts any `json:"accounts"` -} - -func oldConfigFormat(raw []byte) bool { - var conf oldFormat - - err := json.Unmarshal(raw, &conf) - if err != nil { // ignore errors in this case - return false - } - - if conf.Host != nil { - return true - } - - return false -} - -// Parser for JSON configuration format. -type Parser struct{} - -// NewParser returns a JSON parser. -func NewParser() *Parser { - return &Parser{} -} - -// Serialize configuration to raw. -func (p *Parser) Serialize(conf *config.Config) ([]byte, error) { - jsonConf := transformConfigToJSON(conf) - data, err := json.MarshalIndent(jsonConf, "", "\t") - if err != nil { - return nil, err - } - - return data, nil -} - -// Deserialize configuration to config structure. -func (p *Parser) Deserialize(raw []byte) (*config.Config, error) { - // check if old format of config and return an error - if oldConfigFormat(raw) { - return nil, config.ErrOutdatedFormat - } - - var jsonConf jsonConfig - err := json.Unmarshal(raw, &jsonConf) - if err != nil { - return nil, fmt.Errorf("configuration syntax error: %w", err) - } - - return jsonConf.transformToConfig() -} - -// SupportsFormat check if the file format is supported. -func (p *Parser) SupportsFormat(extension string) bool { - return extension == ".json" -} diff --git a/flowkit/config/json/config_test.go b/flowkit/config/json/config_test.go deleted file mode 100644 index 011089851..000000000 --- a/flowkit/config/json/config_test.go +++ /dev/null @@ -1,257 +0,0 @@ -/* -* Flow CLI -* -* Copyright 2019 Dapper Labs, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ -package json - -import ( - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit/config" -) - -func keys() []crypto.PrivateKey { - var keys []crypto.PrivateKey - key, _ := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - keys = append(keys, key) - return keys -} - -func Test_SimpleJSONConfig(t *testing.T) { - b := []byte(`{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - }, - "contracts": {}, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "deployments": {} - }`) - - parser := NewParser() - conf, err := parser.Deserialize(b) - - assert.NoError(t, err) - assert.Len(t, conf.Accounts, 1) - assert.Equal(t, "emulator-account", conf.Accounts[0].Name) - assert.Equal(t, "0x11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", conf.Accounts[0].Key.PrivateKey.String()) - network, err := conf.Networks.ByName("emulator") - assert.NoError(t, err) - assert.Equal(t, "127.0.0.1:3569", network.Host) -} - -func Test_NonExistingContractForDeployment(t *testing.T) { - b := []byte(`{ - "contracts": {}, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "deployments": { - "emulator": { - "emulator-account": ["FungibleToken"] - } - } - }`) - - parser := NewParser() - conf, err := parser.Deserialize(b) - assert.NoError(t, err) - - err = conf.Validate() - assert.Equal(t, "deployment contains nonexisting contract FungibleToken", err.Error()) -} - -func Test_NonExistingAccountForDeployment(t *testing.T) { - b := []byte(`{ - "contracts": { - "FungibleToken": "./test.cdc" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "deployments": { - "emulator": { - "test-1": ["FungibleToken"] - } - } - }`) - - parser := NewParser() - conf, err := parser.Deserialize(b) - assert.NoError(t, err) - - err = conf.Validate() - assert.Equal(t, "deployment contains nonexisting account test-1", err.Error()) -} - -func Test_NonExistingNetworkForDeployment(t *testing.T) { - b := []byte(`{ - "contracts": { - "FungibleToken": "./test.cdc" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "networks": {}, - "deployments": { - "foo": { - "test-1": ["FungibleToken"] - } - } - }`) - - parser := NewParser() - conf, err := parser.Deserialize(b) - assert.NoError(t, err) - - err = conf.Validate() - assert.Equal(t, "deployment contains nonexisting network foo", err.Error()) -} - -func Test_NonExistingAccountForEmulator(t *testing.T) { - b := []byte(`{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - } - }`) - - parser := NewParser() - conf, err := parser.Deserialize(b) - assert.NoError(t, err) - - err = conf.Validate() - assert.Equal(t, "emulator default contains nonexisting service account emulator-account", err.Error()) -} - -// If config has default emulator values, it will not show up in flow.json -func Test_SerializeConfigToJsonEmulatorDefault(t *testing.T) { - configJson := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - } - }`) - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 3569, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{}, - Deployments: config.Deployments{}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - parser := NewParser() - conf, _ := parser.Serialize(&cfg) - assert.JSONEq(t, string(configJson), string(conf)) -} - -func Test_SerializeConfigToJsonEmulatorNotDefault(t *testing.T) { - configJson := []byte(`{ - "emulators": { - "default": { - "port": 6000, - "serviceAccount": "emulator-account" - } - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - } - }`) - config := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 6000, - ServiceAccount: "emulator-account", - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - parser := NewParser() - conf, _ := parser.Serialize(&config) - assert.JSONEq(t, string(configJson), string(conf)) - -} diff --git a/flowkit/config/json/contract.go b/flowkit/config/json/contract.go deleted file mode 100644 index 0cc90a160..000000000 --- a/flowkit/config/json/contract.go +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "fmt" - "path/filepath" - - "github.com/invopop/jsonschema" - "github.com/onflow/flow-go-sdk" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonContracts map[string]jsonContract - -// transformToConfig transforms json structures to config structure. -func (j jsonContracts) transformToConfig() (config.Contracts, error) { - contracts := make(config.Contracts, 0) - - for contractName, c := range j { - if c.Simple != "" { - contract := config.Contract{ - Name: contractName, - Location: c.Simple, - } - - contracts = append(contracts, contract) - } else { - contract := config.Contract{ - Name: contractName, - Location: c.Advanced.Source, - } - for network, alias := range c.Advanced.Aliases { - address := flow.HexToAddress(alias) - if address == flow.EmptyAddress { - return nil, fmt.Errorf("invalid alias address for a contract") - } - - contract.Aliases.Add(network, address) - } - contracts = append(contracts, contract) - } - } - - return contracts, nil -} - -// transformToJSON transforms config structure to json structures for saving. -func transformContractsToJSON(contracts config.Contracts) jsonContracts { - jsonContracts := jsonContracts{} - - for _, c := range contracts { - // If it's a dependency, skip. These are used under the hood and should not be saved. - if c.IsDependency { - continue - } - - // if simple case - if !c.IsAliased() { - jsonContracts[c.Name] = jsonContract{ - Simple: filepath.ToSlash(c.Location), - } - } else { // if advanced config - // check if we already created for this name then add or create - aliases := make(map[string]string) - for _, alias := range c.Aliases { - aliases[alias.Network] = alias.Address.String() - } - - jsonContracts[c.Name] = jsonContract{ - Advanced: jsonContractAdvanced{ - Source: filepath.ToSlash(c.Location), - Aliases: aliases, - }, - } - } - } - - return jsonContracts -} - -// jsonContractAdvanced for json parsing advanced config. -type jsonContractAdvanced struct { - Source string `json:"source"` - Aliases map[string]string `json:"aliases"` -} - -// jsonContract structure for json parsing. -type jsonContract struct { - Simple string - Advanced jsonContractAdvanced -} - -func (j *jsonContract) UnmarshalJSON(b []byte) error { - var source string - var advancedFormat jsonContractAdvanced - - // simple - err := json.Unmarshal(b, &source) - if err == nil { - j.Simple = filepath.FromSlash(source) - return nil - } - - // advanced - err = json.Unmarshal(b, &advancedFormat) - if err == nil { - j.Advanced = advancedFormat - j.Advanced.Source = filepath.FromSlash(j.Advanced.Source) - } else { - return err - } - - return nil -} - -func (j jsonContract) MarshalJSON() ([]byte, error) { - if j.Simple != "" { - return json.Marshal(j.Simple) - } else { - return json.Marshal(j.Advanced) - } -} - -func (j jsonContract) JSONSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - OneOf: []*jsonschema.Schema{ - { - Type: "string", - }, - { - Ref: "#/$defs/jsonContractAdvanced", - }, - }, - Definitions: map[string]*jsonschema.Schema{ - "jsonContractAdvanced": jsonschema.Reflect(jsonContractAdvanced{}), - }, - } -} diff --git a/flowkit/config/json/contract_test.go b/flowkit/config/json/contract_test.go deleted file mode 100644 index bd9ab0800..000000000 --- a/flowkit/config/json/contract_test.go +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package json - -import ( - "encoding/json" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_ConfigContractsSimple(t *testing.T) { - b := []byte(`{ - "KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc", - "KittyItemsMarket": "./cadence/kittyItems/contracts/KittyItemsMarket.cdc" - }`) - - var jsonContracts jsonContracts - err := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - assert.NoError(t, err) - - contract, _ := contracts.ByName("KittyItems") - assert.NotNil(t, contract) - - marketContract, _ := contracts.ByName("KittyItemsMarket") - assert.NotNil(t, marketContract) - - assert.Equal(t, filepath.FromSlash("./cadence/kittyItems/contracts/KittyItems.cdc"), contract.Location) - assert.Equal(t, filepath.FromSlash("./cadence/kittyItems/contracts/KittyItemsMarket.cdc"), marketContract.Location) -} - -func Test_ConfigContractsComplex(t *testing.T) { - b := []byte(`{ - "KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc", - "KittyItemsMarket": { - "source": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", - "aliases": { - "testnet": "f8d6e0586b0a20c7" - } - } - }`) - - var jsonContracts jsonContracts - err := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - assert.NoError(t, err) - - assert.Len(t, contracts, 2) - - kittyItems, _ := contracts.ByName("KittyItems") - assert.NotNil(t, kittyItems) - - kittyItemsMarket, _ := contracts.ByName("KittyItemsMarket") - assert.NotNil(t, kittyItemsMarket) - - assert.Equal(t, filepath.FromSlash("./cadence/kittyItems/contracts/KittyItems.cdc"), kittyItems.Location) - assert.Equal(t, filepath.FromSlash("./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc"), kittyItemsMarket.Location) - - assert.True(t, kittyItemsMarket.Aliases.ByNetwork("emulator") == nil) - - assert.True(t, kittyItemsMarket.IsAliased()) - assert.True(t, kittyItemsMarket.Aliases.ByNetwork("emulator") == nil) - assert.Equal(t, "f8d6e0586b0a20c7", kittyItemsMarket.Aliases.ByNetwork("testnet").Address.String()) - - assert.False(t, kittyItems.IsAliased()) - assert.True(t, kittyItems.Aliases.ByNetwork("emulator") == nil) -} - -func Test_ConfigContractsAliases(t *testing.T) { - b := []byte(`{ - "NonFungibleToken": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - "Kibble": { - "source": "../hungry-kitties/cadence/contracts/Kibble.cdc", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "testnet": "ead892083b3e2c6c" - } - }, - "FungibleToken": { - "source": "../hungry-kitties/cadence/contracts/FungibleToken.cdc", - "aliases": { - "emulator": "e5a8b7f23e8b548f" - } - } - }`) - - var jsonContracts jsonContracts - err := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - assert.NoError(t, err) - - fungibleToken, _ := contracts.ByName("FungibleToken") - assert.NotNil(t, fungibleToken) - assert.True(t, fungibleToken.IsAliased()) - assert.Equal(t, "e5a8b7f23e8b548f", fungibleToken.Aliases.ByNetwork("emulator").Address.String()) - assert.Equal(t, filepath.FromSlash("../hungry-kitties/cadence/contracts/FungibleToken.cdc"), fungibleToken.Location) - - kibble, _ := contracts.ByName("Kibble") - assert.NotNil(t, kibble) - assert.True(t, kibble.IsAliased()) - assert.Equal(t, filepath.FromSlash("../hungry-kitties/cadence/contracts/Kibble.cdc"), kibble.Location) - assert.Equal(t, "ead892083b3e2c6c", kibble.Aliases.ByNetwork("testnet").Address.String()) - assert.Equal(t, "f8d6e0586b0a20c7", kibble.Aliases.ByNetwork("emulator").Address.String()) - - nft, _ := contracts.ByName("NonFungibleToken") - assert.NotNil(t, nft) - assert.False(t, nft.IsAliased()) - assert.Equal(t, nft.Location, filepath.FromSlash("../hungry-kitties/cadence/contracts/NonFungibleToken.cdc")) -} - -func Test_TransformContractToJSON(t *testing.T) { - b := []byte(`{ - "KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc", - "KittyItemsMarket": { - "source": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", - "aliases": { - "testnet":"e5a8b7f23e8b548f" - } - } - }`) - - var jsonContracts jsonContracts - err := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - assert.NoError(t, err) - - j := transformContractsToJSON(contracts) - x, _ := json.Marshal(j) - - assert.JSONEq(t, string(b), string(x)) -} - -func Test_TransformComplexContractToJSON(t *testing.T) { - b := []byte(`{ - "KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc", - "KittyItemsMarket": { - "source": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", - "aliases": { - "testnet":"e5a8b7f23e8b548f" - } - }, - "Kibble": { - "source": "./cadence/kittyItems/contracts/KittyItems.cdc", - "aliases": { - "testnet": "e5a8b7f23e8b548f", - "emulator": "f8d6e0586b0a20c7" - } - } - }`) - - var jsonContracts jsonContracts - err := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - assert.NoError(t, err) - - j := transformContractsToJSON(contracts) - x, _ := json.Marshal(j) - - assert.JSONEq(t, string(b), string(x)) -} diff --git a/flowkit/config/json/dependency.go b/flowkit/config/json/dependency.go deleted file mode 100644 index d724ff6a5..000000000 --- a/flowkit/config/json/dependency.go +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "fmt" - "strings" - - "github.com/invopop/jsonschema" - - "github.com/onflow/flow-go-sdk" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonDependencies map[string]jsonDependency - -func (j jsonDependencies) transformToConfig() (config.Dependencies, error) { - deps := make(config.Dependencies, 0) - - for dependencyName, dependency := range j { - var dep config.Dependency - - if dependency.Simple != "" { - depNetwork, depAddress, depContractName, err := config.ParseSourceString(dependency.Simple) - if err != nil { - return nil, fmt.Errorf("error parsing source for dependency %s: %w", dependencyName, err) - } - - dep = config.Dependency{ - Name: dependencyName, - Source: config.Source{ - NetworkName: depNetwork, - Address: flow.HexToAddress(depAddress), - ContractName: depContractName, - }, - } - } else { - depNetwork, depAddress, depContractName, err := config.ParseSourceString(dependency.Extended.Source) - if err != nil { - return nil, fmt.Errorf("error parsing source for dependency %s: %w", dependencyName, err) - } - - dep = config.Dependency{ - Name: dependencyName, - Hash: dependency.Extended.Hash, - Source: config.Source{ - NetworkName: depNetwork, - Address: flow.HexToAddress(depAddress), - ContractName: depContractName, - }, - } - - for network, alias := range dependency.Extended.Aliases { - address := flow.HexToAddress(alias) - if address == flow.EmptyAddress { - return nil, fmt.Errorf("invalid alias address for a contract") - } - - dep.Aliases.Add(network, address) - } - } - - deps = append(deps, dep) - } - - return deps, nil -} - -func transformDependenciesToJSON(configDependencies config.Dependencies, configContracts config.Contracts) jsonDependencies { - jsonDeps := jsonDependencies{} - - for _, dep := range configDependencies { - aliases := make(map[string]string) - - depContract := configContracts.DependencyContractByName(dep.Name) - if depContract != nil { - for _, alias := range depContract.Aliases { - aliases[alias.Network] = alias.Address.String() - } - } - - jsonDeps[dep.Name] = jsonDependency{ - Extended: jsonDependencyExtended{ - Source: buildSourceString(dep.Source), - Hash: dep.Hash, - Aliases: aliases, - }, - } - } - - return jsonDeps -} - -func buildSourceString(source config.Source) string { - var builder strings.Builder - - builder.WriteString(source.NetworkName) - builder.WriteString("://") - builder.WriteString(source.Address.String()) - builder.WriteString(".") - builder.WriteString(source.ContractName) - - return builder.String() -} - -// jsonDependencyExtended for json parsing advanced config. -type jsonDependencyExtended struct { - Source string `json:"source"` - Hash string `json:"hash"` - Aliases map[string]string `json:"aliases"` -} - -// jsonDependency structure for json parsing. -type jsonDependency struct { - Simple string - Extended jsonDependencyExtended -} - -func (j *jsonDependency) UnmarshalJSON(b []byte) error { - var source string - var extendedFormat jsonDependencyExtended - - // simple - err := json.Unmarshal(b, &source) - if err == nil { - j.Simple = source - return nil - } - - // advanced - err = json.Unmarshal(b, &extendedFormat) - if err == nil { - j.Extended = extendedFormat - } else { - return err - } - - return nil -} - -func (j jsonDependency) MarshalJSON() ([]byte, error) { - if j.Simple != "" { - return json.Marshal(j.Simple) - } else { - return json.Marshal(j.Extended) - } -} - -func (j jsonDependency) JSONSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - OneOf: []*jsonschema.Schema{ - { - Type: "string", - }, - { - Ref: "#/$defs/jsonDependencyExtended", - }, - }, - Definitions: map[string]*jsonschema.Schema{ - "jsonDependencyExtended": jsonschema.Reflect(jsonDependencyExtended{}), - }, - } -} diff --git a/flowkit/config/json/dependency_test.go b/flowkit/config/json/dependency_test.go deleted file mode 100644 index 3467b130c..000000000 --- a/flowkit/config/json/dependency_test.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_ConfigDependencies(t *testing.T) { - b := []byte(`{ - "HelloWorld": "testnet://877931736ee77cff.HelloWorld" - }`) - - var jsonDependencies jsonDependencies - err := json.Unmarshal(b, &jsonDependencies) - assert.NoError(t, err) - - dependencies, err := jsonDependencies.transformToConfig() - assert.NoError(t, err) - - assert.Len(t, dependencies, 1) - - dependencyOne := dependencies.ByName("HelloWorld") - assert.NotNil(t, dependencyOne) - - assert.NotNil(t, dependencyOne) -} - -func Test_TransformDependenciesToJSON(t *testing.T) { - b := []byte(`{ - "HelloWorld": "testnet://877931736ee77cff.HelloWorld" - }`) - - bOut := []byte(`{ - "HelloWorld": { - "source": "testnet://877931736ee77cff.HelloWorld", - "hash": "", - "aliases": {} - } - }`) - - var jsonContracts jsonContracts - errContracts := json.Unmarshal(b, &jsonContracts) - assert.NoError(t, errContracts) - - var jsonDependencies jsonDependencies - err := json.Unmarshal(b, &jsonDependencies) - assert.NoError(t, err) - - contracts, err := jsonContracts.transformToConfig() - dependencies, err := jsonDependencies.transformToConfig() - assert.NoError(t, err) - - j := transformDependenciesToJSON(dependencies, contracts) - x, _ := json.Marshal(j) - - assert.Equal(t, cleanSpecialChars(bOut), cleanSpecialChars(x)) -} diff --git a/flowkit/config/json/deploy.go b/flowkit/config/json/deploy.go deleted file mode 100644 index 9e21270f3..000000000 --- a/flowkit/config/json/deploy.go +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/json" - "fmt" - - "github.com/invopop/jsonschema" - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonDeployments map[string]jsonDeployment - -// transformToConfig transforms json structures to config structure. -func (j jsonDeployments) transformToConfig() (config.Deployments, error) { - deployments := make(config.Deployments, 0) - - for networkName, deploys := range j { - - var deploy config.Deployment - for accountName, contracts := range deploys { - deploy = config.Deployment{ - Network: networkName, - Account: accountName, - } - - var contractDeploys []config.ContractDeployment - for _, contract := range contracts { - if contract.simple != "" { - contractDeploys = append( - contractDeploys, - config.ContractDeployment{ - Name: contract.simple, - Args: nil, - }, - ) - } else { - args := make([]cadence.Value, 0) - for _, arg := range contract.advanced.Args { - b, err := json.Marshal(arg) - if err != nil { - return nil, err - } - - cadenceArg, err := jsoncdc.Decode(nil, b) - if err != nil { - return nil, err - } - - args = append(args, cadenceArg) - } - - contractDeploys = append( - contractDeploys, - config.ContractDeployment{ - Name: contract.advanced.Name, - Args: args, - }, - ) - } - } - - deploy.Contracts = contractDeploys - deployments = append(deployments, deploy) - } - } - - return deployments, nil -} - -// transformToJSON transforms config structure to json structures for saving. -func transformDeploymentsToJSON(configDeployments config.Deployments) jsonDeployments { - jsonDeploys := jsonDeployments{} - - for _, d := range configDeployments { - - deployments := make([]deployment, 0) - for _, c := range d.Contracts { - if len(c.Args) == 0 { - deployments = append(deployments, deployment{ - simple: c.Name, - }) - } else { - args := make([]map[string]any, 0) - for _, arg := range c.Args { - switch arg.Type().ID() { - case "Bool": - args = append(args, map[string]any{ - "type": arg.Type().ID(), - "value": arg.ToGoValue(), - }) - default: - args = append(args, map[string]any{ - "type": arg.Type().ID(), - "value": fmt.Sprintf("%v", arg.ToGoValue()), - }) - } - } - - deployments = append(deployments, deployment{ - advanced: contractDeployment{ - Name: c.Name, - Args: args, - }, - }) - } - } - - if _, ok := jsonDeploys[d.Network]; ok { - jsonDeploys[d.Network][d.Account] = deployments - } else { - jsonDeploys[d.Network] = jsonDeployment{ - d.Account: deployments, - } - } - - } - - return jsonDeploys -} - -type contractDeployment struct { - Name string `json:"name"` - Args []map[string]any `json:"args"` -} - -type deployment struct { - simple string - advanced contractDeployment -} - -type jsonDeployment map[string][]deployment - -func (d *deployment) UnmarshalJSON(b []byte) error { - - // simple format - var simple string - err := json.Unmarshal(b, &simple) - if err == nil { - d.simple = simple - return nil - } - - // advanced format - var advanced contractDeployment - err = json.Unmarshal(b, &advanced) - if err == nil { - d.advanced = advanced - } else { - return err - } - - return nil -} - -func (d deployment) MarshalJSON() ([]byte, error) { - if d.simple != "" { - return json.Marshal(d.simple) - } else { - return json.Marshal(d.advanced) - } -} - -func (j deployment) JSONSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - OneOf: []*jsonschema.Schema{ - { - Type: "string", - }, - { - Ref: "#/$defs/contractDeployment", - }, - }, - Definitions: map[string]*jsonschema.Schema{ - "contractDeployment": jsonschema.Reflect(contractDeployment{}), - }, - } -} diff --git a/flowkit/config/json/deploy_test.go b/flowkit/config/json/deploy_test.go deleted file mode 100644 index 41b0c8805..000000000 --- a/flowkit/config/json/deploy_test.go +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package json - -import ( - "encoding/json" - "regexp" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func cleanSpecialChars(code []byte) string { - space := regexp.MustCompile(`\s+`) - return strings.ReplaceAll(space.ReplaceAllString(string(code), " "), " ", "") -} - -func Test_ConfigDeploymentsSimple(t *testing.T) { - b := []byte(`{ - "testnet": { - "account-1": ["FungibleToken", "NonFungibleToken", "Kibble", "KittyItems"] - }, - "emulator": { - "account-2": ["KittyItems", "KittyItemsMarket"], - "account-3": ["FungibleToken", "NonFungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"] - } - }`) - - var jsonDeployments jsonDeployments - err := json.Unmarshal(b, &jsonDeployments) - assert.NoError(t, err) - - deployments, err := jsonDeployments.transformToConfig() - assert.NoError(t, err) - - const account1Name = "account-1" - const account2Name = "account-2" - const account3Name = "account-3" - - assert.Len(t, deployments.ByNetwork("testnet"), 1) - assert.Len(t, deployments.ByNetwork("emulator"), 2) - - account1Deployment := deployments.ByAccountAndNetwork(account1Name, "testnet") - account2Deployment := deployments.ByAccountAndNetwork(account2Name, "emulator") - account3Deployment := deployments.ByAccountAndNetwork(account3Name, "emulator") - - require.NotNil(t, account1Deployment) - require.NotNil(t, account2Deployment) - require.NotNil(t, account3Deployment) - - assert.Equal(t, account1Name, account1Deployment.Account) - assert.Equal(t, account2Name, account2Deployment.Account) - assert.Equal(t, account3Name, account3Deployment.Account) - - assert.Len(t, account1Deployment.Contracts, 4) - - for i, name := range []string{"FungibleToken", "NonFungibleToken", "Kibble", "KittyItems"} { - assert.Equal(t, account1Deployment.Contracts[i].Name, name) - } - - for i, name := range []string{"KittyItems", "KittyItemsMarket"} { - assert.Equal(t, account2Deployment.Contracts[i].Name, name) - } - - for i, name := range []string{"FungibleToken", "NonFungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"} { - assert.Equal(t, account3Deployment.Contracts[i].Name, name) - } - -} - -func Test_TransformDeployToJSON(t *testing.T) { - b := []byte(`{ - "emulator":{ - "account-3":["KittyItems", { - "name": "Kibble", - "args": [ - { "type": "String", "value": "Hello World" }, - { "type": "Int8", "value": "10" } - ] - }], - "account-4":["FungibleToken","NonFungibleToken","Kibble","KittyItems","KittyItemsMarket"] - }, - "testnet":{ - "account-2":["FungibleToken","NonFungibleToken","Kibble","KittyItems"] - } - }`) - - var jsonDeployments jsonDeployments - err := json.Unmarshal(b, &jsonDeployments) - assert.NoError(t, err) - - deployments, err := jsonDeployments.transformToConfig() - assert.NoError(t, err) - - j := transformDeploymentsToJSON(deployments) - x, _ := json.Marshal(j) - - assert.Equal(t, cleanSpecialChars(b), cleanSpecialChars(x)) -} - -func Test_DeploymentAdvanced(t *testing.T) { - b := []byte(`{ - "emulator": { - "alice": [ - { - "name": "Kibble", - "args": [ - { "type": "String", "value": "Hello World" }, - { "type": "Int8", "value": "10" }, - { "type": "Bool", "value": false } - ] - }, - "KittyItemsMarket" - ] - } - }`) - - var jsonDeployments jsonDeployments - err := json.Unmarshal(b, &jsonDeployments) - assert.NoError(t, err) - - deployments, err := jsonDeployments.transformToConfig() - assert.NoError(t, err) - - alice := deployments.ByAccountAndNetwork("alice", "emulator") - assert.NotNil(t, alice) - assert.Len(t, alice.Contracts, 2) - assert.Equal(t, "Kibble", alice.Contracts[0].Name) - assert.Len(t, alice.Contracts[0].Args, 3) - assert.Equal(t, `"Hello World"`, alice.Contracts[0].Args[0].String()) - assert.Equal(t, "10", alice.Contracts[0].Args[1].String()) - assert.Equal(t, "Bool", alice.Contracts[0].Args[2].Type().ID()) - assert.False(t, alice.Contracts[0].Args[2].ToGoValue().(bool)) - assert.Equal(t, "KittyItemsMarket", alice.Contracts[1].Name) - assert.Len(t, alice.Contracts[1].Args, 0) -} diff --git a/flowkit/config/json/emulator.go b/flowkit/config/json/emulator.go deleted file mode 100644 index c03836c4b..000000000 --- a/flowkit/config/json/emulator.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "fmt" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonEmulators map[string]jsonEmulator - -// transformToConfig transforms json structures to config structure. -func (j jsonEmulators) transformToConfig() (config.Emulators, error) { - emulators := make(config.Emulators, 0) - - for name, e := range j { - if e.Port < 0 || e.Port > 65535 { - return nil, fmt.Errorf("invalid port value") - } - - emulator := config.Emulator{ - Name: name, - Port: e.Port, - ServiceAccount: e.ServiceAccount, - } - - emulators = append(emulators, emulator) - } - - return emulators, nil -} - -// transformToJSON transforms config structure to json structures for saving. -func transformEmulatorsToJSON(emulators config.Emulators) jsonEmulators { - jsonEmulators := jsonEmulators{} - - for _, e := range emulators { - if e == config.DefaultEmulator { - continue - } - jsonEmulators[e.Name] = jsonEmulator{ - Port: e.Port, - ServiceAccount: e.ServiceAccount, - } - } - - return jsonEmulators -} - -type jsonEmulator struct { - Port int `json:"port"` - ServiceAccount string `json:"serviceAccount"` -} diff --git a/flowkit/config/json/emulator_test.go b/flowkit/config/json/emulator_test.go deleted file mode 100644 index cf4eef268..000000000 --- a/flowkit/config/json/emulator_test.go +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package json - -import ( - "encoding/json" - "sort" - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_ConfigEmulatorSimple(t *testing.T) { - b := []byte(`{ - "default": { - "port": 9000, - "serviceAccount": "emulator-account" - } - }`) - - var jsonEmulators jsonEmulators - err := json.Unmarshal(b, &jsonEmulators) - assert.NoError(t, err) - - emulators, err := jsonEmulators.transformToConfig() - assert.NoError(t, err) - - assert.Equal(t, "default", emulators[0].Name) - assert.Equal(t, 9000, emulators[0].Port) -} - -func Test_ConfigMultipleEmulators(t *testing.T) { - b := []byte(`{ - "default": { - "port": 9000, - "serviceAccount": "emulator-account" - }, - "custom-emulator": { - "port": 3000, - "serviceAccount": "custom-emulator-account" - } - }`) - - var jsonEmulators jsonEmulators - err := json.Unmarshal(b, &jsonEmulators) - assert.NoError(t, err) - - emulators, err := jsonEmulators.transformToConfig() - assert.NoError(t, err) - assert.Len(t, emulators, 2) - - sort.Slice(emulators, func(i, j int) bool { - return emulators[i].Port > emulators[j].Port - }) - assert.Equal(t, emulators[0].Name, "default") - assert.Equal(t, emulators[0].Port, 9000) - assert.Equal(t, emulators[0].ServiceAccount, "emulator-account") - assert.Equal(t, emulators[1].Name, "custom-emulator") - assert.Equal(t, emulators[1].Port, 3000) - assert.Equal(t, emulators[1].ServiceAccount, "custom-emulator-account") -} diff --git a/flowkit/config/json/network.go b/flowkit/config/json/network.go deleted file mode 100644 index 4654c1558..000000000 --- a/flowkit/config/json/network.go +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package json - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "strings" - - "github.com/invopop/jsonschema" - "github.com/onflow/flow-go-sdk/crypto" - - "github.com/onflow/flow-cli/flowkit/config" -) - -type jsonNetworks map[string]jsonNetwork - -// transformToConfig transforms json structures to config structure. -func (j jsonNetworks) transformToConfig() (config.Networks, error) { - networks := make(config.Networks, 0) - - for networkName, n := range j { - if n.Advanced.Key != "" && n.Advanced.Host != "" { - err := validateECDSAP256Pub(n.Advanced.Key) - if err != nil { - return nil, fmt.Errorf("invalid key %s for network with name %s", n.Advanced.Key, networkName) - } - - networks = append(networks, config.Network{ - Name: networkName, - Host: n.Advanced.Host, - Key: n.Advanced.Key, - }) - } else if n.Simple.Host != "" { - networks = append(networks, config.Network{ - Name: networkName, - Host: n.Simple.Host, - }) - } else { - return nil, fmt.Errorf("failed to transform networks configuration") - } - } - - return networks, nil -} - -// transformNetworksToJSON transforms config structure to json structures for saving. -func transformNetworksToJSON(networks config.Networks) jsonNetworks { - jsonNetworks := jsonNetworks{} - - for _, n := range networks { - if n.Key != "" { - jsonNetworks[n.Name] = transformAdvancedNetworkToJSON(n) - } else { - jsonNetworks[n.Name] = transformSimpleNetworkToJSON(n) - } - } - - return jsonNetworks -} - -func transformSimpleNetworkToJSON(n config.Network) jsonNetwork { - return jsonNetwork{ - Simple: simpleNetwork{ - Host: n.Host, - }, - } -} - -func transformAdvancedNetworkToJSON(n config.Network) jsonNetwork { - return jsonNetwork{ - Advanced: advancedNetwork{ - Host: n.Host, - Key: n.Key, - }, - } -} - -type jsonNetwork struct { - Simple simpleNetwork - Advanced advancedNetwork -} - -type simpleNetwork struct { - Host string `json:"host"` -} - -type advancedNetwork struct { - Host string `json:"host"` - Key string `json:"key"` -} - -func (j *jsonNetwork) UnmarshalJSON(b []byte) error { - var host string - err := json.Unmarshal(b, &host) - if err == nil { - j.Simple.Host = host - return nil - } - - // ignore advanced schema from previous configuration format - var advanced advancedNetwork - err = json.Unmarshal(b, &advanced) - if err == nil { - j.Advanced.Host = advanced.Host - j.Advanced.Key = advanced.Key - } - - return err -} - -func (j jsonNetwork) MarshalJSON() ([]byte, error) { - if j.Simple != (simpleNetwork{}) { - return json.Marshal(j.Simple.Host) - } - - return json.Marshal(j.Advanced) -} - -// validateECDSAP256Pub attempt to decode the hex string representation of a ECDSA P256 public key -func validateECDSAP256Pub(key string) error { - b, err := hex.DecodeString(strings.TrimPrefix(key, "0x")) - if err != nil { - return fmt.Errorf("failed to decode public key hex string: %w", err) - } - - _, err = crypto.DecodePublicKey(crypto.ECDSA_P256, b) - if err != nil { - return fmt.Errorf("failed to decode public key: %w", err) - } - - return nil -} - -func (j jsonNetwork) JSONSchema() *jsonschema.Schema { - return &jsonschema.Schema{ - OneOf: []*jsonschema.Schema{ - { - Ref: "#/$defs/simpleNetwork", - }, - { - Ref: "#/$defs/advancedNetwork", - }, - }, - Definitions: map[string]*jsonschema.Schema{ - "simpleNetwork": { - Type: "string", - }, - "advancedNetwork": jsonschema.Reflect(advancedNetwork{}), - }, - } -} diff --git a/flowkit/config/json/network_test.go b/flowkit/config/json/network_test.go deleted file mode 100644 index 6cd24c681..000000000 --- a/flowkit/config/json/network_test.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package json - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_ConfigNetworkSimple(t *testing.T) { - b := []byte(`{ - "testnet": "access.testnet.nodes.onflow.org:9000" - }`) - - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - networks, err := jsonNetworks.transformToConfig() - assert.NoError(t, err) - - network, err := networks.ByName("testnet") - assert.NoError(t, err) - assert.Equal(t, "access.testnet.nodes.onflow.org:9000", network.Host) - assert.Equal(t, "testnet", network.Name) -} - -func Test_ConfigNetworkMultiple(t *testing.T) { - b := []byte(`{ - "emulator": "127.0.0.1:3569", - "testnet": { - "host": "access.testnet.nodes.onflow.org:9000", - "key": "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd" - } - }`) - - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - networks, err := jsonNetworks.transformToConfig() - assert.NoError(t, err) - - network, err := networks.ByName("testnet") - assert.NoError(t, err) - assert.Equal(t, "access.testnet.nodes.onflow.org:9000", network.Host) - assert.Equal(t, "testnet", network.Name) - assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", network.Key) - - emulator, err := networks.ByName("emulator") - assert.NoError(t, err) - assert.Equal(t, "emulator", emulator.Name) - assert.Equal(t, "127.0.0.1:3569", emulator.Host) -} - -func Test_TransformNetworkToJSON(t *testing.T) { - b := []byte(`{"emulator":"127.0.0.1:3569","testnet":{"host":"access.testnet.nodes.onflow.org:9000","key":"5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd"}}`) - - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - networks, err := jsonNetworks.transformToConfig() - assert.NoError(t, err) - - j := transformNetworksToJSON(networks) - x, _ := json.Marshal(j) - - assert.Equal(t, string(b), string(x)) -} - -func Test_IgnoreOldFormat(t *testing.T) { - b := []byte(`{"emulator":"127.0.0.1:3569","testnet":{"host":"access.testnet.nodes.onflow.org:9000","key":"5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd"},"mainnet":{"host": "access.mainnet.nodes.onflow.org:9000","chain":"flow-mainnet","key":"5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd"}}`) - - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - conf, err := jsonNetworks.transformToConfig() - assert.NoError(t, err) - - assert.Len(t, jsonNetworks, 3) - - testnet, err := conf.ByName("testnet") - assert.NoError(t, err) - - mainnet, err := conf.ByName("mainnet") - assert.NoError(t, err) - - assert.Equal(t, "access.testnet.nodes.onflow.org:9000", testnet.Host) - assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", testnet.Key) - assert.Equal(t, "access.mainnet.nodes.onflow.org:9000", mainnet.Host) - assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", mainnet.Key) -} - -func Test_TransformConfigAdvanced(t *testing.T) { - t.Run("should returned advanced config with no errors", func(t *testing.T) { - b := []byte(`{"testnet":{"host":"access.testnet.nodes.onflow.org:9000", "key": "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd"}}`) - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - conf, err := jsonNetworks.transformToConfig() - assert.NoError(t, err) - - testnet, err := conf.ByName("testnet") - assert.NoError(t, err) - assert.Equal(t, "access.testnet.nodes.onflow.org:9000", testnet.Host) - assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", testnet.Key) - }) - t.Run("should return error if advanced config does not have key", func(t *testing.T) { - b := []byte(`{"testnet":{"host":"access.testnet.nodes.onflow.org:9000"}}`) - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - _, err = jsonNetworks.transformToConfig() - assert.Error(t, err) - }) - t.Run("should return error if advanced config does not have host", func(t *testing.T) { - b := []byte(`{"testnet":{"key": "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd"}}`) - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - _, err = jsonNetworks.transformToConfig() - assert.Error(t, err) - }) - t.Run("should return error if advanced config provides invalid network key", func(t *testing.T) { - b := []byte(`{"testnet":{"host":"access.testnet.nodes.onflow.org:9000","key": "0xpublickey"}}`) - var jsonNetworks jsonNetworks - err := json.Unmarshal(b, &jsonNetworks) - assert.NoError(t, err) - - _, err = jsonNetworks.transformToConfig() - assert.Error(t, err) - }) -} diff --git a/flowkit/config/json/schema.go b/flowkit/config/json/schema.go deleted file mode 100644 index 6aaa6be09..000000000 --- a/flowkit/config/json/schema.go +++ /dev/null @@ -1,44 +0,0 @@ -package json - -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import ( - "github.com/invopop/jsonschema" -) - -func GenerateSchema() *jsonschema.Schema { - schema := jsonschema.Reflect(jsonConfig{}) - - // Recursively move all definitions to the root of the schema - // This is necessary because the jsonschema library does not support - // definitions in nested schemas and is a workaround - var moveDefinitions func(*jsonschema.Schema) - moveDefinitions = func(s *jsonschema.Schema) { - for k, v := range s.Definitions { - schema.Definitions[k] = v - moveDefinitions(v) - } - if s != schema { - s.Definitions = nil - } - } - moveDefinitions(schema) - - return schema -} diff --git a/flowkit/config/loader.go b/flowkit/config/loader.go deleted file mode 100644 index 6e1176bee..000000000 --- a/flowkit/config/loader.go +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "errors" - "fmt" - "os" - "path/filepath" -) - -// ErrDoesNotExist is error to be returned when config file does not exists. -var ErrDoesNotExist = errors.New("missing configuration") - -// Exists checks if file exists on the specified path. -func Exists(path string) bool { - info, err := os.Stat(path) - if os.IsNotExist(err) { - return false - } - return !info.IsDir() -} - -// Parser is interface for any configuration format parser to implement. -type Parser interface { - Serialize(*Config) ([]byte, error) - Deserialize([]byte) (*Config, error) - SupportsFormat(string) bool -} - -type ReaderWriter interface { - ReadFile(source string) ([]byte, error) - WriteFile(filename string, data []byte, perm os.FileMode) error -} - -// Parsers is a list of all configuration parsers. -type Parsers []Parser - -// FindForFormat finds a parser that can parse a specific format based on extension. -func (c *Parsers) FindForFormat(extension string) Parser { - for _, parser := range *c { - if parser.SupportsFormat(extension) { - return parser - } - } - - return nil -} - -// Loader contains actions for composing and modifying configuration. -type Loader struct { - readerWriter ReaderWriter - configParsers Parsers - LoadedLocations []string -} - -// NewLoader returns a new loader. -func NewLoader(readerWriter ReaderWriter) *Loader { - return &Loader{ - readerWriter: readerWriter, - } -} - -// AddConfigParser adds a new configuration parser. -func (l *Loader) AddConfigParser(format Parser) { - l.configParsers = append(l.configParsers, format) -} - -// Save saves a configuration to a path with correct serializer. -func (l *Loader) Save(conf *Config, path string) error { - configFormat := l.configParsers.FindForFormat( - filepath.Ext(path), - ) - - if configFormat == nil { - return fmt.Errorf("parser not found for format") - } - - data, err := configFormat.Serialize(conf) - if err != nil { - return err - } - - err = l.readerWriter.WriteFile(path, data, 0644) - if err != nil { - return err - } - - return nil -} - -func (l *Loader) loadConfig(confPath string) (*Config, error) { - l.LoadedLocations = append(l.LoadedLocations, confPath) - raw, err := l.loadFile(confPath) - - if err != nil { - return nil, err - } - - preProcessed, err := l.preprocess(raw) - if err != nil { - return nil, fmt.Errorf("failed to preprocess config: %w", err) - } - - configParser := l.configParsers.FindForFormat(filepath.Ext(confPath)) - if configParser == nil { - return nil, fmt.Errorf("parser not found for config: %s", confPath) - } - - return configParser.Deserialize(preProcessed) -} - -// Load loads configuration from one or more file paths. -// -// If more than one path is specified, their contents are merged -// together into on configuration object. -func (l *Loader) Load(paths []string) (*Config, error) { - // special case for default configs - // try to load local config and only if not found try to load global config - if IsDefaultPath(paths) { - conf, err := l.loadConfig(DefaultPath) - if err == nil { // if we could load it then process it - return l.postprocess(conf) - } - if !errors.Is(err, ErrDoesNotExist) { - return nil, err - } - - conf, err = l.loadConfig(GlobalPath()) - if err != nil { - return nil, ErrDoesNotExist - } else { - return l.postprocess(conf) - } - } - - var baseConf *Config - for _, confPath := range paths { - conf, err := l.loadConfig(confPath) - if err != nil { - return nil, err - } - // if first conf just assign as baseConf - if baseConf == nil { - baseConf = conf - continue - } - - l.composeConfig(baseConf, conf) - } - - // if no config was loaded - neither local nor global return an error. - if baseConf == nil { - return nil, ErrDoesNotExist - } - - return l.postprocess(baseConf) -} - -// preprocess does all manipulations to the raw configuration format happens here. -func (l *Loader) preprocess(raw []byte) ([]byte, error) { - return processorRun(raw) -} - -// postprocess does all stateful changes to configuration structures here after it is parsed. -func (l *Loader) postprocess(baseConf *Config) (*Config, error) { - // validate as part of post-processing - err := baseConf.Validate() - if err != nil { - return nil, err - } - - return baseConf, nil -} - -// composeConfig merges multiple configuration files from right to left. -func (l *Loader) composeConfig(baseConf *Config, conf *Config) { - // overwrite base config with the provided one - for _, account := range conf.Accounts { - baseConf.Accounts.AddOrUpdate(account.Name, account) - } - for _, network := range conf.Networks { - baseConf.Networks.AddOrUpdate(network) - } - for _, contract := range conf.Contracts { - baseConf.Contracts.AddOrUpdate(contract) - } - for _, dependency := range conf.Dependencies { - baseConf.Dependencies.AddOrUpdate(dependency) - } - for _, deployment := range conf.Deployments { - baseConf.Deployments.AddOrUpdate(deployment) - } -} - -// loadFile simple file loader. -func (l *Loader) loadFile(path string) ([]byte, error) { - raw, err := l.readerWriter.ReadFile(path) - - if err != nil { - if os.IsNotExist(err) { - return nil, ErrDoesNotExist - } - - return nil, err - } - - return raw, nil -} diff --git a/flowkit/config/loader_test.go b/flowkit/config/loader_test.go deleted file mode 100644 index d77a74e54..000000000 --- a/flowkit/config/loader_test.go +++ /dev/null @@ -1,464 +0,0 @@ -/* -* Flow CLI -* -* Copyright 2019 Dapper Labs, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ -package config_test - -import ( - "fmt" - "os" - "path/filepath" - "testing" - - "github.com/onflow/flow-cli/flowkit/config" - - "github.com/spf13/afero" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/onflow/flow-cli/flowkit/config/json" -) - -var mockFS = afero.NewMemMapFs() - -var af = afero.Afero{Fs: mockFS} - -func Test_JSONSimple(t *testing.T) { - b := []byte(`{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - }, - "contracts": {}, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "deployments": {} - }`) - - err := afero.WriteFile(mockFS, "test2-flow.json", b, 0644) - - assert.NoError(t, err) - - composer := config.NewLoader(af) - composer.AddConfigParser(json.NewParser()) - conf, loadErr := composer.Load([]string{"test2-flow.json"}) - - assert.NoError(t, loadErr) - assert.Len(t, conf.Accounts, 1) - assert.Equal(t, - "0x21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", - conf.Accounts[0].Key.PrivateKey.String(), - ) -} - -func Test_ErrorWhenMissingBothDefaultJsonFiles(t *testing.T) { - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - _, loadErr := composer.Load(config.DefaultPaths()) - - assert.Error(t, loadErr) - assert.Contains(t, loadErr.Error(), "missing configuration") -} - -func Test_AllowMissingLocalJson(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, config.GlobalPath(), b, 0644) - - assert.NoError(t, err) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load(config.DefaultPaths()) - assert.NoError(t, loadErr) - - acc, err := conf.Accounts.ByName("emulator-account") - assert.NoError(t, err) - - assert.Len(t, conf.Accounts, 1) - assert.Equal(t, - "0x21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", - acc.Key.PrivateKey.String(), - ) -} - -func Test_PreferLocalJson(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - b2 := []byte(`{ - "accounts":{ - "emulator-account":{ - "address":"f1d6e0586b0a20c7", - "key":"3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - err2 := afero.WriteFile(mockFS, config.GlobalPath(), b2, 0644) - - assert.NoError(t, err) - assert.NoError(t, err2) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load(config.DefaultPaths()) - assert.NotNil(t, conf) - assert.NoError(t, err) - - acc, err := conf.Accounts.ByName("emulator-account") - assert.NoError(t, err) - - assert.NoError(t, loadErr) - assert.Len(t, conf.Accounts, 1) - assert.Equal(t, "0x21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", - acc.Key.PrivateKey.String(), - ) -} - -func Test_MissingConfiguration(t *testing.T) { - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, err := composer.Load([]string{"flow.json"}) - - assert.Nil(t, conf) - assert.EqualError(t, err, "missing configuration") -} - -func Test_ConfigurationMalformedJSON(t *testing.T) { - b := []byte(`{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account", - } - }, - "contracts": {}, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "deployments": {} - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - - assert.NoError(t, err) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, err := composer.Load(config.DefaultPaths()) - assert.EqualError(t, err, "failed to preprocess config: failed to parse config JSON: invalid character '}' looking for beginning of object key string") - assert.Nil(t, conf) -} - -func Test_ConfigurationWrongFormat(t *testing.T) { - b := []byte(`{ - "deployments": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - - assert.NoError(t, err) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, err := composer.Load(config.DefaultPaths()) - assert.EqualError(t, err, "configuration syntax error: json: cannot unmarshal string into Go struct field jsonConfig.deployments of type []json.deployment") - assert.Nil(t, conf) -} - -func Test_ComposeJSON(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - b2 := []byte(`{ - "accounts":{ - "admin-account":{ - "address":"f1d6e0586b0a20c7", - "key":"3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - err2 := afero.WriteFile(mockFS, "flow-testnet.json", b2, 0644) - - assert.NoError(t, err) - assert.NoError(t, err2) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load([]string{"flow.json", "flow-testnet.json"}) - - assert.NoError(t, loadErr) - assert.Len(t, conf.Accounts, 2) - - account, err := conf.Accounts.ByName("emulator-account") - assert.NoError(t, err) - - adminAccount, err := conf.Accounts.ByName("admin-account") - assert.NoError(t, err) - - assert.Equal(t, "0x21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", account.Key.PrivateKey.String()) - assert.NotNil(t, adminAccount) - assert.Equal(t, "0x3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", adminAccount.Key.PrivateKey.String()) -} - -func Test_ComposeCrossReference(t *testing.T) { - b := []byte(`{ - "accounts": { - "test": { - "address":"f1d6e0586b0a20c7", - "key":"3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - }, - "deployments": { - "testnet": { - "test": ["NFT"] - } - } - }`) - - b2 := []byte(`{ - "networks": { - "testnet": "access.devnet.nodes.onflow.org:9000" - }, - "contracts": { "NFT": "./NFT.cdc" } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - err2 := afero.WriteFile(mockFS, "b.json", b2, 0644) - - assert.NoError(t, err) - assert.NoError(t, err2) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load([]string{"flow.json", "b.json"}) - - assert.NoError(t, loadErr) - account, err := conf.Accounts.ByName("test") - assert.NoError(t, err) - assert.NotNil(t, account) - - deployments := conf.Deployments.ByAccountAndNetwork(account.Name, "testnet") - assert.NotNil(t, deployments) -} - -func Test_ComposeJSONOverwrite(t *testing.T) { - b := []byte(`{ - "accounts": { - "admin-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - b2 := []byte(`{ - "accounts":{ - "admin-account":{ - "address":"f1d6e0586b0a20c7", - "key":"3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "flow.json", b, 0644) - err2 := afero.WriteFile(mockFS, "flow-testnet.json", b2, 0644) - - assert.NoError(t, err) - assert.NoError(t, err2) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load([]string{"flow.json", "flow-testnet.json"}) - - assert.NoError(t, loadErr) - account, err := conf.Accounts.ByName("admin-account") - assert.NoError(t, err) - - assert.Len(t, conf.Accounts, 1) - assert.NotNil(t, account) - assert.Equal(t, "0x3335dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7", account.Key.PrivateKey.String()) -} - -func Test_JSONEnv(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "$EMULATOR_KEY" - }, - "advanced": { - "address": "f8d6e0586b0a20c7", - "key": { - "type": "hex", - "index": 0, - "signatureAlgorithm": "ECDSA_P256", - "hashAlgorithm": "SHA3_256", - "privateKey": "$ADVANCED_KEY" - } - } - } - }`) - const key1 = "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - const key2 = "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - os.Setenv("EMULATOR_KEY", key1) - os.Setenv("ADVANCED_KEY", key2) - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, "test2-flow.json", b, 0644) - require.NoError(t, err) - - t.Run("Load and replace env variable", func(t *testing.T) { - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - conf, loadErr := composer.Load([]string{"test2-flow.json"}) - - assert.NoError(t, loadErr) - assert.Equal(t, 2, len(conf.Accounts)) - - acc1, _ := conf.Accounts.ByName("advanced") - assert.Equal(t, fmt.Sprintf("0x%s", key2), acc1.Key.PrivateKey.String()) - - acc2, _ := conf.Accounts.ByName("emulator-account") - assert.Equal(t, fmt.Sprintf("0x%s", key1), acc2.Key.PrivateKey.String()) - }) - - t.Run("Save and remove replaced env variable", func(t *testing.T) { - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - conf, err := composer.Load([]string{"test2-flow.json"}) - require.NoError(t, err) - - testConf := "test-flow.json" - err = composer.Save(conf, testConf) - require.NoError(t, err) - - content, err := afero.ReadFile(mockFS, testConf) - require.NoError(t, err) - assert.NotContains(t, string(content), key1) - assert.NotContains(t, string(content), key2) - assert.Contains(t, string(content), "$EMULATOR_KEY") - assert.Contains(t, string(content), "$ADVANCED_KEY") - }) - - t.Run("Fail not present env variable", func(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "$NOT_EXISTS" - } - } - }`) - - mockFS := afero.NewMemMapFs() - _ = afero.WriteFile(mockFS, "test.json", b, 0644) - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - _, err = composer.Load([]string{"test.json"}) - assert.EqualError(t, err, "required environment variable NOT_EXISTS not set") - }) - -} - -func Test_LoadAccountFileType(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": { - "type": "file", - "location": "./test.pkey" - } - } - } - }`) - mockFS := afero.NewMemMapFs() - err := afero.WriteFile(mockFS, config.GlobalPath(), b, 0644) - - assert.NoError(t, err) - - composer := config.NewLoader(afero.Afero{Fs: mockFS}) - composer.AddConfigParser(json.NewParser()) - - conf, loadErr := composer.Load(config.DefaultPaths()) - require.NoError(t, loadErr) - - acc, err := conf.Accounts.ByName("emulator-account") - assert.NoError(t, err) - - assert.Len(t, conf.Accounts, 1) - assert.Equal(t, filepath.FromSlash("./test.pkey"), acc.Key.Location) -} diff --git a/flowkit/config/network.go b/flowkit/config/network.go deleted file mode 100644 index 658a79f04..000000000 --- a/flowkit/config/network.go +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "fmt" -) - -var ( - EmptyNetwork = Network{} - EmulatorNetwork = Network{ - Name: "emulator", - Host: "127.0.0.1:3569", - } - TestingNetwork = Network{ - Name: "testing", - Host: "127.0.0.1:3569", - } - TestnetNetwork = Network{ - Name: "testnet", - Host: "access.devnet.nodes.onflow.org:9000", - } - MainnetNetwork = Network{ - Name: "mainnet", - Host: "access.mainnet.nodes.onflow.org:9000", - } - DefaultNetworks = Networks{ - EmulatorNetwork, - TestingNetwork, - TestnetNetwork, - MainnetNetwork, - } -) - -type Networks []Network - -// Network defines the configuration for a Flow network. -type Network struct { - Name string - Host string - Key string -} - -// ByName get network by name or return an error if not found. -func (n *Networks) ByName(name string) (*Network, error) { - for _, network := range *n { - if network.Name == name { - return &network, nil - } - } - - return nil, fmt.Errorf("network named %s does not exist in configuration", name) -} - -// AddOrUpdate add new network or update if already present. -func (n *Networks) AddOrUpdate(network Network) { - for i, existingNetwork := range *n { - if existingNetwork.Name == network.Name { - (*n)[i] = network - return - } - } - - *n = append(*n, network) -} - -// Remove network by the name. -func (n *Networks) Remove(name string) error { - _, err := n.ByName(name) - if err != nil { - return err - } - - for i, network := range *n { - if network.Name == name { - *n = append((*n)[0:i], (*n)[i+1:]...) // remove item - } - } - - return nil -} diff --git a/flowkit/config/network_test.go b/flowkit/config/network_test.go deleted file mode 100644 index 7cb63bc51..000000000 --- a/flowkit/config/network_test.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -* Flow CLI -* -* Copyright 2019-2020 Dapper Labs, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNetworks_ByName(t *testing.T) { - // Define a sample network configuration. - networks := Networks{ - {Name: "flow-local", Host: "localhost:3569", Key: "flow-local-key"}, - {Name: "flow-testnet", Host: "localhost:3570", Key: "flow-testnet-key"}, - } - - // Test getting an existing network. - network, err := networks.ByName("flow-local") - assert.NoError(t, err) - assert.Equal(t, "flow-local", network.Name) - assert.Equal(t, "localhost:3569", network.Host) - assert.Equal(t, "flow-local-key", network.Key) - - // Test getting a non-existent network. - network, err = networks.ByName("flow-mainnet") - assert.Error(t, err) - assert.Nil(t, network) - assert.EqualError(t, err, "network named flow-mainnet does not exist in configuration") -} - -func TestNetworks_AddOrUpdate(t *testing.T) { - // Define a sample network configuration. - networks := Networks{ - {Name: "flow-local", Host: "localhost:3569", Key: "flow-local-key"}, - } - - // Test adding a new network. - networks.AddOrUpdate(Network{Name: "flow-testnet", Host: "localhost:3570", Key: "flow-testnet-key"}) - assert.Equal(t, 2, len(networks)) - - // Test updating an existing network. - networks.AddOrUpdate(Network{Name: "flow-local", Host: "localhost:3580", Key: "flow-local-key-updated"}) - assert.Equal(t, "localhost:3580", networks[0].Host) -} - -func TestNetworks_Remove(t *testing.T) { - // Define a sample network configuration. - networks := Networks{ - {Name: "flow-local", Host: "localhost:3569", Key: "flow-local-key"}, - {Name: "flow-testnet", Host: "localhost:3570", Key: "flow-testnet-key"}, - } - - // Test removing an existing network. - err := networks.Remove("flow-local") - assert.NoError(t, err) - assert.Equal(t, 1, len(networks)) - - // Test removing a non-existent network. - err = networks.Remove("flow-mainnet") - assert.Error(t, err) - assert.EqualError(t, err, "network named flow-mainnet does not exist in configuration") -} diff --git a/flowkit/config/processor.go b/flowkit/config/processor.go deleted file mode 100644 index 883bafade..000000000 --- a/flowkit/config/processor.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "encoding/json" - "fmt" -) - -// processorRun all pre-processors. -func processorRun(raw []byte) ([]byte, error) { - type config struct { - Accounts map[string]map[string]any `json:"accounts,omitempty"` - Contracts any `json:"contracts,omitempty"` - Dependencies any `json:"dependencies,omitempty"` - Networks any `json:"networks,omitempty"` - Deployments any `json:"deployments,omitempty"` - Emulators any `json:"emulators,omitempty"` - } - - var conf config - err := json.Unmarshal(raw, &conf) - if err != nil { - return nil, fmt.Errorf("failed to parse config JSON: %w", err) - } - - raw, err = json.Marshal(conf) - if err != nil { - return nil, fmt.Errorf("failed to marshal config: %w", err) - } - - return raw, nil -} diff --git a/flowkit/config/processor_test.go b/flowkit/config/processor_test.go deleted file mode 100644 index a524558a1..000000000 --- a/flowkit/config/processor_test.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Flow CLI -* -* Copyright 2019-2020 Dapper Labs, Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ - -package config - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func Test_PrivateConfigFileAccounts(t *testing.T) { - b := []byte(`{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - }, - "contracts": {}, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "deployments": {}, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - processorRunRes, err := processorRun(b) - require.NoError(t, err) - - assert.JSONEq(t, `{ - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - }, - "contracts": {}, - "networks": { - "emulator": "127.0.0.1:3569" - }, - "deployments": {}, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "11c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`, string(processorRunRes)) -} diff --git a/flowkit/events.go b/flowkit/events.go deleted file mode 100644 index 7cf6e7679..000000000 --- a/flowkit/events.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" -) - -type Event struct { - Type string - Values map[string]cadence.Value -} - -func (e *Event) GetAddress() *flow.Address { - if a, ok := e.Values["address"].(cadence.Address); ok { - address := flow.HexToAddress(a.String()) - return &address - } - - return nil -} - -type Events []Event - -func EventsFromTransaction(tx *flow.TransactionResult) Events { - var events Events - for _, event := range tx.Events { - events = append(events, NewEvent(event)) - } - - return events -} - -func NewEvent(event flow.Event) Event { - var names []string - - for _, eventType := range event.Value.EventType.Fields { - names = append(names, eventType.Identifier) - } - values := make(map[string]cadence.Value) - for id, field := range event.Value.Fields { - values[names[id]] = field - } - - return Event{ - Type: event.Type, - Values: values, - } -} - -func (e *Events) GetCreatedAddresses() []*flow.Address { - addresses := make([]*flow.Address, 0) - for _, event := range *e { - if event.Type == flow.EventAccountCreated { - addresses = append(addresses, event.GetAddress()) - } - } - - return addresses -} diff --git a/flowkit/events_test.go b/flowkit/events_test.go deleted file mode 100644 index 35b83cb1e..000000000 --- a/flowkit/events_test.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit_test - -import ( - "testing" - - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/tests" -) - -func Test_AccountCreatedEvent(t *testing.T) { - address := flow.HexToAddress("00c4fef62310c807") - flowEvent := tests.NewEvent(0, - flow.EventAccountCreated, - []cadence.Field{{ - Identifier: "address", - Type: cadence.AddressType{}, - }}, - []cadence.Value{cadence.NewAddress(address)}, - ) - tx := tests.NewTransactionResult([]flow.Event{*flowEvent}) - events := flowkit.EventsFromTransaction(tx) - - assert.Len(t, events.GetCreatedAddresses(), 1) - assert.Equal(t, address, *events.GetCreatedAddresses()[0]) - - assert.Len(t, events, 1) - assert.Equal(t, address, *events[0].GetAddress()) - assert.Equal(t, `flow.AccountCreated(address: 0x00c4fef62310c807)`, flowEvent.Value.String()) -} - -func TestAddress(t *testing.T) { - address := flow.HexToAddress("cdfef0f4f0786e9") - assert.Equal(t, "0cdfef0f4f0786e9", address.String()) -} diff --git a/flowkit/flowkit.go b/flowkit/flowkit.go deleted file mode 100644 index b2e21ddd7..000000000 --- a/flowkit/flowkit.go +++ /dev/null @@ -1,1057 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "bytes" - "context" - "crypto/rand" - "fmt" - "strconv" - "strings" - "sync" - - "github.com/btcsuite/btcd/chaincfg/chainhash" - goeth "github.com/ethereum/go-ethereum/accounts" - "github.com/lmars/go-slip10" - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/access/grpc" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/pkg/errors" - "github.com/tyler-smith/go-bip39" - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" - - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/project" - "github.com/onflow/flow-cli/flowkit/transactions" -) - -// BlockQuery defines possible queries for block. -type BlockQuery struct { - ID *flow.Identifier - Height uint64 - Latest bool -} - -// LatestBlockQuery specifies the latest block. -var LatestBlockQuery = BlockQuery{Latest: true} - -// NewBlockQuery creates block query based on the passed query value. -// -// Query string options: -// - "latest" : return the latest block -// - height (e.g. 123456789) : return block at this height -// - ID : return block with this ID -// if none of the valid values are passed an error is returned. -func NewBlockQuery(query string) (BlockQuery, error) { - if query == "latest" { - return LatestBlockQuery, nil - } - if height, ce := strconv.ParseUint(query, 10, 64); ce == nil { - return BlockQuery{Height: height}, nil - } - if id := flow.HexToID(query); id != flow.EmptyID { - return BlockQuery{ID: &id}, nil - } - - return BlockQuery{}, fmt.Errorf("invalid query: %s, valid are: \"latest\", block height or block ID", query) -} - -// ScriptQuery defines block ID or height at which we should execute the script. -type ScriptQuery struct { - Latest bool - ID flow.Identifier - Height uint64 -} - -// LatestScriptQuery specifies the latest block at which query is executed. -var LatestScriptQuery = ScriptQuery{Latest: true} - -// EventWorker defines how many workers do we want to start, each in its own subroutine, and how many blocks -// each worker fetches from the network. This is used to process the event requests concurrently. -type EventWorker struct { - Count int - BlocksPerWorker uint64 -} - -var _ Services = &Flowkit{} - -func NewFlowkit( - state *State, - network config.Network, - gateway gateway.Gateway, - logger output.Logger, -) *Flowkit { - return &Flowkit{state, network, gateway, logger} -} - -type Flowkit struct { - state *State - network config.Network - gateway gateway.Gateway - logger output.Logger -} - -func (f *Flowkit) Network() config.Network { - return f.network -} - -func (f *Flowkit) Gateway() gateway.Gateway { - return f.gateway -} - -func (f *Flowkit) SetLogger(logger output.Logger) { - f.logger = logger -} - -func (f *Flowkit) State() (*State, error) { - if f.state == nil { - return nil, config.ErrDoesNotExist - } - return f.state, nil -} - -func (f *Flowkit) Ping() error { - return f.gateway.Ping() -} - -// GetAccount fetches account on the Flow network. -func (f *Flowkit) GetAccount(_ context.Context, address flow.Address) (*flow.Account, error) { - return f.gateway.GetAccount(address) -} - -// CreateAccount on the Flow network with the provided keys and using the signer for creation transaction. -// Returns the newly created account as well as the ID of the transaction that created the account. -// -// Keys is a slice but only one can be passed as well. If the transaction fails or there are other issues an error is returned. -func (f *Flowkit) CreateAccount( - _ context.Context, - signer *accounts.Account, - keys []accounts.PublicKey, -) (*flow.Account, flow.Identifier, error) { - var accKeys []*flow.AccountKey - for _, k := range keys { - if k.Weight == 0 { // if key weight is not specified - k.Weight = flow.AccountKeyWeightThreshold - } - - accKey := &flow.AccountKey{ - PublicKey: k.Public, - SigAlgo: k.SigAlgo, - HashAlgo: k.HashAlgo, - Weight: k.Weight, - } - - err := accKey.Validate() - if err != nil { - return nil, flow.EmptyID, fmt.Errorf("invalid account key: %w", err) - } - - accKeys = append(accKeys, accKey) - } - - tx, err := transactions.NewCreateAccount(signer, accKeys, nil) - if err != nil { - return nil, flow.EmptyID, err - } - - tx, err = f.prepareTransaction(tx, signer) - if err != nil { - return nil, flow.EmptyID, err - } - - f.logger.Info(fmt.Sprintf("Transaction ID: %s", tx.FlowTransaction().ID())) - f.logger.StartProgress("Creating account...") - defer f.logger.StopProgress() - - sentTx, err := f.gateway.SendSignedTransaction(tx.FlowTransaction()) - if err != nil { - return nil, flow.EmptyID, errors.Wrap(err, "account creation transaction failed") - } - - f.logger.StartProgress("Waiting for transaction to be sealed...") - defer f.logger.StopProgress() - - result, err := f.gateway.GetTransactionResult(sentTx.ID(), true) - if err != nil { - return nil, flow.EmptyID, err - } - - if result.Error != nil { - return nil, flow.EmptyID, result.Error - } - - events := EventsFromTransaction(result) - newAccountAddress := events.GetCreatedAddresses() - if len(newAccountAddress) == 0 { - return nil, flow.EmptyID, fmt.Errorf("new account address couldn't be fetched") - } - - account, err := f.gateway.GetAccount(*newAccountAddress[0]) // we know it's the only and first event - if err != nil { - return nil, flow.EmptyID, err - } - - return account, sentTx.ID(), nil -} - -// prepareTransaction prepares transaction for sending with data from network -func (f *Flowkit) prepareTransaction( - tx *transactions.Transaction, - account *accounts.Account, -) (*transactions.Transaction, error) { - block, err := f.gateway.GetLatestBlock() - if err != nil { - return nil, err - } - - proposer, err := f.gateway.GetAccount(account.Address) - if err != nil { - return nil, err - } - - tx.SetBlockReference(block) - if err = tx.SetProposer(proposer, account.Key.Index()); err != nil { - return nil, err - } - - tx, err = tx.Sign() - if err != nil { - return nil, err - } - - return tx, nil -} - -var errUpdateNoDiff = errors.New("contract already exists and is the same as the contract provided for update") - -type UpdateContract func(existing []byte, new []byte) bool - -func UpdateExistingContract(updateExisting bool) UpdateContract { - return func(existing []byte, new []byte) bool { - return updateExisting - } -} - -// AddContract to the Flow account provided and return the transaction ID. -// -// If the contract already exists on the account the operation will fail and error will be returned. -// Use UpdateExistingContract(bool) to define whether a contract should be updated or not, or you can also -// define a custom UpdateContract function which returns bool indicating whether a contract should be updated or not. -func (f *Flowkit) AddContract( - ctx context.Context, - account *accounts.Account, - contract Script, - update UpdateContract, -) (flow.Identifier, bool, error) { - state, err := f.State() - if err != nil { - return flow.EmptyID, false, err - } - - program, err := project.NewProgram(contract.Code, contract.Args, contract.Location) - if err != nil { - return flow.EmptyID, false, err - } - - if program.HasImports() { - contracts, err := state.DeploymentContractsByNetwork(f.network) - if err != nil { - return flow.EmptyID, false, err - } - - importReplacer := project.NewImportReplacer( - contracts, - state.AliasesForNetwork(f.network), - ) - - program, err = importReplacer.Replace(program) - if err != nil { - return flow.EmptyID, false, err - } - } - - name, err := program.Name() - if err != nil { - return flow.EmptyID, false, err - } - - tx, err := transactions.NewAddAccountContract( - account, - name, - program.Code(), - contract.Args, - ) - if err != nil { - return flow.EmptyID, false, err - } - - f.logger.StartProgress(fmt.Sprintf("Checking contract '%s' on account '%s'...", name, account.Address)) - defer f.logger.StopProgress() - - // check if contract exists on account - flowAccount, err := f.gateway.GetAccount(account.Address) - if err != nil { - return flow.EmptyID, false, err - } - existingContract, exists := flowAccount.Contracts[name] - noDiffInContract := bytes.Equal(program.Code(), existingContract) - - if exists && noDiffInContract { - return flow.EmptyID, false, errUpdateNoDiff - } - - updateExisting := update(existingContract, program.Code()) - if exists && !updateExisting { - return flow.EmptyID, false, fmt.Errorf(fmt.Sprintf("contract %s exists in account %s", name, account.Name)) - } - - if exists && updateExisting { - tx, err = transactions.NewUpdateAccountContract(account, name, program.Code()) - if err != nil { - return flow.EmptyID, false, err - } - } - - tx, err = f.prepareTransaction(tx, account) - if err != nil { - return flow.EmptyID, false, err - } - - // send transaction with contract - sentTx, err := f.gateway.SendSignedTransaction(tx.FlowTransaction()) - if err != nil { - return tx.FlowTransaction().ID(), false, fmt.Errorf("failed to send transaction to deploy a contract: %w", err) - } - - if exists { - f.logger.StartProgress(fmt.Sprintf("Contract '%s' updating on the account '%s'.", name, account.Address)) - } else { - f.logger.StartProgress(fmt.Sprintf("Contract '%s' deploying on the account '%s'.", name, account.Address)) - } - - // we wait for transaction to be sealed - trx, err := f.gateway.GetTransactionResult(sentTx.ID(), true) - if err != nil { - return tx.FlowTransaction().ID(), false, err - } - if trx.Error != nil { - return tx.FlowTransaction().ID(), false, trx.Error - } - - d := state.Deployments().ByAccountAndNetwork(account.Name, f.network.Name) - cd := config.ContractDeployment{ - Name: name, - Args: contract.Args, - } - if d != nil { - d.AddContract(cd) - } else { - deployment := config.Deployment{ - Network: f.network.Name, - Account: account.Name, - Contracts: []config.ContractDeployment{cd}, - } - state.Deployments().AddOrUpdate(deployment) - } - - // don't add contract if it already exists because it might overwrite existing data - if c, _ := state.Contracts().ByName(name); c == nil { - state.Contracts().AddOrUpdate(config.Contract{ - Name: name, - Location: contract.Location, - }) - } - - return sentTx.ID(), updateExisting, err -} - -// RemoveContract from the provided account by its name. -// -// If removal is successful transaction ID is returned. -func (f *Flowkit) RemoveContract( - _ context.Context, - account *accounts.Account, - contractName string, -) (flow.Identifier, error) { - // check if contracts exists on the account - flowAcc, err := f.gateway.GetAccount(account.Address) - if err != nil { - return flow.EmptyID, err - } - - existingContracts := maps.Keys(flowAcc.Contracts) - if !slices.Contains(existingContracts, contractName) { - return flow.EmptyID, fmt.Errorf( - "can not remove a non-existing contract named '%s'. Account only contains the contracts: %v", - contractName, - strings.Join(existingContracts, ", "), - ) - } - - tx, err := transactions.NewRemoveAccountContract(account, contractName) - if err != nil { - return flow.EmptyID, err - } - - tx, err = f.prepareTransaction(tx, account) - if err != nil { - return flow.EmptyID, err - } - - f.logger.StartProgress( - fmt.Sprintf("Removing Contract %s from %s...", contractName, account.Address), - ) - defer f.logger.StopProgress() - - sentTx, err := f.gateway.SendSignedTransaction(tx.FlowTransaction()) - if err != nil { - return flow.EmptyID, err - } - - txr, err := f.gateway.GetTransactionResult(sentTx.ID(), true) - if err != nil { - return flow.EmptyID, err - } - if txr != nil && txr.Error != nil { - return flow.EmptyID, txr.Error - } - - f.logger.StopProgress() - - return sentTx.ID(), nil -} - -// GetBlock by the query from Flow blockchain. Query can define a block by ID, block by height or require the latest block. -func (f *Flowkit) GetBlock(_ context.Context, query BlockQuery) (*flow.Block, error) { - var err error - var block *flow.Block - if query.Latest { - block, err = f.gateway.GetLatestBlock() - } else if query.ID != nil { - block, err = f.gateway.GetBlockByID(*query.ID) - } else { - block, err = f.gateway.GetBlockByHeight(query.Height) - } - - if err != nil { - return nil, fmt.Errorf("error fetching block: %s", err.Error()) - } - - if block == nil { - return nil, fmt.Errorf("block not found") - } - - return block, err -} - -// GetCollection by the ID from Flow network. -func (f *Flowkit) GetCollection(_ context.Context, ID flow.Identifier) (*flow.Collection, error) { - return f.gateway.GetCollection(ID) -} - -// GetEvents from Flow network by their event name in the specified height interval defined by start and end inclusive. -// Optional worker defines parameters for how many concurrent workers do we want to fetch our events, -// and how many blocks between the provided interval each worker fetches. -// -// Providing worker value will produce faster response as the interval will be scanned concurrently. This parameter is optional, -// if not provided only a single worker will be used. -func (f *Flowkit) GetEvents( - _ context.Context, - names []string, - startHeight uint64, - endHeight uint64, - worker *EventWorker, -) ([]flow.BlockEvents, error) { - if endHeight < startHeight { - return nil, fmt.Errorf("cannot have end height (%d) of block range less that start height (%d)", endHeight, startHeight) - } - - if worker == nil { // if no worker is passed, create a default one - worker = &EventWorker{ - Count: 1, - BlocksPerWorker: 250, - } - } - - queries := makeEventQueries(names, startHeight, endHeight, worker.BlocksPerWorker) - - jobChan := make(chan grpc.EventRangeQuery, worker.Count) - results := make(chan eventWorkerResult) - - var wg sync.WaitGroup - - for i := 0; i < worker.Count; i++ { - wg.Add(1) - go func() { - defer wg.Done() - f.eventWorker(jobChan, results) - }() - } - - // wait on the workers to finish and close the result channel - // to signal downstream that all work is done - go func() { - defer close(results) - wg.Wait() - }() - - go func() { - defer close(jobChan) - for _, query := range queries { - jobChan <- query - } - }() - - var resultEvents []flow.BlockEvents - for eventResult := range results { - if eventResult.err != nil { - return nil, eventResult.err - } - - resultEvents = append(resultEvents, eventResult.events...) - } - - return resultEvents, nil -} - -func (f *Flowkit) eventWorker(jobChan <-chan grpc.EventRangeQuery, results chan<- eventWorkerResult) { - for q := range jobChan { - blockEvents, err := f.gateway.GetEvents(q.Type, q.StartHeight, q.EndHeight) - if err != nil { - results <- eventWorkerResult{nil, err} - } - results <- eventWorkerResult{blockEvents, nil} - } -} - -type eventWorkerResult struct { - events []flow.BlockEvents - err error -} - -func makeEventQueries( - events []string, - startHeight uint64, - endHeight uint64, - blockCount uint64, -) []grpc.EventRangeQuery { - var queries []grpc.EventRangeQuery - for startHeight <= endHeight { - suggestedEndHeight := startHeight + blockCount - 1 // since we are inclusive - end := endHeight - if suggestedEndHeight < endHeight { - end = suggestedEndHeight - } - for _, event := range events { - queries = append(queries, grpc.EventRangeQuery{ - Type: event, - StartHeight: startHeight, - EndHeight: end, - }) - } - startHeight = suggestedEndHeight + 1 - } - return queries -} - -// GenerateKey using the signature algorithm and optional seed. If seed is not provided a random safe seed will be generated. -func (f *Flowkit) GenerateKey( - _ context.Context, - sigAlgo crypto.SignatureAlgorithm, - inputSeed string, -) (crypto.PrivateKey, error) { - seed := []byte(inputSeed) - - if inputSeed == "" { - seed = make([]byte, crypto.MinSeedLength) - _, err := rand.Read(seed) - if err != nil { - return nil, fmt.Errorf("failed to generate random seed: %v", err) - } - } - - privateKey, err := crypto.GeneratePrivateKey(sigAlgo, seed) - if err != nil { - return nil, fmt.Errorf("failed to generate private key: %w", err) - } - - return privateKey, nil -} - -// GenerateMnemonicKey will generate a new key with the signature algorithm and optional derivation path. -// -// If the derivation path is not provided a default "m/44'/539'/0'/0/0" will be used. -func (f *Flowkit) GenerateMnemonicKey( - _ context.Context, - sigAlgo crypto.SignatureAlgorithm, - derivationPath string, -) (crypto.PrivateKey, string, error) { - entropy, err := bip39.NewEntropy(128) - if err != nil { - return nil, "", err - } - mnemonic, err := bip39.NewMnemonic(entropy) - if err != nil { - return nil, "", err - } - - if !bip39.IsMnemonicValid(mnemonic) { - return nil, "", fmt.Errorf("invalid mnemonic") - } - - seed := bip39.NewSeed(mnemonic, "") - - key, err := f.derivePrivateKeyFromSeed(seed, sigAlgo, derivationPath) - if err != nil { - return nil, "", err - } - - return key, mnemonic, nil -} - -func (f *Flowkit) DerivePrivateKeyFromMnemonic( - _ context.Context, - mnemonic string, - sigAlgo crypto.SignatureAlgorithm, - derivationPath string, -) (crypto.PrivateKey, error) { - if !bip39.IsMnemonicValid(mnemonic) { - return nil, fmt.Errorf("invalid mnemonic") - } - - seed := bip39.NewSeed(mnemonic, "") - - return f.derivePrivateKeyFromSeed(seed, sigAlgo, derivationPath) -} - -func (f *Flowkit) derivePrivateKeyFromSeed( - seed []byte, - sigAlgo crypto.SignatureAlgorithm, - derivationPath string, -) (crypto.PrivateKey, error) { - // sanity check of seed length - if len(seed) < 16 { - return nil, fmt.Errorf("seed length should be at least 16 bytes, got %d", len(seed)) - } - - if derivationPath == "" { - derivationPath = "m/44'/539'/0'/0/0" - } - - path, err := goeth.ParseDerivationPath(derivationPath) - if err != nil { - return nil, fmt.Errorf("invalid derivation path") - } - - curve := slip10.CurveBitcoin // case ECDSA_secp256k1 - if sigAlgo == crypto.ECDSA_P256 { - curve = slip10.CurveP256 - } else if sigAlgo != crypto.ECDSA_secp256k1 { - return nil, fmt.Errorf("invalid signature algorithm") - } - - accountKey, err := slip10.NewMasterKeyWithCurve(seed, curve) - if err != nil { - return nil, err - } - - for _, n := range path { - accountKey, err = accountKey.NewChildKey(n) - - if err != nil { - return nil, err - } - } - privateKey, err := crypto.DecodePrivateKey(sigAlgo, accountKey.Key) - if err != nil { - return nil, err - } - return privateKey, nil -} - -// DeployProject contracts to the Flow network or update if already exists and UpdateContracts returns true. -// -// Retrieve all the contracts for specified network, sort them for deployment deploy one by one and replace -// the imports in the contract source, so it corresponds to the account name the contract was deployed to. -// If contracts already exist use UpdateExistingContract(bool) to define whether a contract should be updated or not. -func (f *Flowkit) DeployProject(ctx context.Context, update UpdateContract) ([]*project.Contract, error) { - state, err := f.State() - if err != nil { - return nil, err - } - - contracts, err := state.DeploymentContractsByNetwork(f.network) - if err != nil { - return nil, err - } - - deployment, err := project.NewDeployment(contracts, state.AliasesForNetwork(f.network)) - if err != nil { - return nil, err - } - - sorted, err := deployment.Sort() - if err != nil { - return nil, err - } - - f.logger.Info(fmt.Sprintf( - "\nDeploying %d contracts for accounts: %s\n", - len(sorted), - state.AccountsForNetwork(f.network).String(), - )) - defer f.logger.StopProgress() - - deployErr := &ProjectDeploymentError{} - for _, contract := range sorted { - targetAccount, err := state.Accounts().ByName(contract.AccountName) - if err != nil { - return nil, fmt.Errorf("target account for deploying contract not found in configuration") - } - - txID, updated, err := f.AddContract( - ctx, - targetAccount, - Script{Code: contract.Code(), Args: contract.Args, Location: contract.Location()}, - update, - ) - if err != nil && errors.Is(err, errUpdateNoDiff) { - f.logger.Info(fmt.Sprintf( - "%s -> 0x%s [skipping, no changes found]", - output.Italic(contract.Name), - contract.AccountAddress.String(), - )) - continue - } else if err != nil { - deployErr.add(contract, err, fmt.Sprintf("failed to deploy contract %s", contract.Name)) - continue - } - - f.logger.Info(fmt.Sprintf( - "%s -> 0x%s (%s) %s", - output.Green(contract.Name), - contract.AccountAddress, - txID.String(), - map[bool]string{true: "[updated]", false: ""}[updated], - )) - } - - if len(deployErr.contracts) > 0 { - return nil, deployErr - } - - f.logger.Info(fmt.Sprintf("\n%s All contracts deployed successfully", output.SuccessEmoji())) - return sorted, nil -} - -type ProjectDeploymentError struct { - contracts map[string]error -} - -func (d *ProjectDeploymentError) add(contract *project.Contract, err error, msg string) { - if d.contracts == nil { - d.contracts = make(map[string]error) - } - d.contracts[contract.Name] = fmt.Errorf("%s: %w", msg, err) -} - -func (d *ProjectDeploymentError) Contracts() map[string]error { - return d.contracts -} - -func (d *ProjectDeploymentError) Error() string { - err := "" - for c, e := range d.contracts { - err = fmt.Sprintf("%s %s: %s,", err, c, e.Error()) - } - return err -} - -// Script includes Cadence code and optional arguments and filename. -// -// Filename is only required to be passed if the code has imports you want to resolve. -type Script struct { - Code []byte - Args []cadence.Value - Location string -} - -// ExecuteScript on the Flow network and return the Cadence value as a result. The script is executed at the -// block provided as part of the ScriptQuery value. -func (f *Flowkit) ExecuteScript(_ context.Context, script Script, query ScriptQuery) (cadence.Value, error) { - state, err := f.State() - if err != nil { - return nil, err - } - - program, err := project.NewProgram(script.Code, script.Args, script.Location) - if err != nil { - return nil, err - } - - if program.HasImports() { - contracts, err := state.DeploymentContractsByNetwork(f.network) - if err != nil { - return nil, err - } - - importReplacer := project.NewImportReplacer( - contracts, - state.AliasesForNetwork(f.network), - ) - - if state == nil { - return nil, config.ErrDoesNotExist - } - if f.network == config.EmptyNetwork { - return nil, fmt.Errorf("missing network, specify which network to use to resolve imports in script code") - } - if script.Location == "" { - return nil, fmt.Errorf("resolving imports in scripts not supported") - } - - program, err = importReplacer.Replace(program) - if err != nil { - return nil, err - } - } - - if query.Latest { - return f.gateway.ExecuteScript(program.Code(), script.Args) - } else if query.ID != flow.EmptyID { - return f.gateway.ExecuteScriptAtID(program.Code(), script.Args, query.ID) - } else { - return f.gateway.ExecuteScriptAtHeight(program.Code(), script.Args, query.Height) - } -} - -// GetTransactionByID from the Flow network including the transaction result. Using the waitSeal we can wait for the transaction to be sealed. -func (f *Flowkit) GetTransactionByID( - _ context.Context, - ID flow.Identifier, - waitSeal bool, -) (*flow.Transaction, *flow.TransactionResult, error) { - f.logger.StartProgress("Fetching Transaction...") - defer f.logger.StopProgress() - - tx, err := f.gateway.GetTransaction(ID) - if err != nil { - return nil, nil, err - } - - if waitSeal { - f.logger.StartProgress("Waiting for transaction to be sealed...") - defer f.logger.StopProgress() - } - - result, err := f.gateway.GetTransactionResult(ID, waitSeal) - return tx, result, err -} - -func (f *Flowkit) GetTransactionsByBlockID( - _ context.Context, - blockID flow.Identifier, -) ([]*flow.Transaction, []*flow.TransactionResult, error) { - tx, err := f.gateway.GetTransactionsByBlockID(blockID) - if err != nil { - return nil, nil, err - } - - txRes, err := f.gateway.GetTransactionResultsByBlockID(blockID) - if err != nil { - return nil, nil, err - } - return tx, txRes, nil -} - -// BuildTransaction builds a new transaction type for later signing and submitting to the network. -// -// AddressesRoles type defines the address for each role (payer, proposer, authorizers) and the script defines the transaction content. -func (f *Flowkit) BuildTransaction( - _ context.Context, - addresses transactions.AddressesRoles, - proposerKeyIndex int, - script Script, - gasLimit uint64, -) (*transactions.Transaction, error) { - state, err := f.State() - if err != nil { - return nil, err - } - - latestBlock, err := f.gateway.GetLatestBlock() - if err != nil { - return nil, fmt.Errorf("failed to get latest sealed block: %w", err) - } - - proposerAccount, err := f.gateway.GetAccount(addresses.Proposer) - if err != nil { - return nil, err - } - - tx := transactions.New(). - SetPayer(addresses.Payer). - SetComputeLimit(gasLimit). - SetBlockReference(latestBlock) - - program, err := project.NewProgram(script.Code, script.Args, script.Location) - if err != nil { - return nil, err - } - - if program.HasImports() { - if f.network == config.EmptyNetwork { - return nil, fmt.Errorf("missing network, specify which network to use to resolve imports in transaction code") - } - if script.Location == "" { // when used as lib with code we don't support imports - return nil, fmt.Errorf("resolving imports in transactions not supported") - } - - contracts, err := state.DeploymentContractsByNetwork(f.network) - if err != nil { - return nil, err - } - - importReplacer := project.NewImportReplacer( - contracts, - state.AliasesForNetwork(f.network), - ) - - program, err = importReplacer.Replace(program) - if err != nil { - return nil, fmt.Errorf("error resolving imports: %w", err) - } - } - - if err := tx.SetProposer(proposerAccount, proposerKeyIndex); err != nil { - return nil, err - } - - if err := tx.SetScriptWithArgs(program.Code(), script.Args); err != nil { - return nil, err - } - - tx, err = tx.AddAuthorizers(addresses.Authorizers) - if err != nil { - return nil, err - } - - return tx, nil -} - -// SignTransactionPayload will use the signer account provided and the payload raw byte content to sign it. -// -// The payload should be RLP encoded transaction payload and is suggested to be used in pair with BuildTransaction function. -func (f *Flowkit) SignTransactionPayload( - _ context.Context, - signer *accounts.Account, - payload []byte, -) (*transactions.Transaction, error) { - tx, err := transactions.NewFromPayload(payload) - if err != nil { - return nil, err - } - - err = tx.SetSigner(signer) - if err != nil { - return nil, err - } - - return tx.Sign() -} - -// SendSignedTransaction will send a prebuilt and signed transaction to the Flow network. -// -// You can build the transaction using the BuildTransaction method and then sign it using the SignTranscation method. -func (f *Flowkit) SendSignedTransaction( - _ context.Context, - tx *transactions.Transaction, -) (*flow.Transaction, *flow.TransactionResult, error) { - sentTx, err := f.gateway.SendSignedTransaction(tx.FlowTransaction()) - if err != nil { - return nil, nil, err - } - - res, err := f.gateway.GetTransactionResult(sentTx.ID(), true) - if err != nil { - return nil, nil, err - } - - return sentTx, res, nil -} - -// SendTransaction will build and send a transaction to the Flow network, using the accounts provided for each role and -// contain the script. Transaction as well as transaction result will be returned in case the transaction is successfully submitted. -func (f *Flowkit) SendTransaction( - ctx context.Context, - accounts transactions.AccountRoles, - script Script, - gasLimit uint64, -) (*flow.Transaction, *flow.TransactionResult, error) { - tx, err := f.BuildTransaction( - ctx, - accounts.AddressRoles(), - accounts.Proposer.Key.Index(), - script, - gasLimit, - ) - if err != nil { - return nil, nil, err - } - - for _, signer := range accounts.Signers() { - err = tx.SetSigner(signer) - if err != nil { - return nil, nil, err - } - - tx, err = tx.Sign() - if err != nil { - return nil, nil, err - } - } - - f.logger.Info(fmt.Sprintf("Transaction ID: %s", tx.FlowTransaction().ID())) - f.logger.StartProgress("Sending transaction...") - defer f.logger.StopProgress() - - sentTx, err := f.gateway.SendSignedTransaction(tx.FlowTransaction()) - if err != nil { - return nil, nil, err - } - - f.logger.StopProgress() - f.logger.StartProgress("Waiting for transaction to be sealed...") - defer f.logger.StopProgress() - - res, err := f.gateway.GetTransactionResult(sentTx.ID(), true) - - return sentTx, res, err -} - -// this is added to resolve the issue with chainhash ambiguous import, -// the code is not used, but it's needed to force go.mod specify and retain chainhash version -// workaround for issue: https://github.com/golang/go/issues/27899 -var _ = chainhash.Hash{} diff --git a/flowkit/flowkit_test.go b/flowkit/flowkit_test.go deleted file mode 100644 index 7163df545..000000000 --- a/flowkit/flowkit_test.go +++ /dev/null @@ -1,2086 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "context" - "encoding/hex" - "errors" - "fmt" - "strings" - "testing" - - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/transactions" - - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/flow-emulator/emulator" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/access/grpc" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/gateway/mocks" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/project" - "github.com/onflow/flow-cli/flowkit/tests" -) - -func Alice() *accounts.Account { - return newAccount("Alice", "0x1", "seedseedseedseedseedseedseedseedseedseedseedseedAlice") -} - -func Bob() *accounts.Account { - return newAccount("Bob", "0x2", "seedseedseedseedseedseedseedseedseedseedseedseedBob") -} - -func Charlie() *accounts.Account { - return newAccount("Charlie", "0x3", "seedseedseedseedseedseedseedseedseedseedseedseedCharlie") -} - -func Donald() *accounts.Account { - return newAccount("Donald", "0x3", "seedseedseedseedseedseedseedseedseedseedseedseedDonald") -} - -func newAccount(name string, address string, seed string) *accounts.Account { - privateKey, _ := crypto.GeneratePrivateKey(crypto.ECDSA_P256, []byte(seed)) - - return &accounts.Account{ - Name: name, - Address: flow.HexToAddress(address), - Key: accounts.NewHexKeyFromPrivateKey(0, crypto.SHA3_256, privateKey), - } -} - -func setup() (*State, Flowkit, *mocks.TestGateway) { - readerWriter, _ := tests.ReaderWriter() - state, err := Init(readerWriter, crypto.ECDSA_P256, crypto.SHA3_256) - if err != nil { - panic(err) - } - - gw := mocks.DefaultMockGateway() - flowkit := Flowkit{ - state: state, - network: config.EmulatorNetwork, - gateway: gw.Mock, - logger: output.NewStdoutLogger(output.NoneLog), - } - - return state, flowkit, gw -} - -func resourceToContract(res tests.Resource) Script { - return Script{ - Code: res.Source, - Location: res.Filename, - } -} - -var ctx = context.Background() - -func TestAccounts(t *testing.T) { - state, _, _ := setup() - pubKey, _ := crypto.DecodePublicKeyHex(crypto.ECDSA_P256, "858a7d978b25d61f348841a343f79131f4b9fab341dd8a476a6f4367c25510570bf69b795fc9c3d2b7191327d869bcf848508526a3c1cafd1af34f71c7765117") - serviceAcc, _ := state.EmulatorServiceAccount() - serviceAddress := serviceAcc.Address - - t.Run("Get an Account", func(t *testing.T) { - _, flowkit, gw := setup() - account, err := flowkit.GetAccount(ctx, serviceAddress) - - gw.Mock.AssertCalled(t, "GetAccount", serviceAddress) - assert.NoError(t, err) - assert.Equal(t, serviceAddress, account.Address) - }) - - t.Run("Create an Account", func(t *testing.T) { - _, flowkit, gw := setup() - newAddress := flow.HexToAddress("192440c99cb17282") - - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, serviceAddress, tx.Authorizers[0]) - assert.Equal(t, serviceAddress, tx.Payer) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - compareAddress := serviceAddress - gw.GetAccount.Run(func(args mock.Arguments) { - address := args.Get(0).(flow.Address) - assert.Equal(t, address, compareAddress) - compareAddress = newAddress - gw.GetAccount.Return( - tests.NewAccountWithAddress(address.String()), nil, - ) - }) - - gw.GetTransactionResult.Return( - tests.NewAccountCreateResult(newAddress), nil, - ) - - account, ID, err := flowkit.CreateAccount( - ctx, - serviceAcc, - []accounts.PublicKey{{ - pubKey, - flow.AccountKeyWeightThreshold, - crypto.ECDSA_P256, - crypto.SHA3_256, - }}, - ) - - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, serviceAddress) - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, newAddress) - gw.Mock.AssertNumberOfCalls(t, mocks.GetAccountFunc, 2) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 1) - gw.Mock.AssertNumberOfCalls(t, mocks.SendSignedTransactionFunc, 1) - assert.NotNil(t, account) - assert.NotNil(t, ID) - assert.Equal(t, account.Address, newAddress) - assert.NoError(t, err) - }) - - t.Run("Contract Add for Account", func(t *testing.T) { - _, flowkit, gw := setup() - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, serviceAddress) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.add")) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - ID, _, err := flowkit.AddContract( - ctx, - serviceAcc, - resourceToContract(tests.ContractHelloString), - UpdateExistingContract(false), - ) - - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, serviceAddress) - gw.Mock.AssertNumberOfCalls(t, mocks.GetAccountFunc, 2) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 1) - gw.Mock.AssertNumberOfCalls(t, mocks.SendSignedTransactionFunc, 1) - assert.NotNil(t, ID) - assert.NoError(t, err) - }) - - t.Run("Contract Remove for Account", func(t *testing.T) { - _, flowkit, gw := setup() - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, serviceAddress) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.remove")) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - gw.GetAccount.Run(func(args mock.Arguments) { - addr := args.Get(0).(flow.Address) - assert.Equal(t, addr.String(), serviceAcc.Address.String()) - racc := tests.NewAccountWithAddress(addr.String()) - racc.Contracts = map[string][]byte{ - tests.ContractHelloString.Name: tests.ContractHelloString.Source, - } - - gw.GetAccount.Return(racc, nil) - }) - - account, err := flowkit.RemoveContract( - ctx, - serviceAcc, - tests.ContractHelloString.Name, - ) - - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, serviceAddress) - gw.Mock.AssertNumberOfCalls(t, mocks.GetAccountFunc, 2) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 1) - gw.Mock.AssertNumberOfCalls(t, mocks.SendSignedTransactionFunc, 1) - assert.NotNil(t, account) - assert.NoError(t, err) - }) -} - -func setupIntegration() (*State, Flowkit) { - readerWriter, _ := tests.ReaderWriter() - state, err := Init(readerWriter, crypto.ECDSA_P256, crypto.SHA3_256) - if err != nil { - panic(err) - } - - acc, _ := state.EmulatorServiceAccount() - pk, _ := acc.Key.PrivateKey() - gw := gateway.NewEmulatorGatewayWithOpts(&gateway.EmulatorKey{ - PublicKey: (*pk).PublicKey(), - SigAlgo: acc.Key.SigAlgo(), - HashAlgo: acc.Key.HashAlgo(), - }, gateway.WithEmulatorOptions( - emulator.WithTransactionExpiry(10), - )) - - flowkit := Flowkit{ - state: state, - network: config.EmulatorNetwork, - gateway: gw, - logger: output.NewStdoutLogger(output.NoneLog), - } - - return state, flowkit -} - -func TestAccountsCreate_Integration(t *testing.T) { - type accountsIn struct { - account *accounts.Account - pubKeys []crypto.PublicKey - weights []int - sigAlgo []crypto.SignatureAlgorithm - hashAlgo []crypto.HashAlgorithm - } - - type accountsOut struct { - address string - code map[string][]byte - balance uint64 - pubKeys []crypto.PublicKey - weights []int - } - - t.Run("Create", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - accIn := []accountsIn{{ - account: srvAcc, - sigAlgo: []crypto.SignatureAlgorithm{ - tests.SigAlgos()[0], - }, - hashAlgo: []crypto.HashAlgorithm{ - tests.HashAlgos()[0], - }, - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - }, - weights: []int{flow.AccountKeyWeightThreshold}, - }, { - account: srvAcc, - sigAlgo: []crypto.SignatureAlgorithm{ - tests.SigAlgos()[0], - tests.SigAlgos()[1], - }, - hashAlgo: []crypto.HashAlgorithm{ - tests.HashAlgos()[0], - tests.HashAlgos()[1], - }, - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - tests.PubKeys()[1], - }, - weights: []int{500, 500}, - }, { - account: srvAcc, - sigAlgo: []crypto.SignatureAlgorithm{ - tests.SigAlgos()[0], - }, - hashAlgo: []crypto.HashAlgorithm{ - tests.HashAlgos()[0], - }, - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - }, - weights: []int{flow.AccountKeyWeightThreshold}, - }} - - accOut := []accountsOut{{ - address: "01cf0e2f2f715450", - balance: uint64(100000), - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - }, - weights: []int{flow.AccountKeyWeightThreshold}, - }, { - address: "179b6b1cb6755e31", - balance: uint64(100000), - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - tests.PubKeys()[1], - }, - weights: []int{500, 500}, - }, { - address: "f3fcd2c1a78f5eee", - balance: uint64(100000), - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - }, - weights: []int{flow.AccountKeyWeightThreshold}, - }} - - for i, a := range accIn { - keys := make([]accounts.PublicKey, 0) - for j := range a.pubKeys { - keys = append(keys, accounts.PublicKey{ - Public: a.pubKeys[j], - Weight: a.weights[j], - SigAlgo: a.sigAlgo[j], - HashAlgo: a.hashAlgo[j], - }) - } - - acc, ID, err := flowkit.CreateAccount(ctx, a.account, keys) - c := accOut[i] - - assert.NoError(t, err) - assert.NotNil(t, acc) - assert.NotNil(t, ID) - assert.Equal(t, acc.Address.String(), c.address) - assert.Equal(t, acc.Balance, c.balance) - assert.Len(t, acc.Keys, len(c.pubKeys)) - - for x, k := range acc.Keys { - assert.Equal(t, k.PublicKey, a.pubKeys[x]) - assert.Equal(t, k.Weight, c.weights[x]) - assert.Equal(t, k.SigAlgo, a.sigAlgo[x]) - assert.Equal(t, k.HashAlgo, a.hashAlgo[x]) - } - - } - }) - - t.Run("Create Invalid", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - errOut := []string{ - "invalid account key: signing algorithm (UNKNOWN) and hashing algorithm (SHA3_256) are not a valid pair for a Flow account key", - "invalid account key: signing algorithm (UNKNOWN) and hashing algorithm (UNKNOWN) are not a valid pair for a Flow account key", - } - - accIn := []accountsIn{ - { - account: srvAcc, - sigAlgo: []crypto.SignatureAlgorithm{crypto.UnknownSignatureAlgorithm}, - hashAlgo: []crypto.HashAlgorithm{crypto.SHA3_256}, - pubKeys: []crypto.PublicKey{tests.PubKeys()[0]}, - weights: []int{1000}, - }, { - account: srvAcc, - sigAlgo: []crypto.SignatureAlgorithm{crypto.UnknownSignatureAlgorithm}, - hashAlgo: []crypto.HashAlgorithm{crypto.UnknownHashAlgorithm}, - pubKeys: []crypto.PublicKey{tests.PubKeys()[0]}, - weights: []int{1000}, - }, - /*{ - TODO(sideninja): uncomment this test case after https://github.com/onflow/flow-go-sdk/pull/199 is released - account: srvAcc, - sigAlgo: crypto.ECDSA_P256, - hashAlgo: crypto.SHA3_256, - args: nil, - pubKeys: []crypto.PublicKey{ - tests.PubKeys()[0], - }, - weights: []int{-1}, - }*/ - } - - for i, a := range accIn { - keys := make([]accounts.PublicKey, 0) - for i := range a.pubKeys { - keys = append(keys, accounts.PublicKey{ - Public: a.pubKeys[i], - Weight: a.weights[i], - SigAlgo: a.sigAlgo[i], - HashAlgo: a.hashAlgo[i], - }) - } - acc, ID, err := flowkit.CreateAccount(ctx, a.account, keys) - errMsg := errOut[i] - - assert.Nil(t, acc) - assert.Equal(t, flow.EmptyID, ID) - assert.Error(t, err) - assert.Equal(t, errMsg, err.Error()) - } - }) -} - -func TestAccountsAddContract_Integration(t *testing.T) { - t.Run("Update Contract", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - ID, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - require.NoError(t, err) - require.NotNil(t, ID) - - acc, err := flowkit.GetAccount(ctx, srvAcc.Address) - require.NoError(t, err) - require.NotNil(t, acc) - assert.Equal(t, acc.Contracts["Simple"], tests.ContractSimple.Source) - - ID, _, err = flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimpleUpdated), - UpdateExistingContract(true), - ) - require.NoError(t, err) - - acc, err = flowkit.GetAccount(ctx, srvAcc.Address) - require.NoError(t, err) - assert.Equal(t, acc.Contracts["Simple"], tests.ContractSimpleUpdated.Source) - - contract, err := state.Contracts().ByName(tests.ContractSimpleUpdated.Name) - require.NoError(t, err) - require.NotNil(t, contract) - - deployments := state.Deployments().ByAccountAndNetwork(srvAcc.Name, "emulator") - require.NotNil(t, deployments) - }) - - t.Run("Add Contract Invalid Same Content", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // prepare existing contract - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - _, _, err = flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - - require.Error(t, err) - assert.EqualError(t, err, "contract already exists and is the same as the contract provided for update") - }) - - t.Run("Add Contract Invalid Same Content", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // prepare existing contract - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - updated := tests.ContractSimple - updated.Source = []byte(`pub contract Simple { init() {} }`) - _, _, err = flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(updated), - UpdateExistingContract(false), - ) - - require.Error(t, err) - assert.EqualError(t, err, "contract Simple exists in account emulator-account") - }) - - t.Run("Contract is Added to State", func(t *testing.T) { - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - c, _ := state.Contracts().ByName(tests.ContractSimple.Name) - assert.Nil(t, c) - - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - c, _ = state.Contracts().ByName(tests.ContractSimple.Name) - assert.NotNil(t, c) - }) - - t.Run("Add Contract No Overwrite", func(t *testing.T) { - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // Add a contract to state with an alias - contractAliased := config.Contract{ - Name: tests.ContractSimple.Name, - Aliases: []config.Alias{{ - Network: config.EmulatorNetwork.Name, - Address: Donald().Address, - }}, - } - - state.Contracts().AddOrUpdate(contractAliased) - c, _ := state.Contracts().ByName(tests.ContractSimple.Name) - assert.Equal(t, Donald().Address, c.Aliases[0].Address) - - // Deploy contract to emulator account insted of Donald alias - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimple), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - // Check contracts state still has Donald alias - c, _ = state.Contracts().ByName(tests.ContractSimple.Name) - assert.Equal(t, Donald().Address, c.Aliases[0].Address) - }) -} - -func TestAccountsAddContractWithArgs(t *testing.T) { - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // adding contract without argument should return an error - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractSimpleWithArgs), - UpdateExistingContract(false), - ) - assert.Error(t, err) - assert.True(t, strings.Contains(err.Error(), "invalid argument count, too few arguments: expected 1, got 0")) - - c := resourceToContract(tests.ContractSimpleWithArgs) - c.Args = []cadence.Value{cadence.UInt64(4)} - - _, _, err = flowkit.AddContract(ctx, srvAcc, c, UpdateExistingContract(false)) - assert.NoError(t, err) - - acc, err := flowkit.GetAccount(ctx, srvAcc.Address) - require.NoError(t, err) - assert.NotNil(t, acc) - assert.Equal(t, acc.Contracts["Simple"], tests.ContractSimpleWithArgs.Source) -} - -func TestAccountsRemoveContract_Integration(t *testing.T) { - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - c := tests.ContractSimple - // prepare existing contract - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - Script{ - Code: c.Source, - Location: c.Filename, - }, - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - t.Run("Remove Contract", func(t *testing.T) { - _, err := flowkit.RemoveContract(ctx, srvAcc, tests.ContractSimple.Name) - require.NoError(t, err) - - acc, err := flowkit.GetAccount(ctx, srvAcc.Address) - require.NoError(t, err) - assert.Equal(t, acc.Contracts[tests.ContractSimple.Name], []byte(nil)) - }) - - t.Run("Remove Contract", func(t *testing.T) { - _, err := flowkit.RemoveContract(ctx, srvAcc, "invalid") - require.True(t, strings.Contains(err.Error(), "can not remove a non-existing contract named 'invalid'")) - }) -} - -func TestAccountsGet_Integration(t *testing.T) { - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - t.Run("Get Account", func(t *testing.T) { - t.Parallel() - acc, err := flowkit.GetAccount(ctx, srvAcc.Address) - - assert.NoError(t, err) - assert.NotNil(t, acc) - assert.Equal(t, acc.Address, srvAcc.Address) - }) - - t.Run("Get Account Invalid", func(t *testing.T) { - t.Parallel() - - acc, err := flowkit.GetAccount(ctx, flow.HexToAddress("0x1")) - assert.Nil(t, acc) - assert.Equal(t, err.Error(), "could not find account with address 0000000000000001") - }) -} - -func TestBlocks(t *testing.T) { - t.Run("Get Latest Block", func(t *testing.T) { - t.Parallel() - - _, flowkit, gw := setup() - - _, err := flowkit.GetBlock(ctx, BlockQuery{Latest: true}) - - gw.Mock.AssertCalled(t, mocks.GetLatestBlockFunc) - gw.Mock.AssertNotCalled(t, mocks.GetBlockByHeightFunc) - gw.Mock.AssertNotCalled(t, mocks.GetBlockByIDFunc) - assert.NoError(t, err) - }) - - t.Run("Get Block by Height", func(t *testing.T) { - t.Parallel() - - _, flowkit, gw := setup() - - block := tests.NewBlock() - block.Height = 10 - gw.GetBlockByHeight.Return(block, nil) - - _, err := flowkit.GetBlock(ctx, BlockQuery{Height: 10}) - - gw.Mock.AssertCalled(t, mocks.GetBlockByHeightFunc, uint64(10)) - gw.Mock.AssertNotCalled(t, mocks.GetLatestBlockFunc) - gw.Mock.AssertNotCalled(t, mocks.GetBlockByIDFunc) - assert.NoError(t, err) - }) - - t.Run("Get Block by ID", func(t *testing.T) { - t.Parallel() - _, flowkit, gw := setup() - - ID := flow.HexToID("a310685082f0b09f2a148b2e8905f08ea458ed873596b53b200699e8e1f6536f") - _, err := flowkit.GetBlock(ctx, BlockQuery{ID: &ID}) - - assert.NoError(t, err) - gw.Mock.AssertCalled(t, mocks.GetBlockByIDFunc, ID) - gw.Mock.AssertNotCalled(t, mocks.GetBlockByHeightFunc) - gw.Mock.AssertNotCalled(t, mocks.GetLatestBlockFunc) - }) -} - -func TestBlocksGet_Integration(t *testing.T) { - t.Run("Get Block", func(t *testing.T) { - t.Parallel() - _, flowkit := setupIntegration() - - block, err := flowkit.GetBlock(ctx, BlockQuery{Latest: true}) - - assert.NoError(t, err) - assert.Equal(t, block.Height, uint64(0)) - assert.Equal(t, block.ID.String(), "03d40910037d575d52831647b39814f445bc8cc7ba8653286c0eb1473778c34f") - }) -} - -func TestCollections(t *testing.T) { - t.Run("Get Collection", func(t *testing.T) { - _, flowkit, gw := setup() - ID := flow.HexToID("a310685082f0b09f2a148b2e8905f08ea458ed873596b53b200699e8e1f6536f") - - _, err := flowkit.GetCollection(ctx, ID) - - assert.NoError(t, err) - gw.Mock.AssertCalled(t, "GetCollection", ID) - }) -} - -func TestEvents(t *testing.T) { - t.Run("Get Events", func(t *testing.T) { - t.Parallel() - - _, flowkit, gw := setup() - _, err := flowkit.GetEvents(ctx, []string{"flow.CreateAccount"}, 0, 0, nil) - - assert.NoError(t, err) - gw.Mock.AssertCalled(t, mocks.GetEventsFunc, "flow.CreateAccount", uint64(0), uint64(0)) - }) - - t.Run("Should have larger endHeight then startHeight", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - _, err := flowkit.GetEvents(ctx, []string{"flow.CreateAccount"}, 10, 0, nil) - assert.EqualError(t, err, "cannot have end height (0) of block range less that start height (10)") - }) - - t.Run("Test create queries", func(t *testing.T) { - names := []string{"first", "second"} - queries := makeEventQueries(names, 0, 400, 250) - expected := []grpc.EventRangeQuery{ - {Type: "first", StartHeight: 0, EndHeight: 249}, - {Type: "second", StartHeight: 0, EndHeight: 249}, - {Type: "first", StartHeight: 250, EndHeight: 400}, - {Type: "second", StartHeight: 250, EndHeight: 400}, - } - assert.Equal(t, expected, queries) - }) - - t.Run("Should handle error from get events in goroutine", func(t *testing.T) { - t.Parallel() - - _, flowkit, gw := setup() - - gw.GetEvents.Return([]flow.BlockEvents{}, errors.New("failed getting event")) - - _, err := flowkit.GetEvents(ctx, []string{"flow.CreateAccount"}, 0, 1, nil) - - assert.EqualError(t, err, "failed getting event") - }) -} - -func TestEvents_Integration(t *testing.T) { - t.Run("Get Events for non existent event", func(t *testing.T) { - t.Parallel() - - _, flowkit := setupIntegration() - - events, err := flowkit.GetEvents(ctx, []string{"nonexisting"}, 0, 0, nil) - assert.NoError(t, err) - assert.Len(t, events, 1) - assert.Len(t, events[0].Events, 0) - }) - - t.Run("Get Events while adding contracts", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // create events - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractEvents), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - assert.NoError(t, err) - for x := 'A'; x <= 'J'; x++ { // test contract emits events named from A to J - eName := fmt.Sprintf("A.%s.ContractEvents.Event%c", srvAcc.Address.String(), x) - events, err := flowkit.GetEvents(ctx, []string{eName}, 0, 1, nil) - assert.NoError(t, err) - assert.Len(t, events, 2) - assert.Len(t, events[1].Events, 1) - - } - }) - - t.Run("Get Events while adding contracts in parallel", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // create events - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractEvents), - UpdateExistingContract(false), - ) - assert.NoError(t, err) - - assert.NoError(t, err) - var eventNames []string - for x := 'A'; x <= 'J'; x++ { // test contract emits events named from A to J - eName := fmt.Sprintf("A.%s.ContractEvents.Event%c", srvAcc.Address.String(), x) - eventNames = append(eventNames, eName) - } - - events, err := flowkit.GetEvents(ctx, eventNames, 0, 1, &EventWorker{ - Count: 5, - BlocksPerWorker: 250, - }) - assert.NoError(t, err) - assert.Len(t, events, 20) - assert.Len(t, events[1].Events, 1) - }) -} - -func TestKeys(t *testing.T) { - t.Run("Generate Keys", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - key, err := flowkit.GenerateKey(ctx, crypto.ECDSA_P256, "") - assert.NoError(t, err) - assert.Equal(t, len(key.String()), 66) - }) - - t.Run("Generate Keys with seed", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - key, err := flowkit.GenerateKey(ctx, crypto.ECDSA_P256, "aaaaaaaaaaaaaaaaaaaaaaannndddddd_its_gone") - - assert.NoError(t, err) - assert.Equal(t, "0x28350fff13e68ed3887ddc564df737db0a590c02cf4d3928eb30eb79f51672c2", key.String()) - }) - - t.Run("Test Vector SLIP-0010", func(t *testing.T) { - // test against SLIP-0010 test vector. All data are taken from: - // https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vectors - t.Parallel() - _, flowkit, _ := setup() - - type testEntry struct { - sigAlgo crypto.SignatureAlgorithm - seed string - path string - privateKey string - } - - testVector := []testEntry{{ - sigAlgo: crypto.ECDSA_secp256k1, - seed: "000102030405060708090a0b0c0d0e0f", - path: "m/0'/1/2'/2/1000000000", - privateKey: "0x471b76e389e528d6de6d816857e012c5455051cad6660850e58372a6c3e6e7c8", - }, { - sigAlgo: crypto.ECDSA_P256, - seed: "000102030405060708090a0b0c0d0e0f", - path: "m/0'/1/2'/2/1000000000", - privateKey: "0x21c4f269ef0a5fd1badf47eeacebeeaa3de22eb8e5b0adcd0f27dd99d34d0119", - }, { - sigAlgo: crypto.ECDSA_secp256k1, - seed: "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542", - path: "m/0/2147483647'/1/2147483646'/2", - privateKey: "0xbb7d39bdb83ecf58f2fd82b6d918341cbef428661ef01ab97c28a4842125ac23", - }, { - sigAlgo: crypto.ECDSA_P256, - seed: "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542", - path: "m/0/2147483647'/1/2147483646'/2", - privateKey: "0xbb0a77ba01cc31d77205d51d08bd313b979a71ef4de9b062f8958297e746bd67", - }} - - for _, test := range testVector { - seed, err := hex.DecodeString(test.seed) - assert.NoError(t, err) - // use derivePrivateKeyFromSeed to test instead of DerivePrivateKeyFromMnemonic - // because the test vector provides seeds, while it's not possible to derive mnemonics - // corresponding to seeds. - privateKey, err := flowkit.derivePrivateKeyFromSeed(seed, test.sigAlgo, test.path) - assert.NoError(t, err) - assert.Equal(t, test.privateKey, privateKey.String()) - } - }) - - t.Run("Generate Keys with mnemonic (default path)", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - key, err := flowkit.DerivePrivateKeyFromMnemonic(ctx, "normal dune pole key case cradle unfold require tornado mercy hospital buyer", crypto.ECDSA_P256, "") - - assert.NoError(t, err) - assert.Equal(t, key.String(), "0x638dc9ad0eee91d09249f0fd7c5323a11600e20d5b9105b66b782a96236e74cf") - }) - - // https://github.com/onflow/ledger-app-flow/blob/dc61213a9c3d73152b78b7391d04165d07f1ad89/tests_speculos/test-basic-show-address-expert.js#L28 - t.Run("Generate Keys with mnemonic (custom path - Ledger)", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - // ledger test mnemonic: https://github.com/onflow/ledger-app-flow#using-a-real-device-for-integration-tests-nano-s-and-nano-s-plus - key, err := flowkit.DerivePrivateKeyFromMnemonic(ctx, "equip will roof matter pink blind book anxiety banner elbow sun young", crypto.ECDSA_secp256k1, "m/44'/539'/513'/0/0") - - assert.NoError(t, err) - assert.Equal(t, key.String(), "0xd18d051afca7150781fef111f3387d132d31c4a6250268db0f61f836a205e0b8") - - assert.Equal(t, hex.EncodeToString(key.PublicKey().Encode()), "d7482bbaff7827035d5b238df318b10604673dc613808723efbd23fbc4b9fad34a415828d924ec7b83ac0eddf22ef115b7c203ee39fb080572d7e51775ee54be") - }) - - t.Run("Generate mnemonic key", func(t *testing.T) { - _, flowkit, _ := setup() - - pkey, path, err := flowkit.GenerateMnemonicKey(context.Background(), crypto.ECDSA_P256, "") - assert.NoError(t, err) - assert.NotNil(t, pkey) - assert.NotNil(t, path) - }) - - t.Run("Generate Keys Invalid", func(t *testing.T) { - t.Parallel() - - _, flowkit, _ := setup() - inputs := []map[string]crypto.SignatureAlgorithm{ - {"im_short": crypto.ECDSA_P256}, - {"": crypto.StringToSignatureAlgorithm("JUSTNO")}, - } - - errs := []string{ - "failed to generate private key: crypto: insufficient seed length 8, must be at least 32 bytes for ECDSA_P256", - "failed to generate private key: key generation failed: the signature scheme UNKNOWN is not supported", - } - - for x, in := range inputs { - for k, v := range in { - _, err := flowkit.GenerateKey(ctx, v, k) - assert.Equal(t, err.Error(), errs[x]) - x++ - } - } - }) -} - -func TestProject(t *testing.T) { - t.Run("Deploy Project", func(t *testing.T) { - t.Parallel() - - state, flowkit, gw := setup() - - c := config.Contract{ - Name: "Hello", - Location: tests.ContractHelloString.Filename, - } - state.Contracts().AddOrUpdate(c) - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - acct2 := Donald() - state.Accounts().AddOrUpdate(acct2) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: acct2.Name, - Contracts: []config.ContractDeployment{{ - Name: c.Name, - Args: nil, - }}, - } - state.Deployments().AddOrUpdate(d) - - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, acct2.Address) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.add")) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - contracts, err := flowkit.DeployProject(ctx, UpdateExistingContract(false)) - - assert.NoError(t, err) - assert.Equal(t, len(contracts), 1) - assert.Equal(t, contracts[0].AccountAddress, acct2.Address) - }) - - t.Run("Deploy Project Using LocationAliases", func(t *testing.T) { - t.Parallel() - - state, flowkit, gw := setup() - - c1 := config.Contract{ - Name: "ContractB", - Location: tests.ContractB.Filename, - } - state.Contracts().AddOrUpdate(c1) - - c2 := config.Contract{ - Name: "Aliased", - Location: tests.ContractA.Filename, - Aliases: []config.Alias{{ - Network: config.EmulatorNetwork.Name, - Address: Donald().Address, - }}, - } - state.Contracts().AddOrUpdate(c2) - - c3 := config.Contract{ - Name: "ContractC", - Location: tests.ContractC.Filename, - } - state.Contracts().AddOrUpdate(c3) - - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - a := Alice() - state.Accounts().AddOrUpdate(a) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: a.Name, - Contracts: []config.ContractDeployment{ - {Name: c1.Name}, {Name: c3.Name}, - }, - } - state.Deployments().AddOrUpdate(d) - - // for checking imports are correctly resolved - resolved := map[string]string{ - tests.ContractB.Name: fmt.Sprintf(`import ContractA from 0x%s`, Donald().Address.Hex()), - tests.ContractC.Name: fmt.Sprintf(` - import ContractB from 0x%s - import ContractA from 0x%s`, a.Address.Hex(), Donald().Address.Hex()), - } // don't change formatting of the above code since it compares the strings with included formatting - - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, a.Address) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.add")) - - argCode := tx.Arguments[1] - decodeCode, _ := jsoncdc.Decode(nil, argCode) - code := decodeCode.ToGoValue().(string) - - argName := tx.Arguments[0] - decodeName, _ := jsoncdc.Decode(nil, argName) - - testCode, found := resolved[decodeName.ToGoValue().(string)] - require.True(t, found) - assert.True(t, strings.Contains(string(code), testCode)) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - contracts, err := flowkit.DeployProject(ctx, UpdateExistingContract(false)) - - assert.NoError(t, err) - assert.Equal(t, len(contracts), 2) - gw.Mock.AssertCalled(t, mocks.GetLatestBlockFunc) - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, a.Address) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 2) - }) - - t.Run("Deploy Project New Import Schema and LocationAliases", func(t *testing.T) { - t.Parallel() - - state, flowkit, gw := setup() - - c1 := config.Contract{ - Name: "ContractBB", - Location: tests.ContractBB.Filename, - } - state.Contracts().AddOrUpdate(c1) - - c2 := config.Contract{ - Name: "ContractAA", - Location: tests.ContractAA.Filename, - Aliases: []config.Alias{{ - Network: config.EmulatorNetwork.Name, - Address: Donald().Address, - }}, - } - state.Contracts().AddOrUpdate(c2) - - c3 := config.Contract{ - Name: "ContractCC", - Location: tests.ContractCC.Filename, - } - state.Contracts().AddOrUpdate(c3) - - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - a := Alice() - state.Accounts().AddOrUpdate(a) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: a.Name, - Contracts: []config.ContractDeployment{ - {Name: c1.Name}, {Name: c3.Name}, - }, - } - state.Deployments().AddOrUpdate(d) - - // for checking imports are correctly resolved - resolved := map[string]string{ - tests.ContractB.Name: fmt.Sprintf(`import ContractAA from 0x%s`, Donald().Address.Hex()), - tests.ContractC.Name: fmt.Sprintf(` - import ContractBB from 0x%s - import ContractAA from 0x%s`, a.Address.Hex(), Donald().Address.Hex()), - } // don't change formatting of the above code since it compares the strings with included formatting - - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, a.Address) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.add")) - - argCode := tx.Arguments[1] - decodeCode, _ := jsoncdc.Decode(nil, argCode) - code, _ := decodeCode.ToGoValue().(string) - - argName := tx.Arguments[0] - decodeName, _ := jsoncdc.Decode(nil, argName) - - testCode, found := resolved[decodeName.ToGoValue().(string)] - require.True(t, found) - assert.True(t, strings.Contains(string(code), testCode)) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - contracts, err := flowkit.DeployProject(ctx, UpdateExistingContract(false)) - - assert.NoError(t, err) - assert.Equal(t, len(contracts), 2) - gw.Mock.AssertCalled(t, mocks.GetLatestBlockFunc) - gw.Mock.AssertCalled(t, mocks.GetAccountFunc, a.Address) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 2) - }) - - t.Run("Deploy Project Duplicate Address", func(t *testing.T) { - t.Parallel() - - state, flowkit, gw := setup() - - c := config.Contract{ - Name: "Hello", - Location: tests.ContractHelloString.Filename, - } - state.Contracts().AddOrUpdate(c) - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - acct1 := Charlie() - state.Accounts().AddOrUpdate(acct1) - - acct2 := Donald() - state.Accounts().AddOrUpdate(acct2) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: acct2.Name, - Contracts: []config.ContractDeployment{{ - Name: c.Name, - Args: nil, - }}, - } - state.Deployments().AddOrUpdate(d) - - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - assert.Equal(t, tx.Payer, acct2.Address) - assert.True(t, strings.Contains(string(tx.Script), "signer.contracts.add")) - - gw.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - contracts, err := flowkit.DeployProject(ctx, UpdateExistingContract(false)) - - assert.NoError(t, err) - assert.Equal(t, len(contracts), 1) - assert.Equal(t, contracts[0].AccountAddress, acct2.Address) - }) -} - -// used for integration tests -func simpleDeploy(state *State, flowkit Flowkit, update bool) ([]*project.Contract, error) { - srvAcc, _ := state.EmulatorServiceAccount() - - c := config.Contract{ - Name: tests.ContractHelloString.Name, - Location: tests.ContractHelloString.Filename, - } - state.Contracts().AddOrUpdate(c) - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: srvAcc.Name, - Contracts: []config.ContractDeployment{{ - Name: c.Name, - Args: nil, - }}, - } - state.Deployments().AddOrUpdate(d) - - return flowkit.DeployProject(ctx, UpdateExistingContract(update)) -} - -func TestProject_Integration(t *testing.T) { - t.Run("Deploy Project", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - contracts, err := simpleDeploy(state, flowkit, false) - assert.NoError(t, err) - assert.Len(t, contracts, 1) - assert.Equal(t, contracts[0].Name, tests.ContractHelloString.Name) - assert.Equal(t, string(contracts[0].Code()), string(tests.ContractHelloString.Source)) - }) - - t.Run("Deploy Complex Project", func(t *testing.T) { - t.Parallel() - - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - contractFixtures := []tests.Resource{ - tests.ContractB, tests.ContractC, - } - - testContracts := make([]config.Contract, len(contractFixtures)) - for i, c := range contractFixtures { - testContracts[i] = config.Contract{ - Name: c.Name, - Location: c.Filename, - } - state.Contracts().AddOrUpdate(testContracts[i]) - } - - cA := tests.ContractA - state.Contracts().AddOrUpdate(config.Contract{ - Name: cA.Name, - Location: cA.Filename, - Aliases: []config.Alias{{ - Network: config.EmulatorNetwork.Name, - Address: srvAcc.Address, - }}, - }) - - state.Deployments().AddOrUpdate(config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: srvAcc.Name, - Contracts: []config.ContractDeployment{{ - Name: testContracts[0].Name, - Args: nil, - }, { - Name: testContracts[1].Name, - Args: []cadence.Value{ - cadence.String("foo"), - }, - }}, - }) - - // deploy contract imported as alias - _, _, err := flowkit.AddContract( - ctx, - srvAcc, - Script{ - Code: tests.ContractA.Source, - Location: tests.ContractA.Filename, - }, - UpdateExistingContract(false), - ) - require.NoError(t, err) - - // replace imports manually to assert that replacing worked in deploy service - addr := fmt.Sprintf("0x%s", srvAcc.Address) - replacedContracts := make([]string, len(contractFixtures)) - for i, c := range contractFixtures { - replacedContracts[i] = strings.ReplaceAll(string(c.Source), `"./contractA.cdc"`, addr) - replacedContracts[i] = strings.ReplaceAll(replacedContracts[i], `"./contractB.cdc"`, addr) - } - - contracts, err := flowkit.DeployProject(ctx, UpdateExistingContract(false)) - assert.NoError(t, err) - assert.Len(t, contracts, 3) - - account, err := flowkit.GetAccount(ctx, srvAcc.Address) - - for i, c := range testContracts { - code, exists := account.Contracts[c.Name] - assert.True(t, exists) - assert.Equal(t, replacedContracts[i], string(code)) - } - }) - - t.Run("Deploy Project Update", func(t *testing.T) { - t.Parallel() - - // setup - state, flowkit := setupIntegration() - _, err := simpleDeploy(state, flowkit, false) - assert.NoError(t, err) - - _, err = simpleDeploy(state, flowkit, true) - assert.NoError(t, err) - }) -} - -func TestScripts(t *testing.T) { - t.Run("Execute Script", func(t *testing.T) { - _, flowkit, gw := setup() - - gw.ExecuteScript.Run(func(args mock.Arguments) { - assert.Len(t, string(args.Get(0).([]byte)), 78) - assert.Equal(t, "\"Foo\"", args.Get(1).([]cadence.Value)[0].String()) - gw.ExecuteScript.Return(cadence.MustConvertValue(""), nil) - }) - - args := []cadence.Value{cadence.String("Foo")} - _, err := flowkit.ExecuteScript( - ctx, - Script{ - Code: tests.ScriptArgString.Source, - Args: args, - }, - LatestScriptQuery, - ) - - assert.NoError(t, err) - }) -} - -func TestScripts_Integration(t *testing.T) { - t.Run("Execute", func(t *testing.T) { - t.Parallel() - _, flowkit := setupIntegration() - - args := []cadence.Value{cadence.String("Foo")} - res, err := flowkit.ExecuteScript( - ctx, - Script{ - Code: tests.ScriptArgString.Source, - Args: args, - }, - LatestScriptQuery, - ) - - assert.NoError(t, err) - assert.Equal(t, "\"Hello Foo\"", res.String()) - }) - - t.Run("Execute report error", func(t *testing.T) { - t.Parallel() - _, flowkit := setupIntegration() - args := []cadence.Value{cadence.String("Foo")} - res, err := flowkit.ExecuteScript( - ctx, - Script{ - Code: tests.ScriptWithError.Source, - Args: args, - }, - LatestScriptQuery, - ) - - assert.Error(t, err) - assert.Contains(t, err.Error(), "cannot find type in this scope") - assert.Nil(t, res) - }) - - t.Run("Execute With Imports", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - srvAcc, _ := state.EmulatorServiceAccount() - - // setup - c := config.Contract{ - Name: tests.ContractHelloString.Name, - Location: tests.ContractHelloString.Filename, - } - state.Contracts().AddOrUpdate(c) - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: srvAcc.Name, - Contracts: []config.ContractDeployment{{ - Name: c.Name, - Args: nil, - }}, - } - state.Deployments().AddOrUpdate(d) - _, _, _ = flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractHelloString), - UpdateExistingContract(false), - ) - - res, err := flowkit.ExecuteScript( - ctx, - Script{ - Code: tests.ScriptImport.Source, - Location: tests.ScriptImport.Filename, - }, - LatestScriptQuery, - ) - assert.NoError(t, err) - assert.Equal(t, res.String(), "\"Hello Hello, World!\"") - }) - - t.Run("Execute Script Invalid", func(t *testing.T) { - t.Parallel() - _, flowkit := setupIntegration() - in := []string{"", tests.ScriptImport.Filename} - - out := []string{ - "resolving imports in scripts not supported", - "import ./contractHello.cdc could not be resolved from provided contracts", - } - - for x, i := range in { - _, err := flowkit.ExecuteScript( - ctx, - Script{ - Code: tests.ScriptImport.Source, - Location: i, - }, - LatestScriptQuery, - ) - assert.NotNil(t, err) - assert.Equal(t, err.Error(), out[x]) - } - }) -} - -const gasLimit = 1000 - -func TestTransactions(t *testing.T) { - state, _, _ := setup() - serviceAcc, _ := state.EmulatorServiceAccount() - serviceAddress := serviceAcc.Address - - t.Run("Get Transaction", func(t *testing.T) { - t.Parallel() - _, flowkit, gw := setup() - txs := tests.NewTransaction() - - _, _, err := flowkit.GetTransactionByID(ctx, txs.ID(), true) - - assert.NoError(t, err) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 1) - gw.Mock.AssertCalled(t, mocks.GetTransactionFunc, txs.ID()) - }) - - t.Run("Send Transaction args", func(t *testing.T) { - t.Parallel() - _, flowkit, gw := setup() - - var txID flow.Identifier - gw.SendSignedTransaction.Run(func(args mock.Arguments) { - tx := args.Get(0).(*flow.Transaction) - arg, err := tx.Argument(0) - assert.NoError(t, err) - assert.Equal(t, "\"Bar\"", arg.String()) - assert.Equal(t, serviceAddress, tx.Payer) - assert.Len(t, string(tx.Script), 227) - - t := tests.NewTransaction() - txID = t.ID() - gw.SendSignedTransaction.Return(t, nil) - }) - - gw.GetTransactionResult.Run(func(args mock.Arguments) { - assert.Equal(t, txID, args.Get(0).(flow.Identifier)) - gw.GetTransactionResult.Return(tests.NewTransactionResult(nil), nil) - }) - - _, _, err := flowkit.SendTransaction( - ctx, - transactions.SingleAccountRole(*serviceAcc), - Script{ - Code: tests.TransactionArgString.Source, - Args: []cadence.Value{cadence.String("Bar")}, - }, - gasLimit, - ) - - assert.NoError(t, err) - gw.Mock.AssertNumberOfCalls(t, mocks.SendSignedTransactionFunc, 1) - gw.Mock.AssertNumberOfCalls(t, mocks.GetTransactionResultFunc, 1) - }) -} - -func setupAccounts(state *State, flowkit Flowkit) { - setupAccount(state, flowkit, Alice()) - setupAccount(state, flowkit, Bob()) - setupAccount(state, flowkit, Charlie()) -} - -func setupAccount(state *State, flowkit Flowkit, account *accounts.Account) { - srv, _ := state.EmulatorServiceAccount() - - key := account.Key - pk, _ := key.PrivateKey() - acc, _, _ := flowkit.CreateAccount( - ctx, - srv, - []accounts.PublicKey{{ - (*pk).PublicKey(), - flow.AccountKeyWeightThreshold, - key.SigAlgo(), - key.HashAlgo(), - }}, - ) - - state.Accounts().AddOrUpdate(&accounts.Account{ - Name: account.Name, - Address: acc.Address, - Key: key, - }) -} - -func Test_TransactionRoles(t *testing.T) { - t.Run("Building Signers", func(t *testing.T) { - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - a, _ := state.Accounts().ByName("Alice") - b, _ := state.Accounts().ByName("Bob") - c, _ := state.Accounts().ByName("Charlie") - - // we make copies with diffrerent names but same addresses for testing building signers, - // since if same addresses are present that's should be treated as same account - aCopy1 := *a - aCopy2 := *a - aCopy1.Name = "Boo" - aCopy2.Name = "Zoo" - - testVector := []struct { - *transactions.AccountRoles - signerAddresses []flow.Address - }{{ - AccountRoles: &transactions.AccountRoles{ - Proposer: *a, - Authorizers: []accounts.Account{*b}, - Payer: *c, - }, - signerAddresses: []flow.Address{ - a.Address, - b.Address, - c.Address, - }, - }, { - AccountRoles: &transactions.AccountRoles{ - Proposer: *a, - Authorizers: []accounts.Account{*a}, - Payer: *a, - }, - signerAddresses: []flow.Address{ - a.Address, - }, - }, { - AccountRoles: &transactions.AccountRoles{ - Proposer: *a, - Payer: *b, - Authorizers: []accounts.Account{*a}, - }, - signerAddresses: []flow.Address{ - a.Address, b.Address, - }, - }, { - AccountRoles: &transactions.AccountRoles{ - Proposer: *a, - Payer: *a, - }, - signerAddresses: []flow.Address{ - a.Address, - }, - }, { - AccountRoles: &transactions.AccountRoles{ - Proposer: aCopy1, - Payer: aCopy2, - Authorizers: []accounts.Account{*a}, - }, - signerAddresses: []flow.Address{ - a.Address, - }, - }} - - for i, test := range testVector { - signerAccs := test.Signers() - signerAddrs := make([]flow.Address, len(signerAccs)) - for i, sig := range signerAccs { - signerAddrs[i] = sig.Address - } - - assert.Equal(t, test.signerAddresses, signerAddrs, fmt.Sprintf("test %d failed", i)) - } - }) - - t.Run("Building Addresses", func(t *testing.T) { - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - a, _ := state.Accounts().ByName("Alice") - b, _ := state.Accounts().ByName("Bob") - c, _ := state.Accounts().ByName("Charlie") - - roles := &transactions.AccountRoles{ - Proposer: *a, - Authorizers: []accounts.Account{*b, *c}, - Payer: *c, - } - - addresses := roles.AddressRoles() - - assert.Equal(t, a.Address, addresses.Proposer) - assert.Equal(t, c.Address, addresses.Payer) - assert.Equal(t, []flow.Address{b.Address, c.Address}, addresses.Authorizers) - }) -} - -func TestTransactions_Integration(t *testing.T) { - t.Run("Build Transaction", func(t *testing.T) { - t.Parallel() - state, f := setupIntegration() - setupAccounts(state, f) - - type txIn struct { - prop flow.Address - auth []flow.Address - payer flow.Address - index int - code []byte - file string - gas uint64 - args []cadence.Value - network string - yes bool - } - - a, _ := state.Accounts().ByName("Alice") - b, _ := state.Accounts().ByName("Bob") - c, _ := state.Accounts().ByName("Charlie") - - txIns := []txIn{{ - a.Address, - []flow.Address{a.Address}, - a.Address, - 0, - tests.TransactionSimple.Source, - tests.TransactionSimple.Filename, - flow.DefaultTransactionGasLimit, - nil, - "", - true, - }, { - c.Address, - []flow.Address{a.Address, b.Address}, - c.Address, - 0, - tests.TransactionSimple.Source, - tests.TransactionSimple.Filename, - flow.DefaultTransactionGasLimit, - nil, - "", - true, - }} - - for i, txIn := range txIns { - tx, err := f.BuildTransaction( - ctx, - transactions.AddressesRoles{ - Proposer: txIn.prop, - Authorizers: txIn.auth, - Payer: txIn.payer, - }, - txIn.index, - Script{txIn.code, txIn.args, txIn.file}, - txIn.gas, - ) - - require.NoError(t, err, fmt.Sprintf("test vector %d", i)) - ftx := tx.FlowTransaction() - assert.Equal(t, ftx.Script, txIn.code) - assert.Equal(t, ftx.Payer, txIn.payer) - assert.Equal(t, len(ftx.Authorizers), 0) // make sure authorizers weren't added as tx input doesn't require them - assert.Equal(t, ftx.ProposalKey.Address, txIn.prop) - assert.Equal(t, ftx.ProposalKey.KeyIndex, txIn.index) - } - }) - - t.Run("Build Transaction with Imports", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - srvAcc, _ := state.EmulatorServiceAccount() - signer := srvAcc.Address - - // setup - c := config.Contract{ - Name: tests.ContractHelloString.Name, - Location: tests.ContractHelloString.Filename, - } - state.Contracts().AddOrUpdate(c) - state.Networks().AddOrUpdate(config.EmulatorNetwork) - - d := config.Deployment{ - Network: config.EmulatorNetwork.Name, - Account: srvAcc.Name, - Contracts: []config.ContractDeployment{{ - Name: c.Name, - Args: nil, - }}, - } - state.Deployments().AddOrUpdate(d) - _, _, _ = flowkit.AddContract( - ctx, - srvAcc, - resourceToContract(tests.ContractHelloString), - UpdateExistingContract(false), - ) - - tx, err := flowkit.BuildTransaction( - ctx, - transactions.AddressesRoles{ - signer, - []flow.Address{signer}, - signer, - }, - srvAcc.Key.Index(), - Script{ - Code: tests.TransactionImports.Source, - Location: tests.TransactionImports.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - - assert.NoError(t, err) - ftx := tx.FlowTransaction() - assert.Equal(t, - string(ftx.Script), - strings.ReplaceAll( - string(tests.TransactionImports.Source), - "import Hello from \"./contractHello.cdc\"", - fmt.Sprintf("import Hello from 0x%s", srvAcc.Address), - ), - ) - }) - - t.Run("Sign transaction", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, err := flowkit.BuildTransaction( - ctx, - transactions.AddressesRoles{ - a.Address, - nil, - a.Address, - }, - 0, - Script{ - Code: tests.TransactionSimple.Source, - Location: tests.TransactionSimple.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - - assert.Nil(t, err) - assert.NotNil(t, tx) - - txSigned, err := flowkit.SignTransactionPayload( - ctx, - a, - []byte(fmt.Sprintf("%x", tx.FlowTransaction().Encode())), - ) - assert.Nil(t, err) - assert.NotNil(t, txSigned) - assert.Equal(t, len(txSigned.FlowTransaction().Authorizers), 0) - assert.Equal(t, txSigned.FlowTransaction().Payer, a.Address) - assert.Equal(t, txSigned.FlowTransaction().ProposalKey.Address, a.Address) - assert.Equal(t, txSigned.FlowTransaction().ProposalKey.KeyIndex, 0) - assert.Equal(t, txSigned.FlowTransaction().Script, tests.TransactionSimple.Source) - }) - - t.Run("Build, Sign and Send Transaction", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, err := flowkit.BuildTransaction( - ctx, - transactions.AddressesRoles{ - a.Address, - []flow.Address{a.Address}, - a.Address, - }, - 0, - Script{ - Code: tests.TransactionSingleAuth.Source, - Location: tests.TransactionSingleAuth.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - - assert.Nil(t, err) - assert.NotNil(t, tx) - - txSigned, err := flowkit.SignTransactionPayload( - ctx, - a, - []byte(fmt.Sprintf("%x", tx.FlowTransaction().Encode())), - ) - assert.Nil(t, err) - assert.NotNil(t, txSigned) - - txSent, txResult, err := flowkit.SendSignedTransaction(ctx, txSigned) - assert.Nil(t, err) - assert.Equal(t, txResult.Status, flow.TransactionStatusSealed) - assert.NotNil(t, txSent.ID()) - }) - - t.Run("Fails signing transaction, wrong account", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, err := flowkit.BuildTransaction( - ctx, - transactions.AddressesRoles{ - a.Address, - []flow.Address{a.Address}, - a.Address, - }, - 0, - Script{ - Code: tests.TransactionSingleAuth.Source, - Location: tests.TransactionSingleAuth.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - - assert.Nil(t, err) - assert.NotNil(t, tx) - - // sign with wrong account - a, _ = state.Accounts().ByName("Bob") - - txSigned, err := flowkit.SignTransactionPayload( - ctx, - a, - []byte(fmt.Sprintf("%x", tx.FlowTransaction().Encode())), - ) - assert.EqualError(t, err, "not a valid signer 179b6b1cb6755e31, proposer: 01cf0e2f2f715450, payer: 01cf0e2f2f715450, authorizers: [01cf0e2f2f715450]") - assert.Nil(t, txSigned) - }) - - t.Run("Fails building, authorizers mismatch", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, err := flowkit.BuildTransaction( - ctx, - transactions.AddressesRoles{ - Proposer: a.Address, - Authorizers: []flow.Address{a.Address}, - Payer: a.Address, - }, - 0, - Script{Code: tests.TransactionTwoAuth.Source, Location: tests.TransactionTwoAuth.Filename}, - flow.DefaultTransactionGasLimit, - ) - - assert.EqualError(t, err, "provided authorizers length mismatch, required authorizers 2, but provided 1") - assert.Nil(t, tx) - }) - - // TODO(sideninja) we should convert different variations of sending transaction to table tests - - t.Run("Send Transaction No Auths", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.AccountRoles{ - Proposer: *a, - Payer: *a, - }, - Script{ - Code: tests.TransactionSimple.Source, - Location: tests.TransactionSimple.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), a.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) - - t.Run("Send Transaction With Auths", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.SingleAccountRole(*a), - Script{ - Code: tests.TransactionSingleAuth.Source, - Location: tests.TransactionSingleAuth.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), a.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) - - t.Run("Send Transaction multiple account roles", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - b, _ := state.Accounts().ByName("Bob") - c, _ := state.Accounts().ByName("Charlie") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.AccountRoles{ - Proposer: *a, - Authorizers: []accounts.Account{*c}, - Payer: *b, - }, - Script{ - Code: tests.TransactionSingleAuth.Source, - Location: tests.TransactionSingleAuth.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), b.Address.String()) - assert.Equal(t, tx.Authorizers[0].String(), c.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) - - t.Run("Send Transaction two account roles", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - b, _ := state.Accounts().ByName("Bob") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.AccountRoles{ - Proposer: *a, - Authorizers: []accounts.Account{*a}, - Payer: *b, - }, - Script{ - Code: tests.TransactionSingleAuth.Source, - Location: tests.TransactionSingleAuth.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), b.Address.String()) - assert.Equal(t, tx.Authorizers[0].String(), a.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) - - t.Run("Send Transaction with arguments", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.SingleAccountRole(*a), - Script{ - Code: tests.TransactionArgString.Source, - Args: []cadence.Value{ - cadence.String("Bar"), - }, - Location: tests.TransactionArgString.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), a.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Equal(t, fmt.Sprintf("%x", tx.Arguments), "[7b2276616c7565223a22426172222c2274797065223a22537472696e67227d]") - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) - - t.Run("Send transaction with multiple func declaration", func(t *testing.T) { - t.Parallel() - state, flowkit := setupIntegration() - setupAccounts(state, flowkit) - - a, _ := state.Accounts().ByName("Alice") - - tx, txr, err := flowkit.SendTransaction( - ctx, - transactions.SingleAccountRole(*a), - Script{ - Code: tests.TransactionMultipleDeclarations.Source, - Location: tests.TransactionMultipleDeclarations.Filename, - }, - flow.DefaultTransactionGasLimit, - ) - assert.NoError(t, err) - assert.Equal(t, tx.Payer.String(), a.Address.String()) - assert.Equal(t, tx.ProposalKey.KeyIndex, a.Key.Index()) - assert.Nil(t, txr.Error) - assert.Equal(t, txr.Status, flow.TransactionStatusSealed) - }) -} - -func Test_BlockQuery(t *testing.T) { - q, err := NewBlockQuery("latest") - assert.True(t, q.Latest) - assert.NoError(t, err) - - q, err = NewBlockQuery("100") - assert.Equal(t, uint64(100), q.Height) - assert.NoError(t, err) - - id := flow.HexToID("cba22b8c0830d0c86f83a187911a8a82ebd17e8dd95e5212ede0f8e5e2d4a908") - q, err = NewBlockQuery(id.String()) - assert.Equal(t, id, *q.ID) - assert.NoError(t, err) - - _, err = NewBlockQuery("invalid") - assert.EqualError(t, err, "invalid query: invalid, valid are: \"latest\", block height or block ID") -} diff --git a/flowkit/gateway/emulator.go b/flowkit/gateway/emulator.go deleted file mode 100644 index 7e6b0bbe1..000000000 --- a/flowkit/gateway/emulator.go +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gateway - -import ( - "context" - "fmt" - - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/runtime" - "github.com/onflow/flow-emulator/adapters" - "github.com/onflow/flow-emulator/emulator" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - flowGo "github.com/onflow/flow-go/model/flow" - "github.com/rs/zerolog" - "google.golang.org/grpc/status" -) - -type EmulatorKey struct { - PublicKey crypto.PublicKey - SigAlgo crypto.SignatureAlgorithm - HashAlgo crypto.HashAlgorithm -} - -type EmulatorGateway struct { - emulator *emulator.Blockchain - adapter *adapters.SDKAdapter - accessAdapter *adapters.AccessAdapter - ctx context.Context - logger *zerolog.Logger - emulatorOptions []emulator.Option -} - -func UnwrapStatusError(err error) error { - return fmt.Errorf(status.Convert(err).Message()) -} - -func NewEmulatorGateway(key *EmulatorKey) *EmulatorGateway { - return NewEmulatorGatewayWithOpts(key) -} - -func NewEmulatorGatewayWithOpts(key *EmulatorKey, opts ...func(*EmulatorGateway)) *EmulatorGateway { - noopLogger := zerolog.Nop() - gateway := &EmulatorGateway{ - ctx: context.Background(), - logger: &noopLogger, - emulatorOptions: []emulator.Option{}, - } - for _, opt := range opts { - opt(gateway) - } - - gateway.emulator = newEmulator(key, gateway.emulatorOptions...) - gateway.adapter = adapters.NewSDKAdapter(gateway.logger, gateway.emulator) - gateway.accessAdapter = adapters.NewAccessAdapter(gateway.logger, gateway.emulator) - gateway.emulator.EnableAutoMine() - return gateway -} - -func WithLogger(logger *zerolog.Logger) func(g *EmulatorGateway) { - return func(g *EmulatorGateway) { - g.logger = logger - } -} - -func WithEmulatorOptions(options ...emulator.Option) func(g *EmulatorGateway) { - return func(g *EmulatorGateway) { - g.emulatorOptions = append(g.emulatorOptions, options...) - } -} - -func (g *EmulatorGateway) SetContext(ctx context.Context) { - g.ctx = ctx -} - -func newEmulator(key *EmulatorKey, emulatorOptions ...emulator.Option) *emulator.Blockchain { - var opts []emulator.Option - - if key != nil { - opts = append(opts, emulator.WithServicePublicKey(key.PublicKey, key.SigAlgo, key.HashAlgo)) - } - - opts = append(opts, emulatorOptions...) - - b, err := emulator.New(opts...) - if err != nil { - panic(err) - } - - return b -} - -func (g *EmulatorGateway) GetAccount(address flow.Address) (*flow.Account, error) { - account, err := g.adapter.GetAccount(g.ctx, address) - if err != nil { - return nil, UnwrapStatusError(err) - } - return account, nil -} - -func (g *EmulatorGateway) SendSignedTransaction(tx *flow.Transaction) (*flow.Transaction, error) { - err := g.adapter.SendTransaction(context.Background(), *tx) - if err != nil { - return nil, UnwrapStatusError(err) - } - return tx, nil -} - -func (g *EmulatorGateway) GetTransactionResult(ID flow.Identifier, _ bool) (*flow.TransactionResult, error) { - result, err := g.adapter.GetTransactionResult(g.ctx, ID) - if err != nil { - return nil, UnwrapStatusError(err) - } - return result, nil -} - -func (g *EmulatorGateway) GetTransaction(id flow.Identifier) (*flow.Transaction, error) { - transaction, err := g.adapter.GetTransaction(g.ctx, id) - if err != nil { - return nil, UnwrapStatusError(err) - } - return transaction, nil -} - -func (g *EmulatorGateway) GetTransactionResultsByBlockID(id flow.Identifier) ([]*flow.TransactionResult, error) { - txr, err := g.adapter.GetTransactionResultsByBlockID(g.ctx, id) - if err != nil { - return nil, UnwrapStatusError(err) - } - return txr, nil -} - -func (g *EmulatorGateway) GetTransactionsByBlockID(id flow.Identifier) ([]*flow.Transaction, error) { - txr, err := g.adapter.GetTransactionsByBlockID(g.ctx, id) - if err != nil { - return nil, UnwrapStatusError(err) - } - return txr, nil -} - -func (g *EmulatorGateway) Ping() error { - err := g.adapter.Ping(g.ctx) - if err != nil { - return UnwrapStatusError(err) - } - return nil -} - -type scriptQuery struct { - id flow.Identifier - height uint64 - latest bool -} - -func (g *EmulatorGateway) executeScriptQuery( - script []byte, - arguments []cadence.Value, - query scriptQuery, -) (cadence.Value, error) { - args, err := cadenceValuesToMessages(arguments) - if err != nil { - return nil, UnwrapStatusError(err) - } - - var result []byte - if query.id != flow.EmptyID { - result, err = g.adapter.ExecuteScriptAtBlockID(g.ctx, query.id, script, args) - } else if query.height > 0 { - result, err = g.adapter.ExecuteScriptAtBlockHeight(g.ctx, query.height, script, args) - } else { - result, err = g.adapter.ExecuteScriptAtLatestBlock(g.ctx, script, args) - } - - if err != nil { - return nil, UnwrapStatusError(err) - } - - value, err := messageToCadenceValue(result) - if err != nil { - return nil, UnwrapStatusError(err) - } - - return value, nil -} - -func (g *EmulatorGateway) ExecuteScript( - script []byte, - arguments []cadence.Value, -) (cadence.Value, error) { - return g.executeScriptQuery(script, arguments, scriptQuery{latest: true}) -} - -func (g *EmulatorGateway) ExecuteScriptAtHeight( - script []byte, - arguments []cadence.Value, - height uint64, -) (cadence.Value, error) { - return g.executeScriptQuery(script, arguments, scriptQuery{height: height}) -} - -func (g *EmulatorGateway) ExecuteScriptAtID( - script []byte, - arguments []cadence.Value, - id flow.Identifier, -) (cadence.Value, error) { - return g.executeScriptQuery(script, arguments, scriptQuery{id: id}) -} - -func (g *EmulatorGateway) GetLatestBlock() (*flow.Block, error) { - block, _, err := g.adapter.GetLatestBlock(g.ctx, true) - if err != nil { - return nil, UnwrapStatusError(err) - } - - return block, nil -} - -func cadenceValuesToMessages(values []cadence.Value) ([][]byte, error) { - msgs := make([][]byte, len(values)) - for i, val := range values { - msg, err := jsoncdc.Encode(val) - if err != nil { - return nil, fmt.Errorf("convert: %w", err) - } - msgs[i] = msg - } - return msgs, nil -} - -func messageToCadenceValue(m []byte) (cadence.Value, error) { - v, err := jsoncdc.Decode(nil, m) - if err != nil { - return nil, fmt.Errorf("convert: %w", err) - } - - return v, nil -} - -func convertBlock(block *flowGo.Block) *flow.Block { - return &flow.Block{ - BlockHeader: flow.BlockHeader{ - ID: flow.Identifier(block.Header.ID()), - ParentID: flow.Identifier(block.Header.ParentID), - Height: block.Header.Height, - Timestamp: block.Header.Timestamp, - }, - BlockPayload: flow.BlockPayload{ - CollectionGuarantees: nil, - Seals: nil, - }, - } -} - -func (g *EmulatorGateway) GetEvents( - eventType string, - startHeight uint64, - endHeight uint64, -) ([]flow.BlockEvents, error) { - events := make([]flow.BlockEvents, 0) - - for height := startHeight; height <= endHeight; height++ { - events = append(events, g.getBlockEvent(height, eventType)) - } - - return events, nil -} - -func (g *EmulatorGateway) getBlockEvent(height uint64, eventType string) flow.BlockEvents { - events, _ := g.adapter.GetEventsForHeightRange(g.ctx, eventType, height, height) - return *events[0] -} - -func (g *EmulatorGateway) GetCollection(id flow.Identifier) (*flow.Collection, error) { - collection, err := g.adapter.GetCollectionByID(g.ctx, id) - if err != nil { - return nil, UnwrapStatusError(err) - } - return collection, nil -} - -func (g *EmulatorGateway) GetBlockByID(id flow.Identifier) (*flow.Block, error) { - block, _, err := g.adapter.GetBlockByID(g.ctx, id) - if err != nil { - return nil, UnwrapStatusError(err) - } - return block, nil -} - -func (g *EmulatorGateway) GetBlockByHeight(height uint64) (*flow.Block, error) { - block, _, err := g.adapter.GetBlockByHeight(g.ctx, height) - if err != nil { - return nil, UnwrapStatusError(err) - } - return block, nil -} - -func (g *EmulatorGateway) GetLatestProtocolStateSnapshot() ([]byte, error) { - snapshot, err := g.adapter.GetLatestProtocolStateSnapshot(g.ctx) - if err != nil { - return nil, UnwrapStatusError(err) - } - return snapshot, nil -} - -// SecureConnection placeholder func to complete gateway interface implementation -func (g *EmulatorGateway) SecureConnection() bool { - return false -} - -func (g *EmulatorGateway) CoverageReport() *runtime.CoverageReport { - return g.emulator.CoverageReport() -} - -func (g *EmulatorGateway) RollbackToBlockHeight(height uint64) error { - return g.emulator.RollbackToBlockHeight(height) -} diff --git a/flowkit/gateway/gateway.go b/flowkit/gateway/gateway.go deleted file mode 100644 index 7703e5710..000000000 --- a/flowkit/gateway/gateway.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gateway - -import ( - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" -) - -//go:generate mockery --name=Gateway - -// Gateway describes blockchain access interface -type Gateway interface { - GetAccount(flow.Address) (*flow.Account, error) - SendSignedTransaction(*flow.Transaction) (*flow.Transaction, error) - GetTransaction(flow.Identifier) (*flow.Transaction, error) - GetTransactionResultsByBlockID(blockID flow.Identifier) ([]*flow.TransactionResult, error) - GetTransactionResult(flow.Identifier, bool) (*flow.TransactionResult, error) - GetTransactionsByBlockID(blockID flow.Identifier) ([]*flow.Transaction, error) - ExecuteScript([]byte, []cadence.Value) (cadence.Value, error) - ExecuteScriptAtHeight([]byte, []cadence.Value, uint64) (cadence.Value, error) - ExecuteScriptAtID([]byte, []cadence.Value, flow.Identifier) (cadence.Value, error) - GetLatestBlock() (*flow.Block, error) - GetBlockByHeight(uint64) (*flow.Block, error) - GetBlockByID(flow.Identifier) (*flow.Block, error) - GetEvents(string, uint64, uint64) ([]flow.BlockEvents, error) - GetCollection(flow.Identifier) (*flow.Collection, error) - GetLatestProtocolStateSnapshot() ([]byte, error) - Ping() error - SecureConnection() bool -} diff --git a/flowkit/gateway/grpc.go b/flowkit/gateway/grpc.go deleted file mode 100644 index e76704b77..000000000 --- a/flowkit/gateway/grpc.go +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gateway - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - grpcAccess "github.com/onflow/flow-go-sdk/access/grpc" - "github.com/onflow/flow-go/utils/grpcutils" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "github.com/onflow/flow-cli/flowkit/config" -) - -// maxGRPCMessageSize 60mb -const maxGRPCMessageSize = 1024 * 1024 * 60 - -// GrpcGateway is a gateway implementation that uses the Flow Access gRPC API. -type GrpcGateway struct { - client *grpcAccess.Client - ctx context.Context - secureClient bool -} - -// NewGrpcGateway returns a new gRPC gateway. -func NewGrpcGateway(network config.Network) (*GrpcGateway, error) { - - gClient, err := grpcAccess.NewClient( - network.Host, - grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxGRPCMessageSize)), - ) - ctx := context.Background() - - if err != nil || gClient == nil { - return nil, fmt.Errorf("failed to connect to host %s", network.Host) - } - - return &GrpcGateway{ - client: gClient, - ctx: ctx, - secureClient: false, - }, nil -} - -// NewSecureGrpcGateway returns a new gRPC gateway with a secure client connection. -func NewSecureGrpcGateway(network config.Network) (*GrpcGateway, error) { - secureDialOpts, err := grpcutils.SecureGRPCDialOpt(strings.TrimPrefix(network.Key, "0x")) - if err != nil { - return nil, fmt.Errorf("failed to create secure GRPC dial options with network key \"%s\": %w", network.Key, err) - } - - gClient, err := grpcAccess.NewClient( - network.Host, - secureDialOpts, - grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxGRPCMessageSize)), - ) - ctx := context.Background() - - if err != nil || gClient == nil { - return nil, fmt.Errorf("failed to connect to host %s", network.Host) - } - - return &GrpcGateway{ - client: gClient, - ctx: ctx, - secureClient: true, - }, nil -} - -// GetAccount gets an account by address from the Flow Access API. -func (g *GrpcGateway) GetAccount(address flow.Address) (*flow.Account, error) { - account, err := g.client.GetAccountAtLatestBlock(g.ctx, address) - if err != nil { - return nil, fmt.Errorf("failed to get account with address %s: %w", address, err) - } - - return account, nil -} - -// SendSignedTransaction sends a transaction to flow that is already prepared and signed. -func (g *GrpcGateway) SendSignedTransaction(tx *flow.Transaction) (*flow.Transaction, error) { - err := g.client.SendTransaction(g.ctx, *tx) - if err != nil { - return nil, fmt.Errorf("failed to submit transaction: %w", err) - } - - return tx, nil -} - -// GetTransaction gets a transaction by ID from the Flow Access API. -func (g *GrpcGateway) GetTransaction(ID flow.Identifier) (*flow.Transaction, error) { - return g.client.GetTransaction(g.ctx, ID) -} - -func (g *GrpcGateway) GetTransactionResultsByBlockID(blockID flow.Identifier) ([]*flow.TransactionResult, error) { - return g.client.GetTransactionResultsByBlockID(g.ctx, blockID) -} - -func (g *GrpcGateway) GetTransactionsByBlockID(blockID flow.Identifier) ([]*flow.Transaction, error) { - return g.client.GetTransactionsByBlockID(g.ctx, blockID) -} - -// GetTransactionResult gets a transaction result by ID from the Flow Access API. -func (g *GrpcGateway) GetTransactionResult(ID flow.Identifier, waitSeal bool) (*flow.TransactionResult, error) { - result, err := g.client.GetTransactionResult(g.ctx, ID) - if err != nil { - return nil, err - } - - if result.Status != flow.TransactionStatusSealed && waitSeal { - time.Sleep(time.Second) - return g.GetTransactionResult(ID, waitSeal) - } - - return result, nil -} - -// ExecuteScript executes a script on Flow through the Access API. -func (g *GrpcGateway) ExecuteScript(script []byte, arguments []cadence.Value) (cadence.Value, error) { - return g.client.ExecuteScriptAtLatestBlock(g.ctx, script, arguments) -} - -// ExecuteScriptAtHeight executes a script at block height. -func (g *GrpcGateway) ExecuteScriptAtHeight(script []byte, arguments []cadence.Value, height uint64) (cadence.Value, error) { - return g.client.ExecuteScriptAtBlockHeight(g.ctx, height, script, arguments) -} - -// ExecuteScriptAtID executes a script at block ID. -func (g *GrpcGateway) ExecuteScriptAtID(script []byte, arguments []cadence.Value, ID flow.Identifier) (cadence.Value, error) { - return g.client.ExecuteScriptAtBlockID(g.ctx, ID, script, arguments) -} - -// GetLatestBlock gets the latest block on Flow through the Access API. -func (g *GrpcGateway) GetLatestBlock() (*flow.Block, error) { - return g.client.GetLatestBlock(g.ctx, true) -} - -// GetBlockByID get block by ID from the Flow Access API. -func (g *GrpcGateway) GetBlockByID(id flow.Identifier) (*flow.Block, error) { - return g.client.GetBlockByID(g.ctx, id) -} - -// GetBlockByHeight get block by height from the Flow Access API. -func (g *GrpcGateway) GetBlockByHeight(height uint64) (*flow.Block, error) { - return g.client.GetBlockByHeight(g.ctx, height) -} - -// GetEvents gets events by name and block range from the Flow Access API. -func (g *GrpcGateway) GetEvents( - eventType string, - startHeight uint64, - endHeight uint64, -) ([]flow.BlockEvents, error) { - - events, err := g.client.GetEventsForHeightRange( - g.ctx, - eventType, - startHeight, - endHeight, - ) - - return events, err -} - -// GetCollection gets a collection by ID from the Flow Access API. -func (g *GrpcGateway) GetCollection(id flow.Identifier) (*flow.Collection, error) { - return g.client.GetCollection(g.ctx, id) -} - -// GetLatestProtocolStateSnapshot gets the latest finalized protocol state snapshot -func (g *GrpcGateway) GetLatestProtocolStateSnapshot() ([]byte, error) { - return g.client.GetLatestProtocolStateSnapshot(g.ctx) -} - -// Ping is used to check if the access node is alive and healthy. -func (g *GrpcGateway) Ping() error { - return g.client.Ping(g.ctx) -} - -// SecureConnection is used to log warning if a service should be using a secure client but is not -func (g *GrpcGateway) SecureConnection() bool { - return g.secureClient -} diff --git a/flowkit/gateway/mocks/Gateway.go b/flowkit/gateway/mocks/Gateway.go deleted file mode 100644 index 73453438e..000000000 --- a/flowkit/gateway/mocks/Gateway.go +++ /dev/null @@ -1,515 +0,0 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. - -package mocks - -import ( - cadence "github.com/onflow/cadence" - flow "github.com/onflow/flow-go-sdk" - - mock "github.com/stretchr/testify/mock" -) - -// Gateway is an autogenerated mock type for the Gateway type -type Gateway struct { - mock.Mock -} - -// ExecuteScript provides a mock function with given fields: _a0, _a1 -func (_m *Gateway) ExecuteScript(_a0 []byte, _a1 []cadence.Value) (cadence.Value, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for ExecuteScript") - } - - var r0 cadence.Value - var r1 error - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value) (cadence.Value, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value) cadence.Value); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cadence.Value) - } - } - - if rf, ok := ret.Get(1).(func([]byte, []cadence.Value) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ExecuteScriptAtHeight provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Gateway) ExecuteScriptAtHeight(_a0 []byte, _a1 []cadence.Value, _a2 uint64) (cadence.Value, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for ExecuteScriptAtHeight") - } - - var r0 cadence.Value - var r1 error - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value, uint64) (cadence.Value, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value, uint64) cadence.Value); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cadence.Value) - } - } - - if rf, ok := ret.Get(1).(func([]byte, []cadence.Value, uint64) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ExecuteScriptAtID provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Gateway) ExecuteScriptAtID(_a0 []byte, _a1 []cadence.Value, _a2 flow.Identifier) (cadence.Value, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for ExecuteScriptAtID") - } - - var r0 cadence.Value - var r1 error - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value, flow.Identifier) (cadence.Value, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func([]byte, []cadence.Value, flow.Identifier) cadence.Value); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cadence.Value) - } - } - - if rf, ok := ret.Get(1).(func([]byte, []cadence.Value, flow.Identifier) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAccount provides a mock function with given fields: _a0 -func (_m *Gateway) GetAccount(_a0 flow.Address) (*flow.Account, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetAccount") - } - - var r0 *flow.Account - var r1 error - if rf, ok := ret.Get(0).(func(flow.Address) (*flow.Account, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(flow.Address) *flow.Account); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Account) - } - } - - if rf, ok := ret.Get(1).(func(flow.Address) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockByHeight provides a mock function with given fields: _a0 -func (_m *Gateway) GetBlockByHeight(_a0 uint64) (*flow.Block, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetBlockByHeight") - } - - var r0 *flow.Block - var r1 error - if rf, ok := ret.Get(0).(func(uint64) (*flow.Block, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(uint64) *flow.Block); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Block) - } - } - - if rf, ok := ret.Get(1).(func(uint64) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockByID provides a mock function with given fields: _a0 -func (_m *Gateway) GetBlockByID(_a0 flow.Identifier) (*flow.Block, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetBlockByID") - } - - var r0 *flow.Block - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier) (*flow.Block, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(flow.Identifier) *flow.Block); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Block) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetCollection provides a mock function with given fields: _a0 -func (_m *Gateway) GetCollection(_a0 flow.Identifier) (*flow.Collection, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetCollection") - } - - var r0 *flow.Collection - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier) (*flow.Collection, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(flow.Identifier) *flow.Collection); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Collection) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetEvents provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Gateway) GetEvents(_a0 string, _a1 uint64, _a2 uint64) ([]flow.BlockEvents, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for GetEvents") - } - - var r0 []flow.BlockEvents - var r1 error - if rf, ok := ret.Get(0).(func(string, uint64, uint64) ([]flow.BlockEvents, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(string, uint64, uint64) []flow.BlockEvents); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]flow.BlockEvents) - } - } - - if rf, ok := ret.Get(1).(func(string, uint64, uint64) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetLatestBlock provides a mock function with given fields: -func (_m *Gateway) GetLatestBlock() (*flow.Block, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetLatestBlock") - } - - var r0 *flow.Block - var r1 error - if rf, ok := ret.Get(0).(func() (*flow.Block, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() *flow.Block); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Block) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetLatestProtocolStateSnapshot provides a mock function with given fields: -func (_m *Gateway) GetLatestProtocolStateSnapshot() ([]byte, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetLatestProtocolStateSnapshot") - } - - var r0 []byte - var r1 error - if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransaction provides a mock function with given fields: _a0 -func (_m *Gateway) GetTransaction(_a0 flow.Identifier) (*flow.Transaction, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for GetTransaction") - } - - var r0 *flow.Transaction - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier) (*flow.Transaction, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(flow.Identifier) *flow.Transaction); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransactionResult provides a mock function with given fields: _a0, _a1 -func (_m *Gateway) GetTransactionResult(_a0 flow.Identifier, _a1 bool) (*flow.TransactionResult, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetTransactionResult") - } - - var r0 *flow.TransactionResult - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier, bool) (*flow.TransactionResult, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(flow.Identifier, bool) *flow.TransactionResult); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier, bool) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransactionResultsByBlockID provides a mock function with given fields: blockID -func (_m *Gateway) GetTransactionResultsByBlockID(blockID flow.Identifier) ([]*flow.TransactionResult, error) { - ret := _m.Called(blockID) - - if len(ret) == 0 { - panic("no return value specified for GetTransactionResultsByBlockID") - } - - var r0 []*flow.TransactionResult - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier) ([]*flow.TransactionResult, error)); ok { - return rf(blockID) - } - if rf, ok := ret.Get(0).(func(flow.Identifier) []*flow.TransactionResult); ok { - r0 = rf(blockID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier) error); ok { - r1 = rf(blockID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransactionsByBlockID provides a mock function with given fields: blockID -func (_m *Gateway) GetTransactionsByBlockID(blockID flow.Identifier) ([]*flow.Transaction, error) { - ret := _m.Called(blockID) - - if len(ret) == 0 { - panic("no return value specified for GetTransactionsByBlockID") - } - - var r0 []*flow.Transaction - var r1 error - if rf, ok := ret.Get(0).(func(flow.Identifier) ([]*flow.Transaction, error)); ok { - return rf(blockID) - } - if rf, ok := ret.Get(0).(func(flow.Identifier) []*flow.Transaction); ok { - r0 = rf(blockID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(flow.Identifier) error); ok { - r1 = rf(blockID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Ping provides a mock function with given fields: -func (_m *Gateway) Ping() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Ping") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SecureConnection provides a mock function with given fields: -func (_m *Gateway) SecureConnection() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for SecureConnection") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// SendSignedTransaction provides a mock function with given fields: _a0 -func (_m *Gateway) SendSignedTransaction(_a0 *flow.Transaction) (*flow.Transaction, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for SendSignedTransaction") - } - - var r0 *flow.Transaction - var r1 error - if rf, ok := ret.Get(0).(func(*flow.Transaction) (*flow.Transaction, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(*flow.Transaction) *flow.Transaction); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(*flow.Transaction) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewGateway creates a new instance of Gateway. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewGateway(t interface { - mock.TestingT - Cleanup(func()) -}) *Gateway { - mock := &Gateway{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/flowkit/gateway/mocks/gateway_mock.go b/flowkit/gateway/mocks/gateway_mock.go deleted file mode 100644 index cf847ffbc..000000000 --- a/flowkit/gateway/mocks/gateway_mock.go +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package mocks - -import ( - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/mock" - - "github.com/onflow/flow-cli/flowkit/tests" -) - -const ( - GetAccountFunc = "GetAccount" - SendSignedTransactionFunc = "SendSignedTransaction" - GetCollectionFunc = "GetCollection" - GetTransactionResultFunc = "GetTransactionResult" - GetEventsFunc = "GetEvents" - GetLatestBlockFunc = "GetLatestBlock" - GetBlockByHeightFunc = "GetBlockByHeight" - GetBlockByIDFunc = "GetBlockByID" - ExecuteScriptFunc = "ExecuteScript" - GetTransactionFunc = "GetTransaction" -) - -type TestGateway struct { - Mock *Gateway - SendSignedTransaction *mock.Call - GetAccount *mock.Call - GetCollection *mock.Call - GetTransactionResult *mock.Call - GetEvents *mock.Call - GetLatestBlock *mock.Call - GetBlockByHeight *mock.Call - GetBlockByID *mock.Call - ExecuteScript *mock.Call - GetTransaction *mock.Call - GetTransactionResultsByBlockID *mock.Call - GetTransactionsByBlockID *mock.Call - GetLatestProtocolStateSnapshot *mock.Call - Ping *mock.Call - SecureConnection *mock.Call -} - -func DefaultMockGateway() *TestGateway { - m := &Gateway{} - t := &TestGateway{ - Mock: m, - SendSignedTransaction: m.On( - SendSignedTransactionFunc, - mock.AnythingOfType("*flow.Transaction"), - ), - GetAccount: m.On( - GetAccountFunc, - mock.AnythingOfType("flow.Address"), - ), - GetCollection: m.On( - GetCollectionFunc, - mock.AnythingOfType("flow.Identifier"), - ), - GetTransactionResult: m.On( - GetTransactionResultFunc, - mock.AnythingOfType("flow.Identifier"), - mock.AnythingOfType("bool"), - ), - GetTransaction: m.On( - GetTransactionFunc, - mock.AnythingOfType("flow.Identifier"), - ), - GetEvents: m.On( - GetEventsFunc, - mock.AnythingOfType("string"), - mock.AnythingOfType("uint64"), - mock.AnythingOfType("uint64"), - ), - ExecuteScript: m.On( - ExecuteScriptFunc, - mock.AnythingOfType("[]uint8"), - mock.AnythingOfType("[]cadence.Value"), - ), - GetBlockByHeight: m.On(GetBlockByHeightFunc, mock.Anything), - GetBlockByID: m.On(GetBlockByIDFunc, mock.Anything), - GetLatestBlock: m.On(GetLatestBlockFunc), - } - - // default return values - t.SendSignedTransaction.Run(func(args mock.Arguments) { - t.SendSignedTransaction.Return(tests.NewTransaction(), nil) - }) - - t.GetAccount.Run(func(args mock.Arguments) { - addr := args.Get(0).(flow.Address) - t.GetAccount.Return(tests.NewAccountWithAddress(addr.String()), nil) - }) - - t.ExecuteScript.Run(func(args mock.Arguments) { - t.ExecuteScript.Return(cadence.MustConvertValue(""), nil) - }) - - t.GetTransaction.Return(tests.NewTransaction(), nil) - t.GetCollection.Return(tests.NewCollection(), nil) - t.GetTransactionResult.Return(tests.NewTransactionResult(nil), nil) - t.GetEvents.Return([]flow.BlockEvents{}, nil) - t.GetLatestBlock.Return(tests.NewBlock(), nil) - t.GetBlockByHeight.Return(tests.NewBlock(), nil) - t.GetBlockByID.Return(tests.NewBlock(), nil) - - return t -} diff --git a/flowkit/go.mod b/flowkit/go.mod deleted file mode 100644 index 859ef77d2..000000000 --- a/flowkit/go.mod +++ /dev/null @@ -1,207 +0,0 @@ -module github.com/onflow/flow-cli/flowkit - -go 1.20 - -require ( - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 - github.com/ethereum/go-ethereum v1.12.0 - github.com/gosuri/uilive v0.0.4 - github.com/invopop/jsonschema v0.7.0 - github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 - github.com/onflow/cadence v0.42.6 - github.com/onflow/flow-emulator v0.59.0 - github.com/onflow/flow-go v0.32.4-0.20231130134727-3c01c7f8966c - github.com/onflow/flow-go-sdk v0.41.17 - github.com/onflow/flow-go/crypto v0.24.9 - github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.29.0 - github.com/spf13/afero v1.9.4 - github.com/stretchr/testify v1.8.4 - github.com/thoas/go-funk v0.9.2 - github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 - gonum.org/v1/gonum v0.13.0 - google.golang.org/grpc v1.59.0 -) - -require ( - cloud.google.com/go/compute v1.23.0 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.1 // indirect - cloud.google.com/go/kms v1.15.0 // indirect - github.com/DataDog/zstd v1.5.2 // indirect - github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect - github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect - github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect - github.com/VictoriaMetrics/fastcache v1.6.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.7.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect - github.com/cenkalti/backoff/v4 v4.2.1 // indirect - github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e // indirect - github.com/cockroachdb/errors v1.9.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 // indirect - github.com/cockroachdb/redact v1.1.3 // indirect - github.com/coreos/go-semver v0.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect - github.com/deckarep/golang-set/v2 v2.1.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect - github.com/dgraph-io/ristretto v0.1.0 // indirect - github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/dustin/go-humanize v1.0.1 // indirect - github.com/ef-ds/deque v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect - github.com/fxamacker/circlehash v0.3.0 // indirect - github.com/getsentry/sentry-go v0.18.0 // indirect - github.com/glebarez/go-sqlite v1.21.1 // indirect - github.com/go-logr/logr v1.2.4 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-redis/redis/v8 v8.11.5 // indirect - github.com/go-stack/stack v1.8.1 // indirect - github.com/gofrs/flock v0.8.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.1.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect - github.com/googleapis/gax-go/v2 v2.11.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect - github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/holiman/bloomfilter/v2 v2.0.3 // indirect - github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect - github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/ipfs/bbloom v0.0.4 // indirect - github.com/ipfs/go-block-format v0.1.2 // indirect - github.com/ipfs/go-cid v0.4.1 // indirect - github.com/ipfs/go-datastore v0.6.0 // indirect - github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect - github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect - github.com/ipfs/go-ipfs-util v0.0.2 // indirect - github.com/ipfs/go-ipld-format v0.5.0 // indirect - github.com/ipfs/go-log v1.0.5 // indirect - github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/ipfs/go-metrics-interface v0.0.1 // indirect - github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect - github.com/jbenet/goprocess v0.1.4 // indirect - github.com/k0kubun/pp/v3 v3.2.0 // indirect - github.com/kevinburke/go-bindata v3.23.0+incompatible // indirect - github.com/klauspost/compress v1.16.5 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.28.1 // indirect - github.com/logrusorgru/aurora v2.0.3+incompatible // indirect - github.com/logrusorgru/aurora/v4 v4.0.0 // indirect - github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/mr-tron/base58 v1.2.0 // indirect - github.com/multiformats/go-base32 v0.1.0 // indirect - github.com/multiformats/go-base36 v0.2.0 // indirect - github.com/multiformats/go-multiaddr v0.9.0 // indirect - github.com/multiformats/go-multibase v0.2.0 // indirect - github.com/multiformats/go-multicodec v0.9.0 // indirect - github.com/multiformats/go-multihash v0.2.3 // indirect - github.com/multiformats/go-multistream v0.4.1 // indirect - github.com/multiformats/go-varint v0.0.7 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.6.0 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f // indirect - github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f // indirect - github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect - github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect - github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231124194313-106cc495def6 // indirect - github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect - github.com/onflow/sdks v0.5.0 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/pierrec/lz4 v2.6.1+incompatible // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.16.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect - github.com/psiemens/graceland v1.0.0 // indirect - github.com/psiemens/sconfig v0.1.0 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/sethvargo/go-retry v0.2.3 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect - github.com/slok/go-http-metrics v0.10.0 // indirect - github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/cast v1.5.0 // indirect - github.com/spf13/cobra v1.8.0 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.15.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect - github.com/subosito/gotenv v1.4.2 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect - github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect - github.com/tklauser/go-sysconf v0.3.9 // indirect - github.com/tklauser/numcpus v0.3.0 // indirect - github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d // indirect - github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v4 v4.3.11 // indirect - github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/x448/float16 v0.8.4 // indirect - github.com/zeebo/blake3 v0.2.3 // indirect - go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect - go.opentelemetry.io/otel/metric v1.16.0 // indirect - go.opentelemetry.io/otel/sdk v1.16.0 // indirect - go.opentelemetry.io/otel/trace v1.16.0 // indirect - go.opentelemetry.io/proto/otlp v0.19.0 // indirect - go.uber.org/atomic v1.11.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.126.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect - lukechampine.com/blake3 v1.2.1 // indirect - modernc.org/libc v1.22.3 // indirect - modernc.org/mathutil v1.5.0 // indirect - modernc.org/memory v1.5.0 // indirect - modernc.org/sqlite v1.21.1 // indirect -) diff --git a/flowkit/go.sum b/flowkit/go.sum deleted file mode 100644 index 263187cd6..000000000 --- a/flowkit/go.sum +++ /dev/null @@ -1,1475 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.110.7 h1:rJyC7nWRg2jWGZ4wSJ5nY65GTdYJkg0cd/uXb+ACI6o= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= -cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= -cloud.google.com/go/kms v1.0.0/go.mod h1:nhUehi+w7zht2XrUfvTRNpxrfayBHqP4lu2NSywui/0= -cloud.google.com/go/kms v1.15.0 h1:xYl5WEaSekKYN5gGRyhjvZKM22GVBBCzegGNVPy+aIs= -cloud.google.com/go/kms v1.15.0/go.mod h1:c9J991h5DTl+kg7gi3MYomh12YEENGrf48ee/N/2CDM= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= -github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc= -github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw= -github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc= -github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI= -github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VictoriaMetrics/fastcache v1.5.3/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE= -github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= -github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= -github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= -github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/bytecodealliance/wasmtime-go v0.22.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= -github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw= -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.0.1-0.20190104013014-3767db7a7e18/go.mod h1:HD5P3vAIAh+Y2GAxg0PrPN1P8WkepXGpjbUPDHJqqKM= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= -github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw= -github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 h1:T+Np/xtzIjYM/P5NAw0e2Rf1FGvzDau1h54MKvx8G7w= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7HpxfjgkzCGz6s= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= -github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= -github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= -github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/ef-ds/deque v1.0.4 h1:iFAZNmveMT9WERAkqLJ+oaABF9AcVQ5AjXem/hroniI= -github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= -github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/go-ethereum v1.9.9/go.mod h1:a9TqabFudpDu1nucId+k9S8R9whYaHnGBLKFouA5EAo= -github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= -github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/fxamacker/cbor/v2 v2.2.1-0.20210927235116-3d6d5d1de29b/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c h1:5tm/Wbs9d9r+qZaUFXk59CWDD0+77PBqDREffYkyi5c= -github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/fxamacker/circlehash v0.1.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= -github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= -github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= -github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= -github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= -github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= -github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY= -github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/golang-lru/v2 v2.0.2 h1:Dwmkdr5Nc/oBiXgJS3CDHNhJtIHkuZ3DZF5twqnfBdU= -github.com/hashicorp/golang-lru/v2 v2.0.2/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= -github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= -github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= -github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= -github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= -github.com/invopop/jsonschema v0.7.0 h1:2vgQcBz1n256N+FpX3Jq7Y17AjYt46Ig3zIWyy770So= -github.com/invopop/jsonschema v0.7.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= -github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= -github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= -github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo= -github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE= -github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= -github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= -github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= -github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk= -github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= -github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= -github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= -github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= -github.com/ipfs/go-ipfs-blockstore v1.3.0 h1:m2EXaWgwTzAfsmt5UdJ7Is6l4gJcaM/A12XwJyvYvMM= -github.com/ipfs/go-ipfs-blockstore v1.3.0/go.mod h1:KgtZyc9fq+P2xJUiCAzbRdhhqJHvsw8u2Dlqy2MyRTE= -github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= -github.com/ipfs/go-ipfs-ds-help v1.1.0 h1:yLE2w9RAsl31LtfMt91tRZcrx+e61O5mDxFRR994w4Q= -github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNot+rsOU/5IatU= -github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= -github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= -github.com/ipfs/go-ipld-format v0.5.0 h1:WyEle9K96MSrvr47zZHKKcDxJ/vlpET6PSiQsAFO+Ds= -github.com/ipfs/go-ipld-format v0.5.0/go.mod h1:ImdZqJQaEouMjCvqCe0ORUS+uoBmf7Hf+EO/jh+nk3M= -github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= -github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= -github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= -github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= -github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= -github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= -github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= -github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= -github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= -github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= -github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= -github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= -github.com/k0kubun/pp/v3 v3.2.0 h1:h33hNTZ9nVFNP3u2Fsgz8JXiF5JINoZfFq4SvKJwNcs= -github.com/k0kubun/pp/v3 v3.2.0/go.mod h1:ODtJQbQcIRfAD3N+theGCV1m/CBxweERz2dapdz1EwA= -github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= -github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= -github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= -github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= -github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= -github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= -github.com/kevinburke/go-bindata v3.23.0+incompatible h1:rqNOXZlqrYhMVVAsQx8wuc+LaA73YcfbQ407wAykyS8= -github.com/kevinburke/go-bindata v3.23.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= -github.com/libp2p/go-libp2p v0.28.1 h1:YurK+ZAI6cKfASLJBVFkpVBdl3wGhFi6fusOt725ii8= -github.com/libp2p/go-libp2p v0.28.1/go.mod h1:s3Xabc9LSwOcnv9UD4nORnXKTsWkPMkIMB/JIGXVnzk= -github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= -github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= -github.com/libp2p/go-libp2p-pubsub v0.9.3 h1:ihcz9oIBMaCK9kcx+yHWm3mLAFBMAUsM4ux42aikDxo= -github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= -github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ= -github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 h1:qFV7dBLhw5z4hka5gjtIzg1Kq9ie8t8P7Cy0uIxRyAQ= -github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12/go.mod h1:QIsK6U93yCP6TnGsShCv5wl4gcz/mpCHl+aToBsl5Sc= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= -github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/logrusorgru/aurora/v4 v4.0.0 h1:sRjfPpun/63iADiSvGGjgA1cAYegEWMPCJdUpJYn9JA= -github.com/logrusorgru/aurora/v4 v4.0.0/go.mod h1:lP0iIa2nrnT/qoFXcOZSrZQpJ1o6n2CUf/hyHi2Q4ZQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= -github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= -github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= -github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= -github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= -github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= -github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= -github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= -github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= -github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= -github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= -github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= -github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= -github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= -github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= -github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= -github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= -github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= -github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= -github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= -github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= -github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= -github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= -github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= -github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= -github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= -github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= -github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= -github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x071HgCF/0v5hQcaE5qqjc2UqN5gCU8h5Mk6uqpOg= -github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= -github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= -github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.42.6 h1:VtI0EpKrdbfqITRMsvyZC4dhgcW1x1LNUQuEpdMDzus= -github.com/onflow/cadence v0.42.6/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4= -github.com/onflow/flow-emulator v0.59.0 h1:KIfm9/+x62KqcZDjqE35fkuvVuY506OZ917xNtb3U6E= -github.com/onflow/flow-emulator v0.59.0/go.mod h1:Js1KKaXrui2yKKkXAlKTqmByRySis6/FH+vkGA6Kqu0= -github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0= -github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= -github.com/onflow/flow-go v0.32.4-0.20231130134727-3c01c7f8966c h1:75LED6hmarR0uazKZG8nkqqDlUiqz6NdzkdQQiGjvlI= -github.com/onflow/flow-go v0.32.4-0.20231130134727-3c01c7f8966c/go.mod h1:YJDAoDjbY4OWBj44XV+Qe+dIwn+hlywUDL5xclOOLbw= -github.com/onflow/flow-go-sdk v0.24.0/go.mod h1:IoptMLPyFXWvyd9yYA6/4EmSeeozl6nJoIv4FaEMg74= -github.com/onflow/flow-go-sdk v0.41.17 h1:HpNn3j2fqLGA6H3HGfAuh2A+TsPBv8gWO3kvK9Hvtic= -github.com/onflow/flow-go-sdk v0.41.17/go.mod h1:ZIj2XBI9R0QiKzbI6iPwOeqyIy/M4+atczoMOEWdKYw= -github.com/onflow/flow-go/crypto v0.21.3/go.mod h1:vI6V4CY3R6c4JKBxdcRiR/AnjBfL8OSD97bJc60cLuQ= -github.com/onflow/flow-go/crypto v0.24.9 h1:0EQp+kSZYJepMIiSypfJVe7tzsPcb6UXOdOtsTCDhBs= -github.com/onflow/flow-go/crypto v0.24.9/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7Q6u+bCI78lfNX0= -github.com/onflow/flow-nft/lib/go/contracts v1.1.0 h1:rhUDeD27jhLwOqQKI/23008CYfnqXErrJvc4EFRP2a0= -github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9jxdwoTuuhjK8WYWXTyLkIigZY= -github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231124194313-106cc495def6 h1:KMN+OEVaw7KAgxL3p8ux7CMuyTvacAlYTbasOqowh4M= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231124194313-106cc495def6/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= -github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead h1:2j1Unqs76Z1b95Gu4C3Y28hzNUHBix7wL490e61SMSw= -github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead/go.mod h1:E3ScfQb5XcWJCIAdtIeEnr5i5l2y60GT0BTXeIHseWg= -github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= -github.com/onflow/sdks v0.5.0/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= -github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsajnppVD1+zwuYPFyeDVFaQvg= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= -github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= -github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= -github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= -github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/psiemens/graceland v1.0.0 h1:L580AVV4Q2XLcPpmvxJRH9UpEAYr/eu2jBKmMglhvM8= -github.com/psiemens/graceland v1.0.0/go.mod h1:1Tof+vt1LbmcZFE0lzgdwMN0QBymAChG3FRgDx8XisU= -github.com/psiemens/sconfig v0.1.0 h1:xfWqW+TRpih7mXZIqKYTmpRhlZLQ1kbxV8EjllPv76s= -github.com/psiemens/sconfig v0.1.0/go.mod h1:+MLKqdledP/8G3rOBpknbLh0IclCf4WneJUtS26JB2U= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= -github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/robertkrimen/otto v0.0.0-20170205013659-6a77b7cbc37d/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= -github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= -github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko= -github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sethvargo/go-retry v0.2.3 h1:oYlgvIvsju3jNbottWABtbnoLC+GDtLdBHxKWxQm/iU= -github.com/sethvargo/go-retry v0.2.3/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/slok/go-http-metrics v0.10.0 h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM= -github.com/slok/go-http-metrics v0.10.0/go.mod h1:lFqdaS4kWMfUKCSukjC47PdCeTk+hXDUVm8kLHRqJ38= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.0.1-0.20190317074736-539464a789e9/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.9.4 h1:Sd43wM1IWz/s1aVXdOBkjJvuP8UdyqioeE4AmM0QsBs= -github.com/spf13/afero v1.9.4/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= -github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= -github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= -github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v0.0.0-20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= -github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/supranational/blst v0.3.4/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b h1:u49mjRnygnB34h8OKbnNJFVUtWSKIKb1KukdV8bILUM= -github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c h1:HelZ2kAFadG0La9d+4htN4HzQ68Bm2iM9qKMSMES6xg= -github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c/go.mod h1:JlzghshsemAMDGZLytTFY8C1JQxQPhnatWqNwUXjggo= -github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk= -github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= -github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= -github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= -github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d h1:5JInRQbk5UBX8JfUvKh2oYTLMVwj3p6n+wapDDm7hko= -github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d/go.mod h1:Nlx5Y115XQvNcIdIy7dZXaNSUpzwBSge4/Ivk93/Yog= -github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= -github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= -github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0cd26cZoE= -github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= -github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= -github.com/zeebo/blake3 v0.2.0/go.mod h1:G9pM4qQwjRzF1/v7+vabMj/c5mWpGZ2Wzo3Eb4z0pb4= -github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= -github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= -github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= -github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= -github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= -go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0/go.mod h1:vLarbg68dH2Wa77g71zmKQqlQ8+8Rq3GRG31uc0WcWI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 h1:cbsD4cUcviQGXdw8+bo5x2wazq10SKz8hEbtCRPcU78= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0/go.mod h1:JgXSGah17croqhJfhByOLVY719k1emAXC8MVhCIJlRs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 h1:ap+y8RXX3Mu9apKVtOkM6WSFESLM8K3wNQyOU8sWHcc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0/go.mod h1:5w41DY6S9gZrbjuq6Y+753e96WfPha5IcsOSZTtullM= -go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= -go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= -go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= -go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= -go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= -go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= -go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU= -golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200107162124-548cf772de50/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200828161849-5deb26317202/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.6.1/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= -gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= -gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= -google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= -google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211007155348-82e027067bd4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= -google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= -google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= -google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= -gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190213234257-ec84240a7772/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= -modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY= -modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw= -modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= -modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= -modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/sqlite v1.21.1 h1:GyDFqNnESLOhwwDRaHGdp2jKLDzpyT/rNLglX3ZkMSU= -modernc.org/sqlite v1.21.1/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI= -pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= -pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/flowkit/mocks/Services.go b/flowkit/mocks/Services.go deleted file mode 100644 index b63714420..000000000 --- a/flowkit/mocks/Services.go +++ /dev/null @@ -1,708 +0,0 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. - -package mocks - -import ( - cadence "github.com/onflow/cadence" - - accounts "github.com/onflow/flow-cli/flowkit/accounts" - - config "github.com/onflow/flow-cli/flowkit/config" - - context "context" - - crypto "github.com/onflow/flow-go/crypto" - - flow "github.com/onflow/flow-go-sdk" - - flowkit "github.com/onflow/flow-cli/flowkit" - - gateway "github.com/onflow/flow-cli/flowkit/gateway" - - mock "github.com/stretchr/testify/mock" - - output "github.com/onflow/flow-cli/flowkit/output" - - project "github.com/onflow/flow-cli/flowkit/project" - - transactions "github.com/onflow/flow-cli/flowkit/transactions" -) - -// Services is an autogenerated mock type for the Services type -type Services struct { - mock.Mock -} - -// AddContract provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *Services) AddContract(_a0 context.Context, _a1 *accounts.Account, _a2 flowkit.Script, _a3 flowkit.UpdateContract) (flow.Identifier, bool, error) { - ret := _m.Called(_a0, _a1, _a2, _a3) - - if len(ret) == 0 { - panic("no return value specified for AddContract") - } - - var r0 flow.Identifier - var r1 bool - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, flowkit.Script, flowkit.UpdateContract) (flow.Identifier, bool, error)); ok { - return rf(_a0, _a1, _a2, _a3) - } - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, flowkit.Script, flowkit.UpdateContract) flow.Identifier); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(flow.Identifier) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *accounts.Account, flowkit.Script, flowkit.UpdateContract) bool); ok { - r1 = rf(_a0, _a1, _a2, _a3) - } else { - r1 = ret.Get(1).(bool) - } - - if rf, ok := ret.Get(2).(func(context.Context, *accounts.Account, flowkit.Script, flowkit.UpdateContract) error); ok { - r2 = rf(_a0, _a1, _a2, _a3) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// BuildTransaction provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4 -func (_m *Services) BuildTransaction(_a0 context.Context, _a1 transactions.AddressesRoles, _a2 int, _a3 flowkit.Script, _a4 uint64) (*transactions.Transaction, error) { - ret := _m.Called(_a0, _a1, _a2, _a3, _a4) - - if len(ret) == 0 { - panic("no return value specified for BuildTransaction") - } - - var r0 *transactions.Transaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, transactions.AddressesRoles, int, flowkit.Script, uint64) (*transactions.Transaction, error)); ok { - return rf(_a0, _a1, _a2, _a3, _a4) - } - if rf, ok := ret.Get(0).(func(context.Context, transactions.AddressesRoles, int, flowkit.Script, uint64) *transactions.Transaction); ok { - r0 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*transactions.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, transactions.AddressesRoles, int, flowkit.Script, uint64) error); ok { - r1 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreateAccount provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) CreateAccount(_a0 context.Context, _a1 *accounts.Account, _a2 []accounts.PublicKey) (*flow.Account, flow.Identifier, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for CreateAccount") - } - - var r0 *flow.Account - var r1 flow.Identifier - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, []accounts.PublicKey) (*flow.Account, flow.Identifier, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, []accounts.PublicKey) *flow.Account); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Account) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *accounts.Account, []accounts.PublicKey) flow.Identifier); ok { - r1 = rf(_a0, _a1, _a2) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(flow.Identifier) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, *accounts.Account, []accounts.PublicKey) error); ok { - r2 = rf(_a0, _a1, _a2) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// DeployProject provides a mock function with given fields: _a0, _a1 -func (_m *Services) DeployProject(_a0 context.Context, _a1 flowkit.UpdateContract) ([]*project.Contract, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for DeployProject") - } - - var r0 []*project.Contract - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, flowkit.UpdateContract) ([]*project.Contract, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, flowkit.UpdateContract) []*project.Contract); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*project.Contract) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flowkit.UpdateContract) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// DerivePrivateKeyFromMnemonic provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *Services) DerivePrivateKeyFromMnemonic(_a0 context.Context, _a1 string, _a2 crypto.SigningAlgorithm, _a3 string) (crypto.PrivateKey, error) { - ret := _m.Called(_a0, _a1, _a2, _a3) - - if len(ret) == 0 { - panic("no return value specified for DerivePrivateKeyFromMnemonic") - } - - var r0 crypto.PrivateKey - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, crypto.SigningAlgorithm, string) (crypto.PrivateKey, error)); ok { - return rf(_a0, _a1, _a2, _a3) - } - if rf, ok := ret.Get(0).(func(context.Context, string, crypto.SigningAlgorithm, string) crypto.PrivateKey); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(crypto.PrivateKey) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, crypto.SigningAlgorithm, string) error); ok { - r1 = rf(_a0, _a1, _a2, _a3) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ExecuteScript provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) ExecuteScript(_a0 context.Context, _a1 flowkit.Script, _a2 flowkit.ScriptQuery) (cadence.Value, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for ExecuteScript") - } - - var r0 cadence.Value - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, flowkit.Script, flowkit.ScriptQuery) (cadence.Value, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, flowkit.Script, flowkit.ScriptQuery) cadence.Value); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(cadence.Value) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flowkit.Script, flowkit.ScriptQuery) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Gateway provides a mock function with given fields: -func (_m *Services) Gateway() gateway.Gateway { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Gateway") - } - - var r0 gateway.Gateway - if rf, ok := ret.Get(0).(func() gateway.Gateway); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gateway.Gateway) - } - } - - return r0 -} - -// GenerateKey provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) GenerateKey(_a0 context.Context, _a1 crypto.SigningAlgorithm, _a2 string) (crypto.PrivateKey, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for GenerateKey") - } - - var r0 crypto.PrivateKey - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, crypto.SigningAlgorithm, string) (crypto.PrivateKey, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, crypto.SigningAlgorithm, string) crypto.PrivateKey); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(crypto.PrivateKey) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, crypto.SigningAlgorithm, string) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GenerateMnemonicKey provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) GenerateMnemonicKey(_a0 context.Context, _a1 crypto.SigningAlgorithm, _a2 string) (crypto.PrivateKey, string, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for GenerateMnemonicKey") - } - - var r0 crypto.PrivateKey - var r1 string - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, crypto.SigningAlgorithm, string) (crypto.PrivateKey, string, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, crypto.SigningAlgorithm, string) crypto.PrivateKey); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(crypto.PrivateKey) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, crypto.SigningAlgorithm, string) string); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Get(1).(string) - } - - if rf, ok := ret.Get(2).(func(context.Context, crypto.SigningAlgorithm, string) error); ok { - r2 = rf(_a0, _a1, _a2) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// GetAccount provides a mock function with given fields: _a0, _a1 -func (_m *Services) GetAccount(_a0 context.Context, _a1 flow.Address) (*flow.Account, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetAccount") - } - - var r0 *flow.Account - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, flow.Address) (*flow.Account, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, flow.Address) *flow.Account); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Account) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flow.Address) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlock provides a mock function with given fields: _a0, _a1 -func (_m *Services) GetBlock(_a0 context.Context, _a1 flowkit.BlockQuery) (*flow.Block, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetBlock") - } - - var r0 *flow.Block - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, flowkit.BlockQuery) (*flow.Block, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, flowkit.BlockQuery) *flow.Block); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Block) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flowkit.BlockQuery) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetCollection provides a mock function with given fields: _a0, _a1 -func (_m *Services) GetCollection(_a0 context.Context, _a1 flow.Identifier) (*flow.Collection, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetCollection") - } - - var r0 *flow.Collection - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier) (*flow.Collection, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier) *flow.Collection); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Collection) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flow.Identifier) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetEvents provides a mock function with given fields: _a0, _a1, _a2, _a3, _a4 -func (_m *Services) GetEvents(_a0 context.Context, _a1 []string, _a2 uint64, _a3 uint64, _a4 *flowkit.EventWorker) ([]flow.BlockEvents, error) { - ret := _m.Called(_a0, _a1, _a2, _a3, _a4) - - if len(ret) == 0 { - panic("no return value specified for GetEvents") - } - - var r0 []flow.BlockEvents - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []string, uint64, uint64, *flowkit.EventWorker) ([]flow.BlockEvents, error)); ok { - return rf(_a0, _a1, _a2, _a3, _a4) - } - if rf, ok := ret.Get(0).(func(context.Context, []string, uint64, uint64, *flowkit.EventWorker) []flow.BlockEvents); ok { - r0 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]flow.BlockEvents) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, []string, uint64, uint64, *flowkit.EventWorker) error); ok { - r1 = rf(_a0, _a1, _a2, _a3, _a4) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransactionByID provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) GetTransactionByID(_a0 context.Context, _a1 flow.Identifier, _a2 bool) (*flow.Transaction, *flow.TransactionResult, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for GetTransactionByID") - } - - var r0 *flow.Transaction - var r1 *flow.TransactionResult - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier, bool) (*flow.Transaction, *flow.TransactionResult, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier, bool) *flow.Transaction); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flow.Identifier, bool) *flow.TransactionResult); ok { - r1 = rf(_a0, _a1, _a2) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, flow.Identifier, bool) error); ok { - r2 = rf(_a0, _a1, _a2) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// GetTransactionsByBlockID provides a mock function with given fields: _a0, _a1 -func (_m *Services) GetTransactionsByBlockID(_a0 context.Context, _a1 flow.Identifier) ([]*flow.Transaction, []*flow.TransactionResult, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for GetTransactionsByBlockID") - } - - var r0 []*flow.Transaction - var r1 []*flow.TransactionResult - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier) ([]*flow.Transaction, []*flow.TransactionResult, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, flow.Identifier) []*flow.Transaction); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, flow.Identifier) []*flow.TransactionResult); ok { - r1 = rf(_a0, _a1) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, flow.Identifier) error); ok { - r2 = rf(_a0, _a1) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// Network provides a mock function with given fields: -func (_m *Services) Network() config.Network { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Network") - } - - var r0 config.Network - if rf, ok := ret.Get(0).(func() config.Network); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(config.Network) - } - - return r0 -} - -// Ping provides a mock function with given fields: -func (_m *Services) Ping() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Ping") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// RemoveContract provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) RemoveContract(_a0 context.Context, _a1 *accounts.Account, _a2 string) (flow.Identifier, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for RemoveContract") - } - - var r0 flow.Identifier - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, string) (flow.Identifier, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, string) flow.Identifier); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(flow.Identifier) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *accounts.Account, string) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendSignedTransaction provides a mock function with given fields: _a0, _a1 -func (_m *Services) SendSignedTransaction(_a0 context.Context, _a1 *transactions.Transaction) (*flow.Transaction, *flow.TransactionResult, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for SendSignedTransaction") - } - - var r0 *flow.Transaction - var r1 *flow.TransactionResult - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, *transactions.Transaction) (*flow.Transaction, *flow.TransactionResult, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *transactions.Transaction) *flow.Transaction); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *transactions.Transaction) *flow.TransactionResult); ok { - r1 = rf(_a0, _a1) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, *transactions.Transaction) error); ok { - r2 = rf(_a0, _a1) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// SendTransaction provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *Services) SendTransaction(_a0 context.Context, _a1 transactions.AccountRoles, _a2 flowkit.Script, _a3 uint64) (*flow.Transaction, *flow.TransactionResult, error) { - ret := _m.Called(_a0, _a1, _a2, _a3) - - if len(ret) == 0 { - panic("no return value specified for SendTransaction") - } - - var r0 *flow.Transaction - var r1 *flow.TransactionResult - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, transactions.AccountRoles, flowkit.Script, uint64) (*flow.Transaction, *flow.TransactionResult, error)); ok { - return rf(_a0, _a1, _a2, _a3) - } - if rf, ok := ret.Get(0).(func(context.Context, transactions.AccountRoles, flowkit.Script, uint64) *flow.Transaction); ok { - r0 = rf(_a0, _a1, _a2, _a3) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*flow.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, transactions.AccountRoles, flowkit.Script, uint64) *flow.TransactionResult); ok { - r1 = rf(_a0, _a1, _a2, _a3) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*flow.TransactionResult) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, transactions.AccountRoles, flowkit.Script, uint64) error); ok { - r2 = rf(_a0, _a1, _a2, _a3) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// SetLogger provides a mock function with given fields: _a0 -func (_m *Services) SetLogger(_a0 output.Logger) { - _m.Called(_a0) -} - -// SignTransactionPayload provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Services) SignTransactionPayload(_a0 context.Context, _a1 *accounts.Account, _a2 []byte) (*transactions.Transaction, error) { - ret := _m.Called(_a0, _a1, _a2) - - if len(ret) == 0 { - panic("no return value specified for SignTransactionPayload") - } - - var r0 *transactions.Transaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, []byte) (*transactions.Transaction, error)); ok { - return rf(_a0, _a1, _a2) - } - if rf, ok := ret.Get(0).(func(context.Context, *accounts.Account, []byte) *transactions.Transaction); ok { - r0 = rf(_a0, _a1, _a2) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*transactions.Transaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *accounts.Account, []byte) error); ok { - r1 = rf(_a0, _a1, _a2) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewServices(t interface { - mock.TestingT - Cleanup(func()) -}) *Services { - mock := &Services{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/flowkit/mocks/services_mock.go b/flowkit/mocks/services_mock.go deleted file mode 100644 index ec4241e94..000000000 --- a/flowkit/mocks/services_mock.go +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package mocks - -import ( - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/mock" - - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway/mocks" - "github.com/onflow/flow-cli/flowkit/tests" -) - -const ( - addContractFunc = "AddContract" - buildTransactionFunc = "BuildTransaction" - createAccountFunc = "CreateAccount" - deployProjectFunc = "DeployProject" - derivePrivateKeyFromMnemonicFunc = "DerivePrivateKeyFromMnemonic" - gatewayFunc = "Gateway" - generateKeyFunc = "GenerateKey" - generateMnemonicKeyFunc = "GenerateMnemonicKey" - getBlockFunc = "GetBlock" - getTransactionByIDFunc = "GetTransactionByID" - getTransactionsByBlockIDFunc = "GetTransactionsByBlockID" - networkFunc = "Network" - pingFunc = "Ping" - removeContractFunc = "RemoveContract" - sendTransactionFunc = "SendTransaction" - setLoggerFunc = "SetLogger" - signTransactionPayloadFunc = "SignTransactionPayload" - testFunc = "Test" -) - -type MockServices struct { - Mock *Services - AddContract *mock.Call - BuildTransaction *mock.Call - CreateAccount *mock.Call - DeployProject *mock.Call - DerivePrivateKeyFromMnemonic *mock.Call - Gateway *mock.Call - GenerateKey *mock.Call - GenerateMnemonicKey *mock.Call - GetBlock *mock.Call - GetTransactionByID *mock.Call - GetTransactionsByBlockID *mock.Call - Network *mock.Call - Ping *mock.Call - RemoveContract *mock.Call - SendTransaction *mock.Call - SetLogger *mock.Call - SignTransactionPayload *mock.Call - Test *mock.Call - GetAccount *mock.Call - ExecuteScript *mock.Call - SendSignedTransaction *mock.Call - GetEvents *mock.Call - GetCollection *mock.Call -} - -func DefaultMockServices() *MockServices { - m := &Services{} - t := &MockServices{ - Mock: m, - GetAccount: m.On( - mocks.GetAccountFunc, - mock.Anything, - mock.AnythingOfType("flow.Address"), - ), - ExecuteScript: m.On( - mocks.ExecuteScriptFunc, - mock.Anything, - mock.AnythingOfType("flowkit.Script"), - mock.AnythingOfType("flowkit.ScriptQuery"), - ), - SendSignedTransaction: m.On( - mocks.SendSignedTransactionFunc, - mock.Anything, - mock.AnythingOfType("*transactions.Transaction"), - ), - AddContract: m.On( - addContractFunc, - mock.Anything, - mock.AnythingOfType("*accounts.Account"), - mock.AnythingOfType("flowkit.Script"), - mock.AnythingOfType("flowkit.UpdateContract"), - ), - GetCollection: m.On( - mocks.GetCollectionFunc, - mock.Anything, - mock.AnythingOfType("flow.Identifier"), - ), - GetEvents: m.On( - mocks.GetEventsFunc, - mock.Anything, - mock.AnythingOfType("[]string"), - mock.AnythingOfType("uint64"), - mock.AnythingOfType("uint64"), - mock.AnythingOfType("*flowkit.EventWorker"), - ), - BuildTransaction: m.On( - buildTransactionFunc, - mock.Anything, - mock.AnythingOfType("transactions.AddressesRoles"), - mock.AnythingOfType("int"), - mock.AnythingOfType("flowkit.Script"), - mock.AnythingOfType("uint64"), - ), - CreateAccount: m.On( - createAccountFunc, - mock.Anything, - mock.AnythingOfType("*accounts.Account"), - mock.AnythingOfType("[]accounts.PublicKey"), - ), - DeployProject: m.On( - deployProjectFunc, - mock.Anything, - mock.AnythingOfType("flowkit.UpdateContract"), - ), - DerivePrivateKeyFromMnemonic: m.On( - derivePrivateKeyFromMnemonicFunc, - mock.Anything, - mock.AnythingOfType("string"), - mock.AnythingOfType("crypto.SignatureAlgorithm"), - mock.AnythingOfType("string"), - ), - Gateway: m.On(gatewayFunc), - GenerateKey: m.On( - generateKeyFunc, - mock.Anything, - mock.AnythingOfType("crypto.SignatureAlgorithm"), - mock.AnythingOfType("string"), - ), - GenerateMnemonicKey: m.On( - generateMnemonicKeyFunc, - mock.Anything, - mock.AnythingOfType("crypto.SignatureAlgorithm"), - mock.AnythingOfType("string"), - ), - GetBlock: m.On( - getBlockFunc, - mock.Anything, - mock.AnythingOfType("flowkit.BlockQuery"), - ), - GetTransactionByID: m.On( - getTransactionByIDFunc, - mock.Anything, - mock.AnythingOfType("flow.Identifier"), - mock.AnythingOfType("bool"), - ), - GetTransactionsByBlockID: m.On( - getTransactionsByBlockIDFunc, - mock.Anything, - mock.AnythingOfType("flow.Identifier"), - ), - RemoveContract: m.On( - removeContractFunc, - mock.Anything, - mock.AnythingOfType("*accounts.Account"), - mock.AnythingOfType("string"), - ), - SendTransaction: m.On( - sendTransactionFunc, - mock.Anything, - mock.AnythingOfType("transactions.AccountRoles"), - mock.AnythingOfType("flowkit.Script"), - mock.AnythingOfType("uint64"), - ), - SignTransactionPayload: m.On( - signTransactionPayloadFunc, - mock.Anything, - mock.AnythingOfType("*accounts.Account"), - mock.AnythingOfType("[]uint8"), - ), - Test: m.On( - testFunc, - mock.Anything, - mock.AnythingOfType("[]byte"), - mock.AnythingOfType("string"), - ), - Network: m.On(networkFunc), - Ping: m.On(pingFunc), - SetLogger: m.On(setLoggerFunc, mock.AnythingOfType("output.Logger")), - } - - t.GetAccount.Run(func(args mock.Arguments) { - addr := args.Get(1).(flow.Address) - t.GetAccount.Return(tests.NewAccountWithAddress(addr.String()), nil) - }) - - t.ExecuteScript.Run(func(args mock.Arguments) { - t.ExecuteScript.Return(cadence.MustConvertValue(""), nil) - }) - - t.GetTransactionByID.Return(tests.NewTransaction(), nil) - t.GetCollection.Return(tests.NewCollection(), nil) - t.GetEvents.Return([]flow.BlockEvents{}, nil) - t.GetBlock.Return(tests.NewBlock(), nil) - t.AddContract.Return(flow.EmptyID, false, nil) - t.RemoveContract.Return(flow.EmptyID, nil) - t.CreateAccount.Return(tests.NewAccountWithAddress("0x01"), flow.EmptyID, nil) - t.Network.Return(config.EmulatorNetwork) - - return t -} diff --git a/flowkit/output/colors.go b/flowkit/output/colors.go deleted file mode 100644 index f7a5b3a09..000000000 --- a/flowkit/output/colors.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package output - -import ( - "fmt" - "runtime" -) - -const ( - red = "\033[31m" - green = "\033[32m" - magenta = "\033[35m" - bold = "\033[1m" - reset = "\033[0m" - italic = "\033[3m" -) - -func printColor(msg string, color string) string { - if runtime.GOOS == "windows" { - return msg - } - - return fmt.Sprintf("%s%s%s", color, msg, reset) -} - -func Red(msg string) string { - return printColor(msg, red) -} - -func Green(msg string) string { - return printColor(msg, green) -} - -func Magenta(msg string) string { - return printColor(msg, magenta) -} - -func Bold(msg string) string { - return printColor(msg, bold) -} - -func Italic(msg string) string { - return printColor(msg, italic) -} diff --git a/flowkit/output/emoji.go b/flowkit/output/emoji.go deleted file mode 100644 index 0dc5035eb..000000000 --- a/flowkit/output/emoji.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package output - -import "runtime" - -func printEmoji(emoji string) string { - if runtime.GOOS == "windows" { - return "" - } - - return emoji -} - -func ErrorEmoji() string { - return printEmoji("❌") -} - -func TryEmoji() string { - return printEmoji("🙏") -} - -func WarningEmoji() string { - return printEmoji("❗ ") -} - -func SaveEmoji() string { - return printEmoji("💾") -} - -func StopEmoji() string { - return printEmoji("🔴️") -} - -func GoEmoji() string { - return printEmoji("🟢") -} - -func OkEmoji() string { - return printEmoji("✅") -} - -func SuccessEmoji() string { - return printEmoji("🎉") -} diff --git a/flowkit/output/logger.go b/flowkit/output/logger.go deleted file mode 100644 index 1d4e8a652..000000000 --- a/flowkit/output/logger.go +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package output - -import ( - "fmt" -) - -const ( - NoneLog = 0 - ErrorLog = 1 - DebugLog = 2 - InfoLog = 3 -) - -type Logger interface { - Debug(string) - Info(string) - Error(string) - StartProgress(string) - StopProgress() -} - -// NewStdoutLogger returns a new stdout logger. -func NewStdoutLogger(level int) *StdoutLogger { - return &StdoutLogger{ - level: level, - } -} - -var _ Logger = &StdoutLogger{} - -// StdoutLogger is a stdout logging implementation. -type StdoutLogger struct { - level int - spinner *Spinner -} - -func (s *StdoutLogger) log(msg string, level int) { - if s.level < level { - return - } - - fmt.Printf("%s\n", msg) -} - -func (s *StdoutLogger) Info(msg string) { - s.StopProgress() - s.log(msg, InfoLog) -} - -func (s *StdoutLogger) Debug(msg string) { - s.log(msg, DebugLog) -} - -func (s *StdoutLogger) Error(msg string) { - s.log(fmt.Sprintf("%s %s", ErrorEmoji(), Red(msg)), ErrorLog) -} - -func (s *StdoutLogger) StartProgress(msg string) { - if s.level == NoneLog { - return - } - - if s.spinner != nil { - s.spinner.Stop() - } - - s.spinner = NewSpinner(msg, "") - s.spinner.Start() -} - -func (s *StdoutLogger) StopProgress() { - if s.level == NoneLog { - return - } - - if s.spinner != nil { - s.spinner.Stop() - s.spinner = nil - } -} diff --git a/flowkit/output/spinner.go b/flowkit/output/spinner.go deleted file mode 100644 index 4ff870728..000000000 --- a/flowkit/output/spinner.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package output - -import ( - "fmt" - "time" - - "github.com/gosuri/uilive" -) - -var spinnerCharset = []rune{'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'} - -type Spinner struct { - prefix string - suffix string - done chan string -} - -func NewSpinner(prefix, suffix string) *Spinner { - return &Spinner{ - prefix: prefix, - suffix: suffix, - done: make(chan string), - } -} - -func (s *Spinner) Start() { - go s.run() -} - -func (s *Spinner) run() { - writer := uilive.New() - - ticker := time.NewTicker(100 * time.Millisecond) - - i := 0 - - for { - select { - case <-s.done: - _, _ = fmt.Fprintf(writer, "\r") - _ = writer.Flush() - close(s.done) - return - case <-ticker.C: - _, _ = fmt.Fprintf( - writer, - "%s%c%s\n", - s.prefix, - spinnerCharset[i%len(spinnerCharset)], - s.suffix, - ) - _ = writer.Flush() - i++ - } - } -} - -func (s *Spinner) Stop() { - s.done <- "" - time.Sleep(50 * time.Millisecond) -} diff --git a/flowkit/project/contract.go b/flowkit/project/contract.go deleted file mode 100644 index 41b18ca6d..000000000 --- a/flowkit/project/contract.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" -) - -// Contract is a Cadence contract definition for a project. -type Contract struct { - Name string - location string - code []byte - AccountAddress flow.Address - AccountName string - Args []cadence.Value -} - -func NewContract( - name string, - location string, - code []byte, - accountAddress flow.Address, - accountName string, - args []cadence.Value, -) *Contract { - return &Contract{ - Name: name, - location: location, - code: code, - AccountAddress: accountAddress, - AccountName: accountName, - Args: args, - } -} - -func (c *Contract) Code() []byte { - return c.code -} - -func (c *Contract) SetCode(code []byte) { - c.code = code -} - -func (c *Contract) Location() string { - return c.location -} - -// LocationAliases map contract locations to fixed addresses on Flow network -type LocationAliases map[string]string diff --git a/flowkit/project/contract_test.go b/flowkit/project/contract_test.go deleted file mode 100644 index 0122a01d1..000000000 --- a/flowkit/project/contract_test.go +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "testing" - - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" -) - -func TestContractFunctions(t *testing.T) { - name := "contract1" - location := "/path/to/contract1" - code := []byte("code1") - accountAddress := flow.HexToAddress("0x123456789") - accountName := "account1" - str, _ := cadence.NewString("arg1") - args := []cadence.Value{str} - - contract := NewContract(name, location, code, accountAddress, accountName, args) - - assert.Equal(t, name, contract.Name, "contract.Name should be equal to expected value") - assert.Equal(t, location, contract.location, "contract.location should be equal to expected value") - assert.Equal(t, code, contract.code, "contract.code should be equal to expected value") - assert.Equal(t, accountAddress, contract.AccountAddress, "contract.AccountAddress should be equal to expected value") - assert.Equal(t, accountName, contract.AccountName, "contract.AccountName should be equal to expected value") - assert.Equal(t, args, contract.Args, "contract.Args should be equal to expected value") - - assert.Equal(t, code, contract.Code(), "contract.Code() should return expected value") - - newCode := []byte("newcode") - contract.SetCode(newCode) - assert.Equal(t, newCode, contract.code, "contract.code should be equal to expected value") - - assert.Equal(t, location, contract.Location(), "contract.Location() should return expected value") -} diff --git a/flowkit/project/deployment.go b/flowkit/project/deployment.go deleted file mode 100644 index f8b4f1431..000000000 --- a/flowkit/project/deployment.go +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "fmt" - "path/filepath" - - "gonum.org/v1/gonum/graph" - "gonum.org/v1/gonum/graph/simple" - "gonum.org/v1/gonum/graph/topo" -) - -type deployContract struct { - index int64 - *Contract - program *Program - dependencies map[string]*deployContract -} - -func (d *deployContract) ID() int64 { - return d.index -} - -func (d *deployContract) addDependency(location string, dep *deployContract) { - d.dependencies[location] = dep -} - -// Deployment contains logic to sort deployment order of contracts. -// -// Deployment makes sure the contract containing imports is deployed after all importing contracts are deployed. -// This way we can deploy all contracts without missing imports. -// Contracts are iterated and dependency graph is built which is then later sorted -type Deployment struct { - contracts []*deployContract - // map of contracts by their location specified in state - contractsByLocation map[string]*deployContract - contractsByName map[string]*deployContract - aliases LocationAliases -} - -// NewDeployment from the flowkit Contracts and loaded from the contract location using a loader. -func NewDeployment(contracts []*Contract, aliases LocationAliases) (*Deployment, error) { - deployment := &Deployment{ - contractsByLocation: make(map[string]*deployContract), - contractsByName: make(map[string]*deployContract), - aliases: aliases, - } - - for _, contract := range contracts { - err := deployment.add(contract) - if err != nil { - return nil, err - } - } - - return deployment, nil -} - -func (d *Deployment) add(contract *Contract) error { - program, err := NewProgram(contract.code, contract.Args, contract.location) - if err != nil { - return err - } - - c := &deployContract{ - index: int64(len(d.contracts)), - Contract: contract, - program: program, - dependencies: make(map[string]*deployContract), - } - - d.contracts = append(d.contracts, c) - d.contractsByLocation[filepath.Clean(c.Location())] = c - d.contractsByName[c.Name] = c - - return nil -} - -// Sort contracts by deployment order. -// -// Order of sorting is dependent on the possible imports contract contains, since -// any imported contract must be deployed before deploying the contract with that import. -// Only applicable to contracts. -func (d *Deployment) Sort() ([]*Contract, error) { - if d.conflictExists() { - return nil, fmt.Errorf("the same contract cannot be deployed to multiple accounts on the same network") - } - - err := d.buildDependencies() - if err != nil { - return nil, err - } - - sorted, err := sortByDeploymentOrder(d.contracts) - if err != nil { - return nil, err - } - - contracts := make([]*Contract, len(d.contracts)) - for i, s := range sorted { - contracts[i] = s.Contract - } - - return contracts, nil -} - -// conflictExists returns true if the same contract is configured to deploy to more than one account for the same network. -func (d *Deployment) conflictExists() bool { - uniq := make(map[string]bool) - for _, c := range d.contracts { - if _, exists := uniq[c.Name]; exists { - return true - } - uniq[c.Name] = true - } - - return false -} - -// buildDependencies iterates over all contracts and checks the imports which are added as its dependencies. -func (d *Deployment) buildDependencies() error { - for _, contract := range d.contracts { - for _, location := range contract.program.imports() { - // find contract by the path import - importPath := absolutePath(contract.location, location) - importContract, isPath := d.contractsByLocation[importPath] - if isPath { - contract.addDependency(location, importContract) - continue - } - // find contract by identifier import - new schema - importContract, isIdentifier := d.contractsByName[location] - if isIdentifier { - contract.addDependency(location, importContract) - continue - } - - // if aliased then skip, not a dependency - if _, exists := d.aliases[importPath]; exists { - continue - } - if _, exists := d.aliases[location]; exists { - continue - } - - return fmt.Errorf( - "import from %s could not be found: %s, make sure import path is correct, and the contract is added to deployments or has an alias", - contract.Name, - location, - ) - } - } - - return nil -} - -// sortByDeploymentOrder sorts the given set of contracts in order of deployment. -// -// The resulting ordering ensures that each contract is deployed after all of its -// dependencies are deployed. This function returns an error if an import cycle exists. -// -// This function constructs a directed graph in which contracts are nodes and imports are edges. -// The ordering is computed by performing a topological sort on the constructed graph. -func sortByDeploymentOrder(contracts []*deployContract) ([]*deployContract, error) { - g := simple.NewDirectedGraph() - - for _, c := range contracts { - g.AddNode(c) - } - - for _, c := range contracts { - for _, dep := range c.dependencies { - g.SetEdge(g.NewEdge(dep, c)) - } - } - - sorted, err := topo.SortStabilized(g, nil) - if err != nil { - switch topoErr := err.(type) { - case topo.Unorderable: - return nil, &CyclicImportError{Cycles: nodeSetsToContractSets(topoErr)} - default: - return nil, err - } - } - - return nodesToContracts(sorted), nil -} - -func nodeSetsToContractSets(nodes [][]graph.Node) [][]*deployContract { - contracts := make([][]*deployContract, len(nodes)) - - for i, s := range nodes { - contracts[i] = nodesToContracts(s) - } - - return contracts -} - -func nodesToContracts(nodes []graph.Node) []*deployContract { - contracts := make([]*deployContract, len(nodes)) - - for i, s := range nodes { - contracts[i] = s.(*deployContract) - } - - return contracts -} - -// CyclicImportError is returned when contract contain cyclic imports one to the -// other which is not possible to be resolved and deployed. -type CyclicImportError struct { - Cycles [][]*deployContract -} - -func (e *CyclicImportError) contractNames() [][]string { - cycles := make([][]string, 0, len(e.Cycles)) - - for _, cycle := range e.Cycles { - contracts := make([]string, 0, len(cycle)) - for _, contract := range cycle { - contracts = append(contracts, contract.Name) - } - - cycles = append(cycles, contracts) - } - - return cycles -} - -func (e *CyclicImportError) Error() string { - return fmt.Sprintf( - "contracts: import cycle(s) detected: %v", - e.contractNames(), - ) -} diff --git a/flowkit/project/deployment_test.go b/flowkit/project/deployment_test.go deleted file mode 100644 index f5916ea7c..000000000 --- a/flowkit/project/deployment_test.go +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "strings" - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/test" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -type testContract struct { - location string - code []byte - accountAddress flow.Address - accountName string -} - -var addresses = test.AddressGenerator() - -var testContractA = testContract{ - location: "foobar/ContractA.cdc", - code: []byte(`pub contract ContractA {}`), - accountAddress: addresses.New(), -} - -var testContractB = testContract{ - location: "ContractB.cdc", - code: []byte(`pub contract ContractB {}`), - accountAddress: addresses.New(), -} - -var testContractC = testContract{ - location: "foobar/ContractC.cdc", - code: []byte(` - import ContractA from "ContractA.cdc" - - pub contract ContractC {} - `), - accountAddress: addresses.New(), -} - -var testContractD = testContract{ - location: "ContractD.cdc", - code: []byte(` - import ContractC from "foobar/ContractC.cdc" - - pub contract ContractD {} - `), - accountAddress: addresses.New(), -} - -var testContractE = testContract{ - location: "ContractE.cdc", - code: []byte(` - import ContractF from "ContractF.cdc" - - pub contract ContractE {} - `), -} - -var testContractF = testContract{ - location: "ContractF.cdc", - code: []byte(` - import ContractE from "ContractE.cdc" - - pub contract ContractF {} - `), - accountAddress: addresses.New(), -} - -var testContractG = testContract{ - location: "ContractG.cdc", - code: []byte(` - import ContractA from "foobar/ContractA.cdc" - import ContractB from "ContractB.cdc" - - pub contract ContractG {} - `), - accountAddress: addresses.New(), -} - -var testContractH = testContract{ - location: "ContractH.cdc", - code: []byte(` - import ContractFoo from "Foo.cdc" - - pub contract ContractH {} - `), - accountAddress: addresses.New(), -} - -type contractTestCase struct { - name string - contracts []testContract - expectedDeploymentOrder []testContract - expectedDeploymentError error -} - -func getTestCases() []contractTestCase { - return []contractTestCase{ - { - name: "No contracts", - contracts: []testContract{}, - expectedDeploymentOrder: []testContract{}, - }, - { - name: "Single contract no imports", - contracts: []testContract{testContractA}, - expectedDeploymentOrder: []testContract{testContractA}, - }, - { - name: "Two contracts no imports", - contracts: []testContract{testContractA, testContractB}, - expectedDeploymentOrder: []testContract{testContractA, testContractB}, - }, - { - name: "Two contracts with imports", - contracts: []testContract{testContractA, testContractC}, - expectedDeploymentOrder: []testContract{testContractA, testContractC}, - }, - { - name: "Three contracts with imports", - contracts: []testContract{testContractA, testContractC, testContractD}, - expectedDeploymentOrder: []testContract{testContractA, testContractC, testContractD}, - }, - { - name: "Two contracts with import cycle", - contracts: []testContract{testContractE, testContractF}, - expectedDeploymentError: &CyclicImportError{}, - }, - { - name: "Single contract with two imports", - contracts: []testContract{testContractA, testContractB, testContractG}, - expectedDeploymentOrder: []testContract{testContractA, testContractB, testContractG}, - }, - { - name: "Single contract with unresolved import", - contracts: []testContract{testContractH}, - expectedDeploymentOrder: []testContract{testContractH}, - }, - } -} - -func TestContractDeploymentOrder(t *testing.T) { - testCases := getTestCases() - - for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { - - contracts := make([]*Contract, len(testCase.contracts)) - for i, contract := range testCase.contracts { - contracts[i] = NewContract( - strings.Split(contract.location, ".")[0], - contract.location, - contract.code, - contract.accountAddress, - contract.accountName, - nil, - ) - } - - deployment, err := NewDeployment(contracts, nil) - - contracts, err = deployment.Sort() - if !strings.Contains(testCase.name, "unresolved") && !strings.Contains(testCase.name, "cycle") { - assert.NoError(t, err) - } - - if strings.Contains(testCase.name, "unresolved") { - assert.EqualError(t, err, "import from ContractH could not be found: Foo.cdc, make sure import path is correct, and the contract is added to deployments or has an alias") - return - } - - if testCase.expectedDeploymentError != nil { - assert.IsType(t, testCase.expectedDeploymentError, err) - return - } else { - assert.NoError(t, err, testCase.name) - } - - require.Equal( - t, - len(testCase.expectedDeploymentOrder), - len(contracts), - "deployed contract count does not match expected count", - ) - - for i, deployedContract := range contracts { - assert.Equal(t, testCase.expectedDeploymentOrder[i].location, deployedContract.Location()) - } - }) - } -} diff --git a/flowkit/project/imports.go b/flowkit/project/imports.go deleted file mode 100644 index 268b0e86e..000000000 --- a/flowkit/project/imports.go +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "fmt" - "path/filepath" - - "github.com/onflow/flow-go-sdk" -) - -type Account interface { - Name() string - Address() flow.Address -} - -// ImportReplacer implements file import replacements functionality for the project contracts with optionally included aliases. -type ImportReplacer struct { - contracts []*Contract - aliases LocationAliases -} - -func NewImportReplacer(contracts []*Contract, aliases LocationAliases) *ImportReplacer { - return &ImportReplacer{ - contracts: contracts, - aliases: aliases, - } -} - -func (i *ImportReplacer) Replace(program *Program) (*Program, error) { - imports := program.imports() - contractsLocations := i.getContractsLocations() - - for _, imp := range imports { - // check if import by path exists (e.g. import X from ["./X.cdc"]) - importLocation := filepath.Clean(absolutePath(program.Location(), imp)) - address, isPath := contractsLocations[importLocation] - if isPath { - program.replaceImport(imp, address) - continue - } - // check if import by identifier exists (e.g. import ["X"]) - address, isIdentifier := contractsLocations[imp] - if isIdentifier { - program.replaceImport(imp, address) - continue - } - - return nil, fmt.Errorf("import %s could not be resolved from provided contracts", imp) - } - - return program, nil -} - -// getContractsLocations return a map with contract locations as keys and addresses where they are deployed as values. -func (i *ImportReplacer) getContractsLocations() map[string]string { - locationAddress := make(map[string]string) - for _, contract := range i.contracts { - locationAddress[filepath.Clean(contract.Location())] = contract.AccountAddress.String() - // add also by name since we might use the new import schema - locationAddress[contract.Name] = contract.AccountAddress.String() - } - - for source, target := range i.aliases { - locationAddress[filepath.Clean(source)] = flow.HexToAddress(target).String() - } - - return locationAddress -} - -func absolutePath(basePath, relativePath string) string { - return filepath.Join(filepath.Dir(basePath), relativePath) -} diff --git a/flowkit/project/imports_test.go b/flowkit/project/imports_test.go deleted file mode 100644 index e21c52c8e..000000000 --- a/flowkit/project/imports_test.go +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "regexp" - "testing" - - "github.com/onflow/flow-go-sdk" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func cleanCode(code []byte) string { - space := regexp.MustCompile(`\s+`) - return space.ReplaceAllString(string(code), " ") -} - -func TestResolver(t *testing.T) { - - t.Run("Resolve imports", func(t *testing.T) { - contracts := []*Contract{ - NewContract("Kibble", "./tests/Kibble.cdc", nil, flow.HexToAddress("0x1"), "", nil), - NewContract("FT", "./tests/FT.cdc", nil, flow.HexToAddress("0x2"), "", nil), - } - - aliases := map[string]string{ - "./tests/NFT.cdc": flow.HexToAddress("0x4").String(), - } - - paths := []string{ - "./tests/foo.cdc", - "./scripts/bar/foo.cdc", - "./scripts/bar/foo.cdc", - "./tests/foo.cdc", - } - - scripts := [][]byte{ - []byte(` - import Kibble from "./Kibble.cdc" - import FT from "./FT.cdc" - pub fun main() {} - `), []byte(` - import Kibble from "../../tests/Kibble.cdc" - import FT from "../../tests/FT.cdc" - pub fun main() {} - `), []byte(` - import Kibble from "../../tests/Kibble.cdc" - import NFT from "../../tests/NFT.cdc" - pub fun main() {} - `), []byte(` - import Kibble from "./Kibble.cdc" - import Crypto - import Foo from 0x0000000000000001 - pub fun main() {} - `), - } - - resolved := [][]byte{ - []byte(` - import Kibble from 0x0000000000000001 - import FT from 0x0000000000000002 - pub fun main() {} - `), []byte(` - import Kibble from 0x0000000000000001 - import FT from 0x0000000000000002 - pub fun main() {} - `), []byte(` - import Kibble from 0x0000000000000001 - import NFT from 0x0000000000000004 - pub fun main() {} - `), []byte(` - import Kibble from 0x0000000000000001 - import Crypto - import Foo from 0x0000000000000001 - pub fun main() {} - `), - } - - replacer := NewImportReplacer(contracts, aliases) - for i, script := range scripts { - program, err := NewProgram(script, nil, paths[i]) - require.NoError(t, err) - - program, err = replacer.Replace(program) - assert.NoError(t, err) - assert.Equal(t, cleanCode(program.Code()), cleanCode(resolved[i])) - } - }) - - t.Run("Resolve new schema", func(t *testing.T) { - contracts := []*Contract{ - NewContract("Bar", "./Bar.cdc", nil, flow.HexToAddress("0x2"), "", nil), - NewContract("Foo", "./Foo.cdc", nil, flow.HexToAddress("0x1"), "", nil), - NewContract("Zoo", "./Zoo.cdc", nil, flow.HexToAddress("0x2"), "", nil), - } - - replacer := NewImportReplacer(contracts, nil) - - code := []byte(` - import Foo from "./Foo.cdc" - import "Bar" - - pub contract Zoo {} - `) - program, err := NewProgram(code, nil, "./Zoo.cdc") - require.NoError(t, err) - - replaced, err := replacer.Replace(program) - require.NoError(t, err) - - expected := []byte(` - import Foo from 0x0000000000000001 - import Bar from 0x0000000000000002 - - pub contract Zoo {} - `) - - assert.Equal(t, cleanCode(expected), cleanCode(replaced.Code())) - }) - -} diff --git a/flowkit/project/program.go b/flowkit/project/program.go deleted file mode 100644 index 66d0f793c..000000000 --- a/flowkit/project/program.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "fmt" - "regexp" - - "github.com/onflow/cadence" - "github.com/onflow/cadence/runtime/ast" - "github.com/onflow/cadence/runtime/common" - "github.com/onflow/cadence/runtime/parser" -) - -type Program struct { - code []byte - args []cadence.Value - location string - astProgram *ast.Program - codeWithUnprocessedImports []byte -} - -func NewProgram(code []byte, args []cadence.Value, location string) (*Program, error) { - astProgram, err := parser.ParseProgram(nil, code, parser.Config{}) - if err != nil { - return nil, err - } - - return &Program{ - code: code, - args: args, - location: location, - astProgram: astProgram, - codeWithUnprocessedImports: code, // has converted import syntax e.g. 'import "Foo"' - }, nil -} - -func (p *Program) AddressImportDeclarations() []*ast.ImportDeclaration { - addressImports := make([]*ast.ImportDeclaration, 0) - - for _, importDeclaration := range p.astProgram.ImportDeclarations() { - if len(importDeclaration.Identifiers) > 0 && len(importDeclaration.Location.String()) > 0 { - addressImports = append(addressImports, importDeclaration) - } - } - - return addressImports -} - -func (p *Program) HasAddressImports() bool { - return len(p.AddressImportDeclarations()) > 0 -} - -// Imports builds an array of all the import locations -// It currently supports getting import locations as identifiers or as strings. Strings locations -// can represent a file or an account name, whereas identifiers represent contract names. -func (p *Program) imports() []string { - imports := make([]string, 0) - - for _, importDeclaration := range p.astProgram.ImportDeclarations() { - // we parse all string locations, that are all imports that look like "import X from "Y"" or "import "X"" - _, isStringImport := importDeclaration.Location.(common.StringLocation) - if isStringImport { - imports = append(imports, importDeclaration.Location.String()) - } - } - - return imports -} - -func (p *Program) HasImports() bool { - return len(p.imports()) > 0 -} - -func (p *Program) replaceImport(from string, to string) *Program { - code := string(p.Code()) - - pathRegex := regexp.MustCompile(fmt.Sprintf(`import\s+(\w+)\s+from\s+"%s"`, from)) - identifierRegex := regexp.MustCompile(fmt.Sprintf(`import\s+"(%s)"`, from)) - - replacement := fmt.Sprintf(`import $1 from 0x%s`, to) - code = pathRegex.ReplaceAllString(code, replacement) - code = identifierRegex.ReplaceAllString(code, replacement) - - p.code = []byte(code) - p.reload() - return p -} - -func (p *Program) Location() string { - return p.location -} - -func (p *Program) Code() []byte { - return p.code -} - -func (p *Program) CodeWithUnprocessedImports() []byte { - return p.codeWithUnprocessedImports -} - -func (p *Program) Name() (string, error) { - if len(p.astProgram.CompositeDeclarations()) > 1 || len(p.astProgram.InterfaceDeclarations()) > 1 || - len(p.astProgram.CompositeDeclarations())+len(p.astProgram.InterfaceDeclarations()) > 1 { - return "", fmt.Errorf("the code must declare exactly one contract or contract interface") - } - - for _, compositeDeclaration := range p.astProgram.CompositeDeclarations() { - if compositeDeclaration.CompositeKind == common.CompositeKindContract { - return compositeDeclaration.Identifier.Identifier, nil - } - } - - for _, interfaceDeclaration := range p.astProgram.InterfaceDeclarations() { - if interfaceDeclaration.CompositeKind == common.CompositeKindContract { - return interfaceDeclaration.Identifier.Identifier, nil - } - } - - return "", fmt.Errorf("unable to determine contract name") -} - -func (p *Program) ConvertAddressImports() { - code := string(p.code) - addressImportRegex := regexp.MustCompile(`import\s+(\w+)\s+from\s+0x[0-9a-fA-F]+`) - modifiedCode := addressImportRegex.ReplaceAllString(code, `import "$1"`) - - p.codeWithUnprocessedImports = []byte(modifiedCode) -} - -func (p *Program) reload() { - astProgram, err := parser.ParseProgram(nil, p.code, parser.Config{}) - if err != nil { - return - } - - p.astProgram = astProgram - p.ConvertAddressImports() -} diff --git a/flowkit/project/program_test.go b/flowkit/project/program_test.go deleted file mode 100644 index 171f99328..000000000 --- a/flowkit/project/program_test.go +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package project - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestProgram(t *testing.T) { - - t.Run("AddressImports", func(t *testing.T) { - tests := []struct { - code []byte - expectedCount int - }{ - { - code: []byte(` - import Foo from 0x123 - import "Bar" - import FooSpace from 0x124 - import "BarSpace" - - pub contract Foo {} - `), - expectedCount: 2, - }, - } - - for i, test := range tests { - program, err := NewProgram(test.code, nil, "") - require.NoError(t, err, fmt.Sprintf("AddressImports test %d failed", i)) - addressImports := program.AddressImportDeclarations() - assert.Len(t, addressImports, test.expectedCount, fmt.Sprintf("AddressImports test %d failed", i)) - } - }) - - t.Run("Imports", func(t *testing.T) { - tests := []struct { - code []byte - imports []string - }{{ - code: []byte(`pub contract Foo {}`), - imports: []string{}, - }, { - code: []byte(`pub fun main() {}`), - imports: []string{}, - }, { - code: []byte(` - import Bar from "./Bar.cdc" - pub contract Foo {} - `), - imports: []string{"./Bar.cdc"}, - }, { - code: []byte(` - import Bar from "./Bar.cdc" - import Zoo from "./zoo/Zoo.cdc" - pub contract Foo {} - `), - imports: []string{"./Bar.cdc", "./zoo/Zoo.cdc"}, - }, { // new schema import - code: []byte(` - import "Bar" - pub contract Foo {} - `), - imports: []string{"Bar"}, - }, { - code: []byte(` - import "Bar" - import Zoo from "./Zoo.cdc" - import Crypto - import Foo from 0x01 - - pub contract Foo {} - `), - imports: []string{"Bar", "./Zoo.cdc"}, - }} - - for i, test := range tests { - program, err := NewProgram(test.code, nil, "") - require.NoError(t, err, fmt.Sprintf("import test %d failed", i)) - assert.Equal(t, len(test.imports) > 0, program.HasImports(), fmt.Sprintf("import test %d failed", i)) - assert.Equal(t, test.imports, program.imports(), fmt.Sprintf("import test %d failed", i)) - } - }) - - t.Run("Name", func(t *testing.T) { - tests := []struct { - code []byte - name string - }{{ - code: []byte(`pub contract Foo {}`), - name: "Foo", - }, { - code: []byte(` - import Bar from "./Bar.cdc" - pub contract Foo {} - `), - name: "Foo", - }} - - for i, test := range tests { - program, err := NewProgram(test.code, nil, "") - require.NoError(t, err, fmt.Sprintf("import test %d failed", i)) - name, err := program.Name() - require.NoError(t, err) - assert.Equal(t, test.name, name) - } - - failed := [][]byte{ - []byte(` - pub contract Foo {} - pub contract Bar {} - `), - []byte(` - pub contract Foo {} - pub resource interface Test {} - `), - []byte(` - pub contract Foo {} - struct Bar {} - `), - } - - for _, code := range failed { - program, err := NewProgram(code, nil, "") - require.NoError(t, err) - - _, err = program.Name() - assert.EqualError(t, err, "the code must declare exactly one contract or contract interface") - } - - program, err := NewProgram([]byte(`pub fun main() {}`), nil, "") - require.NoError(t, err) - _, err = program.Name() - assert.EqualError(t, err, "unable to determine contract name") - }) - - t.Run("Replace", func(t *testing.T) { - code := []byte(` - import Foo from "./Foo.cdc" - import "Bar" - import FooSpace from "./FooSpace.cdc" - import "BarSpace" - - pub contract Foo {} - `) - - replaced := []byte(` - import Foo from 0x1 - import Bar from 0x2 - import FooSpace from 0x3 - import BarSpace from 0x4 - - pub contract Foo {} - `) - - program, err := NewProgram(code, nil, "") - require.NoError(t, err) - - program. - replaceImport("./Foo.cdc", "1"). - replaceImport("Bar", "2"). - replaceImport("./FooSpace.cdc", "3"). - replaceImport("BarSpace", "4") - - assert.Equal(t, string(replaced), string(program.Code())) - }) - - t.Run("Convert to Import Syntax", func(t *testing.T) { - code := []byte(` - import Foo from 0x123 - import "Bar" - import FooSpace from 0x124 - import "BarSpace" - - pub contract Foo {} - `) - - expected := []byte(` - import "Foo" - import "Bar" - import "FooSpace" - import "BarSpace" - - pub contract Foo {} - `) - - program, err := NewProgram(code, nil, "") - require.NoError(t, err) - - program.ConvertAddressImports() - - assert.Equal(t, string(expected), string(program.CodeWithUnprocessedImports())) - }) - -} diff --git a/flowkit/schema.json b/flowkit/schema.json deleted file mode 100644 index ad6767830..000000000 --- a/flowkit/schema.json +++ /dev/null @@ -1,357 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/onflow/flow-cli/flowkit/config/json/json-config", - "$ref": "#/$defs/jsonConfig", - "$defs": { - "account": { - "oneOf": [ - { - "$ref": "#/$defs/simpleAccount" - }, - { - "$ref": "#/$defs/advancedAccount" - }, - { - "$ref": "#/$defs/simpleAccountPre022" - }, - { - "$ref": "#/$defs/advanceAccountPre022" - } - ] - }, - "advanceAccountPre022": { - "properties": { - "address": { - "type": "string" - }, - "keys": { - "items": { - "$ref": "#/$defs/advanceKey" - }, - "type": "array" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "address", - "keys" - ] - }, - "advanceKey": { - "properties": { - "type": { - "type": "string" - }, - "index": { - "type": "integer" - }, - "signatureAlgorithm": { - "type": "string" - }, - "hashAlgorithm": { - "type": "string" - }, - "privateKey": { - "type": "string" - }, - "mnemonic": { - "type": "string" - }, - "derivationPath": { - "type": "string" - }, - "resourceID": { - "type": "string" - }, - "location": { - "type": "string" - }, - "context": { - "patternProperties": { - ".*": { - "type": "string" - } - }, - "type": "object" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "type" - ] - }, - "advancedAccount": { - "properties": { - "address": { - "type": "string" - }, - "key": { - "$ref": "#/$defs/advanceKey" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "address", - "key" - ] - }, - "advancedNetwork": { - "properties": { - "host": { - "type": "string" - }, - "key": { - "type": "string" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "host", - "key" - ] - }, - "contractDeployment": { - "properties": { - "name": { - "type": "string" - }, - "args": { - "items": { - "type": "object" - }, - "type": "array" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "args" - ] - }, - "deployment": { - "oneOf": [ - { - "type": "string" - }, - { - "$ref": "#/$defs/contractDeployment" - } - ] - }, - "jsonAccounts": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/account" - } - }, - "type": "object" - }, - "jsonConfig": { - "properties": { - "emulators": { - "$ref": "#/$defs/jsonEmulators" - }, - "contracts": { - "$ref": "#/$defs/jsonContracts" - }, - "dependencies": { - "$ref": "#/$defs/jsonDependencies" - }, - "networks": { - "$ref": "#/$defs/jsonNetworks" - }, - "accounts": { - "$ref": "#/$defs/jsonAccounts" - }, - "deployments": { - "$ref": "#/$defs/jsonDeployments" - } - }, - "additionalProperties": false, - "type": "object" - }, - "jsonContract": { - "oneOf": [ - { - "type": "string" - }, - { - "$ref": "#/$defs/jsonContractAdvanced" - } - ] - }, - "jsonContractAdvanced": { - "properties": { - "source": { - "type": "string" - }, - "aliases": { - "patternProperties": { - ".*": { - "type": "string" - } - }, - "type": "object" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "source", - "aliases" - ] - }, - "jsonContracts": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/jsonContract" - } - }, - "type": "object" - }, - "jsonDependencies": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/jsonDependency" - } - }, - "type": "object" - }, - "jsonDependency": { - "oneOf": [ - { - "type": "string" - }, - { - "$ref": "#/$defs/jsonDependencyExtended" - } - ] - }, - "jsonDependencyExtended": { - "properties": { - "source": { - "type": "string" - }, - "hash": { - "type": "string" - }, - "aliases": { - "patternProperties": { - ".*": { - "type": "string" - } - }, - "type": "object" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "source", - "hash", - "aliases" - ] - }, - "jsonDeployment": { - "patternProperties": { - ".*": { - "items": { - "$ref": "#/$defs/deployment" - }, - "type": "array" - } - }, - "type": "object" - }, - "jsonDeployments": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/jsonDeployment" - } - }, - "type": "object" - }, - "jsonEmulator": { - "properties": { - "port": { - "type": "integer" - }, - "serviceAccount": { - "type": "string" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "port", - "serviceAccount" - ] - }, - "jsonEmulators": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/jsonEmulator" - } - }, - "type": "object" - }, - "jsonNetwork": { - "oneOf": [ - { - "$ref": "#/$defs/simpleNetwork" - }, - { - "$ref": "#/$defs/advancedNetwork" - } - ] - }, - "jsonNetworks": { - "patternProperties": { - ".*": { - "$ref": "#/$defs/jsonNetwork" - } - }, - "type": "object" - }, - "simpleAccount": { - "properties": { - "address": { - "type": "string" - }, - "key": { - "type": "string" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "address", - "key" - ] - }, - "simpleAccountPre022": { - "properties": { - "address": { - "type": "string" - }, - "keys": { - "type": "string" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "address", - "keys" - ] - }, - "simpleNetwork": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/flowkit/services.go b/flowkit/services.go deleted file mode 100644 index 31e6b05d9..000000000 --- a/flowkit/services.go +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "context" - - "github.com/onflow/cadence" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/output" - "github.com/onflow/flow-cli/flowkit/project" - "github.com/onflow/flow-cli/flowkit/transactions" -) - -//go:generate mockery --name=Services - -type Services interface { - Network() config.Network - Ping() error - Gateway() gateway.Gateway - SetLogger(output.Logger) - - // GetAccount fetches account on the Flow network. - GetAccount(context.Context, flow.Address) (*flow.Account, error) - - // CreateAccount on the Flow network with the provided keys and using the signer for creation transaction. - // Returns the newly created account as well as the ID of the transaction that created the account. - // - // Keys is a slice but only one can be passed as well. If the transaction fails or there are other issues an error is returned. - CreateAccount(context.Context, *accounts.Account, []accounts.PublicKey) (*flow.Account, flow.Identifier, error) - - // AddContract to the Flow account provided and return the transaction ID. - // - // If the contract already exists on the account the operation will fail and error will be returned. - // Use UpdateExistingContract(bool) to define whether a contract should be updated or not, or you can also - // define a custom UpdateContract function which returns bool indicating whether a contract should be updated or not. - AddContract(context.Context, *accounts.Account, Script, UpdateContract) (flow.Identifier, bool, error) - - // RemoveContract from the provided account by its name. - // - // If removal is successful transaction ID is returned. - RemoveContract(context.Context, *accounts.Account, string) (flow.Identifier, error) - - // GetBlock by the query from Flow blockchain. Query can define a block by ID, block by height or require the latest block. - GetBlock(context.Context, BlockQuery) (*flow.Block, error) - - // GetCollection by the ID from Flow network. - GetCollection(context.Context, flow.Identifier) (*flow.Collection, error) - - // GetEvents from Flow network by their event name in the specified height interval defined by start and end inclusive. - // Optional worker defines parameters for how many concurrent workers do we want to fetch our events, - // and how many blocks between the provided interval each worker fetches. - // - // Providing worker value will produce faster response as the interval will be scanned concurrently. This parameter is optional, - // if not provided only a single worker will be used. - GetEvents(context.Context, []string, uint64, uint64, *EventWorker) ([]flow.BlockEvents, error) - - // GenerateKey using the signature algorithm and optional seed. If seed is not provided a random safe seed will be generated. - GenerateKey(context.Context, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, error) - - // GenerateMnemonicKey will generate a new key with the signature algorithm and optional derivation path. - // - // If the derivation path is not provided a default "m/44'/539'/0'/0/0" will be used. - GenerateMnemonicKey(context.Context, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, string, error) - - DerivePrivateKeyFromMnemonic(context.Context, string, crypto.SignatureAlgorithm, string) (crypto.PrivateKey, error) - - // DeployProject contracts to the Flow network or update if already exists and UpdateContracts returns true. - // - // Retrieve all the contracts for specified network, sort them for deployment deploy one by one and replace - // the imports in the contract source, so it corresponds to the account name the contract was deployed to. - // If contracts already exist use UpdateExistingContract(bool) to define whether a contract should be updated or not. - DeployProject(context.Context, UpdateContract) ([]*project.Contract, error) - - // ExecuteScript on the Flow network and return the Cadence value as a result. The script is executed at the - // block provided as part of the ScriptQuery value. - ExecuteScript(context.Context, Script, ScriptQuery) (cadence.Value, error) - - // GetTransactionByID from the Flow network including the transaction result. Using the waitSeal we can wait for the transaction to be sealed. - GetTransactionByID(context.Context, flow.Identifier, bool) (*flow.Transaction, *flow.TransactionResult, error) - - GetTransactionsByBlockID(context.Context, flow.Identifier) ([]*flow.Transaction, []*flow.TransactionResult, error) - - // BuildTransaction builds a new transaction type for later signing and submitting to the network. - // - // AddressesRoles type defines the address for each role (payer, proposer, authorizers) and the script defines the transaction content. - BuildTransaction(context.Context, transactions.AddressesRoles, int, Script, uint64) (*transactions.Transaction, error) - - // SignTransactionPayload will use the signer account provided and the payload raw byte content to sign it. - // - // The payload should be RLP encoded transaction payload and is suggested to be used in pair with BuildTransaction function. - SignTransactionPayload(context.Context, *accounts.Account, []byte) (*transactions.Transaction, error) - - // SendSignedTransaction will send a prebuilt and signed transaction to the Flow network. - // - // You can build the transaction using the BuildTransaction method and then sign it using the SignTranscation method. - SendSignedTransaction(context.Context, *transactions.Transaction) (*flow.Transaction, *flow.TransactionResult, error) - - // SendTransaction will build and send a transaction to the Flow network, using the accounts provided for each role and - // contain the script. Transaction as well as transaction result will be returned in case the transaction is successfully submitted. - SendTransaction(context.Context, transactions.AccountRoles, Script, uint64) (*flow.Transaction, *flow.TransactionResult, error) -} diff --git a/flowkit/state.go b/flowkit/state.go deleted file mode 100644 index 8bf62d75c..000000000 --- a/flowkit/state.go +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/onflow/cadence/runtime" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/pkg/errors" - "golang.org/x/exp/slices" - - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/config/json" - "github.com/onflow/flow-cli/flowkit/project" -) - -// ReaderWriter defines read file and write file methods. -type ReaderWriter interface { - ReadFile(source string) ([]byte, error) - WriteFile(filename string, data []byte, perm os.FileMode) error - MkdirAll(path string, perm os.FileMode) error - Stat(path string) (os.FileInfo, error) -} - -// State manages the state for a Flow project. -type State struct { - conf *config.Config - confLoader *config.Loader - readerWriter ReaderWriter - accounts *accounts.Accounts -} - -func (p *State) CreateCoverageReport(network string) *runtime.CoverageReport { - coverageReport := runtime.NewCoverageReport() - contractsConfig := *p.Contracts() - locationMappings := make(map[string]string, len(contractsConfig)) - for _, contract := range contractsConfig { - alias := contract.Aliases.ByNetwork(network) - if alias != nil { - locationMappings[contract.Name] = contract.Location - } - } - - coverageReport.WithLocationMappings(locationMappings) - - return coverageReport -} - -// ReaderWriter retrieve current file reader writer. -func (p *State) ReaderWriter() ReaderWriter { - return p.readerWriter -} - -// ReadFile exposes an injected file loader. -func (p *State) ReadFile(source string) ([]byte, error) { - return p.readerWriter.ReadFile(source) -} - -// SaveDefault saves to default path. -func (p *State) SaveDefault() error { - return p.Save(config.DefaultPath) -} - -// SaveEdited saves configuration to valid path. -func (p *State) SaveEdited(paths []string) error { - // if paths are not default only allow specifying one config - if !config.IsDefaultPath(paths) && len(paths) > 1 { - return fmt.Errorf("specifying multiple paths is not supported when updating configuration") - } - // if default paths and local config doesn't exist don't allow updating global config - if config.IsDefaultPath(paths) { - _, err := p.confLoader.Load([]string{config.DefaultPath}) // check if default is present - if err != nil { - return fmt.Errorf("default configuration not found, please initialize it first or specify another configuration file") - } else { - return p.SaveDefault() - } - } - - return p.Save(paths[0]) -} - -// Save saves the project configuration to the given path. -func (p *State) Save(path string) error { - p.conf.Accounts = accounts.ToConfig(*p.accounts) - err := p.confLoader.Save(p.conf, path) - if err != nil { - return fmt.Errorf("failed to save project configuration to: %s", path) - } - - return nil -} - -// Networks get network configuration. -func (p *State) Networks() *config.Networks { - return &p.conf.Networks -} - -// Deployments get deployments configuration. -func (p *State) Deployments() *config.Deployments { - return &p.conf.Deployments -} - -// Contracts get contracts configuration. -func (p *State) Contracts() *config.Contracts { - return &p.conf.Contracts -} - -func (p *State) Dependencies() *config.Dependencies { - return &p.conf.Dependencies -} - -// Accounts get accounts. -func (p *State) Accounts() *accounts.Accounts { - return p.accounts -} - -// Config get underlying configuration for advanced usage. -func (p *State) Config() *config.Config { - return p.conf -} - -// EmulatorServiceAccount returns the service account for the default emulator profile. -func (p *State) EmulatorServiceAccount() (*accounts.Account, error) { - emulator := p.conf.Emulators.Default() - if emulator == nil { - return nil, fmt.Errorf("no default emulator account") - } - - return p.accounts.ByName(emulator.ServiceAccount) -} - -// SetEmulatorKey sets the default emulator service account private key. -func (p *State) SetEmulatorKey(privateKey crypto.PrivateKey) { - acc, _ := p.EmulatorServiceAccount() - acc.Key = accounts.NewHexKeyFromPrivateKey(acc.Key.Index(), acc.Key.HashAlgo(), privateKey) -} - -// DeploymentContractsByNetwork returns all contracts for a network. -// -// Build contract slice based on the network provided, check the deployment section for that network -// and retrieve the account by name, then add the accounts address on the contract as a destination. -func (p *State) DeploymentContractsByNetwork(network config.Network) ([]*project.Contract, error) { - contracts := make([]*project.Contract, 0) - - // get deployments for the specified network - for _, deploy := range p.conf.Deployments.ByNetwork(network.Name) { - account, err := p.accounts.ByName(deploy.Account) - if err != nil { - return nil, err - } - - // go through each contract in this deployment - for _, deploymentContract := range deploy.Contracts { - c, err := p.conf.Contracts.ByName(deploymentContract.Name) - if err != nil { - return nil, err - } - - location := c.Location - // if we loaded config from a single location, we should make the path of contracts defined in config relative to - // config path we have provided, this will make cases where we execute loading in different path than config work - if len(p.confLoader.LoadedLocations) == 1 { - location = filepath.Join( - filepath.Dir(p.confLoader.LoadedLocations[0]), - location, - ) - } - - code, err := p.readerWriter.ReadFile(location) - if err != nil { - return nil, errors.Wrap(err, "deployment by network failed to read contract code") - } - - contract := project.NewContract( - c.Name, - filepath.Clean(location), - code, - account.Address, - account.Name, - deploymentContract.Args, - ) - - contracts = append(contracts, contract) - } - } - - return contracts, nil -} - -// AccountsForNetwork returns all accounts used on a network defined by deployments. -func (p *State) AccountsForNetwork(network config.Network) *accounts.Accounts { - exists := make(map[string]bool, 0) - accs := make(accounts.Accounts, 0) - - for _, account := range *p.accounts { - if p.conf.Deployments.ByAccountAndNetwork(account.Name, network.Name) != nil { - slices.ContainsFunc(accs, func(a accounts.Account) bool { - return a.Name == account.Name - }) - if !exists[account.Name] { - accs = append(accs, account) - } - } - } - return &accs -} - -// AliasesForNetwork returns all deployment aliases for a network. -func (p *State) AliasesForNetwork(network config.Network) project.LocationAliases { - aliases := make(project.LocationAliases) - - // get all contracts for selected network and if any has an address as target make it an alias - for _, contract := range p.conf.Contracts { - if contract.IsAliased() && contract.Aliases.ByNetwork(network.Name) != nil { - alias := contract.Aliases.ByNetwork(network.Name).Address.String() - aliases[filepath.Clean(contract.Location)] = alias // alias for import by file location - aliases[contract.Name] = alias // alias for import by name - } - } - - return aliases -} - -// Load loads a project configuration and returns the resulting project. -func Load(configFilePaths []string, readerWriter ReaderWriter) (*State, error) { - confLoader := config.NewLoader(readerWriter) - - // here we add all available parsers (more to add yaml etc...) - confLoader.AddConfigParser(json.NewParser()) - conf, err := confLoader.Load(configFilePaths) - if err != nil { - return nil, err - } - // only add a default emulator in the config if the emulator account is present in accounts - _, err = conf.Accounts.ByName(config.DefaultEmulator.ServiceAccount) - if err == nil && len(conf.Emulators) == 0 { - conf.Emulators.AddOrUpdate("", config.DefaultEmulator) - } - proj, err := newProject(conf, confLoader, readerWriter) - if err != nil { - return nil, fmt.Errorf("invalid project configuration: %s", err) - } - - return proj, nil -} - -// Init initializes a new Flow project. -func Init( - rw ReaderWriter, - sigAlgo crypto.SignatureAlgorithm, - hashAlgo crypto.HashAlgorithm, -) (*State, error) { - emulatorServiceAccount, err := accounts.NewEmulatorAccount(rw, sigAlgo, hashAlgo) - if err != nil { - return nil, err - } - - loader := config.NewLoader(rw) - loader.AddConfigParser(json.NewParser()) - - return &State{ - confLoader: loader, - readerWriter: rw, - conf: config.Default(), - accounts: &accounts.Accounts{*emulatorServiceAccount}, - }, nil -} - -// newProject creates a new project from a configuration object. -func newProject( - conf *config.Config, - loader *config.Loader, - readerWriter ReaderWriter, -) (*State, error) { - accs, err := accounts.FromConfig(conf) - if err != nil { - return nil, err - } - - return &State{ - conf: conf, - readerWriter: readerWriter, - confLoader: loader, - accounts: &accs, - }, nil -} diff --git a/flowkit/state_test.go b/flowkit/state_test.go deleted file mode 100644 index 0be2fc511..000000000 --- a/flowkit/state_test.go +++ /dev/null @@ -1,894 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package flowkit - -import ( - "fmt" - "os" - "path/filepath" - "sort" - "testing" - - "github.com/onflow/flow-cli/flowkit/accounts" - - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/spf13/afero" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/thoas/go-funk" - - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/config/json" - "github.com/onflow/flow-cli/flowkit/project" -) - -var af = afero.Afero{Fs: afero.NewMemMapFs()} - -var composer = config.NewLoader(af) - -func keys() []crypto.PrivateKey { - var keys []crypto.PrivateKey - key, _ := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47") - keys = append(keys, key) - key, _ = crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "388e3fbdc654b765942610679bb3a66b74212149ab9482187067ee116d9a8118") - keys = append(keys, key) - key, _ = crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "27bbeba308e501f8485ddaab77e285c0bc0d611096a79b4f0b4ccc927c6dbf04") - keys = append(keys, key) - - return keys -} - -func generateComplexProject() State { - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 9000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{{ - Name: "NonFungibleToken", - Location: "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - }, { - Name: "FungibleToken", - Location: "../hungry-kitties/cadence/contracts/FungibleToken.cdc", - }, { - Name: "Kibble", - Location: "./cadence/kibble/contracts/Kibble.cdc", - }, { - Name: "KittyItems", - Location: "./cadence/kittyItems/contracts/KittyItems.cdc", - }, { - Name: "KittyItemsMarket", - Location: "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc", - Aliases: config.Aliases{{ - Network: "testnet", - Address: flow.HexToAddress("0x123123123"), - }}, - }}, - Deployments: config.Deployments{{ - Network: "emulator", - Account: "emulator-account", - Contracts: []config.ContractDeployment{ - {Name: "KittyItems", Args: nil}, - {Name: "KittyItemsMarket", Args: nil}, - }, - }, { - Network: "emulator", - Account: "account-4", - Contracts: []config.ContractDeployment{ - {Name: "FungibleToken", Args: nil}, - {Name: "NonFungibleToken", Args: nil}, - {Name: "Kibble", Args: nil}, - {Name: "KittyItems", Args: nil}, - {Name: "KittyItemsMarket", Args: nil}, - }, - }, { - Network: "testnet", - Account: "account-2", - Contracts: []config.ContractDeployment{ - {Name: "FungibleToken", Args: nil}, - {Name: "NonFungibleToken", Args: nil}, - {Name: "Kibble", Args: nil}, - {Name: "KittyItems", Args: nil}, - }, - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }, { - Name: "account-2", - Address: flow.HexToAddress("2c1162386b0a245f"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[1], - }, - }, { - Name: "account-4", - Address: flow.HexToAddress("f8d6e0586b0a20c1"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[2], - }, - }, { - Name: "emulator-account-2", - Address: flow.HexToAddress("2c1162386b0a245f"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[1], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - - p, err := newProject(&cfg, composer, af) - if err != nil { - fmt.Println(err) - } - - return *p -} - -func generateSimpleProject() State { - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 9000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{{ - Name: "NonFungibleToken", - Location: "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - }}, - Deployments: config.Deployments{{ - Network: "emulator", - Account: "emulator-account", - Contracts: []config.ContractDeployment{ - {Name: "NonFungibleToken", Args: nil}, - }, - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - - composer.AddConfigParser(json.NewParser()) - p, err := newProject(&cfg, composer, af) - if err != nil { - fmt.Println(err) - } - - return *p -} - -func generateAliasesProject() State { - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 9000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{{ - Name: "NonFungibleToken", - Location: "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - }, { - Name: "FungibleToken", - Location: "../hungry-kitties/cadence/contracts/FungibleToken.cdc", - Aliases: config.Aliases{{ - Network: "emulator", - Address: flow.HexToAddress("ee82856bf20e2aa6"), - }}, - }}, - Deployments: config.Deployments{{ - Network: "emulator", - Account: "emulator-account", - Contracts: []config.ContractDeployment{ - {Name: "NonFungibleToken", Args: nil}, - }, - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - - p, err := newProject(&cfg, composer, af) - if err != nil { - fmt.Println(err) - } - - return *p -} - -func generateAliasesComplexProject() State { - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 9000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{{ - Name: "NonFungibleToken", - Location: "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc", - }, { - Name: "FungibleToken", - Location: "../hungry-kitties/cadence/contracts/FungibleToken.cdc", - Aliases: config.Aliases{{ - Network: "emulator", - Address: flow.HexToAddress("ee82856bf20e2aa6"), - }}, - }, { - Name: "Kibble", - Location: "../hungry-kitties/cadence/contracts/Kibble.cdc", - Aliases: config.Aliases{{ - Network: "testnet", - Address: flow.HexToAddress("ee82856bf20e2aa6"), - }}, - }, { - Name: "Kibble", - Location: "../hungry-kitties/cadence/contracts/Kibble.cdc", - Aliases: config.Aliases{{ - Network: "emulator", - Address: flow.HexToAddress("ee82856bf20e2aa6"), - }}, - }}, - Deployments: config.Deployments{{ - Network: "emulator", - Account: "emulator-account", - Contracts: []config.ContractDeployment{ - {Name: "NonFungibleToken", Args: nil}, - }, - }, { - Network: "testnet", - Account: "testnet-account", - Contracts: []config.ContractDeployment{ - {Name: "NonFungibleToken", Args: nil}, - {Name: "FungibleToken", Args: nil}, - }, - }}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }, { - Name: "testnet-account", - Address: flow.HexToAddress("1e82856bf20e2aa6"), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[1], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }, { - Name: "testnet", - Host: "127.0.0.1.3569", - }}, - } - - p, err := newProject(&cfg, composer, af) - if err != nil { - fmt.Println(err) - } - - return *p -} - -func Test_GetContractsByNameSimple(t *testing.T) { - p := generateSimpleProject() - path := filepath.FromSlash("../hungry-kitties/cadence/contracts/NonFungibleToken.cdc") - af.WriteFile(path, []byte("pub contract{}"), os.ModePerm) - - contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork) - require.NoError(t, err) - account, err := p.conf.Accounts.ByName("emulator-account") - require.NoError(t, err) - require.Len(t, contracts, 1) - assert.Equal(t, "NonFungibleToken", contracts[0].Name) - assert.Equal(t, path, contracts[0].Location()) - assert.Equal(t, account.Address, contracts[0].AccountAddress) -} - -func Test_EmulatorConfigSimple(t *testing.T) { - p := generateSimpleProject() - emulatorServiceAccount, _ := p.EmulatorServiceAccount() - - assert.Equal(t, "emulator-account", emulatorServiceAccount.Name) - assert.Equal(t, emulatorServiceAccount.Key.ToConfig().PrivateKey, keys()[0]) - assert.Equal(t, flow.ServiceAddress("flow-emulator"), emulatorServiceAccount.Address) -} - -func Test_AccountByAddressSimple(t *testing.T) { - p := generateSimpleProject() - acc, _ := p.Accounts().ByAddress(flow.ServiceAddress("flow-emulator")) - - assert.Equal(t, "emulator-account", acc.Name) -} - -func Test_AccountByNameSimple(t *testing.T) { - p := generateSimpleProject() - acc, _ := p.Accounts().ByName("emulator-account") - - assert.Equal(t, flow.ServiceAddress("flow-emulator"), acc.Address) - assert.Equal(t, acc.Key.ToConfig().PrivateKey, keys()[0]) -} - -func Test_HostSimple(t *testing.T) { - p := generateSimpleProject() - network, err := p.Networks().ByName("emulator") - - assert.NoError(t, err) - assert.Equal(t, "127.0.0.1.3569", network.Host) -} - -func Test_GetContractsByNameComplex(t *testing.T) { - p := generateComplexProject() - - for _, c := range p.conf.Contracts { - _ = af.WriteFile(c.Location, []byte("pub contract{}"), os.ModePerm) - } - - contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork) - require.NoError(t, err) - require.Equal(t, 7, len(contracts)) - - //sort contracts by name so tests are deterministic - sort.Slice(contracts, func(i, j int) bool { - return contracts[i].Name < contracts[j].Name - }) - - contractNames := funk.Map(contracts, func(c *project.Contract) string { - return c.Name - }).([]string) - - sources := funk.Map(contracts, func(c *project.Contract) string { - return c.Location() - }).([]string) - - targets := funk.Map(contracts, func(c *project.Contract) string { - return c.AccountAddress.String() - }).([]string) - - assert.Equal(t, contractNames[0], "FungibleToken") - assert.Equal(t, contractNames[1], "Kibble") - assert.Equal(t, contractNames[2], "KittyItems") - assert.Equal(t, contractNames[3], "KittyItems") - assert.Equal(t, contractNames[4], "KittyItemsMarket") - assert.Equal(t, contractNames[5], "KittyItemsMarket") - assert.Equal(t, contractNames[6], "NonFungibleToken") - - assert.Equal(t, sources[0], filepath.FromSlash("../hungry-kitties/cadence/contracts/FungibleToken.cdc")) - assert.Equal(t, sources[1], filepath.FromSlash("cadence/kibble/contracts/Kibble.cdc")) - assert.Equal(t, sources[2], filepath.FromSlash("cadence/kittyItems/contracts/KittyItems.cdc")) - assert.Equal(t, sources[3], filepath.FromSlash("cadence/kittyItems/contracts/KittyItems.cdc")) - assert.Equal(t, sources[4], filepath.FromSlash("cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc")) - assert.Equal(t, sources[5], filepath.FromSlash("cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc")) - assert.Equal(t, sources[6], filepath.FromSlash("../hungry-kitties/cadence/contracts/NonFungibleToken.cdc")) - - assert.Equal(t, targets[0], "f8d6e0586b0a20c1") - assert.Equal(t, targets[1], "f8d6e0586b0a20c1") - assert.Equal(t, targets[2], "f8d6e0586b0a20c7") - assert.Equal(t, targets[3], "f8d6e0586b0a20c1") - assert.Equal(t, targets[4], "f8d6e0586b0a20c7") - assert.Equal(t, targets[5], "f8d6e0586b0a20c1") - assert.Equal(t, targets[6], "f8d6e0586b0a20c1") -} - -func Test_EmulatorConfigComplex(t *testing.T) { - p := generateComplexProject() - emulatorServiceAccount, _ := p.EmulatorServiceAccount() - - assert.Equal(t, emulatorServiceAccount.Name, "emulator-account") - assert.Equal(t, emulatorServiceAccount.Key.ToConfig().PrivateKey, keys()[0]) - assert.Equal(t, emulatorServiceAccount.Address, flow.ServiceAddress("flow-emulator")) -} - -func Test_AccountByNameWithDuplicateAddress(t *testing.T) { - p := generateComplexProject() - acc1, err := p.Accounts().ByName("emulator-account") - - assert.NoError(t, err) - acc2, err := p.Accounts().ByName("emulator-account-2") - assert.NoError(t, err) - - assert.Equal(t, acc1.Name, "emulator-account") - assert.Equal(t, acc2.Name, "emulator-account-2") -} - -func Test_AccountByNameComplex(t *testing.T) { - p := generateComplexProject() - acc, _ := p.Accounts().ByName("account-2") - - assert.Equal(t, acc.Address.String(), "2c1162386b0a245f") - assert.Equal(t, acc.Key.ToConfig().PrivateKey, keys()[1]) -} - -func Test_HostComplex(t *testing.T) { - p := generateComplexProject() - network, err := p.Networks().ByName("emulator") - - assert.NoError(t, err) - - assert.Equal(t, network.Host, "127.0.0.1.3569") -} - -func Test_GetAliases(t *testing.T) { - p := generateAliasesProject() - - aliases := p.AliasesForNetwork(config.EmulatorNetwork) - contracts, _ := p.DeploymentContractsByNetwork(config.EmulatorNetwork) - - assert.Len(t, aliases, 2) - assert.Equal(t, aliases[filepath.FromSlash("../hungry-kitties/cadence/contracts/FungibleToken.cdc")], "ee82856bf20e2aa6") - assert.Len(t, contracts, 1) - assert.Equal(t, contracts[0].Name, "NonFungibleToken") -} - -func Test_GetAliasesComplex(t *testing.T) { - p := generateAliasesComplexProject() - - aEmulator := p.AliasesForNetwork(config.EmulatorNetwork) - cEmulator, _ := p.DeploymentContractsByNetwork(config.EmulatorNetwork) - - aTestnet := p.AliasesForNetwork(config.TestnetNetwork) - cTestnet, _ := p.DeploymentContractsByNetwork(config.TestnetNetwork) - - assert.Len(t, cEmulator, 1) - assert.Equal(t, cEmulator[0].Name, "NonFungibleToken") - - assert.Len(t, aEmulator, 4) - assert.Equal(t, aEmulator[filepath.FromSlash("../hungry-kitties/cadence/contracts/FungibleToken.cdc")], "ee82856bf20e2aa6") - assert.Equal(t, aEmulator[filepath.FromSlash("../hungry-kitties/cadence/contracts/Kibble.cdc")], "ee82856bf20e2aa6") - - assert.Len(t, aTestnet, 2) - assert.Equal(t, aTestnet[filepath.FromSlash("../hungry-kitties/cadence/contracts/Kibble.cdc")], "ee82856bf20e2aa6") - - assert.Len(t, cTestnet, 2) - assert.Equal(t, cTestnet[0].Name, "NonFungibleToken") - assert.Equal(t, cTestnet[1].Name, "FungibleToken") -} - -func Test_ChangingState(t *testing.T) { - p := generateSimpleProject() - - em, err := p.EmulatorServiceAccount() - assert.NoError(t, err) - - em.Name = "foo" - em.Address = flow.HexToAddress("0x1") - - pk, _ := crypto.GeneratePrivateKey( - crypto.ECDSA_P256, - []byte("seedseedseedseedseedseedseedseedseedseedseedseed"), - ) - key := accounts.NewHexKeyFromPrivateKey(em.Key.Index(), em.Key.HashAlgo(), pk) - em.Key = key - - foo, err := p.Accounts().ByName("foo") - assert.NoError(t, err) - assert.NotNil(t, foo) - assert.Equal(t, foo.Name, "foo") - assert.Equal(t, foo.Address, flow.HexToAddress("0x1")) - - pkey, err := foo.Key.PrivateKey() - assert.NoError(t, err) - assert.Equal(t, (*pkey).String(), pk.String()) - - bar, err := p.Accounts().ByName("foo") - assert.NoError(t, err) - bar.Name = "zoo" - zoo, err := p.Accounts().ByName("zoo") - assert.NotNil(t, zoo) - assert.NoError(t, err) - - a := accounts.Account{} - a.Name = "bobo" - p.Accounts().AddOrUpdate(&a) - bobo, err := p.Accounts().ByName("bobo") - assert.NotNil(t, bobo) - assert.NoError(t, err) - - zoo2, _ := p.Accounts().ByName("zoo") - zoo2.Name = "emulator-account" - assert.Equal(t, "emulator-account", zoo2.Name) - - pk, _ = crypto.GeneratePrivateKey( - crypto.ECDSA_P256, - []byte("seedseedseedseedseedseedseedseedseed123seedseedseed123"), - ) - - p.SetEmulatorKey(pk) - em, _ = p.EmulatorServiceAccount() - pkey, err = em.Key.PrivateKey() - assert.NoError(t, err) - assert.Equal(t, (*pkey).String(), pk.String()) -} - -func Test_LoadState(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff03a7a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - } - } - }`) - - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", b, 0644) - assert.NoError(t, err) - - paths := []string{"flow.json"} - state, err := Load(paths, af) - assert.NoError(t, err) - - acc, err := state.Accounts().ByName("emulator-account") - assert.NoError(t, err) - assert.Equal(t, acc.Name, "emulator-account") -} - -func Test_LoadStateMultiple(t *testing.T) { - b := []byte(`{ - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "21c5dfdeb0ff0347a73ef39788563b62c89adea67bbb21ab95e5f710bd1d40b7" - }, - "charlie": { - "address": "0xf3fcd2c1a78f5eee", - "key": "9463ceedf08627108ea0b394c96b18446d1370e7332c91ce332aba1594096ba0" - }, - "bob": { - "address": "179b6b1cb6755e31", - "key": "748d21a762aa192976f4d264afe26379b8a63f5d1343773f813a37d4262b9f52" - } - } - }`) - - a := []byte(`{ - "accounts": { - "alice": { - "address": "179b6b1cb6755e31", - "key": "728d21a7622a29d976f4d264afe26379b8a63f5d1343773f813a37d4262b9f52" - }, - "charlie": { - "address": "0xe03daebed8ca0615", - "key": "9463ceedf04427208ea0b394c96b18446d1370e7332c91ce332aba1594096ba0" - } - } - }`) - - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", b, 0644) - assert.NoError(t, err) - err = afero.WriteFile(af.Fs, "a.json", a, 0644) - assert.NoError(t, err) - - paths := []string{"flow.json", "a.json"} - state, err := Load(paths, af) - assert.NoError(t, err) - - acc, err := state.Accounts().ByName("emulator-account") - assert.NoError(t, err) - assert.Equal(t, acc.Address.String(), "f8d6e0586b0a20c7") - - acc, err = state.Accounts().ByName("charlie") - assert.NoError(t, err) - assert.Equal(t, acc.Address.String(), "e03daebed8ca0615") - - acc, err = state.Accounts().ByName("bob") - assert.NoError(t, err) - assert.Equal(t, acc.Address.String(), "179b6b1cb6755e31") - - acc, err = state.Accounts().ByName("alice") - assert.NoError(t, err) - assert.Equal(t, acc.Address.String(), "179b6b1cb6755e31") -} - -func Test_Saving(t *testing.T) { - s := generateSimpleProject() - - err := s.SaveEdited([]string{"a.json", "b.json"}) - assert.EqualError(t, err, "specifying multiple paths is not supported when updating configuration") - - err = s.SaveEdited([]string{config.GlobalPath(), config.DefaultPath}) - assert.EqualError(t, err, "default configuration not found, please initialize it first or specify another configuration file") - - err = s.SaveEdited([]string{"a.json"}) - assert.NoError(t, err) - - _ = afero.WriteFile(af.Fs, config.DefaultPath, []byte(`{ - "networks": { - "foo": "localhost:3000" - } - }`), 0644) - - err = s.SaveEdited([]string{config.GlobalPath(), config.DefaultPath}) - assert.NoError(t, err) -} - -// ensures that default emulator values are in config when no emulator is defined in flow.json -func Test_DefaultEmulatorNotPresentInConfig(t *testing.T) { - configJson := []byte(`{ - "contracts": {}, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - }, - "deployments": { - } - }`) - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 3569, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{}, - Dependencies: config.Dependencies{}, - Deployments: config.Deployments{}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644) - assert.NoError(t, err) - paths := []string{"flow.json"} - state, err := Load(paths, af) - assert.Equal(t, state.conf, &cfg) - assert.NoError(t, err) -} - -// ensures that default emulator values are not in config when no emulator is defined in flow.json -func Test_DefaultEmulatorWithoutEmulatorAccountInConfig(t *testing.T) { - configJson := []byte(`{ - "contracts": {}, - "accounts": { - "testnet-account": { - "address": "1e82856bf20e2aa6", - "key": "388e3fbdc654b765942610679bb3a66b74212149ab9482187067ee116d9a8118" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - }, - "deployments": { - } - }`) - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644) - assert.NoError(t, err) - paths := []string{"flow.json"} - state, _ := Load(paths, af) - assert.Equal(t, config.Emulators{}, state.conf.Emulators) -} - -// ensures that default emulator values are in config when emulator is defined in flow.json -func Test_DefaultEmulatorWithEmulatorAccountInConfig(t *testing.T) { - configJson := []byte(`{ - "contracts": {}, - "accounts": { - "testnet-account": { - "address": "1e82856bf20e2aa6", - "key": "388e3fbdc654b765942610679bb3a66b74212149ab9482187067ee116d9a8118" - }, - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - }, - "deployments": { - } - }`) - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644) - assert.NoError(t, err) - paths := []string{"flow.json"} - state, _ := Load(paths, af) - assert.Len(t, state.conf.Emulators, 1) - assert.Equal(t, state.conf.Emulators, config.DefaultEmulators) -} - -// backward compatibility test to ensure that default emulator values are still observed in flow.json -func Test_DefaultEmulatorPresentInConfig(t *testing.T) { - configJson := []byte(`{ - "contracts": {}, - "emulators": { - "default": { - "port": 3569, - "serviceAccount": "emulator-account" - } - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - }, - "deployments": { - } - }`) - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "default", - Port: 3569, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{}, - Dependencies: config.Dependencies{}, - Deployments: config.Deployments{}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644) - assert.NoError(t, err) - paths := []string{"flow.json"} - state, err := Load(paths, af) - assert.Equal(t, 1, len(state.conf.Emulators)) - assert.Equal(t, state.conf, &cfg) - assert.NoError(t, err) -} - -// ensures that custom emulator values are still observed in flow.json -func Test_CustomEmulatorValuesInConfig(t *testing.T) { - configJson := []byte(`{ - "contracts": {}, - "emulators": { - "custom-emulator": { - "port": 2000, - "serviceAccount": "emulator-account" - } - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47" - } - }, - "networks": { - "emulator": "127.0.0.1.3569" - }, - "deployments": { - } - }`) - cfg := config.Config{ - Emulators: config.Emulators{{ - Name: "custom-emulator", - Port: 2000, - ServiceAccount: "emulator-account", - }}, - Contracts: config.Contracts{}, - Dependencies: config.Dependencies{}, - Deployments: config.Deployments{}, - Accounts: config.Accounts{{ - Name: "emulator-account", - Address: flow.ServiceAddress(flow.Emulator), - Key: config.AccountKey{ - Type: config.KeyTypeHex, - Index: 0, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - PrivateKey: keys()[0], - }, - }}, - Networks: config.Networks{{ - Name: "emulator", - Host: "127.0.0.1.3569", - }}, - } - af := afero.Afero{Fs: afero.NewMemMapFs()} - err := afero.WriteFile(af.Fs, "flow.json", configJson, 0644) - assert.NoError(t, err) - paths := []string{"flow.json"} - state, err := Load(paths, af) - assert.Equal(t, "custom-emulator", state.conf.Emulators[0].Name) - assert.Equal(t, 1, len(state.conf.Emulators)) - assert.Equal(t, state.conf, &cfg) - assert.NoError(t, err) -} diff --git a/flowkit/tests/resources.go b/flowkit/tests/resources.go deleted file mode 100644 index 49808b6c2..000000000 --- a/flowkit/tests/resources.go +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests - -import ( - "fmt" - - "github.com/onflow/cadence" - "github.com/onflow/cadence/runtime/common" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-go-sdk/test" - "github.com/spf13/afero" -) - -type Resource struct { - Name string - Filename string - Source []byte -} - -var ContractHelloString = Resource{ - Name: "Hello", - Filename: "contractHello.cdc", - Source: []byte(` - pub contract Hello { - pub let greeting: String - init() { - self.greeting = "Hello, World!" - } - pub fun hello(): String { - return self.greeting - } - } - `), -} - -var ContractSimple = Resource{ - Name: "Simple", - Filename: "contractSimple.cdc", - Source: []byte(` - pub contract Simple {} - `), -} - -var ContractSimpleUpdated = Resource{ - Name: "Simple", - Filename: "contractSimpleUpdated.cdc", - Source: []byte(` - pub contract Simple { - pub fun newFunc() {} - } - `), -} - -var ContractSimpleWithArgs = Resource{ - Name: "Simple", - Filename: "contractArgs.cdc", - Source: []byte(` - pub contract Simple { - pub let id: UInt64 - init(initId: UInt64) { - self.id = initId - } - } - `), -} - -var ContractEvents = Resource{ - Name: "ContractEvents", - Filename: "contractEvents.cdc", - Source: []byte(` - pub contract ContractEvents { - pub struct S { - pub var x: Int - pub var y: String - - init(x: Int, y: String) { - self.x = x - self.y = y - } - } - - pub event EventA(x: Int) - pub event EventB(x: Int, y: Int) - pub event EventC(x: UInt8) - pub event EventD(x: String) - pub event EventE(x: UFix64) - pub event EventF(x: Address) - pub event EventG(x: [UInt8]) - pub event EventH(x: [[UInt8]]) - pub event EventI(x: {String: Int}) - pub event EventJ(x: S) - - init() { - emit EventA(x: 1) - emit EventB(x: 4, y: 2) - emit EventC(x: 1) - emit EventD(x: "hello") - emit EventE(x: 10.2) - emit EventF(x: 0x436164656E636521) - emit EventG(x: "hello".utf8) - emit EventH(x: ["hello".utf8, "world".utf8]) - emit EventI(x: { "hello": 1337 }) - emit EventJ(x: S(x: 1, y: "hello world")) - } - } - `), -} - -var ContractA = Resource{ - Name: "ContractA", - Filename: "contractA.cdc", - Source: []byte(`pub contract ContractA {}`), -} - -var ContractB = Resource{ - Name: "ContractB", - Filename: "contractB.cdc", - Source: []byte(` - import ContractA from "./contractA.cdc" - pub contract ContractB {} - `), -} - -var ContractC = Resource{ - Name: "ContractC", - Filename: "contractC.cdc", - Source: []byte(` - import ContractB from "./contractB.cdc" - import ContractA from "./contractA.cdc" - - pub contract ContractC { - pub let x: String - init(x: String) { - self.x = x - } - } - `), -} - -var ContractFooCoverage = Resource{ - Name: "FooContract", - Filename: "FooContract.cdc", - Source: []byte(` - pub contract FooContract { - pub let specialNumbers: {Int: String} - - init() { - self.specialNumbers = { - 1729: "Harshad", - 8128: "Harmonic", - 41041: "Carmichael" - } - } - - pub fun addSpecialNumber(_ n: Int, _ trait: String) { - self.specialNumbers[n] = trait - } - - pub fun getIntegerTrait(_ n: Int): String { - if n < 0 { - return "Negative" - } else if n == 0 { - return "Zero" - } else if n < 10 { - return "Small" - } else if n < 100 { - return "Big" - } else if n < 1000 { - return "Huge" - } - - if self.specialNumbers.containsKey(n) { - return self.specialNumbers[n]! - } - - return "Enormous" - } - } - `), -} - -var ContractAA = Resource{ - Name: "ContractAA", - Filename: "contractAA.cdc", - Source: []byte(`pub contract ContractAA {}`), -} - -var ContractBB = Resource{ - Name: "ContractBB", - Filename: "contractBB.cdc", - Source: []byte(` - import "ContractAA" - pub contract ContractB {} - `), -} - -var ContractCC = Resource{ - Name: "ContractCC", - Filename: "contractCC.cdc", - Source: []byte(` - import "ContractBB" - import "ContractAA" - - pub contract ContractC { - pub let x: String - init(x: String) { - self.x = x - } - } - `), -} - -var TransactionArgString = Resource{ - Filename: "transactionArg.cdc", - Source: []byte(` - transaction(greeting: String) { - let guest: Address - - prepare(authorizer: AuthAccount) { - self.guest = authorizer.address - } - - execute { - log(greeting.concat(",").concat(self.guest.toString())) - } - } - `), -} - -var TransactionImports = Resource{ - Filename: "transactionImport.cdc", - Source: []byte(` - import Hello from "./contractHello.cdc" - - transaction() { - prepare(authorizer: AuthAccount) {} - execute { - Hello.hello() - } - } - `), -} - -var TransactionSimple = Resource{ - Filename: "transactionSimple.cdc", - Source: []byte(` - transaction() { } - `), -} - -var TransactionSingleAuth = Resource{ - Filename: "transactionAuth1.cdc", - Source: []byte(` - transaction() { - prepare(authorizer: AuthAccount) {} - } - `), -} - -var TransactionTwoAuth = Resource{ - Filename: "transactionAuth2.cdc", - Source: []byte(` - transaction() { - prepare(auth1: AuthAccount, auth2: AuthAccount) {} - } - `), -} - -var TransactionMultipleDeclarations = Resource{ - Filename: "transactionMultipleDec.cdc", - Source: []byte(` - pub fun dummy(_ address: Address): Void {} - - transaction() { - prepare(authorizer: AuthAccount) {} - } - `), -} - -var ScriptWithError = Resource{ - Filename: "scriptError.cdc", - Source: []byte(` - pub fun main(name: String): Strin { - return "Hello ".concat(name) - } - `), -} - -var ScriptArgString = Resource{ - Filename: "scriptArg.cdc", - Source: []byte(` - pub fun main(name: String): String { - return "Hello ".concat(name) - } - `), -} - -var ScriptImport = Resource{ - Filename: "scriptImport.cdc", - Source: []byte(` - import Hello from "./contractHello.cdc" - - pub fun main(): String { - return "Hello ".concat(Hello.greeting) - } - `), -} - -var HelperImport = Resource{ - Filename: "test_helpers.cdc", - Source: []byte(` - pub fun double(_ x: Int): Int { - return x * 2 - } - `), -} - -var TestScriptSimple = Resource{ - Filename: "./testScriptSimple.cdc", - Source: []byte(` - import Test - - pub fun testSimple() { - Test.assert(true) - } - `), -} - -var TestScriptSimpleFailing = Resource{ - Filename: "./testScriptSimpleFailing.cdc", - Source: []byte(` - import Test - - pub fun testSimple() { - Test.assert(false) - } - `), -} - -var TestScriptWithImport = Resource{ - Filename: "testScriptWithImport.cdc", - Source: []byte(` - import Test - import "Hello" - - pub fun setup() { - let err = Test.deployContract( - name: "Hello", - path: "contractHello.cdc", - arguments: [] - ) - Test.expect(err, Test.beNil()) - } - - pub fun testSimple() { - Test.assertEqual("Hello, World!", Hello.greeting) - } - `), -} - -var TestScriptWithMissingContract = Resource{ - Filename: "testScriptWithImport.cdc", - Source: []byte(` - import Test - import "ApprovalVoting" - - pub fun setup() { - let err = Test.deployContract( - name: "ApprovalVoting", - path: "ApprovalVoting.cdc", - arguments: [] - ) - Test.expect(err, Test.beNil()) - } - `), -} - -var TestScriptWithHelperImport = Resource{ - Filename: "testScriptWithHelperImport.cdc", - Source: []byte(` - import Test - import "test_helpers.cdc" - - pub fun testDouble() { - Test.expect(double(2), Test.equal(4)) - } - `), -} - -var TestScriptWithRelativeImports = Resource{ - Filename: "testScriptWithRelativeImport.cdc", - Source: []byte(` - import Test - import FooContract from "../contracts/FooContract.cdc" - import Hello from "../contracts/contractHello.cdc" - - pub fun setup() { - var err = Test.deployContract( - name: "FooContract", - path: "../contracts/FooContract.cdc", - arguments: [] - ) - Test.expect(err, Test.beNil()) - - err = Test.deployContract( - name: "Hello", - path: "../contracts/contractHello.cdc", - arguments: [] - ) - Test.expect(err, Test.beNil()) - } - - pub fun testSimple() { - Test.assertEqual("Enormous", FooContract.getIntegerTrait(100001)) - Test.assertEqual("Hello, World!", Hello.greeting) - } - `), -} - -var TestScriptWithFileRead = Resource{ - Filename: "testScriptWithFileRead.cdc", - Source: []byte(` - import Test - - pub fun testSimple() { - let content = Test.readFile("./someFile.cdc") - Test.assertEqual("This was read from a file!", content) - } - `), -} - -var TestScriptWithCoverage = Resource{ - Filename: "testScriptWithCoverage.cdc", - Source: []byte(` - import Test - import "FooContract" - - pub fun setup() { - let err = Test.deployContract( - name: "FooContract", - path: "FooContract.cdc", - arguments: [] - ) - - Test.expect(err, Test.beNil()) - } - - pub fun testGetIntegerTrait() { - // Arrange - let testInputs: {Int: String} = { - -1: "Negative", - 0: "Zero", - 9: "Small", - 99: "Big", - 999: "Huge", - 1001: "Enormous", - 1729: "Harshad", - 8128: "Harmonic", - 41041: "Carmichael" - } - - for input in testInputs.keys { - // Act - let result = FooContract.getIntegerTrait(input) - - // Assert - Test.assertEqual(testInputs[input]!, result) - } - } - - pub fun testAddSpecialNumber() { - // Act - FooContract.addSpecialNumber(78557, "Sierpinski") - - // Assert - Test.assertEqual(FooContract.getIntegerTrait(78557), "Sierpinski") - } - `), -} - -var SomeFile = Resource{ - Filename: "someFile.cdc", - Source: []byte(`This was read from a file!`), -} - -var resources = []Resource{ - ContractHelloString, - TransactionArgString, - ScriptArgString, - TestScriptSimple, - ContractSimple, - ContractSimpleWithArgs, - ContractSimpleUpdated, - TransactionSimple, - ScriptImport, - HelperImport, - ContractA, - ContractB, - ContractC, - ContractAA, - ContractBB, - ContractCC, - ContractFooCoverage, -} - -func ReaderWriter() (afero.Afero, afero.Fs) { - var mockFS = afero.NewMemMapFs() - - for _, c := range resources { - _ = afero.WriteFile(mockFS, c.Filename, c.Source, 0644) - } - - return afero.Afero{Fs: mockFS}, mockFS -} - -func PubKeys() []crypto.PublicKey { - var pubKeys []crypto.PublicKey - privKeys := PrivKeys() - for _, priv := range privKeys { - pubKeys = append(pubKeys, priv.PublicKey()) - } - return pubKeys -} - -func PrivKeys() []crypto.PrivateKey { - var privKeys []crypto.PrivateKey - for x := 0; x < 5; x++ { - pk, _ := crypto.GeneratePrivateKey( - crypto.ECDSA_P256, - []byte(fmt.Sprintf("seedseedseedseedseedseedseedseedseedseedseedseed%d", x)), - ) - privKeys = append(privKeys, pk) - } - return privKeys -} - -func SigAlgos() []crypto.SignatureAlgorithm { - var sigAlgos []crypto.SignatureAlgorithm - privKeys := PrivKeys() - for _, priv := range privKeys { - sigAlgos = append(sigAlgos, priv.Algorithm()) - } - return sigAlgos -} - -func HashAlgos() []crypto.HashAlgorithm { - var hashAlgos []crypto.HashAlgorithm - for x := 0; x < 5; x++ { - hashAlgos = append(hashAlgos, crypto.SHA3_256) - } - return hashAlgos -} - -var accounts = test.AccountGenerator() - -var transactions = test.TransactionGenerator() - -var transactionResults = test.TransactionResultGenerator() - -func NewAccountWithAddress(address string) *flow.Account { - account := accounts.New() - account.Address = flow.HexToAddress(address) - return account -} - -func NewAccountWithContracts(address string, contracts ...Resource) *flow.Account { - account := accounts.New() - account.Address = flow.HexToAddress(address) - - if account.Contracts == nil { - account.Contracts = make(map[string][]byte) - } - - for _, contract := range contracts { - account.Contracts[contract.Name] = contract.Source - } - - return account -} - -func NewTransaction() *flow.Transaction { - return transactions.New() -} - -func NewBlock() *flow.Block { - return test.BlockGenerator().New() -} - -func NewCollection() *flow.Collection { - return test.CollectionGenerator().New() -} - -func NewEvent(index int, eventId string, fields []cadence.Field, values []cadence.Value) *flow.Event { - testEventType := &cadence.EventType{ - Location: nil, - QualifiedIdentifier: eventId, - Fields: fields, - } - - testEvent := cadence. - NewEvent(values). - WithType(testEventType) - - event := flow.Event{ - Type: eventId, - TransactionID: flow.Identifier{}, - TransactionIndex: index, - EventIndex: index, - Value: testEvent, - } - - return &event -} - -func NewTransactionResult(events []flow.Event) *flow.TransactionResult { - res := transactionResults.New() - res.Events = events - res.Error = nil - - return &res -} - -func NewAccountCreateResult(address flow.Address) *flow.TransactionResult { - events := []flow.Event{{ - Type: flow.EventAccountCreated, - TransactionID: flow.Identifier{}, - TransactionIndex: 0, - EventIndex: 0, - Value: cadence.Event{ - EventType: cadence.NewEventType(common.NewStringLocation(nil, flow.EventAccountCreated), "", []cadence.Field{{ - Identifier: "address", - Type: cadence.AddressType{}, - }}, nil), - Fields: []cadence.Value{ - cadence.NewAddress(address), - }, - }, - Payload: nil, - }} - - return NewTransactionResult(events) -} diff --git a/flowkit/tests/testnet_test.go b/flowkit/tests/testnet_test.go deleted file mode 100644 index f6a79401f..000000000 --- a/flowkit/tests/testnet_test.go +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package tests - -import ( - "context" - "testing" - - accounts2 "github.com/onflow/flow-cli/flowkit/accounts" - transactions2 "github.com/onflow/flow-cli/flowkit/transactions" - - "github.com/onflow/cadence" - flowsdk "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/spf13/afero" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/onflow/flow-cli/flowkit" - "github.com/onflow/flow-cli/flowkit/config" - "github.com/onflow/flow-cli/flowkit/gateway" - "github.com/onflow/flow-cli/flowkit/output" -) - -const testAccountName = "test-account" - -func initTestnet(t *testing.T) (gateway.Gateway, *flowkit.State, flowkit.Services, flowkit.ReaderWriter, afero.Fs) { - readerWriter, mockFs := ReaderWriter() - - state, err := flowkit.Init(readerWriter, crypto.ECDSA_P256, crypto.SHA3_256) - require.NoError(t, err) - - gw, err := gateway.NewGrpcGateway(config.TestnetNetwork) - require.NoError(t, err) - - logger := output.NewStdoutLogger(output.NoneLog) - flow := flowkit.NewFlowkit(state, config.TestnetNetwork, gw, logger) - - key, err := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, "4b2b6442fcbef2209bc1182af15d203a6195346cc8d95ebb433d3df1acb3910c") - require.NoError(t, err) - - funderKey := accounts2.NewHexKeyFromPrivateKey(0, crypto.SHA3_256, key) - funder := &accounts2.Account{ - Name: "funder", - Address: flowsdk.HexToAddress("0x72ddb3d2cec14114"), - Key: funderKey, - } - - testKey, err := flow.GenerateKey(context.Background(), crypto.ECDSA_P256, "") - require.NoError(t, err) - - flowAccount, _, err := flow.CreateAccount( - context.Background(), - funder, - []accounts2.PublicKey{{ - Public: testKey.PublicKey(), - Weight: 1000, - SigAlgo: crypto.ECDSA_P256, - HashAlgo: crypto.SHA3_256, - }}, - ) - require.NoError(t, err) - - testAccount := &accounts2.Account{ - Name: testAccountName, - Address: flowAccount.Address, - Key: accounts2.NewHexKeyFromPrivateKey(0, crypto.SHA3_256, testKey), - } - state.Accounts().AddOrUpdate(testAccount) - - // fund the account - // TODO(sideninja) refactor core contracts lib to offer the template - transferTx := []byte(` - import FungibleToken from 0x9a0766d93b6608b7 - import FlowToken from 0x7e60df042a9c0868 - - transaction(amount: UFix64, to: Address) { - - // The Vault resource that holds the tokens that are being transferred - let sentVault: @FungibleToken.Vault - - prepare(signer: AuthAccount) { - - // Get a reference to the signer's stored vault - let vaultRef = signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenVault) - ?? panic("Could not borrow reference to the owner's Vault!") - - // Withdraw tokens from the signer's stored vault - self.sentVault <- vaultRef.withdraw(amount: amount) - } - - execute { - - // Get a reference to the recipient's Receiver - let receiverRef = getAccount(to) - .getCapability(/public/flowTokenReceiver) - .borrow<&{FungibleToken.Receiver}>() - ?? panic("Could not borrow receiver reference to the recipient's Vault") - - // Deposit the withdrawn tokens in the recipient's receiver - receiverRef.deposit(from: <-self.sentVault) - } - }`) - - amount, _ := cadence.NewUFix64("0.01") - _, _, err = flow.SendTransaction( - context.Background(), - transactions2.SingleAccountRole(*funder), - flowkit.Script{ - Code: transferTx, - Args: []cadence.Value{amount, cadence.NewAddress(testAccount.Address)}, - }, - flowsdk.DefaultTransactionGasLimit, - ) - require.NoError(t, err) - - return gw, state, flow, readerWriter, mockFs -} - -var testnet = config.TestnetNetwork.Name - -func Test_Foo(t *testing.T) { - _, st, _, rw, _ := initTestnet(t) - - rw.WriteFile("test", []byte("foo"), 0644) - - out, _ := rw.ReadFile("test") - assert.Equal(t, out, []byte("foo")) - - rw.WriteFile("test", []byte("bar"), 0644) - out, _ = st.ReadFile("test") - assert.Equal(t, out, []byte("bar")) -} - -func Test_Testnet_ProjectDeploy(t *testing.T) { - _, state, flow, rw, _ := initTestnet(t) - - state.Contracts().AddOrUpdate(config.Contract{ - Name: ContractA.Name, - Location: ContractA.Filename, - }) - - state.Contracts().AddOrUpdate(config.Contract{ - Name: ContractB.Name, - Location: ContractB.Filename, - }) - - state.Contracts().AddOrUpdate(config.Contract{ - Name: ContractC.Name, - Location: ContractC.Filename, - }) - - initArg, _ := cadence.NewString("foo") - state.Deployments().AddOrUpdate(config.Deployment{ - Network: testnet, - Account: testAccountName, - Contracts: []config.ContractDeployment{ - {Name: ContractA.Name}, - {Name: ContractB.Name}, - {Name: ContractC.Name, Args: []cadence.Value{initArg}}, - }, - }) - - contracts, err := flow.DeployProject(context.Background(), flowkit.UpdateExistingContract(false)) - assert.NoError(t, err) - assert.Len(t, contracts, 3) - assert.Equal(t, ContractA.Name, contracts[0].Name) - assert.Equal(t, ContractB.Name, contracts[1].Name) - assert.Equal(t, ContractC.Name, contracts[2].Name) - - // make a change - updated := []byte(` - import "ContractA" - pub contract ContractB { - pub init() {} - } - `) - ContractB.Source = updated - err = rw.WriteFile(ContractB.Filename, ContractB.Source, 0644) - require.NoError(t, err) - - contracts, err = flow.DeployProject(context.Background(), flowkit.UpdateExistingContract(true)) - assert.NoError(t, err) - assert.Len(t, contracts, 3) - assert.Equal(t, ContractA.Name, contracts[0].Name) - assert.Equal(t, ContractB.Name, contracts[1].Name) - assert.Equal(t, ContractB.Source, updated) - assert.Equal(t, ContractC.Name, contracts[2].Name) -} diff --git a/flowkit/transactions/transaction.go b/flowkit/transactions/transaction.go deleted file mode 100644 index 9f65d47b9..000000000 --- a/flowkit/transactions/transaction.go +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package transactions - -import ( - "context" - "encoding/hex" - "fmt" - - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/runtime/ast" - "github.com/onflow/cadence/runtime/parser" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/templates" - - "github.com/onflow/flow-cli/flowkit/accounts" -) - -// New create new instance of transaction. -func New() *Transaction { - return &Transaction{ - tx: flow.NewTransaction(), - } -} - -// NewFromPayload build transaction from payload. -func NewFromPayload(payload []byte) (*Transaction, error) { - partialTxBytes, err := hex.DecodeString(string(payload)) - if err != nil { - return nil, fmt.Errorf("failed to decode partial transaction from %s: %v", payload, err) - } - - decodedTx, err := flow.DecodeTransaction(partialTxBytes) - if err != nil { - return nil, fmt.Errorf("failed to decode transaction from %s: %v", payload, err) - } - - tx := &Transaction{ - tx: decodedTx, - } - - return tx, nil -} - -// NewUpdateAccountContract update account contract. -func NewUpdateAccountContract(signer *accounts.Account, name string, source []byte) (*Transaction, error) { - contract := templates.Contract{ - Name: name, - Source: string(source), - } - - return newFromTemplate( - templates.UpdateAccountContract(signer.Address, contract), - signer, - ) -} - -// NewAddAccountContract add new contract to the account. -func NewAddAccountContract( - signer *accounts.Account, - name string, - source []byte, - args []cadence.Value, -) (*Transaction, error) { - return addAccountContractWithArgs(signer, templates.Contract{ - Name: name, - Source: string(source), - }, args) -} - -// NewRemoveAccountContract creates new transaction to remove contract. -func NewRemoveAccountContract(signer *accounts.Account, name string) (*Transaction, error) { - return newFromTemplate( - templates.RemoveAccountContract(signer.Address, name), - signer, - ) -} - -// addAccountContractWithArgs contains logic to build a transaction and include the contract code -// as well as possible init arguments. -func addAccountContractWithArgs( - signer *accounts.Account, - contract templates.Contract, - args []cadence.Value, -) (*Transaction, error) { - // define the add contract transaction template, note that the transaction has possibility - // of multiple arguments with the last %s which is extended in the next step - const addAccountContractTemplate = ` - transaction(name: String, code: String %s) { - prepare(signer: AuthAccount) { - signer.contracts.add(name: name, code: code.utf8 %s) - } - }` - - cadenceName := cadence.String(contract.Name) - cadenceCode := cadence.String(contract.Source) - - tx := flow.NewTransaction(). - AddRawArgument(jsoncdc.MustEncode(cadenceName)). - AddRawArgument(jsoncdc.MustEncode(cadenceCode)). - AddAuthorizer(signer.Address) - - for _, arg := range args { - arg.Type().ID() - tx.AddRawArgument(jsoncdc.MustEncode(arg)) - } - - // here we itterate over all arguments and possibly extend the transaction input argument - // in the above template to include them - txArgs, addArgs := "", "" - for i, arg := range args { - txArgs += fmt.Sprintf(",arg%d:%s", i, arg.Type().ID()) - addArgs += fmt.Sprintf(",arg%d", i) - } - - script := fmt.Sprintf(addAccountContractTemplate, txArgs, addArgs) - tx.SetScript([]byte(script)) - tx.SetGasLimit(flow.DefaultTransactionGasLimit) - - t := &Transaction{tx: tx} - err := t.SetSigner(signer) - if err != nil { - return nil, err - } - t.SetPayer(signer.Address) - - return t, nil -} - -// NewCreateAccount creates new transaction for account. -func NewCreateAccount( - signer *accounts.Account, - keys []*flow.AccountKey, - contracts []templates.Contract, -) (*Transaction, error) { - template, err := templates.CreateAccount(keys, contracts, signer.Address) - if err != nil { - return nil, err - } - return newFromTemplate(template, signer) -} - -func newFromTemplate(templateTx *flow.Transaction, signer *accounts.Account) (*Transaction, error) { - tx := &Transaction{tx: templateTx} - - err := tx.SetSigner(signer) - if err != nil { - return nil, err - } - tx.SetPayer(signer.Address) - tx.SetComputeLimit(flow.DefaultTransactionGasLimit) // TODO(sideninja) change this to calculated limit - - return tx, nil -} - -// Transaction builder of flow transactions. -type Transaction struct { - signer *accounts.Account - proposer *flow.Account - tx *flow.Transaction -} - -// Signer get signer. -func (t *Transaction) Signer() *accounts.Account { - return t.signer -} - -// Proposer get proposer. -func (t *Transaction) Proposer() *flow.Account { - return t.proposer -} - -// FlowTransaction get flow transaction. -func (t *Transaction) FlowTransaction() *flow.Transaction { - return t.tx -} - -func (t *Transaction) SetScriptWithArgs(script []byte, args []cadence.Value) error { - t.tx.SetScript(script) - return t.AddArguments(args) -} - -// SetSigner sets the signer for transaction. -func (t *Transaction) SetSigner(account *accounts.Account) error { - if account.Key == nil { - return fmt.Errorf("signer account missing the key") - } - - err := account.Key.Validate() - if err != nil { - return err - } - - if !t.validSigner(account.Address) { - return fmt.Errorf( - "not a valid signer %s, proposer: %s, payer: %s, authorizers: %s", - account.Address, - t.tx.ProposalKey.Address, - t.tx.Payer, - t.tx.Authorizers, - ) - } - - t.signer = account - return nil -} - -// validSigner checks whether the signer is valid for transaction -func (t *Transaction) validSigner(s flow.Address) bool { - return t.tx.ProposalKey.Address == s || - t.tx.Payer == s || - t.authorizersContains(s) -} - -// authorizersContains checks whether address is in the authorizer list -func (t *Transaction) authorizersContains(address flow.Address) bool { - for _, a := range t.tx.Authorizers { - if address == a { - return true - } - } - - return false -} - -// SetProposer sets the proposer for transaction. -func (t *Transaction) SetProposer(proposer *flow.Account, keyIndex int) error { - if len(proposer.Keys) <= keyIndex { - return fmt.Errorf("failed to retrieve proposer key at index %d", keyIndex) - } - - t.proposer = proposer - proposerKey := proposer.Keys[keyIndex] - - t.tx.SetProposalKey( - proposer.Address, - proposerKey.Index, - proposerKey.SequenceNumber, - ) - - return nil -} - -// SetPayer sets the payer for transaction. -func (t *Transaction) SetPayer(address flow.Address) *Transaction { - t.tx.SetPayer(address) - return t -} - -// SetBlockReference sets block reference for transaction. -func (t *Transaction) SetBlockReference(block *flow.Block) *Transaction { - t.tx.SetReferenceBlockID(block.ID) - return t -} - -// SetComputeLimit sets the gas limit for transaction. -func (t *Transaction) SetComputeLimit(limit uint64) *Transaction { - t.tx.SetGasLimit(limit) - return t -} - -// AddArguments add array of cadence arguments. -func (t *Transaction) AddArguments(args []cadence.Value) error { - for _, arg := range args { - err := t.AddArgument(arg) - if err != nil { - return err - } - } - - return nil -} - -// AddArgument add cadence typed argument. -func (t *Transaction) AddArgument(arg cadence.Value) error { - return t.tx.AddArgument(arg) -} - -// AddAuthorizers add group of authorizers. -func (t *Transaction) AddAuthorizers(authorizers []flow.Address) (*Transaction, error) { - program, err := parser.ParseProgram(nil, t.tx.Script, parser.Config{}) - if err != nil { - return nil, err - } - - // get authorizers param list if exists - declarations := program.TransactionDeclarations() - if len(declarations) != 1 { - return nil, fmt.Errorf("can only support one transaction declaration per file, found %d", len(declarations)) - } - - requiredAuths := make([]*ast.Parameter, 0) - // if prepare block is missing set default authorizers to empty - if declarations[0].Prepare == nil { - authorizers = nil - } else { // if prepare block is present get authorizers - requiredAuths = declarations[0]. - Prepare. - FunctionDeclaration. - ParameterList. - Parameters - } - - if len(requiredAuths) != len(authorizers) { - return nil, fmt.Errorf( - "provided authorizers length mismatch, required authorizers %d, but provided %d", - len(requiredAuths), - len(authorizers), - ) - } - - for _, authorizer := range authorizers { - t.tx.AddAuthorizer(authorizer) - } - - return t, nil -} - -// Sign signs transaction using signer account. -func (t *Transaction) Sign() (*Transaction, error) { - keyIndex := t.signer.Key.Index() - signer, err := t.signer.Key.Signer(context.Background()) - if err != nil { - return nil, err - } - - if t.shouldSignEnvelope() { - err = t.tx.SignEnvelope(t.signer.Address, keyIndex, signer) - if err != nil { - return nil, fmt.Errorf("failed to sign transaction: %s", err) - } - } else { - err = t.tx.SignPayload(t.signer.Address, keyIndex, signer) - if err != nil { - return nil, fmt.Errorf("failed to sign transaction: %s", err) - } - } - - return t, nil -} - -// shouldSignEnvelope checks if signer should sign envelope or payload -func (t *Transaction) shouldSignEnvelope() bool { - return t.signer.Address == t.tx.Payer -} - -// SingleAccountRole creates transaction accounts from a single provided -// account fulfilling all the roles (proposer, payer, authorizer). -func SingleAccountRole(account accounts.Account) AccountRoles { - return AccountRoles{ - Proposer: account, - Authorizers: []accounts.Account{account}, - Payer: account, - } -} - -// AccountRoles define all the accounts for different transaction roles. -// -// You can read more about roles here: https://developers.flow.com/learn/concepts/accounts-and-keys -type AccountRoles struct { - Proposer accounts.Account - Authorizers []accounts.Account - Payer accounts.Account -} - -// AddressRoles returns address roles using the provided accounts. -func (t AccountRoles) AddressRoles() AddressesRoles { - auths := make([]flow.Address, len(t.Authorizers)) - for i, a := range t.Authorizers { - auths[i] = a.Address - } - - return AddressesRoles{ - Proposer: t.Proposer.Address, - Authorizers: auths, - Payer: t.Payer.Address, - } -} - -// Signers for signing the transaction, detect if all accounts are same so only return the one account. -func (t AccountRoles) Signers() []*accounts.Account { - // build only unique accounts to sign, it's important payer account is last - sigs := make([]*accounts.Account, 0) - addLastIfUnique := func(signer accounts.Account) { - for _, sig := range sigs { - if sig.Address == signer.Address { - return - } - } - sigs = append(sigs, &signer) - } - - addLastIfUnique(t.Proposer) - for _, auth := range t.Authorizers { - addLastIfUnique(auth) - } - addLastIfUnique(t.Payer) - - return sigs -} - -// AddressesRoles defines transaction roles by account addresses. -// -// You can read more about roles here: https://developers.flow.com/learn/concepts/accounts-and-keys -type AddressesRoles struct { - Proposer flow.Address - Authorizers []flow.Address - Payer flow.Address -} diff --git a/flowkit/transactions/transaction_test.go b/flowkit/transactions/transaction_test.go deleted file mode 100644 index 44d446195..000000000 --- a/flowkit/transactions/transaction_test.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Flow CLI - * - * Copyright 2019 Dapper Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package transactions_test - -import ( - "testing" - - "github.com/onflow/cadence" - jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/flow-go-sdk" - "github.com/onflow/flow-go-sdk/crypto" - "github.com/stretchr/testify/assert" - - "github.com/onflow/flow-cli/flowkit/accounts" - "github.com/onflow/flow-cli/flowkit/tests" - "github.com/onflow/flow-cli/flowkit/transactions" -) - -func TestNew(t *testing.T) { - tx := transactions.New() - - assert.NotNil(t, tx) - assert.NotNil(t, tx.FlowTransaction()) - - computeLimit := uint64(1000) - tx.SetComputeLimit(computeLimit) - assert.Equal(t, computeLimit, tx.FlowTransaction().GasLimit) - - arg := cadence.NewInt(1) - _ = tx.AddArgument(arg) - enc, _ := jsoncdc.Encode(arg) - assert.Equal(t, string(enc), string(tx.FlowTransaction().Arguments[0])) - - payer := flow.HexToAddress("0x01") - tx.SetPayer(payer) - assert.Equal(t, payer, tx.FlowTransaction().Payer) - - script := []byte(` - transaction (arg: Int) { - prepare(auth: AuthAccount) {} - execute {} - } - `) - err := tx.SetScriptWithArgs(script, []cadence.Value{arg}) - assert.NoError(t, err) - assert.Equal(t, script, tx.FlowTransaction().Script) - assert.Equal(t, string(enc), string(tx.FlowTransaction().Arguments[0])) - - auths := []flow.Address{flow.HexToAddress("0x02")} - tx, err = tx.AddAuthorizers(auths) - assert.NoError(t, err) - assert.Equal(t, auths, tx.FlowTransaction().Authorizers) - - addr := flow.HexToAddress("0x03") - index := 1 - proposer := tests.NewAccountWithAddress(addr.String()) - err = tx.SetProposer(proposer, index) - assert.NoError(t, err) - assert.Equal(t, addr.String(), tx.FlowTransaction().ProposalKey.Address.String()) - assert.Equal(t, proposer.Keys[index].Index, tx.FlowTransaction().ProposalKey.KeyIndex) - - rw, _ := tests.ReaderWriter() - sig, _ := accounts.NewEmulatorAccount(rw, crypto.ECDSA_P256, crypto.SHA3_256) - sig.Address = flow.HexToAddress("0x01") - err = tx.SetSigner(sig) - assert.NoError(t, err) - assert.Equal(t, sig, tx.Signer()) - - signed, err := tx.Sign() - assert.NoError(t, err) - assert.Len(t, signed.FlowTransaction().EnvelopeSignatures, 1) -} From c969d4854cf73dda0f2ea02a49cd6cd23830569f Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Thu, 1 Feb 2024 16:20:33 -0800 Subject: [PATCH 11/21] update ci --- .github/workflows/ci.yml | 3 +-- Makefile | 13 +------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e96e4d97..399fb163e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,12 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: "1.20" - name: Run tests run: | make ci make check-tidy make check-headers - make check-schema - name: Upload coverage report uses: codecov/codecov-action@v1 with: diff --git a/Makefile b/Makefile index 47b4c6dfd..16692d4bc 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,6 @@ install-tools: .PHONY: test test: GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./... - cd flowkit; GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./... .PHONY: test-e2e-emulator test-e2e-emulator: @@ -97,20 +96,10 @@ fix-lint: check-headers: @./check-headers.sh -.PHONY: check-schema -check-schema: - cd flowkit && go run ./cmd/flow-schema/flow-schema.go --verify=true ./schema.json - .PHONY: check-tidy check-tidy: go mod tidy - cd flowkit; go mod tidy - -.PHONY: generate-schema -generate-schema: - cd flowkit && go run ./cmd/flow-schema/flow-schema.go ./schema.json .PHONY: generate generate: install-tools - cd flowkit; \ - go generate ./... + go generate ./... From 25ea7320310af49159ea6b14708a804b116b8a0d Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Fri, 2 Feb 2024 15:47:39 -0800 Subject: [PATCH 12/21] update readme --- flowkit/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flowkit/README.md b/flowkit/README.md index 490a69f45..c48a65f09 100644 --- a/flowkit/README.md +++ b/flowkit/README.md @@ -1,3 +1,3 @@ ## Flowkit -Note: This module has been deprecated. The latest supported version is v1.13.0. The module migrated since to github.com/onflow/flowkit. Please use the new module github.com/onflow/flowkit instead. Version v1.13.0 is equivalent to version v1.13.0 on the new module. +Note: This module has been migrated to github.com/onflow/flowkit. The latest supported version is v1.13.0. Please use the new module github.com/onflow/flowkit instead for any future updates. Version v1.13.0 is equivalent to version v1.13.0 on the new module. From 7792783e3eada46585b59069705b16de1a66f144 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Fri, 2 Feb 2024 15:48:56 -0800 Subject: [PATCH 13/21] add back schema.sjon --- flowkit/schema.json | 327 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 flowkit/schema.json diff --git a/flowkit/schema.json b/flowkit/schema.json new file mode 100644 index 000000000..30504ea93 --- /dev/null +++ b/flowkit/schema.json @@ -0,0 +1,327 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/onflow/flow-cli/flowkit/config/json/json-config", + "$ref": "#/$defs/jsonConfig", + "$defs": { + "account": { + "oneOf": [ + { + "$ref": "#/$defs/simpleAccount" + }, + { + "$ref": "#/$defs/advancedAccount" + }, + { + "$ref": "#/$defs/simpleAccountPre022" + }, + { + "$ref": "#/$defs/advanceAccountPre022" + } + ] + }, + "advanceAccountPre022": { + "properties": { + "address": { + "type": "string" + }, + "keys": { + "items": { + "$ref": "#/$defs/advanceKey" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["address", "keys"] + }, + "advanceKey": { + "properties": { + "type": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "signatureAlgorithm": { + "type": "string" + }, + "hashAlgorithm": { + "type": "string" + }, + "privateKey": { + "type": "string" + }, + "mnemonic": { + "type": "string" + }, + "derivationPath": { + "type": "string" + }, + "resourceID": { + "type": "string" + }, + "location": { + "type": "string" + }, + "context": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["type"] + }, + "advancedAccount": { + "properties": { + "address": { + "type": "string" + }, + "key": { + "$ref": "#/$defs/advanceKey" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["address", "key"] + }, + "advancedNetwork": { + "properties": { + "host": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["host", "key"] + }, + "contractDeployment": { + "properties": { + "name": { + "type": "string" + }, + "args": { + "items": { + "type": "object" + }, + "type": "array" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["name", "args"] + }, + "deployment": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/$defs/contractDeployment" + } + ] + }, + "jsonAccounts": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/account" + } + }, + "type": "object" + }, + "jsonConfig": { + "properties": { + "emulators": { + "$ref": "#/$defs/jsonEmulators" + }, + "contracts": { + "$ref": "#/$defs/jsonContracts" + }, + "dependencies": { + "$ref": "#/$defs/jsonDependencies" + }, + "networks": { + "$ref": "#/$defs/jsonNetworks" + }, + "accounts": { + "$ref": "#/$defs/jsonAccounts" + }, + "deployments": { + "$ref": "#/$defs/jsonDeployments" + } + }, + "additionalProperties": false, + "type": "object" + }, + "jsonContract": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/$defs/jsonContractAdvanced" + } + ] + }, + "jsonContractAdvanced": { + "properties": { + "source": { + "type": "string" + }, + "aliases": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["source", "aliases"] + }, + "jsonContracts": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/jsonContract" + } + }, + "type": "object" + }, + "jsonDependencies": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/jsonDependency" + } + }, + "type": "object" + }, + "jsonDependency": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/$defs/jsonDependencyExtended" + } + ] + }, + "jsonDependencyExtended": { + "properties": { + "source": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "aliases": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["source", "hash", "aliases"] + }, + "jsonDeployment": { + "patternProperties": { + ".*": { + "items": { + "$ref": "#/$defs/deployment" + }, + "type": "array" + } + }, + "type": "object" + }, + "jsonDeployments": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/jsonDeployment" + } + }, + "type": "object" + }, + "jsonEmulator": { + "properties": { + "port": { + "type": "integer" + }, + "serviceAccount": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["port", "serviceAccount"] + }, + "jsonEmulators": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/jsonEmulator" + } + }, + "type": "object" + }, + "jsonNetwork": { + "oneOf": [ + { + "$ref": "#/$defs/simpleNetwork" + }, + { + "$ref": "#/$defs/advancedNetwork" + } + ] + }, + "jsonNetworks": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/jsonNetwork" + } + }, + "type": "object" + }, + "simpleAccount": { + "properties": { + "address": { + "type": "string" + }, + "key": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["address", "key"] + }, + "simpleAccountPre022": { + "properties": { + "address": { + "type": "string" + }, + "keys": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": ["address", "keys"] + }, + "simpleNetwork": { + "type": "string" + } + } +} From 94e1b04f413fd85c298100248b96e87085ce86c6 Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Fri, 2 Feb 2024 15:50:17 -0800 Subject: [PATCH 14/21] update --- flowkit/schema.json | 52 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/flowkit/schema.json b/flowkit/schema.json index 30504ea93..ad6767830 100644 --- a/flowkit/schema.json +++ b/flowkit/schema.json @@ -33,7 +33,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["address", "keys"] + "required": [ + "address", + "keys" + ] }, "advanceKey": { "properties": { @@ -75,7 +78,9 @@ }, "additionalProperties": false, "type": "object", - "required": ["type"] + "required": [ + "type" + ] }, "advancedAccount": { "properties": { @@ -88,7 +93,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["address", "key"] + "required": [ + "address", + "key" + ] }, "advancedNetwork": { "properties": { @@ -101,7 +109,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["host", "key"] + "required": [ + "host", + "key" + ] }, "contractDeployment": { "properties": { @@ -117,7 +128,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["name", "args"] + "required": [ + "name", + "args" + ] }, "deployment": { "oneOf": [ @@ -187,7 +201,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["source", "aliases"] + "required": [ + "source", + "aliases" + ] }, "jsonContracts": { "patternProperties": { @@ -234,7 +251,11 @@ }, "additionalProperties": false, "type": "object", - "required": ["source", "hash", "aliases"] + "required": [ + "source", + "hash", + "aliases" + ] }, "jsonDeployment": { "patternProperties": { @@ -266,7 +287,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["port", "serviceAccount"] + "required": [ + "port", + "serviceAccount" + ] }, "jsonEmulators": { "patternProperties": { @@ -305,7 +329,10 @@ }, "additionalProperties": false, "type": "object", - "required": ["address", "key"] + "required": [ + "address", + "key" + ] }, "simpleAccountPre022": { "properties": { @@ -318,10 +345,13 @@ }, "additionalProperties": false, "type": "object", - "required": ["address", "keys"] + "required": [ + "address", + "keys" + ] }, "simpleNetwork": { "type": "string" } } -} +} \ No newline at end of file From d6116c15984689c5acbe228d43cb491ce6e57166 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:41:05 -0800 Subject: [PATCH 15/21] Format boilerplat access modifiers --- internal/super/generate.go | 6 ++++-- internal/super/generate_test.go | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/super/generate.go b/internal/super/generate.go index b60f4ca09..5837819ab 100644 --- a/internal/super/generate.go +++ b/internal/super/generate.go @@ -157,11 +157,13 @@ func generateNew( switch templateType { case "contract": fileToWrite = fmt.Sprintf(` -access(all) contract %s { +access(all) +contract %s { init() {} }`, name) case "script": - fileToWrite = `access(all) fun main() { + fileToWrite = `access(all) +fun main() { // Script details here }` case "transaction": diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index 6183fbf6a..dbf1e274d 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -51,7 +51,8 @@ func TestGenerateNewContract(t *testing.T) { // Check content is correct expectedContent := ` -access(all) contract TestContract { +access(all) +contract TestContract { init() {} }` assert.Equal(t, expectedContent, string(fileContent)) @@ -129,7 +130,8 @@ func TestGenerateNewScript(t *testing.T) { assert.NoError(t, err, "Failed to read generated file") assert.NotNil(t, content) - expectedContent := `access(all) fun main() { + expectedContent := `access(all) +fun main() { // Script details here }` assert.Equal(t, expectedContent, string(content)) @@ -185,7 +187,8 @@ func TestGenerateNewWithDirFlag(t *testing.T) { assert.NotNil(t, content) expectedContent := ` -access(all) contract TestContract { +access(all) +contract TestContract { init() {} }` assert.Equal(t, expectedContent, string(content)) From a31695657d678f4625b8169b57227c7607a4ca8a Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:25:54 -0800 Subject: [PATCH 16/21] Remove os dir code --- internal/super/generate_test.go | 61 ++++----------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/internal/super/generate_test.go b/internal/super/generate_test.go index dbf1e274d..0a9239ce4 100644 --- a/internal/super/generate_test.go +++ b/internal/super/generate_test.go @@ -19,7 +19,6 @@ package super import ( - "os" "testing" "github.com/onflow/flow-cli/internal/util" @@ -30,19 +29,11 @@ import ( ) func TestGenerateNewContract(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) // Test contract generation - _, err = generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", logger, state) assert.NoError(t, err, "Failed to generate contract") fileContent, err := state.ReaderWriter().ReadFile("cadence/contracts/TestContract.cdc") @@ -64,19 +55,11 @@ contract TestContract { } func TestGenerateNewContractFileAlreadyExists(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) // Test contract generation - _, err = generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", logger, state) assert.NoError(t, err, "Failed to generate contract") //// Check if the file exists in the correct directory @@ -91,18 +74,10 @@ func TestGenerateNewContractFileAlreadyExists(t *testing.T) { } func TestGenerateNewContractWithFileExtension(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err = generateNew([]string{"TestContract.cdc"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract.cdc"}, "contract", logger, state) assert.NoError(t, err, "Failed to generate contract") // Check file exists @@ -112,18 +87,10 @@ func TestGenerateNewContractWithFileExtension(t *testing.T) { } func TestGenerateNewScript(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err = generateNew([]string{"TestScript"}, "script", logger, state) + _, err := generateNew([]string{"TestScript"}, "script", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("cadence/scripts/TestScript.cdc") @@ -138,18 +105,10 @@ fun main() { } func TestGenerateNewTransaction(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) - _, err = generateNew([]string{"TestTransaction"}, "transaction", logger, state) + _, err := generateNew([]string{"TestTransaction"}, "transaction", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("cadence/transactions/TestTransaction.cdc") @@ -165,21 +124,13 @@ func TestGenerateNewTransaction(t *testing.T) { } func TestGenerateNewWithDirFlag(t *testing.T) { - dir, err := os.MkdirTemp("", "test") - assert.NoError(t, err, "Failed to create temp dir") - defer os.RemoveAll(dir) - - if err := os.Chdir(dir); err != nil { - t.Fatalf("Failed to change directory: %v", err) - } - logger := output.NewStdoutLogger(output.NoneLog) _, state, _ := util.TestMocks(t) // Set a custom directory generateFlags.Directory = "customDir" - _, err = generateNew([]string{"TestContract"}, "contract", logger, state) + _, err := generateNew([]string{"TestContract"}, "contract", logger, state) assert.NoError(t, err, "Failed to generate contract") content, err := state.ReaderWriter().ReadFile("customDir/TestContract.cdc") From b5ec241f1f9b96d3cb2b1d408a10df192e3f5f3e Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:29:32 -0800 Subject: [PATCH 17/21] Update migration url --- cmd/flow/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 79fd78961..9ccf802b2 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -63,7 +63,7 @@ func main() { if outputFlag != "json" { width := 80 - url := "https://developers.flow.com/build/cadence-migration-guide" + url := "https://cadence-lang.org/docs/cadence_migration_guide" // Function to center text within a given width centerText := func(text string, width int) string { From 5d9c27af11cb4c0ce16fe06eb51c34e6466e869c Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:30:52 -0800 Subject: [PATCH 18/21] Bump version to v1.13.1 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index e58d236a7..47ca3661d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.13.0 \ No newline at end of file +v1.13.1 \ No newline at end of file From 267c1fdd3ae96197d4308becc4e6cbc6058f0253 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:52:09 +0000 Subject: [PATCH 19/21] Bump github.com/getsentry/sentry-go from 0.26.0 to 0.27.0 Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.26.0 to 0.27.0. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e4f405376..b275c37ea 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/dukex/mixpanel v1.0.1 - github.com/getsentry/sentry-go v0.26.0 + github.com/getsentry/sentry-go v0.27.0 github.com/go-git/go-git/v5 v5.11.0 github.com/gosuri/uilive v0.0.4 github.com/manifoldco/promptui v0.9.0 diff --git a/go.sum b/go.sum index f6228df2e..830a201be 100644 --- a/go.sum +++ b/go.sum @@ -314,8 +314,8 @@ github.com/gammazero/workerpool v1.1.2 h1:vuioDQbgrz4HoaCi2q1HLlOXdpbap5AET7xu5/ github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= -github.com/getsentry/sentry-go v0.26.0 h1:IX3++sF6/4B5JcevhdZfdKIHfyvMmAq/UnqcyT2H6mA= -github.com/getsentry/sentry-go v0.26.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From e47db16d1aae76c097499acc82998fdb36451d59 Mon Sep 17 00:00:00 2001 From: Tom Haile Date: Tue, 13 Feb 2024 10:20:29 -0600 Subject: [PATCH 20/21] updated version of flixkit, update processing state to create contract dependencies structure for flix generation --- go.mod | 2 +- go.sum | 4 ++-- internal/super/flix.go | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index e4f405376..211cb2177 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/onflow/cadence-tools/languageserver v0.33.3 github.com/onflow/cadence-tools/test v0.14.5 github.com/onflow/fcl-dev-wallet v0.7.4 - github.com/onflow/flixkit-go v1.1.1 + github.com/onflow/flixkit-go v1.1.2 github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f github.com/onflow/flow-emulator v0.59.0 github.com/onflow/flow-go-sdk v0.41.17 diff --git a/go.sum b/go.sum index f6228df2e..46b833bf6 100644 --- a/go.sum +++ b/go.sum @@ -875,8 +875,8 @@ github.com/onflow/cadence-tools/test v0.14.5 h1:u1kYkotKdwKEf9c3h65mI3VMevBkHY+7 github.com/onflow/cadence-tools/test v0.14.5/go.mod h1:ix09Bb3GQ/fZMNpSR8E+vSFItGF54fzP9gFxU7AsOIw= github.com/onflow/fcl-dev-wallet v0.7.4 h1:vI6t3U0AO88R/Iitn5KsnniSpbN9Lqsqwvi9EJT4C0k= github.com/onflow/fcl-dev-wallet v0.7.4/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= -github.com/onflow/flixkit-go v1.1.1 h1:ARgLsfWxc3LjgUHUAELildY5lxJ6kA4gVfAS2+ZRaCE= -github.com/onflow/flixkit-go v1.1.1/go.mod h1:XkbRPv6drM8uQpvdKgZ5stShtOlOMiQ6Fy86D0EsW5U= +github.com/onflow/flixkit-go v1.1.2 h1:pn8CtUr1qpHrZF+xbl6FXU+nVGtUgFKYm3XGaX0yKj8= +github.com/onflow/flixkit-go v1.1.2/go.mod h1:XkbRPv6drM8uQpvdKgZ5stShtOlOMiQ6Fy86D0EsW5U= github.com/onflow/flow-cli/flowkit v1.11.0 h1:RSfKlla/l+ZJwqAmlvA5HPFbQ6ia2wzKSG0kJ8fqVa0= github.com/onflow/flow-cli/flowkit v1.11.0/go.mod h1:aH4shan7Ggxd0GIXZD2S4kYMemNfzP1rLWvzKnb6K3g= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= diff --git a/internal/super/flix.go b/internal/super/flix.go index edb92a6f2..08b83dc99 100644 --- a/internal/super/flix.go +++ b/internal/super/flix.go @@ -261,14 +261,31 @@ func (fr *flixResult) Oneliner() string { func getDeployedContracts(state *flowkit.State) flixkit.ContractInfos { allContracts := make(flixkit.ContractInfos) depNetworks := make([]string, 0) + accountAddresses := make(map[string]string) // get all configured networks in flow.json for _, n := range *state.Networks() { depNetworks = append(depNetworks, n.Name) } + // get account addresses + for _, a := range *state.Accounts() { + accountAddresses[a.Name] = a.Address.Hex() + } + + for _, d := range *state.Deployments() { + addr := accountAddresses[d.Account] + for _, c := range d.Contracts { + if _, ok := allContracts[c.Name]; !ok { + allContracts[c.Name] = make(flixkit.NetworkAddressMap) + } + allContracts[c.Name][d.Network] = addr + } + } + // get all deployed and alias contracts for configured networks for _, network := range depNetworks { - contracts, err := state.DeploymentContractsByNetwork(config.Network{Name: network}) + cfg := config.Network{Name: network} + contracts, err := state.DeploymentContractsByNetwork(cfg) if err != nil { continue } @@ -278,7 +295,7 @@ func getDeployedContracts(state *flowkit.State) flixkit.ContractInfos { } allContracts[c.Name][network] = c.AccountAddress.Hex() } - locAliases := state.AliasesForNetwork(config.Network{Name: network}) + locAliases := state.AliasesForNetwork(cfg) for name, addr := range locAliases { address := flow.BytesToAddress([]byte(addr)) if isPath(name) { @@ -290,6 +307,7 @@ func getDeployedContracts(state *flowkit.State) flixkit.ContractInfos { allContracts[name][network] = address.Hex() } } + return allContracts } From 75f63b825a9faa80900433a5e4583b7dadf93a7b Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:11:10 -0800 Subject: [PATCH 21/21] Bump version to v1.13.2 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 47ca3661d..c192da6df 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.13.1 \ No newline at end of file +v1.13.2 \ No newline at end of file