From 7a76ac7c1ab91aeb4ef28c8698540fe90a7fc890 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 12 Jul 2024 11:16:01 -0600 Subject: [PATCH 1/2] Add Burner to systemcontracts --- fvm/systemcontracts/system_contracts.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fvm/systemcontracts/system_contracts.go b/fvm/systemcontracts/system_contracts.go index e1ec33cec39..d9a58c77861 100644 --- a/fvm/systemcontracts/system_contracts.go +++ b/fvm/systemcontracts/system_contracts.go @@ -39,6 +39,7 @@ const ( ContractNameMetadataViews = "MetadataViews" ContractNameViewResolver = "ViewResolver" ContractNameEVM = "EVM" + ContractNameBurner = "Burner" // AccountNameEVMStorage is not a contract, but a special account that is used to store EVM state AccountNameEVMStorage = "EVMStorageAccount" @@ -155,6 +156,9 @@ type SystemContracts struct { // EVM related contracts EVMContract SystemContract EVMStorage SystemAccount + + // Utility contracts + Burner SystemContract } // AsTemplateEnv returns a template environment with all system contracts filled in. @@ -180,6 +184,8 @@ func (c SystemContracts) AsTemplateEnv() templates.Environment { MetadataViewsAddress: c.MetadataViews.Address.Hex(), ViewResolverAddress: c.ViewResolver.Address.Hex(), FungibleTokenSwitchboardAddress: c.FungibleToken.Address.Hex(), + + BurnerAddress: c.Burner.Address.Hex(), } } @@ -206,6 +212,8 @@ func (c SystemContracts) All() []SystemContract { c.EVMContract, // EVMStorage is not included here, since it is not a contract + + c.Burner, } } @@ -328,6 +336,8 @@ func init() { ContractNameEVM: serviceAddressFunc, AccountNameEVMStorage: evmStorageEVMFunc, + + ContractNameBurner: serviceAddressFunc, } getSystemContractsForChain := func(chainID flow.ChainID) *SystemContracts { @@ -379,6 +389,8 @@ func init() { EVMContract: addressOfContract(ContractNameEVM), EVMStorage: addressOfAccount(AccountNameEVMStorage), + + Burner: addressOfContract(ContractNameBurner), } return contracts From 73970f85e1c310c3de89537d0eec0b92f3cf25d1 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 12 Jul 2024 13:31:39 -0600 Subject: [PATCH 2/2] Add FungibleToken contracts --- fvm/systemcontracts/system_contracts.go | 63 ++++++++++++++----------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/fvm/systemcontracts/system_contracts.go b/fvm/systemcontracts/system_contracts.go index d9a58c77861..7b685957c88 100644 --- a/fvm/systemcontracts/system_contracts.go +++ b/fvm/systemcontracts/system_contracts.go @@ -24,22 +24,24 @@ import ( const ( // Unqualified names of system smart contracts (not including address prefix) - ContractNameEpoch = "FlowEpoch" - ContractNameIDTableStaking = "FlowIDTableStaking" - ContractNameClusterQC = "FlowClusterQC" - ContractNameDKG = "FlowDKG" - ContractNameServiceAccount = "FlowServiceAccount" - ContractNameFlowFees = "FlowFees" - ContractNameStorageFees = "FlowStorageFees" - ContractNameNodeVersionBeacon = "NodeVersionBeacon" - ContractNameRandomBeaconHistory = "RandomBeaconHistory" - ContractNameFungibleToken = "FungibleToken" - ContractNameFlowToken = "FlowToken" - ContractNameNonFungibleToken = "NonFungibleToken" - ContractNameMetadataViews = "MetadataViews" - ContractNameViewResolver = "ViewResolver" - ContractNameEVM = "EVM" - ContractNameBurner = "Burner" + ContractNameEpoch = "FlowEpoch" + ContractNameIDTableStaking = "FlowIDTableStaking" + ContractNameClusterQC = "FlowClusterQC" + ContractNameDKG = "FlowDKG" + ContractNameServiceAccount = "FlowServiceAccount" + ContractNameFlowFees = "FlowFees" + ContractNameStorageFees = "FlowStorageFees" + ContractNameNodeVersionBeacon = "NodeVersionBeacon" + ContractNameRandomBeaconHistory = "RandomBeaconHistory" + ContractNameFungibleToken = "FungibleToken" + ContractNameFlowToken = "FlowToken" + ContractNameFungibleTokenSwitchboard = "FungibleTokenSwitchboard" + ContractNameFungibleTokenMetadataViews = "FungibleTokenMetadataViews" + ContractNameNonFungibleToken = "NonFungibleToken" + ContractNameMetadataViews = "MetadataViews" + ContractNameViewResolver = "ViewResolver" + ContractNameEVM = "EVM" + ContractNameBurner = "Burner" // AccountNameEVMStorage is not a contract, but a special account that is used to store EVM state AccountNameEVMStorage = "EVMStorageAccount" @@ -146,6 +148,7 @@ type SystemContracts struct { FlowFees SystemContract FlowToken SystemContract FungibleToken SystemContract + FungibleTokenSwitchboard SystemContract FungibleTokenMetadataViews SystemContract // NFT related contracts @@ -178,12 +181,12 @@ func (c SystemContracts) AsTemplateEnv() templates.Environment { FlowFeesAddress: c.FlowFees.Address.Hex(), FlowTokenAddress: c.FlowToken.Address.Hex(), FungibleTokenAddress: c.FungibleToken.Address.Hex(), - FungibleTokenMetadataViewsAddress: c.FungibleToken.Address.Hex(), + FungibleTokenSwitchboardAddress: c.FungibleTokenSwitchboard.Address.Hex(), + FungibleTokenMetadataViewsAddress: c.FungibleTokenMetadataViews.Address.Hex(), - NonFungibleTokenAddress: c.NonFungibleToken.Address.Hex(), - MetadataViewsAddress: c.MetadataViews.Address.Hex(), - ViewResolverAddress: c.ViewResolver.Address.Hex(), - FungibleTokenSwitchboardAddress: c.FungibleToken.Address.Hex(), + NonFungibleTokenAddress: c.NonFungibleToken.Address.Hex(), + MetadataViewsAddress: c.MetadataViews.Address.Hex(), + ViewResolverAddress: c.ViewResolver.Address.Hex(), BurnerAddress: c.Burner.Address.Hex(), } @@ -205,6 +208,8 @@ func (c SystemContracts) All() []SystemContract { c.FlowFees, c.FlowToken, c.FungibleToken, + c.FungibleTokenMetadataViews, + c.FungibleTokenSwitchboard, c.NonFungibleToken, c.MetadataViews, @@ -326,9 +331,11 @@ func init() { ContractNameServiceAccount: serviceAddressFunc, ContractNameStorageFees: serviceAddressFunc, - ContractNameFlowFees: nthAddressFunc(FlowFeesAccountIndex), - ContractNameFungibleToken: nthAddressFunc(FungibleTokenAccountIndex), - ContractNameFlowToken: nthAddressFunc(FlowTokenAccountIndex), + ContractNameFlowFees: nthAddressFunc(FlowFeesAccountIndex), + ContractNameFungibleToken: nthAddressFunc(FungibleTokenAccountIndex), + ContractNameFlowToken: nthAddressFunc(FlowTokenAccountIndex), + ContractNameFungibleTokenSwitchboard: nthAddressFunc(FungibleTokenAccountIndex), + ContractNameFungibleTokenMetadataViews: nthAddressFunc(FungibleTokenAccountIndex), ContractNameNonFungibleToken: nftTokenAddressFunc, ContractNameMetadataViews: nftTokenAddressFunc, @@ -379,9 +386,11 @@ func init() { RandomBeaconHistory: addressOfContract(ContractNameRandomBeaconHistory), FlowStorageFees: addressOfContract(ContractNameStorageFees), - FlowFees: addressOfContract(ContractNameFlowFees), - FlowToken: addressOfContract(ContractNameFlowToken), - FungibleToken: addressOfContract(ContractNameFungibleToken), + FlowFees: addressOfContract(ContractNameFlowFees), + FlowToken: addressOfContract(ContractNameFlowToken), + FungibleToken: addressOfContract(ContractNameFungibleToken), + FungibleTokenMetadataViews: addressOfContract(ContractNameFungibleTokenMetadataViews), + FungibleTokenSwitchboard: addressOfContract(ContractNameFungibleTokenSwitchboard), NonFungibleToken: addressOfContract(ContractNameNonFungibleToken), MetadataViews: addressOfContract(ContractNameMetadataViews),