evmgrantrole

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpEVMGrantRole = operations.NewOperation(
	"evm-timelock-grant-role",
	semver.MustParse("1.0.0"),
	"Grants an RBACTimelock role to one EVM address via the MCMS SDK timelock configurer",
	func(b operations.Bundle, deps cldf_evm.Chain, in OpEVMGrantRoleInput) (opscontract.WriteOutput, error) {
		if !in.NoSend && deps.DeployerKey == nil {
			return opscontract.WriteOutput{}, fmt.Errorf("missing deployer key for chain %d", deps.Selector)
		}

		var opts *bind.TransactOpts
		if in.NoSend {
			opts = cldf.SimTransactOpts()
		} else {
			opts = gasboost.CloneTransactOptsWithGas(deps.DeployerKey, in.GasLimit, in.GasPrice)
		}
		if opts == nil {
			return opscontract.WriteOutput{}, fmt.Errorf("failed to build transact opts for chain %d", deps.Selector)
		}
		opts.Context = b.GetContext()

		configurer := mcmsevm.NewTimelockConfigurer(deps.Client, opts)
		res, err := configurer.GrantRole(b.GetContext(), in.Target.Timelock.Hex(), in.Target.Role, in.Target.Address.Hex())
		if err != nil {
			return opscontract.WriteOutput{}, fmt.Errorf("failed to grant role %s to %s on %s: %w",
				in.Target.Role.String(), in.Target.Address.Hex(), in.Target.Timelock.Hex(), err)
		}

		tx, err := rawTransaction(res.RawData)
		if err != nil {
			return opscontract.WriteOutput{}, err
		}

		out := writeOutputFromGrant(deps.Selector, in.Target.Timelock, tx)
		if in.NoSend {
			return out, nil
		}

		if _, err = cldf.ConfirmIfNoErrorWithABI(deps, tx, mcmsbindings.RBACTimelockABI, nil); err != nil {
			return opscontract.WriteOutput{}, fmt.Errorf("failed to confirm grant role tx against %s: %w", in.Target.Timelock.Hex(), err)
		}
		b.Logger.Infow("GrantRole tx confirmed", "txHash", tx.Hash().Hex(), "timelock", in.Target.Timelock.Hex())

		out.ExecInfo = &opscontract.ExecInfo{Hash: tx.Hash().Hex()}

		return out, nil
	},
)

Functions

func AddressesNeedingGrant

func AddressesNeedingGrant(
	ctx context.Context,
	inspector mcmssdk.TimelockInspector,
	timelock common.Address,
	grant grantrole.RoleGrant,
) ([]common.Address, error)

AddressesNeedingGrant returns grant addresses that do not yet hold the role.

func Registration

func Registration() grantrole.Registration

Types

type GrantRoleTarget

type GrantRoleTarget struct {
	Timelock common.Address       `json:"timelock"`
	Role     mcmssdk.TimelockRole `json:"role"`
	Address  common.Address       `json:"address"`
}

type OpEVMGrantRoleInput

type OpEVMGrantRoleInput struct {
	Target   GrantRoleTarget `json:"target"`
	NoSend   bool            `json:"noSend"`
	GasPrice uint64          `json:"gasPrice"`
	GasLimit uint64          `json:"gasLimit"`
}

func (OpEVMGrantRoleInput) GasBoostValues

func (in OpEVMGrantRoleInput) GasBoostValues() (gasLimit, gasPrice uint64)

func (OpEVMGrantRoleInput) WithGasBoost

func (in OpEVMGrantRoleInput) WithGasBoost(gasLimit, gasPrice uint64) OpEVMGrantRoleInput

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL