pragma solidity ^0.4.24; import "./ERC223TokenWidgetRenderer.sol"; import "tokenboost-solidity/contracts/utils/strings.sol"; import "tokenboost-solidity/contracts/widget/Widgets.sol"; contract MintTokensWidgetRenderer is ERC223TokenWidgetRenderer { using strings for *; using Widgets for Widgets.Widget; using UintUtils for uint; using SafeMath for uint; string public constant MINT_TOKENS = "mint_tokens"; string public constant SHORT_DESC = "short_desc"; string public constant LONG_DESC = "long_desc"; string public constant MINTABLE_ETH = "mintable_eth"; string public constant ADDRESS = "address"; string public constant AMOUNT = "amount"; string public constant MINT = "mint"; string public constant MINT_CONFIRM = "mint_confirm"; function render(string _locale, ERC223Token _token) public view returns (string) { if (_token.mintable() && _token.activated()) { uint maxMintable = _token.maxMintable(); uint totalSupply = _token.totalSupply(); uint mintableEth = maxMintable > totalSupply ? maxMintable.sub(totalSupply) : 0; Elements.Element[] memory elements = new Elements.Element[](4); elements[0] = Elements.Element( true, MINTABLE_ETH, "token".toSlice().concat(uint(_token.decimals()).toString().toSlice()), resources[_locale][MINTABLE_ETH], maxMintable == 0 ? '"∞"' : mintableEth.toString(), Actions.empty(), Tables.empty() ); elements[1] = Elements.Element( true, ADDRESS, "addressEdit", resources[_locale][ADDRESS], '""', Actions.empty(), Tables.empty() ); elements[2] = Elements.Element( true, AMOUNT, "tokenEdit".toSlice().concat(uint(_token.decimals()).toString().toSlice()), resources[_locale][AMOUNT], "0", Actions.empty(), Tables.empty() ); elements[3] = Elements.Element( true, MINT, "button", resources[_locale][MINT], "null", Actions.Action( true, address(_token), "mint()", '{"address":"address","amount":"uint"}', resources[_locale][MINT_CONFIRM] ), Tables.empty() ); Widgets.Widget memory widget = Widgets.Widget( resources[_locale][MINT_TOKENS], resources[_locale][SHORT_DESC], resources[_locale][LONG_DESC], 4, elements ); return widget.toJson(); } else { return ""; } } }