Skip to content

Commit

Permalink
Merge pull request #48 from onflow/ls/improvement/local-emulator
Browse files Browse the repository at this point in the history
[LS] Using local emulator
  • Loading branch information
sideninja authored Jan 3, 2023
2 parents 94e821e + 0a05662 commit 73ece73
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions languageserver/integration/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ func (f *flowkitClient) Initialize(configPath string, numberOfAccounts int) erro
return err
}

hostedEmulator := gateway.NewEmulatorGateway(serviceAccount)

f.services = services.NewServices(hostedEmulator, state, logger)
var emulator gateway.Gateway
// try connecting to already running local emulator
emulator, err = gateway.NewGrpcGateway(config.DefaultEmulatorNetwork().Host)
if err != nil || emulator.Ping() != nil { // fallback to hosted emulator if error
emulator = gateway.NewEmulatorGateway(serviceAccount)
}

f.services = services.NewServices(emulator, state, 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

0 comments on commit 73ece73

Please sign in to comment.