From 3c4a11c81637b99a6094aacaa5738e19f7dd08e0 Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 24 Sep 2024 15:20:14 +0300 Subject: [PATCH] Fix: unlock assets --- internal/storage/bridge.go | 1 + internal/storage/mock/bridge.go | 39 ++++++++++++++ internal/storage/postgres/bridge.go | 18 +++++++ internal/storage/postgres/bridge_test.go | 25 +++++++++ pkg/indexer/decode/actions.go | 27 +++++++--- pkg/indexer/decode/actions_test.go | 66 +++++++++++++----------- pkg/indexer/decode/context.go | 10 +++- pkg/indexer/indexer.go | 25 +++++++-- pkg/indexer/parser/parse.go | 2 +- pkg/indexer/parser/parseTxs_test.go | 8 +-- pkg/indexer/parser/parser.go | 10 ++-- pkg/indexer/parser/parser_test.go | 2 +- 12 files changed, 181 insertions(+), 52 deletions(-) diff --git a/internal/storage/bridge.go b/internal/storage/bridge.go index 8a8e39f..ee950bd 100644 --- a/internal/storage/bridge.go +++ b/internal/storage/bridge.go @@ -18,6 +18,7 @@ type IBridge interface { ByAddress(ctx context.Context, addressId uint64) (Bridge, error) ByRollup(ctx context.Context, rollupId uint64, limit, offset int) ([]Bridge, error) ByRoles(ctx context.Context, addressId uint64, limit, offset int) ([]Bridge, error) + ListWithAddress(ctx context.Context, limit, offset int) ([]Bridge, error) } type Bridge struct { diff --git a/internal/storage/mock/bridge.go b/internal/storage/mock/bridge.go index 301576d..a03661d 100644 --- a/internal/storage/mock/bridge.go +++ b/internal/storage/mock/bridge.go @@ -355,6 +355,45 @@ func (c *MockIBridgeListCall) DoAndReturn(f func(context.Context, uint64, uint64 return c } +// ListWithAddress mocks base method. +func (m *MockIBridge) ListWithAddress(ctx context.Context, limit, offset int) ([]storage.Bridge, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListWithAddress", ctx, limit, offset) + ret0, _ := ret[0].([]storage.Bridge) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWithAddress indicates an expected call of ListWithAddress. +func (mr *MockIBridgeMockRecorder) ListWithAddress(ctx, limit, offset any) *MockIBridgeListWithAddressCall { + mr.mock.ctrl.T.Helper() + call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWithAddress", reflect.TypeOf((*MockIBridge)(nil).ListWithAddress), ctx, limit, offset) + return &MockIBridgeListWithAddressCall{Call: call} +} + +// MockIBridgeListWithAddressCall wrap *gomock.Call +type MockIBridgeListWithAddressCall struct { + *gomock.Call +} + +// Return rewrite *gomock.Call.Return +func (c *MockIBridgeListWithAddressCall) Return(arg0 []storage.Bridge, arg1 error) *MockIBridgeListWithAddressCall { + c.Call = c.Call.Return(arg0, arg1) + return c +} + +// Do rewrite *gomock.Call.Do +func (c *MockIBridgeListWithAddressCall) Do(f func(context.Context, int, int) ([]storage.Bridge, error)) *MockIBridgeListWithAddressCall { + c.Call = c.Call.Do(f) + return c +} + +// DoAndReturn rewrite *gomock.Call.DoAndReturn +func (c *MockIBridgeListWithAddressCall) DoAndReturn(f func(context.Context, int, int) ([]storage.Bridge, error)) *MockIBridgeListWithAddressCall { + c.Call = c.Call.DoAndReturn(f) + return c +} + // Save mocks base method. func (m_2 *MockIBridge) Save(ctx context.Context, m *storage.Bridge) error { m_2.ctrl.T.Helper() diff --git a/internal/storage/postgres/bridge.go b/internal/storage/postgres/bridge.go index 8c7c3ce..402184b 100644 --- a/internal/storage/postgres/bridge.go +++ b/internal/storage/postgres/bridge.go @@ -8,6 +8,7 @@ import ( "github.com/celenium-io/astria-indexer/internal/storage" "github.com/dipdup-net/go-lib/database" + sdk "github.com/dipdup-net/indexer-sdk/pkg/storage" "github.com/dipdup-net/indexer-sdk/pkg/storage/postgres" ) @@ -89,3 +90,20 @@ func (b *Bridge) ByRoles(ctx context.Context, addressId uint64, limit, offset in Scan(ctx, &result) return } + +func (b *Bridge) ListWithAddress(ctx context.Context, limit, offset int) (result []storage.Bridge, err error) { + query := b.DB().NewSelect(). + Model((*storage.Bridge)(nil)). + Offset(offset) + + query = limitScope(query, limit) + query = sortScope(query, "id", sdk.SortOrderAsc) + + err = b.DB().NewSelect(). + TableExpr("(?) as bridge", query). + ColumnExpr("bridge.*"). + ColumnExpr("address.hash as address__hash"). + Join("left join address as address on address.id = bridge.address_id"). + Scan(ctx, &result) + return +} diff --git a/internal/storage/postgres/bridge_test.go b/internal/storage/postgres/bridge_test.go index 657127b..760a6e5 100644 --- a/internal/storage/postgres/bridge_test.go +++ b/internal/storage/postgres/bridge_test.go @@ -98,3 +98,28 @@ func (s *StorageTestSuite) TestBridgeByRoles() { hash, _ := hex.DecodeString("19ba8abb3e4b56a309df6756c47b97e298e3a72d88449d36a0fadb1ca7366539") s.Require().Equal(hash, bridge.Rollup.AstriaId) } + +func (s *StorageTestSuite) TestBridgeListWithAddress() { + ctx, ctxCancel := context.WithTimeout(context.Background(), 5*time.Second) + defer ctxCancel() + + bridges, err := s.storage.Bridges.ListWithAddress(ctx, 1, 0) + s.Require().NoError(err) + s.Require().Len(bridges, 1) + + bridge := bridges[0] + s.Require().EqualValues(7316, bridge.InitHeight) + s.Require().EqualValues(1, bridge.AddressId) + s.Require().EqualValues(1, bridge.SudoId) + s.Require().EqualValues(1, bridge.WithdrawerId) + s.Require().EqualValues(1, bridge.RollupId) + s.Require().EqualValues("nria", bridge.Asset) + s.Require().EqualValues("nria", bridge.FeeAsset) + + s.Require().NotNil(bridge.Address) + s.Require().Equal("astria1lm45urgugesyhaymn68xww0m6g49zreqa32w7p", bridge.Address.Hash) + + s.Require().Nil(bridge.Sudo) + s.Require().Nil(bridge.Withdrawer) + s.Require().Nil(bridge.Rollup) +} diff --git a/pkg/indexer/decode/actions.go b/pkg/indexer/decode/actions.go index 95e6707..aa422f2 100644 --- a/pkg/indexer/decode/actions.go +++ b/pkg/indexer/decode/actions.go @@ -9,6 +9,7 @@ import ( "time" astria "buf.build/gen/go/astria/protocol-apis/protocolbuffers/go/astria/protocol/transactions/v1alpha1" + "github.com/celenium-io/astria-indexer/internal/currency" "github.com/celenium-io/astria-indexer/internal/storage" storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types" "github.com/celenium-io/astria-indexer/pkg/types" @@ -513,6 +514,7 @@ func parseInitBridgeAccount(body *astria.Action_InitBridgeAccountAction, from st ActionType: action.Type, } ctx.AddBridge(&bridge) + ctx.AddBridgeAsset(from, bridge.Asset) } return nil } @@ -651,7 +653,6 @@ func parseBridgeLock(body *astria.Action_BridgeLockAction, from string, height t Update: decAmount.Neg(), }, ) - } } return nil @@ -676,16 +677,26 @@ func parseBridgeUnlock(body *astria.Action_BridgeUnlockAction, from string, heig action.Data["bridge"] = bridge } - decAmount := decimal.RequireFromString(amount) - toAddr := ctx.Addresses.Set(toAddress, height, decAmount, feeAsset, 1, 0) + var ( + decAmount = decimal.RequireFromString(amount) + fromAddr *storage.Address + unlockAsset string + ) - var fromAddr *storage.Address if bridge == "" { - fromAddr = ctx.Addresses.Set(from, height, decAmount.Neg(), feeAsset, 1, 0) + fromAddr = ctx.Addresses.Set(from, height, decAmount.Neg(), "", 1, 0) + unlockAsset = currency.DefaultCurrency } else { - fromAddr = ctx.Addresses.Set(bridge, height, decAmount.Neg(), feeAsset, 1, 0) + asset, ok := ctx.bridgeAssets[bridge] + if !ok { + return errors.Errorf("unknown bridge asset: %s", bridge) + } + fromAddr = ctx.Addresses.Set(bridge, height, decAmount.Neg(), asset, 1, 0) + unlockAsset = asset } + toAddr := ctx.Addresses.Set(toAddress, height, decAmount, unlockAsset, 1, 0) + action.Addresses = append(action.Addresses, &storage.AddressAction{ Address: toAddr, @@ -707,13 +718,13 @@ func parseBridgeUnlock(body *astria.Action_BridgeUnlockAction, from string, heig storage.BalanceUpdate{ Address: toAddr, Height: action.Height, - Currency: feeAsset, + Currency: unlockAsset, Update: decAmount, }, storage.BalanceUpdate{ Address: fromAddr, Height: action.Height, - Currency: feeAsset, + Currency: unlockAsset, Update: decAmount.Neg(), }, ) diff --git a/pkg/indexer/decode/actions_test.go b/pkg/indexer/decode/actions_test.go index bf38144..f72b0cb 100644 --- a/pkg/indexer/decode/actions_test.go +++ b/pkg/indexer/decode/actions_test.go @@ -56,7 +56,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("ics 20 withdrawal", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) address := testsuite.RandomAddress() from := testsuite.RandomAddress() @@ -167,7 +167,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("sequence", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) from := testsuite.RandomAddress() addressModel := decodeContext.Addresses.Set(from, 1000, decimal.Zero, "", 0, 1) @@ -219,7 +219,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("sudo address change", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) newAddress := testsuite.RandomAddress() message := &astria.Action_SudoAddressChangeAction{ @@ -259,7 +259,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("transfer", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) from := testsuite.RandomAddress() fromModel := &storage.Address{ @@ -346,7 +346,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("transfer to myself", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) from := testsuite.RandomAddress() fromModel := &storage.Address{ @@ -401,7 +401,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("validator update", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_ValidatorUpdateAction{ ValidatorUpdateAction: &abci.ValidatorUpdate{ PubKey: &crypto.PublicKey{ @@ -504,7 +504,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge lock", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) to := testsuite.RandomAddress() dest := testsuite.RandomAddress() @@ -599,7 +599,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge lock the same address", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) to := testsuite.RandomAddress() dest := testsuite.RandomAddress() @@ -660,10 +660,12 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge unlock", func(t *testing.T) { - decodeContext := NewContext() + bridge := testsuite.RandomAddress() + decodeContext := NewContext(map[string]string{ + bridge: assetId, + }) to := testsuite.RandomAddress() - bridge := testsuite.RandomAddress() message := &astria.Action_BridgeUnlockAction{ BridgeUnlockAction: &astria.BridgeUnlockAction{ @@ -685,7 +687,7 @@ func TestDecodeActions(t *testing.T) { SignedTxCount: 0, Balance: []*storage.Balance{ { - Currency: feeAssetId, + Currency: assetId, Total: decimal.RequireFromString("10"), }, }, @@ -697,7 +699,7 @@ func TestDecodeActions(t *testing.T) { SignedTxCount: 0, Balance: []*storage.Balance{ { - Currency: feeAssetId, + Currency: assetId, Total: decimal.RequireFromString("-10"), }, }, @@ -718,13 +720,13 @@ func TestDecodeActions(t *testing.T) { { Address: toModel, Update: toModel.Balance[0].Total, - Currency: feeAssetId, + Currency: assetId, Height: 1000, }, { Address: fromModel, Update: fromModel.Balance[0].Total, - Currency: feeAssetId, + Currency: assetId, Height: 1000, }, }, @@ -753,7 +755,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("init bridge account", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) rollupId := testsuite.RandomHash(10) from := testsuite.RandomAddress() @@ -817,10 +819,12 @@ func TestDecodeActions(t *testing.T) { err := parseInitBridgeAccount(message, from, 1000, &decodeContext, &action) require.NoError(t, err) require.Equal(t, wantAction, action) + require.Len(t, decodeContext.bridgeAssets, 1) + require.Contains(t, decodeContext.bridgeAssets, from) }) t.Run("init bridge account: the same address", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) rollupId := testsuite.RandomHash(10) from := testsuite.RandomAddress() @@ -863,10 +867,12 @@ func TestDecodeActions(t *testing.T) { err := parseInitBridgeAccount(message, from, 1000, &decodeContext, &action) require.NoError(t, err) require.Equal(t, wantAction, action) + require.Len(t, decodeContext.bridgeAssets, 1) + require.Contains(t, decodeContext.bridgeAssets, from) }) t.Run("ibc relayer change: addition", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) address := testsuite.RandomAddress() message := &astria.Action_IbcRelayerChangeAction{ @@ -914,7 +920,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("ibc relayer change: removal", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) address := testsuite.RandomAddress() message := &astria.Action_IbcRelayerChangeAction{ @@ -962,7 +968,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: sequence_base_fee", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -989,7 +995,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: bridge_lock_byte_cost_multiplier", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1016,7 +1022,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: bridge_sudo_change_base_fee", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1043,7 +1049,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: ics20_withdrawal_base_fee", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1070,7 +1076,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: init_bridge_account_base_fee", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1097,7 +1103,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: sequence_byte_cost_multiplier", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1124,7 +1130,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("fee change: transfer_base_fee", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) message := &astria.Action_FeeChangeAction{ FeeChangeAction: &astria.FeeChangeAction{ @@ -1151,7 +1157,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge sudo change", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) bridge := testsuite.RandomAddress() sudo := testsuite.RandomAddress() withdrawer := testsuite.RandomAddress() @@ -1233,7 +1239,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge sudo change: bridge is suor", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) bridge := testsuite.RandomAddress() sudo := bridge withdrawer := testsuite.RandomAddress() @@ -1300,7 +1306,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge sudo change: bridge is withdrawer", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) bridge := testsuite.RandomAddress() sudo := testsuite.RandomAddress() withdrawer := bridge @@ -1367,7 +1373,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge sudo change: sudo is withdrawer", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) bridge := testsuite.RandomAddress() sudo := testsuite.RandomAddress() withdrawer := sudo @@ -1434,7 +1440,7 @@ func TestDecodeActions(t *testing.T) { }) t.Run("bridge sudo change: all equals", func(t *testing.T) { - decodeContext := NewContext() + decodeContext := NewContext(map[string]string{}) bridge := testsuite.RandomAddress() sudo := bridge withdrawer := bridge diff --git a/pkg/indexer/decode/context.go b/pkg/indexer/decode/context.go index fe83557..323e904 100644 --- a/pkg/indexer/decode/context.go +++ b/pkg/indexer/decode/context.go @@ -27,9 +27,11 @@ type Context struct { Bridges map[string]*storage.Bridge Fees []*storage.Fee Proposer string + + bridgeAssets map[string]string } -func NewContext() Context { +func NewContext(bridgeAssets map[string]string) Context { return Context{ Addresses: NewAddress(), Rollups: NewRollups(), @@ -39,6 +41,8 @@ func NewContext() Context { Constants: make(map[string]*storage.Constant), Bridges: make(map[string]*storage.Bridge), Fees: make([]*storage.Fee, 0), + + bridgeAssets: bridgeAssets, } } @@ -74,3 +78,7 @@ func (ctx *Context) BridgesArray() []*storage.Bridge { func (ctx *Context) AddFee(fee *storage.Fee) { ctx.Fees = append(ctx.Fees, fee) } + +func (ctx *Context) AddBridgeAsset(bridge, asset string) { + ctx.bridgeAssets[bridge] = asset +} diff --git a/pkg/indexer/indexer.go b/pkg/indexer/indexer.go index 40b3ab3..41f9740 100644 --- a/pkg/indexer/indexer.go +++ b/pkg/indexer/indexer.go @@ -54,7 +54,7 @@ func New(ctx context.Context, cfg config.Config, stopperModule modules.Module) ( return Indexer{}, errors.Wrap(err, "while creating rollback module") } - p, err := createParser(r, &api) + p, err := createParser(ctx, r, &api, pg) if err != nil { return Indexer{}, errors.Wrap(err, "while creating parser module") } @@ -146,8 +146,27 @@ func createRollback(receiverModule modules.Module, pg postgres.Storage, api node return &rollbackModule, nil } -func createParser(receiverModule modules.Module, api node.Api) (*parser.Module, error) { - parserModule := parser.NewModule(api) +func makeBridgeAssetsMap(ctx context.Context, pg postgres.Storage) (map[string]string, error) { + assets := make(map[string]string) + for end := false; !end; { + data, err := pg.Bridges.ListWithAddress(ctx, 100, len(assets)) + if err != nil { + return nil, err + } + for i := range data { + assets[data[i].Address.Hash] = data[i].Asset + } + end = len(data) < 100 + } + return assets, nil +} + +func createParser(ctx context.Context, receiverModule modules.Module, api node.Api, pg postgres.Storage) (*parser.Module, error) { + assets, err := makeBridgeAssetsMap(ctx, pg) + if err != nil { + return nil, errors.Wrap(err, "make bridge asset map") + } + parserModule := parser.NewModule(api, assets) if err := parserModule.AttachTo(receiverModule, receiver.BlocksOutput, parser.InputName); err != nil { return nil, errors.Wrap(err, "while attaching parser to receiver") diff --git a/pkg/indexer/parser/parse.go b/pkg/indexer/parser/parse.go index c4fc4d7..e0bf678 100644 --- a/pkg/indexer/parser/parse.go +++ b/pkg/indexer/parser/parse.go @@ -28,7 +28,7 @@ func (p *Module) parse(ctx context.Context, b types.BlockData) error { return errors.Wrap(err, "decoding block proposer address") } - decodeCtx := decode.NewContext() + decodeCtx := decode.NewContext(p.bridgeAssets) decodeCtx.Proposer = proposer txs, err := parseTxs(ctx, b, &decodeCtx, p.api) diff --git a/pkg/indexer/parser/parseTxs_test.go b/pkg/indexer/parser/parseTxs_test.go index 44ca5ce..6b1f45d 100644 --- a/pkg/indexer/parser/parseTxs_test.go +++ b/pkg/indexer/parser/parseTxs_test.go @@ -19,7 +19,7 @@ import ( func TestParseTxs_EmptyTxsResults(t *testing.T) { block, _ := testsuite.EmptyBlock() - decodeCtx := decode.NewContext() + decodeCtx := decode.NewContext(map[string]string{}) ctrl := gomock.NewController(t) defer ctrl.Finish() api := mock.NewMockApi(ctrl) @@ -57,7 +57,7 @@ func TestParseTxs_SuccessTx(t *testing.T) { Codespace: "codespace", } block, now := testsuite.CreateTestBlock(txRes, true) - ctx := decode.NewContext() + ctx := decode.NewContext(map[string]string{}) ctrl := gomock.NewController(t) defer ctrl.Finish() api := mock.NewMockApi(ctrl) @@ -88,7 +88,7 @@ func TestParseTxs_FailedTx(t *testing.T) { Codespace: "codespace", } block, now := testsuite.CreateTestBlock(txRes, true) - ctx := decode.NewContext() + ctx := decode.NewContext(map[string]string{}) ctrl := gomock.NewController(t) defer ctrl.Finish() api := mock.NewMockApi(ctrl) @@ -118,7 +118,7 @@ func TestParseTxs_FailedTxWithNonstandardErrorCode(t *testing.T) { Codespace: "codespace", } block, now := testsuite.CreateTestBlock(txRes, true) - ctx := decode.NewContext() + ctx := decode.NewContext(map[string]string{}) ctrl := gomock.NewController(t) defer ctrl.Finish() api := mock.NewMockApi(ctrl) diff --git a/pkg/indexer/parser/parser.go b/pkg/indexer/parser/parser.go index f495704..28ba336 100644 --- a/pkg/indexer/parser/parser.go +++ b/pkg/indexer/parser/parser.go @@ -13,7 +13,8 @@ import ( type Module struct { modules.BaseModule - api node.Api + api node.Api + bridgeAssets map[string]string } var _ modules.Module = (*Module)(nil) @@ -24,10 +25,11 @@ const ( StopOutput = "stop" ) -func NewModule(api node.Api) Module { +func NewModule(api node.Api, bridgeAssets map[string]string) Module { m := Module{ - BaseModule: modules.New("parser"), - api: api, + BaseModule: modules.New("parser"), + api: api, + bridgeAssets: bridgeAssets, } m.CreateInput(InputName) m.CreateOutput(OutputName) diff --git a/pkg/indexer/parser/parser_test.go b/pkg/indexer/parser/parser_test.go index 34ce97b..ff694a2 100644 --- a/pkg/indexer/parser/parser_test.go +++ b/pkg/indexer/parser/parser_test.go @@ -26,7 +26,7 @@ func createModules(t *testing.T, ctrl *gomock.Controller) (modules.BaseModule, s writerModule.CreateOutput(outputName) api := mock.NewMockApi(ctrl) - parserModule := NewModule(api) + parserModule := NewModule(api, map[string]string{}) err := parserModule.AttachTo(&writerModule, outputName, InputName) assert.NoError(t, err)