Exemplo n.º 1
0
        public static bool TryGetAvatarStateV2(
            this IAccountStateDelta states,
            Address agentAddress,
            Address avatarAddress,
            out AvatarState avatarState
            )
        {
            avatarState = null;
            if (states.GetState(avatarAddress) is Dictionary serializedAvatar)
            {
                try
                {
                    if (serializedAvatar[AgentAddressKey].ToAddress() != agentAddress)
                    {
                        return(false);
                    }

                    avatarState = GetAvatarStateV2(states, avatarAddress);
                    return(true);
                }
                catch (Exception e)
                {
                    // BackWardCompatible.
                    if (e is KeyNotFoundException || e is FailedLoadStateException)
                    {
                        return(states.TryGetAvatarState(agentAddress, avatarAddress, out avatarState));
                    }

                    return(false);
                }
            }

            return(false);
        }