Commit 00b6718e authored by Yingjie Qiao's avatar Yingjie Qiao Committed by GitHub

feat(op-challenger):Get the PreimageOracleContract with corresponding GameType (#9149)

* feat(op-challenger):Get the PreimageOracleContract with corresponding GameType

* Make error message generic.

---------
Co-authored-by: default avatarAdrian Sutton <adrian@symphonious.net>
parent e704fc61
......@@ -99,7 +99,7 @@ func registerAlphabet(
genesisValidator := NewPrestateValidator(contract.GetGenesisOutputRoot, prestateProvider)
return NewGamePlayer(ctx, logger, m, dir, game.Proxy, txMgr, contract, []Validator{prestateValidator, genesisValidator}, creator)
}
oracle, err := createOracle(ctx, gameFactory, caller)
oracle, err := createOracle(ctx, gameFactory, caller, alphabetGameType)
if err != nil {
return err
}
......@@ -107,10 +107,10 @@ func registerAlphabet(
return nil
}
func createOracle(ctx context.Context, gameFactory *contracts.DisputeGameFactoryContract, caller *batching.MultiCaller) (*contracts.PreimageOracleContract, error) {
implAddr, err := gameFactory.GetGameImpl(ctx, alphabetGameType)
func createOracle(ctx context.Context, gameFactory *contracts.DisputeGameFactoryContract, caller *batching.MultiCaller, gameType uint8) (*contracts.PreimageOracleContract, error) {
implAddr, err := gameFactory.GetGameImpl(ctx, gameType)
if err != nil {
return nil, fmt.Errorf("failed to load alphabet game implementation: %w", err)
return nil, fmt.Errorf("failed to load implementation for game type %v: %w", gameType, err)
}
contract, err := contracts.NewFaultDisputeGameContract(implAddr, caller)
if err != nil {
......@@ -160,7 +160,7 @@ func registerCannon(
genesisValidator := NewPrestateValidator(contract.GetGenesisOutputRoot, prestateProvider)
return NewGamePlayer(ctx, logger, m, dir, game.Proxy, txMgr, contract, []Validator{prestateValidator, genesisValidator}, creator)
}
oracle, err := createOracle(ctx, gameFactory, caller)
oracle, err := createOracle(ctx, gameFactory, caller, cannonGameType)
if err != nil {
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment