diff --git a/engine/execution/state/bootstrap/bootstrap_test.go b/engine/execution/state/bootstrap/bootstrap_test.go index 5a9d394a5ac..c014e957b0d 100644 --- a/engine/execution/state/bootstrap/bootstrap_test.go +++ b/engine/execution/state/bootstrap/bootstrap_test.go @@ -53,7 +53,7 @@ func TestBootstrapLedger(t *testing.T) { } func TestBootstrapLedger_ZeroTokenSupply(t *testing.T) { - expectedStateCommitmentBytes, _ := hex.DecodeString("6e70a1ff40e4312a547d588a4355a538610bc22844a1faa907b4ec333ff1eca9") + expectedStateCommitmentBytes, _ := hex.DecodeString("50eb71c0391c1e8535dcea1ed2de29b9980436ca9615064e577043eedf632ff0") expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes) require.NoError(t, err) diff --git a/fvm/bootstrap.go b/fvm/bootstrap.go index 0f3526c8d83..a37d0948461 100644 --- a/fvm/bootstrap.go +++ b/fvm/bootstrap.go @@ -8,6 +8,9 @@ import ( "github.com/onflow/flow-core-contracts/lib/go/contracts" "github.com/onflow/flow-core-contracts/lib/go/templates" + usdc "github.com/onflow/bridged-usdc/lib/go/contracts" + storefront "github.com/onflow/nft-storefront/lib/go/contracts" + "github.com/onflow/flow-go/fvm/blueprints" "github.com/onflow/flow-go/fvm/environment" "github.com/onflow/flow-go/fvm/errors" @@ -370,6 +373,12 @@ func (b *bootstrapExecutor) Execute() error { b.deployMetadataViews(fungibleToken, nonFungibleToken, &env) b.deployFungibleTokenSwitchboard(fungibleToken, &env) + // deploys the USDCFlow smart contract + b.deployUSDCFlow(fungibleToken, &env) + + // deploys the NFTStorefrontV2 contract + b.deployNFTStorefrontV2(nonFungibleToken, &env) + flowToken := b.deployFlowToken(service, &env) err = expectAccounts(systemcontracts.FlowTokenAccountIndex) if err != nil { @@ -731,6 +740,45 @@ func (b *bootstrapExecutor) deployServiceAccount(deployTo flow.Address, env *tem panicOnMetaInvokeErrf("failed to deploy service account contract: %s", txError, err) } +func (b *bootstrapExecutor) deployNFTStorefrontV2(deployTo flow.Address, env *templates.Environment) { + + contract := storefront.NFTStorefrontV2( + env.FungibleTokenAddress, + env.NonFungibleTokenAddress) + + txError, err := b.invokeMetaTransaction( + b.ctx, + Transaction( + blueprints.DeployContractTransaction( + deployTo, + contract, + "NFTStorefrontV2"), + 0), + ) + panicOnMetaInvokeErrf("failed to deploy NFTStorefrontV2 contract: %s", txError, err) +} + +func (b *bootstrapExecutor) deployUSDCFlow(deployTo flow.Address, env *templates.Environment) { + + contract := usdc.USDCFlowBasic( + env.FungibleTokenAddress, + env.MetadataViewsAddress, + env.FungibleTokenMetadataViewsAddress, + env.ViewResolverAddress, + env.BurnerAddress) + + txError, err := b.invokeMetaTransaction( + b.ctx, + Transaction( + blueprints.DeployContractTransaction( + deployTo, + contract, + "USDCFlow"), + 0), + ) + panicOnMetaInvokeErrf("failed to deploy USDCFlow contract: %s", txError, err) +} + func (b *bootstrapExecutor) mintInitialTokens( service, fungibleToken, flowToken flow.Address, initialSupply cadence.UFix64, diff --git a/go.mod b/go.mod index c9beac7c5b5..ea5421ce231 100644 --- a/go.mod +++ b/go.mod @@ -106,6 +106,7 @@ require ( github.com/huandu/go-clone/generic v1.7.2 github.com/ipfs/boxo v0.17.1-0.20240131173518-89bceff34bf1 github.com/mitchellh/mapstructure v1.5.0 + github.com/onflow/bridged-usdc/lib/go/contracts v0.0.0-20241031171244-21575ddc23e0 github.com/onflow/go-ethereum v1.14.7 github.com/onflow/wal v1.0.2 github.com/slok/go-http-metrics v0.10.0 @@ -258,6 +259,7 @@ require ( github.com/onflow/flow-ft/lib/go/templates v1.0.1 // 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/nft-storefront/lib/go/contracts v1.0.0 // indirect github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/ginkgo/v2 v2.13.2 // indirect diff --git a/go.sum b/go.sum index 036ed5849f6..0fc8da564d8 100644 --- a/go.sum +++ b/go.sum @@ -913,6 +913,8 @@ github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84= github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/onflow/bridged-usdc/lib/go/contracts v0.0.0-20241031171244-21575ddc23e0 h1:XgYxjWGPhMBzKUgbWEvzKFH/DZRffy5EOjv/1G/1mVA= +github.com/onflow/bridged-usdc/lib/go/contracts v0.0.0-20241031171244-21575ddc23e0/go.mod h1:K4/oaEhhnSuJ9q6fpq1w9WEWRGtkNskhmoyH8t+X9Mk= github.com/onflow/cadence v1.2.1 h1:hmSsgX3rTsp2E5qTSl1JXINt8qepdRrHTwDSYqN5Nxs= github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= @@ -937,6 +939,8 @@ github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1C github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= +github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc= +github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk= github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc= diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index a5e911b3771..fb12310e358 100644 --- a/utils/unittest/execution_state.go +++ b/utils/unittest/execution_state.go @@ -23,7 +23,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256 const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256 // Pre-calculated state commitment with root account with the above private key -const GenesisStateCommitmentHex = "c42fc978c2702793d2640e3ed8644ba54db4e92aa5d0501234dfbb9bbc5784fd" +const GenesisStateCommitmentHex = "8a39695626e505a667c1c3d67abab13d30cc6a1a007b4cd6de21c3fbbd51d638" var GenesisStateCommitment flow.StateCommitment @@ -87,10 +87,10 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string { return GenesisStateCommitmentHex } if chainID == flow.Testnet { - return "e29456decb9ee90ad3ed1e1239383c18897b031ea851ff07f5f616657df4d4a0" + return "6de2175363c8136ce966759fcc7a744d1b7f49d0d4dbf9a39970c82e29430b13" } if chainID == flow.Sandboxnet { return "e1c08b17f9e5896f03fe28dd37ca396c19b26628161506924fbf785834646ea1" } - return "e1989abf50fba23015251a313eefe2ceff45639a75252f4da5970dcda32dd95e" + return "cf7a9c80987d0d62b6d3c299fe603617a398def464b71ecb841b9de3b53ba395" }