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"); } }
public async Task Init(Block block, RawOperation op, RawActivationContent content) { var account = (User)await Cache.Accounts.GetAsync(content.Address); account.Delegate ??= Cache.Accounts.GetDelegate(account.DelegateId); Activation = new ActivationOperation { Id = Cache.AppState.NextOperationId(), Block = block, Level = block.Level, Timestamp = block.Timestamp, OpHash = op.Hash, Account = account, Balance = content.Metadata.BalanceUpdates[0].Change }; }
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); }