diff --git a/go.mod b/go.mod index eff88df..1fc167d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/dipdup-io/starknet-indexer go 1.22 require ( - github.com/dipdup-io/starknet-go-api v0.0.0-20240517123614-8bb965043f0b + github.com/dipdup-io/starknet-go-api v0.0.0-20240610163809-69297a8e3cac github.com/dipdup-io/workerpool v0.0.4 github.com/dipdup-net/go-lib v0.3.3 github.com/dipdup-net/indexer-sdk v0.0.4 diff --git a/go.sum b/go.sum index 82ba8b9..f635003 100644 --- a/go.sum +++ b/go.sum @@ -39,12 +39,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw= github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo= -github.com/dipdup-io/starknet-go-api v0.0.0-20240428115333-9db5c96f6b81 h1:jKSCsoLYm4uuO4tu/0pcBthvixgXII4KQQCVmcoL3Cc= -github.com/dipdup-io/starknet-go-api v0.0.0-20240428115333-9db5c96f6b81/go.mod h1:y3KGLFQtwzUBcT0X2LMj6CxocUimr/A9XYg+j0KIRDE= -github.com/dipdup-io/starknet-go-api v0.0.0-20240428184801-e7a7f9b05da9 h1:gLnNH4kZZXjHBG3WVmwi91giiGHPol0VszqOdalNMXA= -github.com/dipdup-io/starknet-go-api v0.0.0-20240428184801-e7a7f9b05da9/go.mod h1:y3KGLFQtwzUBcT0X2LMj6CxocUimr/A9XYg+j0KIRDE= -github.com/dipdup-io/starknet-go-api v0.0.0-20240517123614-8bb965043f0b h1:mIonvNL2IM9/2kyGvSuqV1ut0yL1W4kpPP5ojTyA3SY= -github.com/dipdup-io/starknet-go-api v0.0.0-20240517123614-8bb965043f0b/go.mod h1:y3KGLFQtwzUBcT0X2LMj6CxocUimr/A9XYg+j0KIRDE= +github.com/dipdup-io/starknet-go-api v0.0.0-20240610163809-69297a8e3cac h1:mlbq1oUC0yKwDXfdWvWMOEGYZT6RuCsNtJNT9UGRTIs= +github.com/dipdup-io/starknet-go-api v0.0.0-20240610163809-69297a8e3cac/go.mod h1:y3KGLFQtwzUBcT0X2LMj6CxocUimr/A9XYg+j0KIRDE= github.com/dipdup-io/workerpool v0.0.4 h1:m58fuFY3VIPRc+trWpjw2Lsm4FvIgtjP/4VRe79r+/s= github.com/dipdup-io/workerpool v0.0.4/go.mod h1:m6YMqx7M+fORTyabHD/auKymBRpbDax0t1aPZ1i7GZA= github.com/dipdup-net/go-lib v0.3.3 h1:vTUI+sT4L+x+eiMf712Cg8EtlqUCMiN6M3vcNaPlCw8= diff --git a/pkg/indexer/parser/resolver/class.go b/pkg/indexer/parser/resolver/class.go index b44b177..fff9baf 100644 --- a/pkg/indexer/parser/resolver/class.go +++ b/pkg/indexer/parser/resolver/class.go @@ -5,15 +5,22 @@ import ( "github.com/dipdup-io/starknet-go-api/pkg/data" "github.com/dipdup-io/starknet-go-api/pkg/encoding" + api "github.com/dipdup-io/starknet-go-api/pkg/rpc" "github.com/dipdup-io/starknet-indexer/internal/starknet" "github.com/dipdup-io/starknet-indexer/internal/storage" + "github.com/pkg/errors" "github.com/rs/zerolog/log" ) +var ErrUndeclaredClass = errors.New("undeclared class") + // ReceiveClass - func (resolver *Resolver) ReceiveClass(ctx context.Context, class *storage.Class) error { rawClass, err := resolver.receiver.GetClass(ctx, encoding.EncodeHex(class.Hash)) if err != nil { + if e, ok := err.(*api.Error); ok && e.Code == 28 { + return ErrUndeclaredClass + } return err } diff --git a/pkg/indexer/parser/version/v0/fee.go b/pkg/indexer/parser/version/v0/fee.go index 885417e..7c50e56 100644 --- a/pkg/indexer/parser/version/v0/fee.go +++ b/pkg/indexer/parser/version/v0/fee.go @@ -186,6 +186,9 @@ func (parser FeeParser) ParseInvocation(ctx context.Context, txCtx data.TxContex } if err := parser.resolver.ReceiveClass(ctx, &tx.Class); err != nil { + if errors.Is(err, resolver.ErrUndeclaredClass) { + return nil, nil + } return nil, err } tx.Class.Height = tx.Height diff --git a/pkg/indexer/parser/version/v0/internal_tx.go b/pkg/indexer/parser/version/v0/internal_tx.go index dc541ff..85c9e6d 100644 --- a/pkg/indexer/parser/version/v0/internal_tx.go +++ b/pkg/indexer/parser/version/v0/internal_tx.go @@ -130,14 +130,14 @@ func (parser InternalTxParser) Parse(ctx context.Context, txCtx parserData.TxCon } if err := parser.Resolver.ReceiveClass(ctx, &tx.Class); err != nil { + if errors.Is(err, resolver.ErrUndeclaredClass) { + return tx, nil + } return tx, err } tx.Class.Height = tx.Height } - // txHash := encoding.EncodeHex(tx.Hash) - // log.Info().Msg(txHash) - if len(tx.Selector) > 0 && internal.Selector != "0x0" { var ( _, has = contractAbi.GetByTypeAndSelector(internal.EntrypointType, encoding.EncodeHex(tx.Selector))