diff --git a/frostfsid/frostfsid_contract.go b/frostfsid/frostfsid_contract.go index fd2d446..cfd1920 100644 --- a/frostfsid/frostfsid_contract.go +++ b/frostfsid/frostfsid_contract.go @@ -417,7 +417,12 @@ func GetSubject(addr interop.Hash160) Subject { sKey := subjectKeyFromAddr(addr) data := storage.Get(ctx, sKey).([]byte) if data == nil { - panic("subject not found") + aa := getPrimaryAddr(ctx, addr) + sKey = subjectKeyFromAddr(aa) + data = storage.Get(ctx, sKey).([]byte) + if data == nil { + panic("subject not found") + } } return std.Deserialize(data).(Subject) @@ -469,21 +474,25 @@ func GetSubjectByKey(key interop.PublicKey) Subject { return std.Deserialize(data).(Subject) } - saPrefix := subjectAdditionalPrefix(key) - it := storage.Find(ctx, saPrefix, storage.KeysOnly|storage.RemovePrefix) - for iterator.Next(it) { - addr := iterator.Value(it).([]byte) - sKey = subjectKeyFromAddr(addr) - data = storage.Get(ctx, sKey).([]byte) - if data != nil { - return std.Deserialize(data).(Subject) - } - break + addr := getPrimaryAddr(ctx, contract.CreateStandardAccount(key)) + sKey = subjectKeyFromAddr(addr) + data = storage.Get(ctx, sKey).([]byte) + if data != nil { + return std.Deserialize(data).(Subject) } panic("subject not found") } +func getPrimaryAddr(ctx storage.Context, addr interop.Hash160) interop.Hash160 { + saPrefix := append([]byte{additionalKeysPrefix}, addr...) + it := storage.Find(ctx, saPrefix, storage.KeysOnly|storage.RemovePrefix) + if iterator.Next(it) { + return iterator.Value(it).([]byte) + } + panic("subject not found") +} + // GetSubjectByName retrieves the subject with the specified name within the given namespace. func GetSubjectByName(ns, name string) Subject { key := GetSubjectKeyByName(ns, name)