Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Changelog

## vNEXT
- Index first parameter of match an claim events in `Voucher` contract. (#61, #72)
- Add upgrade workflow. (#64)
- Add Halborn "Poco v5.5 & Voucher v1.0" audit report ( #70)
- Add `dealId` to `TaskClaimedWithVoucher` event. (#61)
- Add type-checking script (#53)
- Run partial upgrade tests on fork.
- Should maintain consistent voucher addresses (#61)
Expand Down
2 changes: 1 addition & 1 deletion contracts/beacon/IVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IVoucher {
event AccountUnauthorized(address indexed account);
event OrdersMatchedWithVoucher(bytes32 indexed dealId);
event OrdersBoostMatchedWithVoucher(bytes32 indexed dealId);
event TaskClaimedWithVoucher(bytes32 indexed taskId, bytes32 indexed dealId);
event TaskClaimedWithVoucher(bytes32 indexed taskId);

function setExpiration(uint256 expiration) external;
function authorizeAccount(address account) external;
Expand Down
7 changes: 3 additions & 4 deletions contracts/beacon/Voucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
}

modifier onlyOwner() {
require(msg.sender == owner(), "Voucher: sender is not owner");

Check warning on line 43 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
_;
}

modifier onlyAuthorized() {
VoucherStorage storage $ = _getVoucherStorage();
require(

Check warning on line 49 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

Error message for require is too long: 33 counted / 32 allowed

Check warning on line 49 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
msg.sender == owner() || $._authorizedAccounts[msg.sender],
"Voucher: sender is not authorized"
);
Expand All @@ -55,17 +55,17 @@

modifier onlyVoucherHub() {
VoucherStorage storage $ = _getVoucherStorage();
require(msg.sender == $._voucherHub, "Voucher: sender is not VoucherHub");

Check warning on line 58 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

Error message for require is too long: 33 counted / 32 allowed

Check warning on line 58 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
_;
}

modifier onlyNotExpired() {
require(block.timestamp < getExpiration(), "Voucher: voucher is expired");

Check warning on line 63 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
_;
}

modifier onlyExpired() {
require(getExpiration() <= block.timestamp, "Voucher: voucher is not expired");

Check warning on line 68 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
_;
}

Expand Down Expand Up @@ -214,8 +214,7 @@
if (task.status != IexecLibCore_v5.TaskStatusEnum.FAILED) {
IexecPoco2(iexecPoco).claim(taskId);
}
bytes32 dealId = task.dealid;
IexecLibCore_v5.Deal memory deal = IexecPocoAccessors(iexecPoco).viewDeal(dealId);
IexecLibCore_v5.Deal memory deal = IexecPocoAccessors(iexecPoco).viewDeal(task.dealid);
// If the deal was matched by the voucher, then the voucher should be refunded.
// If the deal was partially or not sponsored by the voucher, then the requester
// should be refunded.
Expand All @@ -230,7 +229,7 @@
deal.requester
);
}
emit TaskClaimedWithVoucher(taskId, dealId);
emit TaskClaimedWithVoucher(taskId);
}

/**
Expand Down Expand Up @@ -263,7 +262,7 @@
deal.requester
);
}
emit TaskClaimedWithVoucher(taskId, dealId);
emit TaskClaimedWithVoucher(taskId);
}

/**
Expand All @@ -277,7 +276,7 @@
//
// msg.sender is the VoucherHub. No need to read the address from storage.
if (!IERC20(IVoucherHub(msg.sender).getIexecPoco()).transfer(msg.sender, amount)) {
revert("Voucher: drain failed");

Check warning on line 279 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of revert statements
}
}

Expand Down Expand Up @@ -357,7 +356,7 @@
* @param isAuthorized Whether to authorize or unauthorize the account.
*/
function _setAccountAuthorization(address account, bool isAuthorized) private {
require(account != owner(), "Voucher: owner is already authorized.");

Check warning on line 359 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

Error message for require is too long: 37 counted / 32 allowed

Check warning on line 359 in contracts/beacon/Voucher.sol

View workflow job for this annotation

GitHub Actions / coverage

GC: Use Custom Errors instead of require statements
VoucherStorage storage $ = _getVoucherStorage();
$._authorizedAccounts[account] = isAuthorized;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/IVoucher.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ event OrdersBoostMatchedWithVoucher(bytes32 dealId)
### TaskClaimedWithVoucher

```solidity
event TaskClaimedWithVoucher(bytes32 taskId, bytes32 dealId)
event TaskClaimedWithVoucher(bytes32 taskId)
```

### setExpiration
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@
"lint": "solhint 'contracts/**/*.sol' --fix && eslint . --fix"
},
"lint-staged": {
"*.ts": [
"npm run lint:ts"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's funny we did not see that

],
"*.sol": [
"npm run lint:sol"
"*.{ts,sol}": [
"npm run lint"
]
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/voucherHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ export async function getExpectedVoucherProxyCodeHash(voucherBeaconAddress: stri
*
* Also see test/NextVersionUpgrade.test.ts to double check behavior.
*/
return '0x31a4f4707138270dd34b040129096c67e1039fb242deebb8a0d0f8ed9da82232';
return '0x1904181fa3fbe85a0796789e46d9ee31e5585fbdbabce28931332862d68c9313';
}
}
2 changes: 1 addition & 1 deletion test/beacon/Voucher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ describe('Voucher', function () {
.to.emit(voucherHub, 'VoucherRefunded')
.withArgs(voucherAddress, taskSponsoredAmount)
.to.emit(voucherAsOwner, 'TaskClaimedWithVoucher')
.withArgs(taskId, dealId);
.withArgs(taskId);
const {
voucherCreditBalance: voucherCreditBalancePostClaim,
voucherSrlcBalance: voucherSrlcBalancePostClaim,
Expand Down
Loading