Skip to content

Commit

Permalink
Fix: duplication implicit accounts in teztnets
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 7, 2023
1 parent b337e03 commit bda13f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/indexer/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (bi *BlockchainIndexer) implicitMigration(ctx context.Context, block *Block
return err
}

implicitParser, err := migrations.NewImplicitParser(bi.Context, bi.RPC, specific.ContractParser, protocol)
implicitParser, err := migrations.NewImplicitParser(bi.Context, bi.RPC, specific.ContractParser, protocol, bi.Contracts)
if err != nil {
return err
}
Expand Down
13 changes: 11 additions & 2 deletions internal/parsers/migrations/implicit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/baking-bad/bcdhub/internal/config"
"github.com/baking-bad/bcdhub/internal/logger"
"github.com/baking-bad/bcdhub/internal/models/account"
contracts "github.com/baking-bad/bcdhub/internal/models/contract"
"github.com/baking-bad/bcdhub/internal/models/migration"
"github.com/baking-bad/bcdhub/internal/models/operation"
"github.com/baking-bad/bcdhub/internal/models/protocol"
Expand All @@ -23,11 +24,16 @@ type ImplicitParser struct {
rpc noderpc.INode
contractParser contract.Parser
protocol protocol.Protocol
contractsRepo contracts.Repository
}

// NewImplicitParser -
func NewImplicitParser(ctx *config.Context, rpc noderpc.INode, contractParser contract.Parser, protocol protocol.Protocol) (*ImplicitParser, error) {
return &ImplicitParser{ctx, rpc, contractParser, protocol}, nil
func NewImplicitParser(ctx *config.Context,
rpc noderpc.INode,
contractParser contract.Parser,
protocol protocol.Protocol,
contractsRepo contracts.Repository) (*ImplicitParser, error) {
return &ImplicitParser{ctx, rpc, contractParser, protocol, contractsRepo}, nil
}

// Parse -
Expand Down Expand Up @@ -57,6 +63,9 @@ func (p *ImplicitParser) IsMigratable(address string) bool {
}

func (p *ImplicitParser) origination(ctx context.Context, implicit noderpc.ImplicitOperationsResult, head noderpc.Header, store parsers.Store) error {
if _, err := p.contractsRepo.Get(implicit.OriginatedContracts[0]); err == nil {
return nil
}
origination := operation.Operation{
ProtocolID: p.protocol.ID,
Level: head.Level,
Expand Down
1 change: 1 addition & 0 deletions internal/parsers/migrations/jakarta.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewJakarta() *Jakarta {
"KT1QwBaLj5TRaGU3qkU4ZKKQ5mvNvyyzGBFv": {},
"KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5": {},
"KT1VqarPDicMFn1ejmQqqshUkUXTCTXwmkCN": {},
"KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo": {},
},
}
}
Expand Down

0 comments on commit bda13f8

Please sign in to comment.