示例#1
0
        public override void LoadPlainValue(IValue plainValue)
        {
            var asDict = (Dictionary)plainValue;

            Sender    = asDict["sender"].ToAddress();
            Recipient = asDict["recipient"].ToAddress();
            Amount    = asDict["amount"].ToBigInteger();
            Currency  = CurrencyExtensions.Deserialize((Dictionary)asDict["currency"]);
        }
        public UnaryResult <byte[]> GetBalance(byte[] addressBytes, byte[] currencyBytes)
        {
            var        address            = new Address(addressBytes);
            var        serializedCurrency = (Bencodex.Types.Dictionary)_codec.Decode(currencyBytes);
            Currency   currency           = CurrencyExtensions.Deserialize(serializedCurrency);
            BigInteger balance            = _blockChain.GetBalance(address, currency);

            byte[] encoded = _codec.Encode((Bencodex.Types.Integer)balance);
            return(UnaryResult(encoded));
        }
示例#3
0
        public FungibleAssetValue GetBalance(Address address, Currency currency)
        {
            var result = _service.GetBalance(
                address.ToByteArray(),
                _codec.Encode(currency.Serialize())
                );

            byte[] raw        = result.ResponseAsync.Result;
            var    serialized = (Bencodex.Types.List)_codec.Decode(raw);

            return(FungibleAssetValue.FromRawValue(
                       CurrencyExtensions.Deserialize((Bencodex.Types.Dictionary)serialized.ElementAt(0)),
                       serialized.ElementAt(1).ToBigInteger()));
        }
示例#4
0
        public UnaryResult <byte[]> GetBalance(byte[] addressBytes, byte[] currencyBytes)
        {
            var                address            = new Address(addressBytes);
            var                serializedCurrency = (Bencodex.Types.Dictionary)_codec.Decode(currencyBytes);
            Currency           currency           = CurrencyExtensions.Deserialize(serializedCurrency);
            FungibleAssetValue balance            = _blockChain.GetBalance(address, currency);

            byte[] encoded = _codec.Encode(
                new Bencodex.Types.List(
                    new IValue[]
            {
                balance.Currency.Serialize(),
                (Integer)balance.RawValue,
            }
                    )
                );
            return(UnaryResult(encoded));
        }
示例#5
0
 public GoldCurrencyState(Dictionary serialized)
     : base(serialized)
 {
     Currency = CurrencyExtensions.Deserialize((Dictionary)serialized["currency"]);
 }