From 7263bee93efe6c114204f7459b6b0d80d1155382 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Tue, 13 Aug 2024 12:18:57 +0200 Subject: [PATCH] add information about genesis state to did resolution document --- pkg/services/blockchain/eth/resolver.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/services/blockchain/eth/resolver.go b/pkg/services/blockchain/eth/resolver.go index 72fa524..d74709f 100644 --- a/pkg/services/blockchain/eth/resolver.go +++ b/pkg/services/blockchain/eth/resolver.go @@ -207,21 +207,28 @@ func (r *Resolver) Resolve( default: stateInfo, gistInfo, err = r.resolveLatest(ctx, userID) } - - if err != nil && err.Error() != "state not found" { + // err == http.505 + if err != nil && !errors.Is(err, services.ErrNotFound) { return services.IdentityState{}, err } - if err != nil { + if opts.State != nil && errors.Is(err, services.ErrNotFound) { idGen, err := core.CheckGenesisStateID(userID.BigInt(), opts.State) if err != nil { return services.IdentityState{}, err } if !idGen { - return services.IdentityState{}, services.ErrNotFound + return services.IdentityState{}, + fmt.Errorf("identity '%s' is '%v' and state '%s' not genesis", userID.String(), err, opts.State) + } + stateInfo = &contract.IStateStateInfo{ + State: opts.State, + ReplacedByState: big.NewInt(0), + CreatedAtTimestamp: big.NewInt(0), + ReplacedAtTimestamp: big.NewInt(0), + CreatedAtBlock: big.NewInt(0), + ReplacedAtBlock: big.NewInt(0), } - stateInfo = &contract.IStateStateInfo{} - stateInfo.State = opts.State } }