Skip to content

Commit b10913c

Browse files
committed
Publish latest contracts and artifacts
1 parent 78aabd4 commit b10913c

File tree

141 files changed

+96061
-845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+96061
-845
lines changed

contracts/CarbonOffsetBatches.sol

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,7 @@ contract CarbonOffsetBatches is
197197
}
198198

199199
/// @dev internal helper function to set the status and emit an event
200-
function _updateStatus(uint256 tokenId, BatchStatus newStatus)
201-
internal
202-
virtual
203-
{
200+
function _updateStatus(uint256 tokenId, BatchStatus newStatus) internal {
204201
nftList[tokenId].status = newStatus;
205202
emit BatchStatusUpdate(tokenId, newStatus);
206203
}
@@ -225,7 +222,7 @@ contract CarbonOffsetBatches is
225222
function setStatusForDetokenizationOrRetirement(
226223
uint256 tokenId,
227224
BatchStatus newStatus
228-
) external virtual override {
225+
) external {
229226
onlyUnpaused();
230227
onlyEscrow();
231228
address tokenOwner = ownerOf(tokenId);
@@ -262,7 +259,7 @@ contract CarbonOffsetBatches is
262259
/// Fractionalization requires status Confirmed.
263260
/// @dev Callable only by verifiers, only for pending batches. This flow requires a previous linking with a vintage
264261
/// @param tokenId The token ID of the batch
265-
function confirmBatch(uint256 tokenId) external virtual {
262+
function confirmBatch(uint256 tokenId) external {
266263
onlyUnpaused();
267264
onlyWithRole(VERIFIER_ROLE);
268265
_confirmBatch(tokenId);
@@ -284,22 +281,18 @@ contract CarbonOffsetBatches is
284281
/// @notice Reject Batch-NFTs, e.g. if the serial number entered is incorrect.
285282
/// @dev Callable only by verifiers, only for pending batches.
286283
/// @param tokenId The token ID of the batch
287-
function rejectBatch(uint256 tokenId) public virtual {
284+
function rejectBatch(uint256 tokenId) public {
288285
onlyUnpaused();
289286
onlyWithRole(VERIFIER_ROLE);
290287
onlyPending(tokenId);
291288

292-
// unsetting serialnumber with rejection
293-
serialNumberApproved[nftList[tokenId].serialNumber] = false;
294289
_updateStatus(tokenId, BatchStatus.Rejected);
295290
}
296291

297292
/// @notice Function to reject Batch-NFTs, including a reason to be displayed to the user.
298293
function rejectWithComment(uint256 tokenId, string memory comment)
299294
external
300-
virtual
301295
{
302-
onlyUnpaused();
303296
rejectBatch(tokenId);
304297
_addComment(tokenId, comment);
305298
}
@@ -318,6 +311,9 @@ contract CarbonOffsetBatches is
318311
ownerOf(tokenId)
319312
)
320313
) revert(Errors.COB_ALREADY_FRACTIONALIZED);
314+
315+
serialNumberApproved[nftList[tokenId].serialNumber] = false;
316+
321317
_updateStatus(tokenId, BatchStatus.Rejected);
322318
_addComment(tokenId, comment);
323319
}
@@ -327,7 +323,7 @@ contract CarbonOffsetBatches is
327323
/// batch, e.g. the batch was incorrectly rejected.
328324
/// @dev Callable only by verifiers, only for rejected batches.
329325
/// @param tokenId The token ID of the batch
330-
function setToPending(uint256 tokenId) external virtual {
326+
function setToPending(uint256 tokenId) external {
331327
onlyUnpaused();
332328
onlyWithRole(VERIFIER_ROLE);
333329
if (nftList[tokenId].status != BatchStatus.Rejected)
@@ -341,7 +337,6 @@ contract CarbonOffsetBatches is
341337
/// @param projectVintageTokenId The token ID of the vintage
342338
function linkWithVintage(uint256 tokenId, uint256 projectVintageTokenId)
343339
external
344-
virtual
345340
{
346341
onlyUnpaused();
347342
onlyWithRole(VERIFIER_ROLE);
@@ -367,7 +362,7 @@ contract CarbonOffsetBatches is
367362
function confirmBatchWithVintage(
368363
uint256 tokenId,
369364
uint256 projectVintageTokenId
370-
) external virtual {
365+
) external {
371366
onlyUnpaused();
372367
onlyWithRole(VERIFIER_ROLE);
373368
// We don't want this to be a "backdoor" for modifying the vintage; it
@@ -402,7 +397,7 @@ contract CarbonOffsetBatches is
402397
/// @dev To be updated by NFT owner after serial number has been provided
403398
/// @param to The address the NFT should be minted to. This should be the user.
404399
/// @return The token ID of the newly minted NFT
405-
function mintEmptyBatch(address to) external virtual returns (uint256) {
400+
function mintEmptyBatch(address to) external returns (uint256) {
406401
onlyUnpaused();
407402
return _mintEmptyBatch(to, to);
408403
}
@@ -443,7 +438,7 @@ contract CarbonOffsetBatches is
443438
string memory serialNumber,
444439
uint256 quantity,
445440
string memory uri
446-
) external virtual {
441+
) external {
447442
onlyUnpaused();
448443
onlyVerifierOrBatchOwner(tokenId);
449444
onlyPending(tokenId);
@@ -477,7 +472,7 @@ contract CarbonOffsetBatches is
477472
uint256 tokenId,
478473
string memory newSerialNumber,
479474
uint256 newQuantity
480-
) external virtual {
475+
) external {
481476
onlyUnpaused();
482477
onlyVerifierOrBatchOwner(tokenId);
483478
onlyPending(tokenId);
@@ -489,8 +484,6 @@ contract CarbonOffsetBatches is
489484
function getConfirmationStatus(uint256 tokenId)
490485
external
491486
view
492-
virtual
493-
override
494487
returns (BatchStatus)
495488
{
496489
return nftList[tokenId].status;
@@ -505,8 +498,6 @@ contract CarbonOffsetBatches is
505498
function getBatchNFTData(uint256 tokenId)
506499
external
507500
view
508-
virtual
509-
override
510501
returns (
511502
uint256,
512503
uint256,
@@ -527,8 +518,6 @@ contract CarbonOffsetBatches is
527518
function getSerialNumber(uint256 tokenId)
528519
external
529520
view
530-
virtual
531-
override
532521
returns (string memory)
533522
{
534523
if (!_exists(tokenId)) revert(Errors.COB_NOT_EXISTS);
@@ -542,7 +531,6 @@ contract CarbonOffsetBatches is
542531
function getComments(uint256 tokenId)
543532
external
544533
view
545-
virtual
546534
returns (string[] memory, address[] memory)
547535
{
548536
return (nftList[tokenId].comments, nftList[tokenId].commentAuthors);
@@ -564,7 +552,7 @@ contract CarbonOffsetBatches is
564552
/// Queries the factory to find the corresponding TCO2 contract
565553
/// Fractionalization happens via receive hook on `safeTransferFrom`
566554
/// @param tokenId The token ID of the batch
567-
function fractionalize(uint256 tokenId) external virtual {
555+
function fractionalize(uint256 tokenId) external {
568556
onlyApprovedOrOwner(tokenId);
569557
// Fractionalize by transferring the batch-NFT to the TCO2 contract.
570558
safeTransferFrom(
@@ -606,7 +594,6 @@ contract CarbonOffsetBatches is
606594
function supportsInterface(bytes4 interfaceId)
607595
public
608596
view
609-
virtual
610597
override(AccessControlUpgradeable, ERC721EnumerableUpgradeable)
611598
returns (bool)
612599
{

contracts/CarbonOffsetBatchesStorage.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ abstract contract CarbonOffsetBatchesStorageV1 {
2020
struct NFTData {
2121
uint256 projectVintageTokenId;
2222
string serialNumber;
23+
// Quantity is denominated in tonnes
2324
uint256 quantity;
2425
BatchStatus status;
2526
string uri;

contracts/CarbonProjectVintages.sol

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,6 @@ contract CarbonProjectVintages is
202202
emit ProjectVintageUpdated(tokenId);
203203
}
204204

205-
/// @dev Removes a project-vintage and corresponding data
206-
function removeVintage(uint256 tokenId)
207-
external
208-
virtual
209-
onlyManagers
210-
whenNotPaused
211-
{
212-
totalSupply--;
213-
delete vintageData[tokenId];
214-
}
215-
216205
/// @dev retrieve all data from VintageData struct
217206
function getProjectVintageDataByTokenId(uint256 tokenId)
218207
external

contracts/ToucanCarbonOffsets.sol

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract ToucanCarbonOffsets is
2323
/// @dev Version-related parameters. VERSION keeps track of production
2424
/// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations
2525
/// of a VERSION in our staging environment.
26-
string public constant VERSION = '1.6.0';
26+
string public constant VERSION = '1.7.0';
2727
uint256 public constant VERSION_RELEASE_CANDIDATE = 1;
2828

2929
// ----------------------------------------
@@ -56,16 +56,18 @@ contract ToucanCarbonOffsets is
5656
msg.sender,
5757
_projectVintageTokenId,
5858
amount,
59+
'',
5960
true
6061
);
6162
}
6263

6364
/// @notice Mint an NFT showing how many tonnes of CO2 have been retired/cancelled
6465
/// Going forward users should mint NFT directly in the RetirementCertificates contract.
65-
/// @param retiringEntityString An identifiable string for the retiring entity, eg. their name.
66-
/// @param beneficiary The beneficiary to set in the NFT.
67-
/// @param beneficiaryString The beneficiaryString to set in the NFT.
68-
/// @param retirementMessage The retirementMessage to set in the NFT.
66+
/// Note that this information is publicly written to the blockchain in plaintext.
67+
/// @param retiringEntityString An identifiable string for the retiring entity, eg. their name
68+
/// @param beneficiary The address of the beneficiary of the retirement
69+
/// @param beneficiaryString An identifiable string for the beneficiary, eg. their name
70+
/// @param retirementMessage A message to be included in the retirement certificate
6971
function mintCertificateLegacy(
7072
string calldata retiringEntityString,
7173
address beneficiary,

contracts/ToucanCarbonOffsetsEscrow.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
99
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
1010
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
1111
import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
12+
import '@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol';
1213

1314
import './bases/RoleInitializer.sol';
1415
import {Errors} from './libraries/Errors.sol';
@@ -160,6 +161,9 @@ contract ToucanCarbonOffsetsEscrow is
160161
uint256 batchIdLength = tokenIds.length;
161162
for (uint256 i = 0; i < batchIdLength; ++i) {
162163
uint256 tokenId = tokenIds[i];
164+
if (IERC721Upgradeable(batchNFT).ownerOf(tokenId) != msg.sender) {
165+
revert(Errors.COB_INVALID_BATCH_OWNER);
166+
}
163167
(, uint256 batchAmount, ) = _getNormalizedDataFromBatch(
164168
batchNFT,
165169
tokenId

contracts/ToucanCarbonOffsetsFactory.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ contract ToucanCarbonOffsetsFactory is ToucanCarbonOffsetsFactoryBase {
1919
/// @dev Version-related parameters. VERSION keeps track of production
2020
/// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations
2121
/// of a VERSION in our staging environment.
22-
string public constant VERSION = '1.3.0';
22+
string public constant VERSION = '1.4.0';
2323
uint256 public constant VERSION_RELEASE_CANDIDATE = 1;
2424

2525
// ----------------------------------------

contracts/bases/ToucanCarbonOffsetsBase.sol

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -249,70 +249,32 @@ abstract contract ToucanCarbonOffsetsBase is
249249
_burn(account, amount);
250250
}
251251

252-
// @dev Internal function for the burning of TCO2 tokens
253-
// @dev retiringEntityAddress is a parameter to handle scenarios, when
254-
// retirements are performed from the escrow contract and the retiring entity
255-
// is different than the account.
252+
/// @dev Internal function for the burning of TCO2 tokens
253+
/// @param account The account from where TCO2s are burned
254+
/// @param amount The amount of TCO2s to burn
255+
/// @param retiringEntity The entity that is retiring TCO2
256+
/// @param serialNumber The serial number of the batch associated with the retirement
257+
/// @return retirementEventId The id of the retirement event
256258
function _retire(
257259
address account,
258260
uint256 amount,
259-
address retiringEntityAddress
261+
address retiringEntity,
262+
string memory serialNumber
260263
) internal virtual returns (uint256 retirementEventId) {
261264
_burn(account, amount);
262265

263266
// Register retirement event in the certificates contract
264267
address certAddr = IToucanContractRegistry(contractRegistry)
265268
.retirementCertificatesAddress();
266269
retirementEventId = IRetirementCertificates(certAddr).registerEvent(
267-
retiringEntityAddress,
270+
retiringEntity,
268271
_projectVintageTokenId,
269272
amount,
273+
serialNumber,
270274
false
271275
);
272276

273-
emit Retired(retiringEntityAddress, amount, retirementEventId);
274-
}
275-
276-
// @dev Internal function retire and mint certificates
277-
function _retireAndMintCertificate(
278-
address retiringEntity,
279-
CreateRetirementRequestParams memory params
280-
) internal virtual whenNotPaused {
281-
uint256[] memory retirementEventIds;
282-
if (params.tokenIds.length == 0) {
283-
uint256 retirementEventId = _retire(
284-
msg.sender,
285-
params.amount,
286-
retiringEntity
287-
);
288-
retirementEventIds = new uint256[](1);
289-
retirementEventIds[0] = retirementEventId;
290-
} else {
291-
retirementEventIds = new uint256[](params.tokenIds.length);
292-
uint256 decimalMultiplier = 10**decimals();
293-
for (uint256 i = 0; i < params.tokenIds.length; i++) {
294-
//slither-disable-next-line unused-return
295-
(, uint256 batchQuantity, ) = ICarbonOffsetBatches(
296-
IToucanContractRegistry(contractRegistry)
297-
.carbonOffsetBatchesAddress()
298-
).getBatchNFTData(params.tokenIds[i]);
299-
uint256 retirementEventId = _retire(
300-
msg.sender,
301-
batchQuantity * decimalMultiplier,
302-
retiringEntity
303-
);
304-
retirementEventIds[i] = retirementEventId;
305-
}
306-
}
307-
//slither-disable-next-line unused-return
308-
IRetirementCertificates(
309-
IToucanContractRegistry(contractRegistry)
310-
.retirementCertificatesAddress()
311-
).mintCertificateWithExtraData(
312-
retiringEntity,
313-
params,
314-
retirementEventIds
315-
);
277+
emit Retired(retiringEntity, amount, retirementEventId);
316278
}
317279

318280
// -----------------------------

0 commit comments

Comments
 (0)