Skip to content

Commit 9616b5c

Browse files
YashYash
authored andcommitted
removed handling of bundleId from TokenBundle
1 parent 43dc143 commit 9616b5c

File tree

4 files changed

+12
-153
lines changed

4 files changed

+12
-153
lines changed

contracts/feature/TokenBundle.sol

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ pragma solidity ^0.8.0;
44
import "./interface/ITokenBundle.sol";
55

66
abstract contract TokenBundle is ITokenBundle {
7-
uint256 public bundleId;
87
mapping(uint256 => BundleInfo) public bundle;
9-
mapping(uint256 => bool) public deletedBundle;
108

11-
// function getNextTokenId() public virtual returns (uint256);
9+
// function _getNextBundleId() internal virtual returns (uint256);
1210

1311
function getTokenCount(uint256 _bundleId) public view returns (uint256) {
1412
return bundle[_bundleId].count;
@@ -22,23 +20,7 @@ abstract contract TokenBundle is ITokenBundle {
2220
return bundle[_bundleId].uri;
2321
}
2422

25-
function getNextBundleId() public view returns (uint256) {
26-
return bundleId;
27-
}
28-
29-
function _setBundle(Token[] calldata _tokensToBind) internal returns (uint256 _bundleId) {
30-
require(_tokensToBind.length > 0, "no tokens to bind");
31-
for (uint256 i = 0; i < _tokensToBind.length; i += 1) {
32-
bundle[bundleId].tokens[i] = _tokensToBind[i];
33-
}
34-
bundle[bundleId].count = _tokensToBind.length;
35-
_bundleId = bundleId;
36-
bundleId += 1;
37-
}
38-
39-
function _resetBundle(Token[] calldata _tokensToBind, uint256 _bundleId) internal {
40-
require(_bundleId < bundleId, "bundle doesn't exist");
41-
require(!deletedBundle[_bundleId], "this bundle was deleted");
23+
function _setBundle(Token[] calldata _tokensToBind, uint256 _bundleId) internal {
4224
require(_tokensToBind.length > 0, "no tokens to bind");
4325
for (uint256 i = 0; i < _tokensToBind.length; i += 1) {
4426
bundle[_bundleId].tokens[i] = _tokensToBind[i];
@@ -50,25 +32,17 @@ abstract contract TokenBundle is ITokenBundle {
5032
Token memory _tokenToBind,
5133
uint256 _bundleId,
5234
uint256 index,
53-
bool update
35+
bool isUpdate
5436
) internal {
55-
require(_bundleId < bundleId, "bundle doesn't exist");
56-
require(!deletedBundle[_bundleId], "this bundle was deleted");
5737
bundle[_bundleId].tokens[index] = _tokenToBind;
58-
bundle[_bundleId].count += update ? 0 : 1;
38+
bundle[_bundleId].count += isUpdate ? 0 : 1;
5939
}
6040

6141
function _setUri(string calldata _uri, uint256 _bundleId) internal {
62-
require(_bundleId < bundleId, "bundle doesn't exist");
63-
require(!deletedBundle[_bundleId], "this bundle was deleted");
6442
bundle[_bundleId].uri = _uri;
6543
}
6644

6745
function _deleteBundle(uint256 _bundleId) internal {
68-
require(_bundleId < bundleId, "bundle doesn't exist");
69-
require(!deletedBundle[_bundleId], "already deleted");
70-
7146
delete bundle[_bundleId];
72-
deletedBundle[_bundleId] = true;
7347
}
7448
}

contracts/multiwrap/TempMultiwrap.sol

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ contract TempMultiwrap is
9595
//mychange
9696
// mapping(uint256=>BundleInfo) private bundle;
9797

98-
//mychange
99-
mapping(uint256 => uint256) private tokenToBundle;
100-
10198
/*///////////////////////////////////////////////////////////////
10299
Constructor + initializer logic
103100
//////////////////////////////////////////////////////////////*/
@@ -175,7 +172,7 @@ contract TempMultiwrap is
175172
/// @dev Returns the URI for a given tokenId.
176173
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
177174
// return uri[_tokenId]; //mychange
178-
return getUri(tokenToBundle[_tokenId]);
175+
return getUri(_tokenId);
179176
}
180177

181178
/// @dev See ERC 165
@@ -219,7 +216,7 @@ contract TempMultiwrap is
219216
//mychange
220217
// tokenId = _getNextTokenId();
221218

222-
tokenToBundle[tokenId] = _setBundle(_wrappedContents); //mychange
219+
_setBundle(_wrappedContents, tokenId); //mychange
223220

224221
//mychange
225222
// for (uint256 i = 0; i < _wrappedContents.length; i += 1) {
@@ -230,7 +227,7 @@ contract TempMultiwrap is
230227
//mychange
231228
// uri[tokenId] = _uriForWrappedToken;
232229

233-
_setUri(_uriForWrappedToken, tokenToBundle[tokenId]);
230+
_setUri(_uriForWrappedToken, tokenId);
234231

235232
_safeMint(_recipient, tokenId);
236233

@@ -251,17 +248,17 @@ contract TempMultiwrap is
251248

252249
// uint256 count = wrappedContents[_tokenId].count; //mychange
253250

254-
uint256 count = getTokenCount(tokenToBundle[_tokenId]);
251+
uint256 count = getTokenCount(_tokenId);
255252
Token[] memory tokensUnwrapped = new Token[](count);
256253

257254
for (uint256 i = 0; i < count; i += 1) {
258255
// tokensUnwrapped[i] = wrappedContents[_tokenId].token[i]; //mychange
259-
tokensUnwrapped[i] = getToken(tokenToBundle[_tokenId], i);
256+
tokensUnwrapped[i] = getToken(_tokenId, i);
260257
transferToken(address(this), _recipient, tokensUnwrapped[i]);
261258
}
262259

263260
// delete wrappedContents[_tokenId]; //mychange
264-
_deleteBundle(tokenToBundle[_tokenId]);
261+
_deleteBundle(_tokenId);
265262

266263
emit TokensUnwrapped(_msgSender(), _recipient, _tokenId, tokensUnwrapped);
267264
}
@@ -328,12 +325,12 @@ contract TempMultiwrap is
328325
/// @dev Returns the underlygin contents of a wrapped NFT.
329326
function getWrappedContents(uint256 _tokenId) external view returns (Token[] memory contents) {
330327
//mychange
331-
uint256 total = getTokenCount(tokenToBundle[_tokenId]);
328+
uint256 total = getTokenCount(_tokenId);
332329
contents = new Token[](total);
333330

334331
//mychange
335332
for (uint256 i = 0; i < total; i += 1) {
336-
contents[i] = getToken(tokenToBundle[_tokenId], i);
333+
contents[i] = getToken(_tokenId, i);
337334
}
338335
}
339336

docs/TempMultiwrap.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ function bundle(uint256) external view returns (uint256 count, string uri)
8989
| count | uint256 | undefined
9090
| uri | string | undefined
9191

92-
### bundleId
93-
94-
```solidity
95-
function bundleId() external view returns (uint256)
96-
```
97-
98-
99-
100-
101-
102-
103-
#### Returns
104-
105-
| Name | Type | Description |
106-
|---|---|---|
107-
| _0 | uint256 | undefined
108-
10992
### contractType
11093

11194
```solidity
@@ -157,28 +140,6 @@ function contractVersion() external pure returns (uint8)
157140
|---|---|---|
158141
| _0 | uint8 | undefined
159142

160-
### deletedBundle
161-
162-
```solidity
163-
function deletedBundle(uint256) external view returns (bool)
164-
```
165-
166-
167-
168-
169-
170-
#### Parameters
171-
172-
| Name | Type | Description |
173-
|---|---|---|
174-
| _0 | uint256 | undefined
175-
176-
#### Returns
177-
178-
| Name | Type | Description |
179-
|---|---|---|
180-
| _0 | bool | undefined
181-
182143
### getApproved
183144

184145
```solidity
@@ -219,23 +180,6 @@ function getDefaultRoyaltyInfo() external view returns (address, uint16)
219180
| _0 | address | undefined
220181
| _1 | uint16 | undefined
221182

222-
### getNextBundleId
223-
224-
```solidity
225-
function getNextBundleId() external view returns (uint256)
226-
```
227-
228-
229-
230-
231-
232-
233-
#### Returns
234-
235-
| Name | Type | Description |
236-
|---|---|---|
237-
| _0 | uint256 | undefined
238-
239183
### getRoleAdmin
240184

241185
```solidity

docs/TokenBundle.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,62 +33,6 @@ function bundle(uint256) external view returns (uint256 count, string uri)
3333
| count | uint256 | undefined
3434
| uri | string | undefined
3535

36-
### bundleId
37-
38-
```solidity
39-
function bundleId() external view returns (uint256)
40-
```
41-
42-
43-
44-
45-
46-
47-
#### Returns
48-
49-
| Name | Type | Description |
50-
|---|---|---|
51-
| _0 | uint256 | undefined
52-
53-
### deletedBundle
54-
55-
```solidity
56-
function deletedBundle(uint256) external view returns (bool)
57-
```
58-
59-
60-
61-
62-
63-
#### Parameters
64-
65-
| Name | Type | Description |
66-
|---|---|---|
67-
| _0 | uint256 | undefined
68-
69-
#### Returns
70-
71-
| Name | Type | Description |
72-
|---|---|---|
73-
| _0 | bool | undefined
74-
75-
### getNextBundleId
76-
77-
```solidity
78-
function getNextBundleId() external view returns (uint256)
79-
```
80-
81-
82-
83-
84-
85-
86-
#### Returns
87-
88-
| Name | Type | Description |
89-
|---|---|---|
90-
| _0 | uint256 | undefined
91-
9236
### getToken
9337

9438
```solidity

0 commit comments

Comments
 (0)