diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 3c62a2d93..1ebf55796 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -20,6 +20,7 @@ package analysis import ( "fmt" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index a531cf5dd..887cb02a0 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -36,6 +36,8 @@ import ( "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/flow" + + "github.com/onflow/flow-core-contracts/lib/go/contracts" ) const LoadMode = analysis.NeedTypes @@ -126,13 +128,18 @@ func (c *ContractsChecker) analyze( sc := systemcontracts.SystemContractsForChain(c.chain.ChainID()) + cryptoContractLocation := common.AddressLocation{ + Address: common.Address(sc.Crypto.Address), + Name: string(stdlib.CryptoContractLocation), + } + + // TODO: Remove once the Crypto contract is available on-chain. + c.Codes[cryptoContractLocation] = contracts.Crypto() + programs := analysis.Programs{ Programs: make(map[common.Location]*analysis.Program, len(locations)), CryptoContractLocation: func() common.Location { - return common.AddressLocation{ - Address: common.Address(sc.Crypto.Address), - Name: string(stdlib.CryptoContractLocation), - } + return cryptoContractLocation }, } diff --git a/tools/compatibility-check/contracts_checker_test.go b/tools/compatibility-check/contracts_checker_test.go index 5dfb44f9c..bef2e761f 100644 --- a/tools/compatibility-check/contracts_checker_test.go +++ b/tools/compatibility-check/contracts_checker_test.go @@ -20,12 +20,10 @@ package compatibility_check import ( "bytes" - "fmt" "testing" "github.com/stretchr/testify/assert" - "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/flow" ) @@ -69,19 +67,12 @@ func TestCryptoImport(t *testing.T) { checker := NewContractChecker(chainID.Chain(), &output) - sc := systemcontracts.SystemContractsForChain(chainID) - cryptoLocation := sc.Crypto.Location() - - contractsCSV := fmt.Sprintf( - `location,code + contractsCSV := `location,code A.0000000000000001.Foo,"import Crypto access(all) contract Foo {}" -%s,"access(all) contract Crypto {}" A.0000000000000001.Bar,"import Crypto access(all) contract Bar {}" -`, - cryptoLocation.ID(), - ) +` input.Write([]byte(contractsCSV)) diff --git a/tools/compatibility-check/go.mod b/tools/compatibility-check/go.mod index d811668cd..44484aee7 100644 --- a/tools/compatibility-check/go.mod +++ b/tools/compatibility-check/go.mod @@ -43,10 +43,13 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/onflow/atree v0.8.0 // indirect github.com/onflow/crypto v0.25.2 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 // indirect + github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 // indirect github.com/onflow/flow-go-sdk v1.1.0 // indirect + github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect github.com/onflow/go-ethereum v1.14.7 // indirect diff --git a/tools/compatibility-check/go.sum b/tools/compatibility-check/go.sum index 3c5fe3ede..ee2555e61 100644 --- a/tools/compatibility-check/go.sum +++ b/tools/compatibility-check/go.sum @@ -253,14 +253,20 @@ github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlp github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 h1:swCMX7k//QjHatAZ3URX4GhfUWmLc6S/tmaw2mS/0ZU= github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24= +github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 h1:Bt7WUgRd3C3o93A9KL+cuLwxzrMgfpqKGxTTZF97RJY= github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36/go.mod h1:ZWA2u8gALTYLl5L9M+2ylotWu90kfDmm5RnLNezew/c= github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80mO1PzUJYPfdhXFsGbQ= +github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc=