-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add contract migration check on all calls #1547
Changes from 38 commits
1d60627
7d3d289
a2d3035
63d7a04
8c088cf
4b97f0f
bce8af0
6d8a8d3
fe3475d
13d1582
71b47a9
1d5fd8e
aaa6383
63af7e6
8a16b1b
1ce938b
682c562
427d845
7a740d4
0e92418
339fb21
49fd909
0ee2665
87af46c
6e0170d
e394a79
805e3a0
bedd97b
f607271
7796bac
93e569f
44d166d
b518842
87cb8d0
37b40f1
a49a609
751ebbc
3a34a57
a10057f
026e718
21c87fb
25e164b
f923a07
765164b
a5f50ca
98d0884
67810c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
|
||
"github.com/dukex/mixpanel" | ||
"github.com/getsentry/sentry-go" | ||
"github.com/google/go-github/github" | ||
"github.com/spf13/afero" | ||
"github.com/spf13/cobra" | ||
|
||
|
@@ -45,6 +46,7 @@ import ( | |
"github.com/onflow/flowkit/v2/output" | ||
|
||
"github.com/onflow/flow-cli/build" | ||
"github.com/onflow/flow-cli/internal/migrate/validator" | ||
"github.com/onflow/flow-cli/internal/settings" | ||
"github.com/onflow/flow-cli/internal/util" | ||
) | ||
|
@@ -126,6 +128,11 @@ func (c Command) AddToParent(parent *cobra.Command) { | |
checkVersion(logger) | ||
} | ||
|
||
// check contract migrations if flag is set | ||
if !Flags.SkipContractMigrationCheck { | ||
checkContractMigrations(state, logger, flow) | ||
ianthpun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// record command usage | ||
wg := sync.WaitGroup{} | ||
go UsageMetrics(c.Cmd, &wg) | ||
|
@@ -424,14 +431,40 @@ func UsageMetrics(command *cobra.Command, wg *sync.WaitGroup) { | |
|
||
// GlobalFlags contains all global flags definitions. | ||
type GlobalFlags struct { | ||
Filter string | ||
Format string | ||
Save string | ||
Host string | ||
HostNetworkKey string | ||
Log string | ||
Network string | ||
Yes bool | ||
ConfigPaths []string | ||
SkipVersionCheck bool | ||
Filter string | ||
Format string | ||
Save string | ||
Host string | ||
HostNetworkKey string | ||
Log string | ||
Network string | ||
Yes bool | ||
ConfigPaths []string | ||
SkipVersionCheck bool | ||
SkipContractMigrationCheck bool | ||
} | ||
|
||
func checkContractMigrations(state *flowkit.State, logger output.Logger, flow flowkit.Services) { | ||
contractStatuses, err := validator.NewValidator(github.NewClient(nil).Repositories, flow.Network(), state, logger).GetContractStatuses() | ||
if err != nil { | ||
logger.Error(fmt.Sprintf("failed to validate contracts: %s", err)) | ||
ianthpun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
|
||
for _, contract := range contractStatuses { | ||
if contract.IsFailure() { | ||
logger.Error(fmt.Sprintf( | ||
"Contract %s has failed the last emulated migration\n"+ | ||
ianthpun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
" - Account: %s\n"+ | ||
" - Contract: %s\n"+ | ||
" - Error: %s\n", | ||
contract.ContractName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this is a lot to show. Is it better just to say like "3 contracts with errors found since last migration," and then a way to see more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya i agree i think it's quite a bit. Maybe we can list the contracts and then just like to the migration data? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does it look like if there are multiple that fail? Is there any sort of separation before they repeat? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
contract.AccountAddress, | ||
contract.ContractName, | ||
contract.Error, | ||
)) | ||
ianthpun marked this conversation as resolved.
Show resolved
Hide resolved
ianthpun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
return | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import ( | |
|
||
"github.com/onflow/flow-cli/internal/command" | ||
"github.com/onflow/flow-cli/internal/scripts" | ||
"github.com/onflow/flow-cli/internal/util" | ||
) | ||
|
||
var getStagedCodeflags struct{} | ||
|
@@ -53,13 +54,13 @@ func getStagedCode( | |
flow flowkit.Services, | ||
state *flowkit.State, | ||
) (command.Result, error) { | ||
err := checkNetwork(flow.Network()) | ||
err := util.CheckNetwork(flow.Network()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
contractName := args[0] | ||
addr, err := getAddressByContractName(state, contractName, flow.Network()) | ||
addr, err := util.GetAddressByContractName(state, contractName, flow.Network()) | ||
if err != nil { | ||
return nil, fmt.Errorf("error getting address by contract name: %w", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleting this since this feature branch is literally 1.0