Skip to content

Commit 2bb0f4a

Browse files
committed
Merge remote-tracking branch 'origin/master' into jribbink/height-pins
2 parents 43c624a + de44b8a commit 2bb0f4a

File tree

10 files changed

+975
-80
lines changed

10 files changed

+975
-80
lines changed

go.mod

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ require (
1212
github.com/getsentry/sentry-go v0.40.0
1313
github.com/gosuri/uilive v0.0.4
1414
github.com/logrusorgru/aurora/v4 v4.0.0
15-
github.com/onflow/cadence v1.9.2
16-
github.com/onflow/cadence-tools/languageserver v1.8.0
17-
github.com/onflow/cadence-tools/lint v1.7.0
18-
github.com/onflow/cadence-tools/test v1.10.0
15+
github.com/onflow/cadence v1.9.4
16+
github.com/onflow/cadence-tools/languageserver v1.9.0
17+
github.com/onflow/cadence-tools/lint v1.7.1
18+
github.com/onflow/cadence-tools/test v1.10.1
1919
github.com/onflow/fcl-dev-wallet v0.9.1
20-
github.com/onflow/flixkit-go/v2 v2.7.0
20+
github.com/onflow/flixkit-go/v2 v2.7.1
2121
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2
2222
github.com/onflow/flow-core-contracts/lib/go/templates v1.9.2
23-
github.com/onflow/flow-emulator v1.15.0
24-
github.com/onflow/flow-evm-gateway v1.4.4
25-
github.com/onflow/flow-go v0.45.0-experimental-cadence-v1.8.7.0.20251219170433-76749cca9738
26-
github.com/onflow/flow-go-sdk v1.9.8
27-
github.com/onflow/flow/protobuf/go/flow v0.4.18
28-
github.com/onflow/flowkit/v2 v2.10.1-0.20260106074841-4cacbcfc75c5
23+
github.com/onflow/flow-emulator v1.15.3
24+
github.com/onflow/flow-evm-gateway v1.4.5-0.20260109131900-576c361f7c70
25+
github.com/onflow/flow-go v0.45.0-experimental-cadence-v1.8.7.0.20260109014156-2abea7b5732a
26+
github.com/onflow/flow-go-sdk v1.9.10
27+
github.com/onflow/flow/protobuf/go/flow v0.4.19
28+
github.com/onflow/flowkit/v2 v2.10.1
2929
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48
3030
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
3131
github.com/pkg/errors v0.9.1
@@ -44,7 +44,7 @@ require (
4444

4545
require (
4646
cloud.google.com/go v0.121.6 // indirect
47-
cloud.google.com/go/auth v0.17.0 // indirect
47+
cloud.google.com/go/auth v0.18.0 // indirect
4848
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
4949
cloud.google.com/go/compute/metadata v0.9.0 // indirect
5050
cloud.google.com/go/iam v1.5.3 // indirect
@@ -132,7 +132,7 @@ require (
132132
github.com/google/s2a-go v0.1.9 // indirect
133133
github.com/google/uuid v1.6.0 // indirect
134134
github.com/googleapis/enterprise-certificate-proxy v0.3.7 // indirect
135-
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
135+
github.com/googleapis/gax-go/v2 v2.16.0 // indirect
136136
github.com/gorilla/mux v1.8.1 // indirect
137137
github.com/gorilla/websocket v1.5.3 // indirect
138138
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
@@ -280,27 +280,27 @@ require (
280280
go.uber.org/zap v1.27.0 // indirect
281281
go.yaml.in/yaml/v2 v2.4.2 // indirect
282282
go.yaml.in/yaml/v3 v3.0.4 // indirect
283-
golang.org/x/crypto v0.45.0 // indirect
284-
golang.org/x/net v0.47.0 // indirect
285-
golang.org/x/oauth2 v0.33.0 // indirect
286-
golang.org/x/sync v0.18.0 // indirect
283+
golang.org/x/crypto v0.46.0 // indirect
284+
golang.org/x/net v0.48.0 // indirect
285+
golang.org/x/oauth2 v0.34.0 // indirect
286+
golang.org/x/sync v0.19.0 // indirect
287287
golang.org/x/sys v0.39.0 // indirect
288-
golang.org/x/text v0.31.0 // indirect
288+
golang.org/x/text v0.32.0 // indirect
289289
golang.org/x/time v0.14.0 // indirect
290290
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
291291
gonum.org/v1/gonum v0.16.0 // indirect
292-
google.golang.org/api v0.257.0 // indirect
292+
google.golang.org/api v0.259.0 // indirect
293293
google.golang.org/appengine v1.6.8 // indirect
294-
google.golang.org/genproto v0.0.0-20251111163417-95abcf5c77ba // indirect
295-
google.golang.org/genproto/googleapis/api v0.0.0-20251103181224-f26f9409b101 // indirect
296-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect
297-
google.golang.org/protobuf v1.36.10 // indirect
294+
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect
295+
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
296+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
297+
google.golang.org/protobuf v1.36.11 // indirect
298298
gopkg.in/yaml.v2 v2.4.0 // indirect
299299
gopkg.in/yaml.v3 v3.0.1 // indirect
300300
lukechampine.com/blake3 v1.4.1 // indirect
301301
modernc.org/libc v1.66.10 // indirect
302302
modernc.org/mathutil v1.7.1 // indirect
303303
modernc.org/memory v1.11.0 // indirect
304-
modernc.org/sqlite v1.40.1 // indirect
304+
modernc.org/sqlite v1.41.0 // indirect
305305
nhooyr.io/websocket v1.8.7 // indirect
306306
)

go.sum

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

internal/cadence/lint_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,33 @@ func Test_Lint(t *testing.T) {
189189
)
190190
})
191191

192+
t.Run("generates synthetic replacement for replacement category diagnostics", func(t *testing.T) {
193+
t.Parallel()
194+
195+
state := setupMockState(t)
196+
197+
results, err := lintFiles(state, "ReplacementHint.cdc")
198+
require.NoError(t, err)
199+
200+
require.Len(t, results.Results, 1)
201+
require.Len(t, results.Results[0].Diagnostics, 1)
202+
203+
diagnostic := results.Results[0].Diagnostics[0]
204+
205+
// Should have the replacement category
206+
require.Equal(t, "replacement-hint", diagnostic.Category)
207+
208+
// Should have a secondary message with the replacement suggestion
209+
require.Equal(t, "consider replacing with:", diagnostic.Message)
210+
require.Equal(t, "1.0", diagnostic.SecondaryMessage)
211+
212+
// Should have synthetic suggested fixes generated from secondary message
213+
require.Len(t, diagnostic.SuggestedFixes, 1)
214+
require.Equal(t, "consider replacing with: `1.0`", diagnostic.SuggestedFixes[0].Message)
215+
require.Len(t, diagnostic.SuggestedFixes[0].TextEdits, 1)
216+
require.Equal(t, "1.0", diagnostic.SuggestedFixes[0].TextEdits[0].Replacement)
217+
})
218+
192219
t.Run("linter resolves imports from flowkit state", func(t *testing.T) {
193220
t.Parallel()
194221

@@ -476,6 +503,12 @@ func setupMockState(t *testing.T) *flowkit.State {
476503
qqq
477504
}
478505
}`), 0644)
506+
_ = afero.WriteFile(mockFs, "ReplacementHint.cdc", []byte(`
507+
access(all) contract ReplacementHint {
508+
access(all) fun test() {
509+
let x = UFix64(1)
510+
}
511+
}`), 0644)
479512
_ = afero.WriteFile(mockFs, "CadenceV1Error.cdc", []byte(`
480513
access(all) contract CadenceV1Error {
481514
init() {

internal/cadence/linter.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,28 @@ func (l *linter) lintFile(
156156
}
157157
analysisProgram.Run(analyzers, report)
158158

159+
// Generate synthetic replacements for replacement category diagnostics
160+
// that don't have suggested fixes
161+
for i := range diagnostics {
162+
diagnostic := &diagnostics[i]
163+
if diagnostic.Category == cdclint.ReplacementCategory &&
164+
len(diagnostic.SuggestedFixes) == 0 &&
165+
diagnostic.SecondaryMessage != "" {
166+
// Create a synthetic suggested fix from the secondary message
167+
diagnostic.SuggestedFixes = []cdcerrors.SuggestedFix[ast.TextEdit]{
168+
{
169+
Message: fmt.Sprintf("%s `%s`", diagnostic.Message, diagnostic.SecondaryMessage),
170+
TextEdits: []ast.TextEdit{
171+
{
172+
Range: diagnostic.Range,
173+
Replacement: diagnostic.SecondaryMessage,
174+
},
175+
},
176+
},
177+
}
178+
}
179+
}
180+
159181
return diagnostics, nil
160182
}
161183

internal/command/command.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@ import (
3434
"sync"
3535
"time"
3636

37-
"github.com/onflow/flow-cli/internal/prompt"
38-
3937
"github.com/coreos/go-semver/semver"
4038
"github.com/dukex/mixpanel"
4139
"github.com/getsentry/sentry-go"
4240
"github.com/spf13/afero"
4341
"github.com/spf13/cobra"
4442

4543
"github.com/onflow/flowkit/v2"
44+
"github.com/onflow/flowkit/v2/accounts"
4645
"github.com/onflow/flowkit/v2/config"
4746
"github.com/onflow/flowkit/v2/gateway"
4847
"github.com/onflow/flowkit/v2/output"
4948

5049
"github.com/onflow/flow-cli/build"
50+
"github.com/onflow/flow-cli/common/branding"
51+
"github.com/onflow/flow-cli/internal/prompt"
5152
"github.com/onflow/flow-cli/internal/settings"
5253
"github.com/onflow/flow-cli/internal/util"
5354
)
@@ -131,6 +132,9 @@ func (c Command) AddToParent(parent *cobra.Command) {
131132
checkVersion(logger)
132133
}
133134

135+
// warn about inline keys in config
136+
checkForInlineKeys(state, logger)
137+
134138
// record command usage
135139
wg := sync.WaitGroup{}
136140
go UsageMetrics(c.Cmd, &wg)
@@ -328,6 +332,33 @@ func isDevelopment() bool {
328332
return build.Semver() == "undefined"
329333
}
330334

335+
// checkForInlineKeys warns users if they have accounts with inline private keys in flow.json
336+
func checkForInlineKeys(state *flowkit.State, logger output.Logger) {
337+
if state == nil {
338+
return
339+
}
340+
341+
var inlineKeyAccounts []string
342+
for _, account := range *state.Accounts() {
343+
if _, isHexKey := account.Key.(*accounts.HexKey); isHexKey {
344+
inlineKeyAccounts = append(inlineKeyAccounts, account.Name)
345+
}
346+
}
347+
348+
if len(inlineKeyAccounts) > 0 {
349+
cmd := branding.GreenStyle.Render("flow config extract-key --all")
350+
logger.Info(fmt.Sprintf(
351+
"\n%s Security warning: %d account(s) have private keys stored directly in flow.json: %s\n"+
352+
" Extract them to separate key files by running: %s\n"+
353+
" Learn more: https://developers.flow.com/build/tools/flow-cli/flow.json/security\n",
354+
output.WarningEmoji(),
355+
len(inlineKeyAccounts),
356+
strings.Join(inlineKeyAccounts, ", "),
357+
cmd,
358+
))
359+
}
360+
}
361+
331362
// initCrashReporting set-ups sentry as crash reporting tool, it also sets listener for panics
332363
// and asks before sending the error for a permission to do so from the user.
333364
func initCrashReporting() {

internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var Cmd = &cobra.Command{
3131
func init() {
3232
Cmd.AddCommand(addCmd)
3333
Cmd.AddCommand(removeCmd)
34+
extractKeyCommand.AddToParent(Cmd)
3435
}
3536

3637
type result struct {

0 commit comments

Comments
 (0)