From 8d65f4c4a6c1c780fa715cb56da2815f5ac51aa8 Mon Sep 17 00:00:00 2001 From: Jemil Ezzet Date: Mon, 18 Dec 2023 12:56:02 -0800 Subject: [PATCH 1/2] feat(setup): add context --- codegen/processor.go | 4 ++-- example/bindings/example.go | 2 +- example/bindings/example.handlers.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen/processor.go b/codegen/processor.go index d39dd08..15080c0 100644 --- a/codegen/processor.go +++ b/codegen/processor.go @@ -37,7 +37,7 @@ import ( {{range $handler := .Processors}} type {{.Type}}Processor interface { - Setup(address common.Address, eth interface { + Setup(ctx context.Context, address common.Address, eth interface { ethereum.ChainReader ethereum.ChainStateReader ethereum.TransactionReader @@ -62,7 +62,7 @@ import ( } } - func (h *Base{{.Type}}Processor) Setup(address common.Address, eth interface { + func (h *Base{{.Type}}Processor) Setup(ctx context.Context, address common.Address, eth interface { ethereum.ChainReader ethereum.ChainStateReader ethereum.TransactionReader diff --git a/example/bindings/example.go b/example/bindings/example.go index 35f4258..791d103 100644 --- a/example/bindings/example.go +++ b/example/bindings/example.go @@ -369,7 +369,7 @@ func (_Example *ExampleFilterer) ParseExampleEvent(log types.Log) (*ExampleExamp // FakeExampleMetaData contains all meta data concerning the FakeExample contract. var FakeExampleMetaData = &bind.MetaData{ ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"}],\"name\":\"ExampleEvent\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"exampleValue\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"value\",\"type\":\"string\"}],\"name\":\"fakeEmitExampleEvent\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"retstringExampleValue0\",\"type\":\"string\"}],\"name\":\"fakeSetExampleValue\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610395806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063010ac92514610046578063b8290c1a1461005b578063d8f7c4cf1461006e575b600080fd5b61005961005436600461021e565b61008c565b005b61005961006936600461021e565b6100c6565b6100766100dd565b60405161008391906102cf565b60405180910390f35b7fb74a38eb2ebca56512a2bb0283f335555a4a4dac46ab998d65fd76f9027dca70816040516100bb91906102cf565b60405180910390a150565b80516100d990600090602084019061016f565b5050565b6060600080546100ec90610324565b80601f016020809104026020016040519081016040528092919081815260200182805461011890610324565b80156101655780601f1061013a57610100808354040283529160200191610165565b820191906000526020600020905b81548152906001019060200180831161014857829003601f168201915b5050505050905090565b82805461017b90610324565b90600052602060002090601f01602090048101928261019d57600085556101e3565b82601f106101b657805160ff19168380011785556101e3565b828001600101855582156101e3579182015b828111156101e35782518255916020019190600101906101c8565b506101ef9291506101f3565b5090565b5b808211156101ef57600081556001016101f4565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561023057600080fd5b813567ffffffffffffffff8082111561024857600080fd5b818401915084601f83011261025c57600080fd5b81358181111561026e5761026e610208565b604051601f8201601f19908116603f0116810190838211818310171561029657610296610208565b816040528281528760208487010111156102af57600080fd5b826020860160208301376000928101602001929092525095945050505050565b600060208083528351808285015260005b818110156102fc578581018301518582016040015282016102e0565b8181111561030e576000604083870101525b50601f01601f1916929092016040019392505050565b600181811c9082168061033857607f821691505b6020821081141561035957634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212200d9a7cea162c03631cca67410b5e158cb8942957609ddde40bec8f8a21362e6764736f6c634300080a0033", + Bin: "0x608060405234801561001057600080fd5b506103fc806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063010ac92514610046578063b8290c1a1461005b578063d8f7c4cf1461006e575b600080fd5b61005961005436600461017e565b61008c565b005b61005961006936600461017e565b6100c6565b6100766100d6565b604051610083919061022f565b60405180910390f35b7fb74a38eb2ebca56512a2bb0283f335555a4a4dac46ab998d65fd76f9027dca70816040516100bb919061022f565b60405180910390a150565b60006100d28282610306565b5050565b6060600080546100e59061027d565b80601f01602080910402602001604051908101604052809291908181526020018280546101119061027d565b801561015e5780601f106101335761010080835404028352916020019161015e565b820191906000526020600020905b81548152906001019060200180831161014157829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561019057600080fd5b813567ffffffffffffffff808211156101a857600080fd5b818401915084601f8301126101bc57600080fd5b8135818111156101ce576101ce610168565b604051601f8201601f19908116603f011681019083821181831017156101f6576101f6610168565b8160405282815287602084870101111561020f57600080fd5b826020860160208301376000928101602001929092525095945050505050565b600060208083528351808285015260005b8181101561025c57858101830151858201604001528201610240565b506000604082860101526040601f19601f8301168501019250505092915050565b600181811c9082168061029157607f821691505b6020821081036102b157634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561030157600081815260208120601f850160051c810160208610156102de5750805b601f850160051c820191505b818110156102fd578281556001016102ea565b5050505b505050565b815167ffffffffffffffff81111561032057610320610168565b6103348161032e845461027d565b846102b7565b602080601f83116001811461036957600084156103515750858301515b600019600386901b1c1916600185901b1785556102fd565b600085815260208120601f198616915b8281101561039857888601518255948401946001909101908401610379565b50858210156103b65787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220652f78b5bfeb9da187cdac8658b98042d364caaa266b9d9138a3a4883698a11a64736f6c63430008130033", } // FakeExampleABI is the input ABI used to generate the binding from. diff --git a/example/bindings/example.handlers.go b/example/bindings/example.handlers.go index e484125..5c1ab5c 100644 --- a/example/bindings/example.handlers.go +++ b/example/bindings/example.handlers.go @@ -19,7 +19,7 @@ import ( ) type ExampleProcessor interface { - Setup(address common.Address, eth interface { + Setup(ctx context.Context, address common.Address, eth interface { ethereum.ChainReader ethereum.ChainStateReader ethereum.TransactionReader @@ -44,7 +44,7 @@ type BaseExampleProcessor struct { } } -func (h *BaseExampleProcessor) Setup(address common.Address, eth interface { +func (h *BaseExampleProcessor) Setup(ctx context.Context, address common.Address, eth interface { ethereum.ChainReader ethereum.ChainStateReader ethereum.TransactionReader From 5600a77da598b222779edc84ab597b89d784b04b Mon Sep 17 00:00:00 2001 From: Jemil Ezzet Date: Mon, 18 Dec 2023 13:01:41 -0800 Subject: [PATCH 2/2] feat(setup): add extra --- codegen/processor.go | 4 ++-- example/bindings/example.handlers.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codegen/processor.go b/codegen/processor.go index 15080c0..c365fba 100644 --- a/codegen/processor.go +++ b/codegen/processor.go @@ -42,7 +42,7 @@ import ( ethereum.ChainStateReader ethereum.TransactionReader bind.ContractBackend - }) error + }, extra map[string]interface{}) error Initialize(ctx context.Context, start uint64, {{$s := separator ", "}}{{range $type := $.InputTypes}}{{call $s}}{{$type.Name}} {{formatPointer $type.Kind}}{{$type.Ident}}{{end}}) error {{range .Events}} Process{{.Normalized.Name}}(ctx context.Context, e {{$handler.Type}}{{.Normalized.Name}}) (func({{$s := separator ", "}}{{range $type := $.InputTypes}}{{call $s}}{{$type.Name}} {{formatPointer $type.Kind}}{{$type.Ident}}{{end}}) error, error) @@ -67,7 +67,7 @@ import ( ethereum.ChainStateReader ethereum.TransactionReader bind.ContractBackend - }) error { + }, extra map[string]interface{}) error { contract, err := New{{.Type}}(address, eth) if err != nil { return fmt.Errorf("new {{.Type}}: %w", err) diff --git a/example/bindings/example.handlers.go b/example/bindings/example.handlers.go index 5c1ab5c..fe000c8 100644 --- a/example/bindings/example.handlers.go +++ b/example/bindings/example.handlers.go @@ -24,7 +24,7 @@ type ExampleProcessor interface { ethereum.ChainStateReader ethereum.TransactionReader bind.ContractBackend - }) error + }, extra map[string]interface{}) error Initialize(ctx context.Context, start uint64, tx *example.TestInput, testtx *testexample.TestInput) error ProcessExampleEvent(ctx context.Context, e ExampleExampleEvent) (func(tx *example.TestInput, testtx *testexample.TestInput) error, error) @@ -49,7 +49,7 @@ func (h *BaseExampleProcessor) Setup(ctx context.Context, address common.Address ethereum.ChainStateReader ethereum.TransactionReader bind.ContractBackend -}) error { +}, extra map[string]interface{}) error { contract, err := NewExample(address, eth) if err != nil { return fmt.Errorf("new Example: %w", err)