Skip to content

Commit e71297c

Browse files
authored
Merge pull request #2129 from onflow/cf/merge-fixes
Update code with changes from master
2 parents 1401e52 + 932faba commit e71297c

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

internal/schedule/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func listRun(
7272
accountInput := args[0]
7373

7474
// Resolve account address from input (could be address or account name)
75-
address, err := util.ResolveAddressOrAccountName(accountInput, state)
75+
address, err := util.ResolveAddressOrAccountNameForNetworks(accountInput, state, []string{"mainnet", "testnet", "emulator"})
7676
if err != nil {
7777
return nil, fmt.Errorf("failed to resolve account: %w", err)
7878
}

internal/util/accounts.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,12 @@ func ResolveAddressOrAccountNameForNetworks(input string, state *flowkit.State,
145145
networksStr := strings.Join(supportedNetworks, " and ")
146146
return flow.EmptyAddress, fmt.Errorf("account %s has address %s which is not valid for %s addresses", input, account.Address.String(), networksStr)
147147
}
148+
149+
// GetSignerAccount resolves and returns the signer account from the state by name
150+
func GetSignerAccount(state *flowkit.State, signerName string) (*accounts.Account, error) {
151+
signer, err := state.Accounts().ByName(signerName)
152+
if err != nil {
153+
return nil, fmt.Errorf("failed to resolve signer account '%s': %w", signerName, err)
154+
}
155+
return signer, nil
156+
}

internal/util/util.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
flowGo "github.com/onflow/flow-go/model/flow"
3737

3838
"github.com/onflow/flowkit/v2"
39-
"github.com/onflow/flowkit/v2/accounts"
4039
"github.com/onflow/flowkit/v2/config"
4140
)
4241

@@ -284,31 +283,6 @@ func IsCoreContract(contractName string) bool {
284283
return false
285284
}
286285

287-
// ResolveAddressOrAccountName resolves a string that could be either an address or account name
288-
func ResolveAddressOrAccountName(input string, state *flowkit.State) (flow.Address, error) {
289-
address := flow.HexToAddress(input)
290-
291-
if address.IsValid(flow.Mainnet) || address.IsValid(flow.Testnet) || address.IsValid(flow.Emulator) {
292-
return address, nil
293-
}
294-
295-
account, err := state.Accounts().ByName(input)
296-
if err != nil {
297-
return flow.EmptyAddress, fmt.Errorf("could not find account with name %s", input)
298-
}
299-
300-
return account.Address, nil
301-
}
302-
303-
// GetSignerAccount resolves and returns the signer account from the state by name
304-
func GetSignerAccount(state *flowkit.State, signerName string) (*accounts.Account, error) {
305-
signer, err := state.Accounts().ByName(signerName)
306-
if err != nil {
307-
return nil, fmt.Errorf("failed to resolve signer account '%s': %w", signerName, err)
308-
}
309-
return signer, nil
310-
}
311-
312286
// IsEmulatorRunning checks if the emulator is running on the given host
313287
func IsEmulatorRunning(host string) bool {
314288
conn, err := net.DialTimeout("tcp", host, 2*time.Second)

0 commit comments

Comments
 (0)