github.com/koko1123/flow-go-1@v0.29.6/fvm/blueprints/system.go (about)

     1  package blueprints
     2  
     3  import (
     4  	_ "embed"
     5  	"fmt"
     6  
     7  	"github.com/onflow/flow-core-contracts/lib/go/templates"
     8  
     9  	"github.com/koko1123/flow-go-1/fvm/systemcontracts"
    10  	"github.com/koko1123/flow-go-1/model/flow"
    11  )
    12  
    13  const SystemChunkTransactionGasLimit = 100_000_000
    14  
    15  // TODO (Ramtin) after changes to this method are merged into master move them here.
    16  
    17  //go:embed scripts/systemChunkTransactionTemplate.cdc
    18  var systemChunkTransactionTemplate string
    19  
    20  // SystemChunkTransaction creates and returns the transaction corresponding to the system chunk
    21  // for the given chain.
    22  func SystemChunkTransaction(chain flow.Chain) (*flow.TransactionBody, error) {
    23  
    24  	contracts, err := systemcontracts.SystemContractsForChain(chain.ChainID())
    25  	if err != nil {
    26  		return nil, fmt.Errorf("could not get system contracts for chain: %w", err)
    27  	}
    28  
    29  	tx := flow.NewTransactionBody().
    30  		SetScript([]byte(templates.ReplaceAddresses(systemChunkTransactionTemplate,
    31  			templates.Environment{
    32  				EpochAddress: contracts.Epoch.Address.Hex(),
    33  			})),
    34  		).
    35  		AddAuthorizer(contracts.Epoch.Address).
    36  		SetGasLimit(SystemChunkTransactionGasLimit)
    37  
    38  	return tx, nil
    39  }