Skip to content

Commit

Permalink
Add Crypto to WASM
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Oct 24, 2024
1 parent 7e381c6 commit 682ed26
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions languageserver/cmd/languageserver/main_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ import (
"syscall/js"

"github.com/onflow/cadence/common"
"github.com/onflow/cadence/stdlib"

"github.com/onflow/cadence-tools/languageserver/server"

coreContracts "github.com/onflow/flow-core-contracts/lib/go/contracts"
)

const globalFunctionNamePrefix = "CADENCE_LANGUAGE_SERVER"
Expand Down Expand Up @@ -185,6 +188,13 @@ func start(id int) {
return res.String(), nil
}

identifierImportResolver := func(location common.IdentifierLocation) (code string, err error) {
if location == stdlib.CryptoContractLocation {
return string(coreContracts.Crypto()), nil
}
return "", fmt.Errorf("CLS %d: unknown identifier location: %s", id, location)
}

languageServer, err := server.NewServer()
if err != nil {
panic(err)
Expand All @@ -193,6 +203,7 @@ func start(id int) {
err = languageServer.SetOptions(
server.WithAddressImportResolver(addressImportResolver),
server.WithStringImportResolver(stringImportResolver),
server.WithIdentifierImportResolver(identifierImportResolver),
)
if err != nil {
panic(err)
Expand Down

0 comments on commit 682ed26

Please sign in to comment.