public IReadOnlyTaggedTokens Tag(Address owner, BigInteger amount) { if (amount <= 0) { throw new NonPositiveTokenAmountException(nameof(amount), amount); } var tokens = new ReadOnlyTaggedTokens(new SortedDictionary <string, BigInteger> { [TokenTag] = amount, }); return(tokens); }
public void Mint_WhenMintingToSplitter_ShouldSplitToRecipients(int splitAmount) { this.registry.SendMessage(this.permissionManager, this.tokenManager, MintAction.Type, new Dictionary <string, object>() { { MintAction.To, this.splitter.ToString() }, { MintAction.Amount, splitAmount.ToString() }, }); foreach (Address recipient in this.recipients) { BigInteger expectedBalance = splitAmount / this.recipients.Count; BigInteger actualBalance = new ReadOnlyTaggedTokens( this.registry.GetContract(this.tokenManager).GetState() .GetDictionary("Balances") .GetDictionary(recipient.ToString()) ?? new Dictionary <string, object>()).TotalBalance; Assert.Equal(expectedBalance, actualBalance); } }
public IReadOnlyTaggedTokens Pick(IReadOnlyTaggedTokens tokens, BigInteger amount) { if (amount < 0) { throw new NonPositiveTokenAmountException(nameof(amount), amount); } BigInteger availableTokens = tokens.TotalBalanceByTag(TokenTag); if (availableTokens < amount) { throw new InsufficientTokenAmountException(nameof(amount), availableTokens, amount); } var pickedTokens = new ReadOnlyTaggedTokens(new SortedDictionary <string, BigInteger> { [TokenTag] = amount, }); return(pickedTokens); }