github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/evm/txs/factory.go (about) 1 package txs 2 3 import ( 4 "fmt" 5 "github.com/fibonacci-chain/fbc/x/evm/txs/base" 6 "github.com/fibonacci-chain/fbc/x/evm/txs/check" 7 "github.com/fibonacci-chain/fbc/x/evm/txs/deliver" 8 "github.com/fibonacci-chain/fbc/x/evm/txs/tracetxlog" 9 ) 10 11 type factory struct { 12 base.Config 13 } 14 15 func NewFactory(config base.Config) *factory { 16 return &factory{config} 17 } 18 19 func (factory *factory) CreateTx() (Tx, error) { 20 if factory == nil || factory.Keeper == nil { 21 return nil, fmt.Errorf("evm txs factory not inited") 22 } 23 if factory.Ctx.IsTraceTxLog() { 24 return tracetxlog.NewTx(factory.Config), nil 25 } else if factory.Ctx.IsCheckTx() { 26 return check.NewTx(factory.Config), nil 27 } 28 29 return deliver.NewTx(factory.Config), nil 30 }