public async Task <string> GetName() { string name = string.Empty; var result = await GetTokenName.SendRequestAsync(); if (result != null) { var temp = result.Stack[0].Value.ToString(); name = Helper.HextoString(temp); } return(name); }
//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); }
public async Task <string> GetName(string tokenScriptHash, bool humanReadable = false) { var result = await GetTokenName.SendRequestAsync(tokenScriptHash); if (result.State == "FAULT, BREAK") { throw new RpcResponseException(new RpcError(0, "RPC state response: FAULT, BREAK ")); } var resultString = result.Stack[0].Value.ToString(); if (!humanReadable) { return(resultString); } return(resultString.HexToString()); }
/// <summary> /// Main function for TokenStoreInputBinding logic. Returns an access token for specified service, or creates a token if it does not exist. /// </summary> private async Task <String> BuildItemFromAttribute(TokenStoreInputBindingAttribute attribute, ValueBindingContext arg2) { attribute.CheckValidity_URL(); string tokenResourceUrl = attribute.tokenUrl; // for user scenario only specify path up to service, for msi scienario specify path up to token name // default token display name int pos = tokenResourceUrl.LastIndexOf("/") + 1; tokenDisplayName = tokenResourceUrl.Substring(pos, tokenResourceUrl.Length - pos); try { if (attribute.scenario.ToLower() == "user") // If Flag = "USER" or "user" { GetTokenName getTokenName = new GetTokenName(attribute); tokenResourceUrl = getTokenName.tokenResourceUrl; tokenDisplayName = getTokenName.tokenDisplayName; } // Shared logic for If scenario = "tokenName" or "user" if (attribute.scenario.ToLower() == "tokenname" || attribute.scenario.ToLower() == "user") { try { // Use TokenStoreHelper to interact with your Token Store resource TokenStoreHelper tokenStoreHelper = new TokenStoreHelper(tokenResourceUrl, tokenDisplayName, attribute); return(await tokenStoreHelper.GetOrCreateToken()); } catch (Exception exp) { throw new SystemException($"{exp}"); } } else // error, incorrect usage of scenario binding input { throw new ArgumentException("Incorrect usage of {scenario} binding input: Choose \"tokenName\" or \"user\" "); } } catch (Exception exp) // Overall catch statement { throw new SystemException($"{exp}"); } }
public async Task <string> GetName() { var result = await GetTokenName.SendRequestAsync().ConfigureAwait(false); return(result.Stack[0].Value.ToString()); }