Skip to content

Commit

Permalink
Temporarily provide source code for Cypto contract
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Oct 21, 2024
1 parent cfd6412 commit 871780e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
15 changes: 11 additions & 4 deletions tools/compatibility-check/contracts_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
},
}

Expand Down
13 changes: 2 additions & 11 deletions tools/compatibility-check/contracts_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions tools/compatibility-check/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tools/compatibility-check/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 871780e

Please sign in to comment.