Skip to content

Commit

Permalink
Merge pull request #91 from onflow/ls/flowkit-update
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Apr 10, 2023
2 parents 708636f + 9ad4c27 commit 9129578
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 75 deletions.
11 changes: 3 additions & 8 deletions languageserver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/onflow/cadence v0.37.0
github.com/onflow/cadence-tools/lint v0.6.0
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230327102447-8c34a92f8cbb
github.com/onflow/flow-go-sdk v0.37.0
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230404110506-8464bcb4f9ec
github.com/onflow/flow-go-sdk v0.38.0
github.com/sourcegraph/jsonrpc2 v0.1.0
github.com/spf13/afero v1.9.4
github.com/spf13/pflag v1.0.5
Expand All @@ -29,7 +29,6 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
Expand All @@ -38,7 +37,7 @@ require (
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ef-ds/deque v1.0.4 // indirect
github.com/ethereum/go-ethereum v1.10.21 // indirect
github.com/ethereum/go-ethereum v1.10.22 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.1-0.20220515183430-ad2eae63303f // indirect
github.com/fxamacker/circlehash v0.3.0 // indirect
Expand Down Expand Up @@ -82,7 +81,6 @@ require (
github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
Expand All @@ -96,7 +94,6 @@ require (
github.com/multiformats/go-multistream v0.3.3 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onflow/atree v0.5.0 // indirect
github.com/onflow/cadence-tools/test v0.5.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v0.12.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v0.12.1 // indirect
github.com/onflow/flow-emulator v0.45.0 // indirect
Expand All @@ -116,9 +113,7 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230126093431-47fa9a501578 // indirect
github.com/rivo/uniseg v0.2.1-0.20211004051800-57c86be7915a // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sethvargo/go-retry v0.2.3 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand Down
25 changes: 6 additions & 19 deletions languageserver/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ 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.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
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/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
Expand Down Expand Up @@ -132,8 +129,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
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/ethereum/go-ethereum v1.10.21 h1:5lqsEx92ZaZzRyOqBEXux4/UR06m296RGzN3ol3teJY=
github.com/ethereum/go-ethereum v1.10.21/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/ethereum/go-ethereum v1.10.22 h1:HbEgsDo1YTGIf4KB/NNpn+XH+PiNJXUZ9ksRxiqWyMc=
github.com/ethereum/go-ethereum v1.10.22/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
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.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand Down Expand Up @@ -363,8 +360,6 @@ github.com/m4ksio/wal v1.0.1-0.20221209164835-154a17396e4c h1:OqVcb1Dkheracn4fgC
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand Down Expand Up @@ -426,10 +421,8 @@ github.com/onflow/cadence v0.37.0 h1:eRdHzkkYtRKu6vNMkX0rGXca63zL4X4h9lqsvnDVD9c
github.com/onflow/cadence v0.37.0/go.mod h1:SpfjNhPsJxGIHbOthE9JD/e8JFaFY73joYLPsov+PY4=
github.com/onflow/cadence-tools/lint v0.6.0 h1:JCMfpS5b9k7/O7xMXrE4AysEq0sEP2PzW72PbYavqL4=
github.com/onflow/cadence-tools/lint v0.6.0/go.mod h1:WcjQPrABRCvkmQohcYvSx/UDktcemKQ3u3R+UhUbyR4=
github.com/onflow/cadence-tools/test v0.5.0 h1:5Z/E2VImOO59LGFeYvjWZt0lF1juMGB8iC5OqG0cXkc=
github.com/onflow/cadence-tools/test v0.5.0/go.mod h1:YyNM1YjyWaPVKO/k8jUl2J82FYPeKOCOUQ3EPnVu9gs=
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230327102447-8c34a92f8cbb h1:Ac0+2r8Xzng7mYE3JZd458zml9qiXzye46IHn3ArNYU=
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230327102447-8c34a92f8cbb/go.mod h1:6cQ6zouz8WBZEzfnbUbH3FhfkM7gesXphII2dgPqtuM=
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230404110506-8464bcb4f9ec h1:949zivil/W5cxG9UiW3lAcUm8ZCku88fGUuwP5k9UQs=
github.com/onflow/flow-cli/pkg/flowkit v0.0.0-20230404110506-8464bcb4f9ec/go.mod h1:OqELANsL3ePf71a153A+c+EfeF4wiSkfFUTTu/X/Xz0=
github.com/onflow/flow-core-contracts/lib/go/contracts v0.12.1 h1:9QEI+C9k/Cx/TRC3SCAHmNQqV7UlLG0DHQewTl8Lg6w=
github.com/onflow/flow-core-contracts/lib/go/contracts v0.12.1/go.mod h1:xiSs5IkirazpG89H5jH8xVUKNPlCZqUhLH4+vikQVS4=
github.com/onflow/flow-core-contracts/lib/go/templates v0.12.1 h1:dhXSFiBkS6Q3XmBctJAfwR4XPkgBT7VNx08F/zTBgkM=
Expand All @@ -440,8 +433,8 @@ github.com/onflow/flow-ft/lib/go/contracts v0.5.0 h1:Cg4gHGVblxcejfNNG5Mfj98Wf4z
github.com/onflow/flow-ft/lib/go/contracts v0.5.0/go.mod h1:1zoTjp1KzNnOPkyqKmWKerUyf0gciw+e6tAEt0Ks3JE=
github.com/onflow/flow-go v0.29.6-with-pr-3835.0.20230324174649-2f1a1d0f6fc4 h1:Zl+jmEMRSDqFMYb0Rin8xcqk8XD3ZytAwOw2R5jm3D0=
github.com/onflow/flow-go v0.29.6-with-pr-3835.0.20230324174649-2f1a1d0f6fc4/go.mod h1:C19gQskmsR9yvi7pemTtvHsj3bnKrx1gPBhlmp6Oz6k=
github.com/onflow/flow-go-sdk v0.37.0 h1:eTQBYNCXQKkajiqcx5l3SZoCGejV7HXWB6mp1UlAlXk=
github.com/onflow/flow-go-sdk v0.37.0/go.mod h1:VMVRJhU6CZkQvcSuTzqcShzc7NQ97CshV0lyIcnLDpM=
github.com/onflow/flow-go-sdk v0.38.0 h1:xOyUZ4jFOnFzKFr2o2ko/D+ZS97steaVwQLrHfi+wN8=
github.com/onflow/flow-go-sdk v0.38.0/go.mod h1:Kyn3PdNjZ7hxLQ3BZJEN9KFJ6XKUqf+v+VI/dZ1hSEQ=
github.com/onflow/flow-go/crypto v0.24.7 h1:RCLuB83At4z5wkAyUCF7MYEnPoIIOHghJaODuJyEoW0=
github.com/onflow/flow-go/crypto v0.24.7/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7Q6u+bCI78lfNX0=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20221202093946-932d1c70e288 h1:haWv3D5loiH+zcOoWEvDXtWQvXt5U8PLliQjwhv9sfw=
Expand Down Expand Up @@ -500,14 +493,11 @@ github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6us
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.8.3 h1:FnLGl3ewlDUP+YdSwveXBaXs053Mem/du+wr7XSYKl8=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
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/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/slok/go-http-metrics v0.10.0 h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/sourcegraph/jsonrpc2 v0.1.0 h1:ohJHjZ+PcaLxDUjqk2NC3tIGsVa5bXThe1ZheSXOjuk=
Expand Down Expand Up @@ -753,7 +743,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-20181122145206-62eef0e2fa9b/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-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -797,7 +786,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/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-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
Expand Down Expand Up @@ -998,7 +986,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
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.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Expand Down
107 changes: 60 additions & 47 deletions languageserver/integration/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package integration

import (
"context"
"fmt"
"net/url"
"os"
Expand All @@ -29,8 +30,6 @@ import (
"github.com/onflow/flow-cli/pkg/flowkit/config"
"github.com/onflow/flow-cli/pkg/flowkit/gateway"
"github.com/onflow/flow-cli/pkg/flowkit/output"
"github.com/onflow/flow-cli/pkg/flowkit/services"
"github.com/onflow/flow-cli/pkg/flowkit/util"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/crypto"
)
Expand Down Expand Up @@ -77,7 +76,7 @@ var names = []string{
}

type flowkitClient struct {
services *services.Services
services flowkit.Services
loader flowkit.ReaderWriter
state *flowkit.State
accounts []*clientAccount
Expand All @@ -101,19 +100,24 @@ func (f *flowkitClient) Initialize(configPath string, numberOfAccounts int) erro

logger := output.NewStdoutLogger(output.NoneLog)

serviceAccount, err := state.EmulatorServiceAccount()
acc, err := state.EmulatorServiceAccount()
if err != nil {
return err
}

var emulator gateway.Gateway
// try connecting to already running local emulator
emulator, err = gateway.NewGrpcGateway(config.DefaultEmulatorNetwork().Host)
emulator, err = gateway.NewGrpcGateway(config.EmulatorNetwork)
if err != nil || emulator.Ping() != nil { // fallback to hosted emulator if error
emulator = gateway.NewEmulatorGateway(serviceAccount)
pk, _ := acc.Key.PrivateKey()
emulator = gateway.NewEmulatorGateway(&gateway.EmulatorKey{
PublicKey: (*pk).PublicKey(),
SigAlgo: acc.Key.SigAlgo(),
HashAlgo: acc.Key.HashAlgo(),
})
}

f.services = services.NewServices(emulator, state, logger)
f.services = flowkit.NewFlowkit(state, config.EmulatorNetwork, emulator, logger)
if numberOfAccounts > len(names) || numberOfAccounts <= 0 {
return fmt.Errorf(fmt.Sprintf("only possible to create between 1 and %d accounts", len(names)))
}
Expand Down Expand Up @@ -199,16 +203,20 @@ func (f *flowkitClient) ExecuteScript(
return nil, err
}

return f.services.Scripts.Execute(
flowkit.NewScript(code, args, codeFilename),
config.DefaultEmulatorNetwork().Name,
&util.ScriptQuery{},
return f.services.ExecuteScript(
context.Background(),
flowkit.Script{
Code: code,
Args: args,
Location: codeFilename,
},
flowkit.LatestScriptQuery,
)
}

func (f *flowkitClient) DeployContract(
address flow.Address,
name string,
_ string,
location *url.URL,
) error {
code, err := f.loader.ReadFile(location.Path)
Expand All @@ -226,11 +234,14 @@ func (f *flowkitClient) DeployContract(
return err
}

_, _, err = f.services.Accounts.AddContract(
_, _, err = f.services.AddContract(
context.Background(),
signer,
flowkit.NewScript(code, nil, codeFilename),
config.DefaultEmulatorNetwork().Name,
services.UpdateExisting(true),
flowkit.Script{
Code: code,
Location: codeFilename,
},
flowkit.UpdateExistingContract(true),
)
return err
}
Expand All @@ -255,53 +266,58 @@ func (f *flowkitClient) SendTransaction(
return nil, nil, err
}

authAccs := make([]*flowkit.Account, len(authorizers))
authAccs := make([]flowkit.Account, len(authorizers))
for i, auth := range authorizers {
signer, err := f.createSigner(auth)
if err != nil {
return nil, nil, err
}

authAccs[i] = signer
authAccs[i] = *signer
if err != nil {
return nil, nil, err
}
}

accs, err := services.NewTransactionAccountRoles(service, service, authAccs)
if err != nil {
return nil, nil, err
}

return f.services.Transactions.Send(
accs,
flowkit.NewScript(code, args, codeFilename),
return f.services.SendTransaction(
context.Background(),
flowkit.TransactionAccountRoles{
Proposer: *service,
Authorizers: authAccs,
Payer: *service,
},
flowkit.Script{
Code: code,
Args: args,
Location: codeFilename,
},
flow.DefaultTransactionGasLimit,
config.DefaultEmulatorNetwork().Name,
)
}

func (f *flowkitClient) GetAccount(address flow.Address) (*flow.Account, error) {
return f.services.Accounts.Get(address)
return f.services.GetAccount(context.Background(), address)
}

func (f *flowkitClient) CreateAccount() (*clientAccount, error) {
service, err := f.state.EmulatorServiceAccount()
if err != nil {
return nil, err
}
serviceKey, err := service.Key().PrivateKey()
serviceKey, err := service.Key.PrivateKey()
if err != nil {
return nil, err
}

account, err := f.services.Accounts.Create(
account, _, err := f.services.CreateAccount(
context.Background(),
service,
[]crypto.PublicKey{(*serviceKey).PublicKey()},
[]int{flow.AccountKeyWeightThreshold},
[]crypto.SignatureAlgorithm{crypto.ECDSA_P256},
[]crypto.HashAlgorithm{crypto.SHA3_256},
nil,
[]flowkit.AccountPublicKey{{
Public: (*serviceKey).PublicKey(),
Weight: flow.AccountKeyWeightThreshold,
SigAlgo: crypto.ECDSA_P256,
HashAlgo: crypto.SHA3_256,
}},
)
if err != nil {
return nil, err
Expand All @@ -327,17 +343,17 @@ func (f *flowkitClient) CreateAccount() (*clientAccount, error) {
func (f *flowkitClient) accountsFromState() []*clientAccount {
accounts := make([]*clientAccount, 0)
for _, acc := range *f.state.Accounts() {
account, err := f.services.Accounts.Get(acc.Address())
account, err := f.services.GetAccount(context.Background(), acc.Address)
if err != nil {
// we skip user configured accounts that weren't already created on-chain
// by user because we can't guarantee addresses are available
continue
}

key := acc.Key()
key := acc.Key
accounts = append(accounts, &clientAccount{
Account: account,
Name: fmt.Sprintf("%s [flow.json]", acc.Name()),
Name: fmt.Sprintf("%s [flow.json]", acc.Name),
Key: &key,
})
}
Expand All @@ -357,9 +373,6 @@ func (f *flowkitClient) createSigner(address flow.Address) (*flowkit.Account, er
return nil, fmt.Errorf(fmt.Sprintf("account with address %s not found in the list of accounts", address))
}

signer := &flowkit.Account{}
signer.SetAddress(address)

var accountKey flowkit.AccountKey
if account.Key != nil {
accountKey = *account.Key
Expand All @@ -368,17 +381,17 @@ func (f *flowkitClient) createSigner(address flow.Address) (*flowkit.Account, er
if err != nil {
return nil, err
}
accountKey = service.Key()
accountKey = service.Key
}

signer.SetKey(accountKey)
return signer, nil
return &flowkit.Account{
Address: address,
Key: accountKey,
}, nil
}

func (f *flowkitClient) GetCodeByName(name string) (string, error) {
contracts, err := f.state.DeploymentContractsByNetwork(
config.DefaultEmulatorNetwork().Name,
)
contracts, err := f.state.DeploymentContractsByNetwork(config.EmulatorNetwork)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion languageserver/integration/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (r *resolvers) addressContractNames(address common.Address) ([]string, erro
//
// if the contracts were deployed on the same account then it returns true and hence allows the access, false otherwise.
func (r *resolvers) accountAccess(checker *sema.Checker, memberLocation common.Location) bool {
contracts, err := r.client.getState().DeploymentContractsByNetwork(config.DefaultEmulatorNetwork().Name)
contracts, err := r.client.getState().DeploymentContractsByNetwork(config.EmulatorNetwork)
if err != nil {
return false
}
Expand Down

0 comments on commit 9129578

Please sign in to comment.