-
Notifications
You must be signed in to change notification settings - Fork 175
/
system.go
38 lines (30 loc) · 1.12 KB
/
system.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package blueprints
import (
_ "embed"
"github.com/onflow/flow-core-contracts/lib/go/templates"
"github.com/onflow/flow-go/fvm/systemcontracts"
"github.com/onflow/flow-go/model/flow"
)
const SystemChunkTransactionGasLimit = 100_000_000
// systemChunkTransactionTemplate looks for the epoch and version beacon heartbeat resources
// and calls them.
//
//go:embed scripts/systemChunkTransactionTemplate.cdc
var systemChunkTransactionTemplate string
// SystemChunkTransaction creates and returns the transaction corresponding to the
// system chunk for the given chain.
func SystemChunkTransaction(chain flow.Chain) (*flow.TransactionBody, error) {
contracts := systemcontracts.SystemContractsForChain(chain.ChainID())
tx := flow.NewTransactionBody().
SetScript(
[]byte(templates.ReplaceAddresses(
systemChunkTransactionTemplate,
contracts.AsTemplateEnv(),
)),
).
// The heartbeat resources needed by the system tx have are on the service account,
// therefore, the service account is the only authorizer needed.
AddAuthorizer(chain.ServiceAddress()).
SetGasLimit(SystemChunkTransactionGasLimit)
return tx, nil
}