@@ -4,22 +4,25 @@ pragma solidity ^0.8.0;
44import "./interface/ITokenBundle.sol " ;
55
66abstract contract TokenBundle is ITokenBundle {
7+ /// @dev UID => asset count, bundle uri, and tokens contained in the bundle
78 mapping (uint256 => BundleInfo) private bundle;
89
9- // function _getNextBundleId() internal virtual returns (uint256);
10-
10+ /// @dev Returns the count of assets in a bundle, given a bundle Id.
1111 function getTokenCount (uint256 _bundleId ) public view returns (uint256 ) {
1212 return bundle[_bundleId].count;
1313 }
1414
15+ /// @dev Returns a token contained in a bundle, given a bundle Id and index of token.
1516 function getToken (uint256 _bundleId , uint256 index ) public view returns (Token memory ) {
1617 return bundle[_bundleId].tokens[index];
1718 }
1819
20+ /// @dev Returns the uri of bundle for a particular bundle Id.
1921 function getUri (uint256 _bundleId ) public view returns (string memory ) {
2022 return bundle[_bundleId].uri;
2123 }
2224
25+ /// @dev Lets the calling contract create/update a bundle, by passing in a list of tokens and a unique id.
2326 function _setBundle (Token[] calldata _tokensToBind , uint256 _bundleId ) internal {
2427 // uint256 _bundleId = _getNextBundleId();
2528 require (_tokensToBind.length > 0 , "no tokens to bind " );
@@ -29,6 +32,7 @@ abstract contract TokenBundle is ITokenBundle {
2932 bundle[_bundleId].count = _tokensToBind.length ;
3033 }
3134
35+ /// @dev Lets the calling contract set/update a token in a bundle for a unique bundle id and index.
3236 function _setBundleToken (
3337 Token memory _tokenToBind ,
3438 uint256 _bundleId ,
@@ -39,10 +43,12 @@ abstract contract TokenBundle is ITokenBundle {
3943 bundle[_bundleId].count += isUpdate ? 0 : 1 ;
4044 }
4145
46+ /// @dev Lets the calling contract set/update the bundle uri for a particular bundle id.
4247 function _setUri (string calldata _uri , uint256 _bundleId ) internal {
4348 bundle[_bundleId].uri = _uri;
4449 }
4550
51+ /// @dev Lets the calling contract delete a bundle with a given id.
4652 function _deleteBundle (uint256 _bundleId ) internal {
4753 delete bundle[_bundleId];
4854 }
0 commit comments