Esempio n. 1
0
        protected async Task ValidateActivation(RawActivationContent activation)
        {
            if (await Cache.Accounts.ExistsAsync(activation.Address, AccountType.User) &&
                ((await Cache.Accounts.GetAsync(activation.Address)) as User).Activated == true)
            {
                throw new ValidationException("account is already activated");
            }

            if ((activation.Metadata.BalanceUpdates[0] as ContractUpdate)?.Contract != activation.Address)
            {
                throw new ValidationException($"invalid activation balance updates");
            }
        }
Esempio n. 2
0
 public async Task Init(Block block, RawOperation op, RawActivationContent content)
 {
     Activation = new ActivationOperation
     {
         Id        = Cache.AppState.NextOperationId(),
         Block     = block,
         Level     = block.Level,
         Timestamp = block.Timestamp,
         OpHash    = op.Hash,
         Account   = (User)await Cache.Accounts.GetAsync(content.Address),
         Balance   = content.Metadata.BalanceUpdates[0].Change
     };
 }
Esempio n. 3
0
        public static async Task <ActivationsCommit> Apply(ProtocolHandler proto, Block block, RawOperation op, RawActivationContent content)
        {
            var commit = new ActivationsCommit(proto);
            await commit.Init(block, op, content);

            await commit.Apply();

            return(commit);
        }