diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-22 09:14:22 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-08-22 09:14:22 +0800 |
commit | 3760eb5bafcc0980b3a42dd5f10e745390702b16 (patch) | |
tree | 964c5c3cb0eeacf70bece4e485b5fddceea2adb4 /packages/contracts/src/2.0.0 | |
parent | 7fa5b474ebac649b6a23c8b9108e07c117dcc00b (diff) | |
download | dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.gz dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.zst dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.zip |
Add getBalancesAndAllowances
Diffstat (limited to 'packages/contracts/src/2.0.0')
-rw-r--r-- | packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol b/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol index 8f4ce9ccc..a18345245 100644 --- a/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol +++ b/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol @@ -158,6 +158,25 @@ contract OrderValidator { return (balance, allowance); } + /// @dev Fetches token balances and allowances of an address for each given assetProxy. Supports ERC20 and ERC721. + /// @param target Address to fetch balances and allowances of. + /// @param assetData Array of encoded byte arrays that can be decoded by a specified proxy contract when transferring asset. + /// @return Balances and allowances of assets. + /// For ERC721 tokens, these values will always be 1 or 0. + function getBalancesAndAllowances(address target, bytes[] memory assetData) + public + view + returns (uint256[] memory, uint256[] memory) + { + uint256 length = assetData.length; + uint256[] memory balances = new uint256[](length); + uint256[] memory allowances = new uint256[](length); + for (uint256 i = 0; i != length; i++) { + (balances[i], allowances[i]) = getBalanceAndAllowance(target, assetData[i]); + } + return (balances, allowances); + } + /// @dev Calls `token.ownerOf(tokenId)`, but returns a null owner instead of reverting on an unowned token. /// @param token Address of ERC721 token. /// @param tokenId The identifier for the specific NFT. |