public override Empty InitialTotalResourceTokens(ResourceTokenAmount input)
 {
     CheckSenderIsParliamentOrZeroContract();
     State.TotalResourceTokenAmount.Value  = input;
     State.RemainResourceTokenAmount.Value = input;
     return(new Empty());
 }
Esempio n. 2
0
        public static ResourceTokenAmount operator +(ResourceTokenAmount amount1, ResourceTokenAmount amount2)
        {
            var result = new ResourceTokenAmount();

            foreach (var symbol in amount1.Value.Keys.Union(amount2.Value.Keys))
            {
                var symbolAmount1 = amount1.Value.ContainsKey(symbol) ? amount1.Value[symbol] : 0;
                var symbolAmount2 = amount2.Value.ContainsKey(symbol) ? amount2.Value[symbol] : 0;
                result.Value.Add(symbol, symbolAmount1.Add(symbolAmount2));
            }

            return(result);
        }
        public override Empty UpdateTotalResourceTokens(ResourceTokenAmount input)
        {
            CheckOwnerAuthority();
            var change = input - State.TotalResourceTokenAmount.Value;

            if (State.RemainResourceTokenAmount.Value == null)
            {
                State.RemainResourceTokenAmount.Value = change;
            }
            else
            {
                State.RemainResourceTokenAmount.Value += change;
            }
            State.TotalResourceTokenAmount.Value = input;
            return(new Empty());
        }