Skip to content

Commit

Permalink
add NFTStorefrontV2 and USDCFlow to bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Oct 31, 2024
1 parent 3496c0f commit 7009009
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion engine/execution/state/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
48 changes: 48 additions & 0 deletions fvm/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions utils/unittest/execution_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 7009009

Please sign in to comment.