Skip to content

Commit

Permalink
Merge pull request #1466 from onflow/chasefleming/1406
Browse files Browse the repository at this point in the history
Switch hardcoded Mainnet contracts check to use system contracts library
  • Loading branch information
chasefleming authored Mar 19, 2024
2 parents 5f6355c + 3b16a91 commit 86c91f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 56 deletions.
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvD
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo=
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
Expand Down Expand Up @@ -669,6 +670,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand Down Expand Up @@ -724,6 +726,7 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
Expand Down Expand Up @@ -830,6 +833,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
Expand Down Expand Up @@ -1191,6 +1195,7 @@ github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM=
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
Expand Down
68 changes: 12 additions & 56 deletions internal/project/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"context"
"errors"
"fmt"

Check failure on line 24 in internal/project/deploy.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/onflow/flow-cli (goimports)
"github.com/onflow/flow-go/fvm/systemcontracts"
flowGo "github.com/onflow/flow-go/model/flow"

flowsdk "github.com/onflow/flow-go-sdk"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -119,62 +121,16 @@ func (r *deployResult) Oneliner() string {
// are referencing standard contract and if so warn the use that they should use the already
// deployed contracts as an alias on mainnet instead of deploying their own copy.
func checkForStandardContractUsageOnMainnet(state *flowkit.State, logger output.Logger, replace bool) error {
mainnetContracts := map[string]standardContract{
"FungibleToken": {
name: "FungibleToken",
address: flowsdk.HexToAddress("0xf233dcee88fe0abe"),
infoLink: "https://developers.flow.com/flow/core-contracts/fungible-token",
},
"FlowToken": {
name: "FlowToken",
address: flowsdk.HexToAddress("0x1654653399040a61"),
infoLink: "https://developers.flow.com/flow/core-contracts/flow-token",
},
"FlowFees": {
name: "FlowFees",
address: flowsdk.HexToAddress("0xf919ee77447b7497"),
infoLink: "https://developers.flow.com/flow/core-contracts/flow-fees",
},
"FlowServiceAccount": {
name: "FlowServiceAccount",
address: flowsdk.HexToAddress("0xe467b9dd11fa00df"),
infoLink: "https://developers.flow.com/flow/core-contracts/service-account",
},
"FlowStorageFees": {
name: "FlowStorageFees",
address: flowsdk.HexToAddress("0xe467b9dd11fa00df"),
infoLink: "https://developers.flow.com/flow/core-contracts/service-account",
},
"FlowIDTableStaking": {
name: "FlowIDTableStaking",
address: flowsdk.HexToAddress("0x8624b52f9ddcd04a"),
infoLink: "https://developers.flow.com/flow/core-contracts/staking-contract-reference",
},
"FlowEpoch": {
name: "FlowEpoch",
address: flowsdk.HexToAddress("0x8624b52f9ddcd04a"),
infoLink: "https://developers.flow.com/flow/core-contracts/epoch-contract-reference",
},
"FlowClusterQC": {
name: "FlowClusterQC",
address: flowsdk.HexToAddress("0x8624b52f9ddcd04a"),
infoLink: "https://developers.flow.com/flow/core-contracts/epoch-contract-reference",
},
"FlowDKG": {
name: "FlowDKG",
address: flowsdk.HexToAddress("0x8624b52f9ddcd04a"),
infoLink: "https://developers.flow.com/flow/core-contracts/epoch-contract-reference",
},
"NonFungibleToken": {
name: "NonFungibleToken",
address: flowsdk.HexToAddress("0x1d7e57aa55817448"),
infoLink: "https://developers.flow.com/flow/core-contracts/non-fungible-token",
},
"MetadataViews": {
name: "MetadataViews",
address: flowsdk.HexToAddress("0x1d7e57aa55817448"),
infoLink: "https://developers.flow.com/flow/core-contracts/nft-metadata",
},

mainnetContracts := make(map[string]standardContract)
sc := systemcontracts.SystemContractsForChain(flowGo.Mainnet)

for _, coreContract := range sc.All() {
mainnetContracts[coreContract.Name] = standardContract{
name: coreContract.Name,
address: flowsdk.HexToAddress(coreContract.Address.String()),
infoLink: "https://developers.flow.com/flow/core-contracts/",
}
}

contracts, err := state.DeploymentContractsByNetwork(config.MainnetNetwork)
Expand Down

0 comments on commit 86c91f4

Please sign in to comment.