Ejemplo n.º 1
0
        //TODO: can refractor this more
        public void ChangeTokenScripHash(string tokenScriptHash)
        {
            if (string.IsNullOrEmpty(tokenScriptHash))
            {
                throw new ArgumentNullException(nameof(tokenScriptHash));
            }

            TokenScriptHash = tokenScriptHash;
            GetTokenBalance.ChangeScriptHash(tokenScriptHash);
            GetTokenDecimals.ChangeScriptHash(tokenScriptHash);
            GetTokenName.ChangeScriptHash(tokenScriptHash);
            GetTokenTotalSupply.ChangeScriptHash(tokenScriptHash);
            GetTokenSymbol.ChangeScriptHash(tokenScriptHash);
        }
Ejemplo n.º 2
0
        public async Task <decimal> GetTotalSupply(string tokenScriptHash, int decimals = 8)
        {
            var result = await GetTokenTotalSupply.SendRequestAsync(tokenScriptHash);

            if (result.State == "FAULT, BREAK")
            {
                throw new RpcResponseException(new RpcError(0, "RPC state response: FAULT, BREAK "));
            }

            var totalSupplyBigInteger = new BigInteger(result.Stack[0].Value.ToString().HexStringToBytes());

            if (decimals.Equals(0))
            {
                return((decimal)totalSupplyBigInteger);
            }

            var totalSupply = Nep5Helper.CalculateDecimalFromBigInteger(totalSupplyBigInteger, decimals);

            return(totalSupply);
        }
Ejemplo n.º 3
0
        public async Task <string> GetTotalSupply(string decimals)
        {
            string totalSupply = string.Empty;

            if (string.IsNullOrEmpty(decimals))
            {
                return(totalSupply);
            }

            var result = await GetTokenTotalSupply.SendRequestAsync();

            if (result != null)
            {
                var value            = result.Stack[0].Value.ToString();
                var supplyValueArray = value.HexToBytes().Reverse().ToArray(); // todo, add explanation for this
                value       = BitConverter.ToString(supplyValueArray).Replace("-", "");
                totalSupply = (HexToBigInteger(value) / DecimalStringToBigInteger(decimals)).ToString();
            }
            return(totalSupply);
        }
Ejemplo n.º 4
0
        public async Task <string> GetTotalSupply()
        {
            var result = await GetTokenTotalSupply.SendRequestAsync().ConfigureAwait(false);

            return(result.Stack[0].Value.ToString());
        }