Ejemplo n.º 1
0
        public async Task <ElysiumBalance> GetBalanceAsync(
            BitcoinAddress address,
            Property property,
            CancellationToken cancellationToken = default)
        {
            var resp = await this.Client.SendCommandAsync("elysium_getbalance", address.ToString(), property.Id.Value);

            var balance  = resp.Result.Value <string>("balance");
            var reserved = resp.Result.Value <string>("reserved");

            return(new ElysiumBalance(TokenAmount.Parse(balance), TokenAmount.Parse(reserved)));
        }
Ejemplo n.º 2
0
        public async Task <TokenGrants> GetGrantsAsync(Property property, CancellationToken cancellationToken = default)
        {
            var resp = await this.Client.SendCommandAsync("elysium_getgrants", property.Id.Value);

            var histories = ((JArray)resp.Result["issuances"]).Select(i =>
            {
                var grant  = i.Value <string?>("grant");
                var revoke = i.Value <string>("revoke");
                var type   = (grant != null) ? TokenGrantType.Grant : TokenGrantType.Revoke;
                var tx     = uint256.Parse(i.Value <string>("txid"));
                var amount = TokenAmount.Parse(grant ?? revoke);

                return(new TokenGrantHistory(type, tx, amount));
            }).ToList();

            return(new TokenGrants(
                       new PropertyId(resp.Result.Value <long>("propertyid")),
                       resp.Result.Value <string>("name"),
                       BitcoinAddress.Create(resp.Result.Value <string>("issuer"), this.Client.Network),
                       uint256.Parse(resp.Result.Value <string>("creationtxid")),
                       TokenAmount.Parse(resp.Result.Value <string>("totaltokens")),
                       histories));
        }
Ejemplo n.º 3
0
 public void Parse_WithIndivisibleOutOfRange_ShouldThrow(string s)
 {
     Assert.Throws <OverflowException>(() => TokenAmount.Parse(s));
 }
Ejemplo n.º 4
0
        public void Parse_WithValidDivisible_ShouldSuccess(string divisible, long expected)
        {
            var amount = TokenAmount.Parse(divisible);

            Assert.Equal(expected, amount.Value);
        }
Ejemplo n.º 5
0
 public void Parse_WithInvalidIndivisible_ShouldThrow(string s)
 {
     Assert.Throws <FormatException>(() => TokenAmount.Parse(s));
 }