mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
// (c) 2023-2024, Lux Partners Limited. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package warp
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/luxdefi/evm/precompile/contract"
|
|
"github.com/luxdefi/evm/precompile/modules"
|
|
"github.com/luxdefi/evm/precompile/precompileconfig"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
var _ contract.Configurator = &configurator{}
|
|
|
|
// ConfigKey is the key used in json config files to specify this precompile config.
|
|
// must be unique across all precompiles.
|
|
const ConfigKey = "warpConfig"
|
|
|
|
// ContractAddress is the address of the warp precompile contract
|
|
var ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000005")
|
|
|
|
// Module is the precompile module. It is used to register the precompile contract.
|
|
var Module = modules.Module{
|
|
ConfigKey: ConfigKey,
|
|
Address: ContractAddress,
|
|
Contract: WarpPrecompile,
|
|
Configurator: &configurator{},
|
|
}
|
|
|
|
type configurator struct{}
|
|
|
|
func init() {
|
|
// Register the precompile module.
|
|
// Each precompile contract registers itself through [RegisterModule] function.
|
|
if err := modules.RegisterModule(Module); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// MakeConfig returns a new precompile config instance.
|
|
// This is required to Marshal/Unmarshal the precompile config.
|
|
func (*configurator) MakeConfig() precompileconfig.Config {
|
|
return new(Config)
|
|
}
|
|
|
|
// Configure is a no-op for warp since it does not need to store any information in the state
|
|
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, _ contract.ConfigurationBlockContext) error {
|
|
if _, ok := cfg.(*Config); !ok {
|
|
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
|
|
}
|
|
return nil
|
|
}
|