Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard import placeholders #476

Merged
merged 8 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ git

coverage.json
coverage.lcov
lcov.info
*.pkey

# Private flow.jsons
Expand Down
6 changes: 3 additions & 3 deletions contracts/FlowFees.cdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import FlowStorageFees from "FlowStorageFees"
import "FungibleToken"
import "FlowToken"
import "FlowStorageFees"

access(all) contract FlowFees {

Expand Down
8 changes: 4 additions & 4 deletions contracts/FlowIDTableStaking.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

*/

import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import Burner from "Burner"
import FlowFees from "FlowFees"
import "FungibleToken"
import "FlowToken"
import "Burner"
import "FlowFees"
import Crypto

access(all) contract FlowIDTableStaking {
Expand Down
10 changes: 5 additions & 5 deletions contracts/FlowServiceAccount.cdc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import FlowFees from "FlowFees"
import FlowStorageFees from "FlowStorageFees"
import FlowExecutionParameters from "FlowExecutionParameters"
import "FungibleToken"
import "FlowToken"
import "FlowFees"
import "FlowStorageFees"
import "FlowExecutionParameters"

access(all) contract FlowServiceAccount {

Expand Down
18 changes: 9 additions & 9 deletions contracts/FlowStakingCollection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

*/

import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import FlowIDTableStaking from "FlowIDTableStaking"
import LockedTokens from "LockedTokens"
import FlowStorageFees from "FlowStorageFees"
import FlowClusterQC from "FlowClusterQC"
import FlowDKG from "FlowDKG"
import FlowEpoch from "FlowEpoch"
import Burner from "Burner"
import "FungibleToken"
import "FlowToken"
import "FlowIDTableStaking"
import "LockedTokens"
import "FlowStorageFees"
import "FlowClusterQC"
import "FlowDKG"
import "FlowEpoch"
import "Burner"

access(all) contract FlowStakingCollection {

Expand Down
4 changes: 2 additions & 2 deletions contracts/FlowStorageFees.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*
*/

import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import "FungibleToken"
import "FlowToken"

access(all) contract FlowStorageFees {

Expand Down
6 changes: 3 additions & 3 deletions contracts/FlowToken.cdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FungibleToken from "FungibleToken"
import MetadataViews from "MetadataViews"
import FungibleTokenMetadataViews from "FungibleTokenMetadataViews"
import "FungibleToken"
import "MetadataViews"
import "FungibleTokenMetadataViews"

access(all) contract FlowToken: FungibleToken {

Expand Down
10 changes: 5 additions & 5 deletions contracts/LockedTokens.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

*/

import FlowToken from "FlowToken"
import FungibleToken from "FungibleToken"
import FlowIDTableStaking from "FlowIDTableStaking"
import FlowStorageFees from "FlowStorageFees"
import StakingProxy from "StakingProxy"
import "FlowToken"
import "FungibleToken"
import "FlowIDTableStaking"
import "FlowStorageFees"
import "StakingProxy"

access(all) contract LockedTokens {

Expand Down
12 changes: 6 additions & 6 deletions contracts/epochs/FlowEpoch.cdc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import FlowIDTableStaking from "FlowIDTableStaking"
import FlowClusterQC from "FlowClusterQC"
import FlowDKG from "FlowDKG"
import FlowFees from "FlowFees"
import "FungibleToken"
import "FlowToken"
import "FlowIDTableStaking"
import "FlowClusterQC"
import "FlowDKG"
import "FlowFees"

// The top-level smart contract managing the lifecycle of epochs. In Flow,
// epochs are the smallest unit of time where the identity table (the set of
Expand Down
4 changes: 2 additions & 2 deletions contracts/testContracts/TestFlowIDTableStaking.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

*/

import FungibleToken from "FungibleToken"
import FlowToken from "FlowToken"
import "FungibleToken"
import "FlowToken"
// import Burner from "Burner"

access(all) contract FlowIDTableStaking {
Expand Down
63 changes: 30 additions & 33 deletions lib/go/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func MetadataViews(env templates.Environment) []byte {
return nftcontracts.MetadataViews(env.FungibleTokenAddress, env.NonFungibleTokenAddress, env.ViewResolverAddress)
}

func CrossVMMetadataViews(env templates.Environment) []byte {
return nftcontracts.CrossVMMetadataViews(env.ViewResolverAddress, env.EVMAddress)
}

// FlowToken returns the FlowToken contract.
//
// The returned contract will import the FungibleToken contract from the specified address.
Expand Down Expand Up @@ -189,12 +193,11 @@ func FlowServiceAccount(env templates.Environment) []byte {
code := assets.MustAssetString(flowServiceAccountFilename)

if env.FlowExecutionParametersAddress == "" {

// Remove the import of FlowExecutionParameters
code = strings.ReplaceAll(
code,
"import FlowExecutionParameters from \"FlowExecutionParameters\"",
"//import FlowExecutionParameters from \"FlowExecutionParameters\"",
"import \"FlowExecutionParameters\"",
"//import \"FlowExecutionParameters\"",
)

// Replace the metering getter functions
Expand Down Expand Up @@ -294,6 +297,10 @@ func FlowContractAudits() []byte {
return assets.MustAsset(flowContractAuditsFilename)
}

func Crypto() []byte {
return assets.MustAsset(cryptoFilename)
}

/******************** Test contracts *********************/

// TESTFlowIDTableStaking returns the TestFlowIDTableStaking contract
Expand All @@ -320,16 +327,20 @@ func TESTFlowStakingCollection(
) []byte {
code := assets.MustAssetString(flowStakingCollectionFilename)

code = strings.ReplaceAll(code, placeholderFungibleTokenAddress, withHexPrefix(fungibleTokenAddress))
code = strings.ReplaceAll(code, placeholderBurnerAddress, withHexPrefix(storageFeesAddress))
code = strings.ReplaceAll(code, placeholderFlowTokenAddress, withHexPrefix(flowTokenAddress))
code = strings.ReplaceAll(code, placeholderIDTableAddress, withHexPrefix(idTableAddress))
code = strings.ReplaceAll(code, placeholderStakingProxyAddress, withHexPrefix(stakingProxyAddress))
code = strings.ReplaceAll(code, placeholderLockedTokensAddress, withHexPrefix(lockedTokensAddress))
code = strings.ReplaceAll(code, placeholderStorageFeesAddress, withHexPrefix(storageFeesAddress))
code = strings.ReplaceAll(code, placeholderQCAddr, withHexPrefix(qcAddress))
code = strings.ReplaceAll(code, placeholderDKGAddr, withHexPrefix(dkgAddress))
code = strings.ReplaceAll(code, placeholderEpochAddr, withHexPrefix(epochAddress))
env := templates.Environment{
FungibleTokenAddress: fungibleTokenAddress,
FlowTokenAddress: flowTokenAddress,
IDTableAddress: idTableAddress,
StakingProxyAddress: stakingProxyAddress,
LockedTokensAddress: lockedTokensAddress,
StorageFeesAddress: storageFeesAddress,
QuorumCertificateAddress: qcAddress,
DkgAddress: dkgAddress,
EpochAddress: epochAddress,
BurnerAddress: storageFeesAddress,
}

code = templates.ReplaceAddresses(code, env)

code = strings.ReplaceAll(code, "access(self) fun getTokens", "access(all) fun getTokens")
code = strings.ReplaceAll(code, "access(self) fun depositTokens", "access(all) fun depositTokens")
Expand All @@ -340,27 +351,13 @@ func TESTFlowStakingCollection(
func TestFlowFees(fungibleTokenAddress, flowTokenAddress, storageFeesAddress string) []byte {
code := assets.MustAssetString(flowFeesFilename)

code = strings.ReplaceAll(
code,
placeholderFungibleTokenAddress,
withHexPrefix(fungibleTokenAddress),
)

code = strings.ReplaceAll(
code,
placeholderFlowTokenAddress,
withHexPrefix(flowTokenAddress),
)
env := templates.Environment{
FungibleTokenAddress: fungibleTokenAddress,
FlowTokenAddress: flowTokenAddress,
StorageFeesAddress: storageFeesAddress,
}

code = strings.ReplaceAll(
code,
placeholderStorageFeesAddress,
withHexPrefix(storageFeesAddress),
)
code = templates.ReplaceAddresses(code, env)

return []byte(code)
}

func Crypto() []byte {
return assets.MustAsset(cryptoFilename)
}
Loading
Loading