コード例 #1
0
        private void Burn(BigInteger amount, Address from, ITokenPicker customPicker = null)
        {
            if (amount <= 0)
            {
                throw new NonPositiveTokenAmountException(nameof(amount), amount);
            }

            customPicker = customPicker ?? this.DefaultTokenPicker;

            IReadOnlyTaggedTokens tokensToBurn = customPicker.Pick(this.GetBalances(from), amount);

            this.RemoveFromBalances(tokensToBurn, from);
        }
コード例 #2
0
        private void Transfer(BigInteger amount, Address from, Address to, ITokenPicker customPicker = null)
        {
            if (from.Equals(to))
            {
                throw new ArgumentException("Addresses can't transfer to themselves");
            }

            if (amount <= 0)
            {
                throw new NonPositiveTokenAmountException(nameof(amount), amount);
            }

            customPicker = customPicker ?? this.DefaultTokenPicker;

            IReadOnlyTaggedTokens tokensToTransfer = customPicker.Pick(this.GetBalances(from), amount);

            this.RemoveFromBalances(tokensToTransfer, from);
            this.AddToBalances(tokensToTransfer, to);
            this.NotifyReceived(tokensToTransfer, from, to);
        }