Skip to content

Commit

Permalink
set view functions to external
Browse files Browse the repository at this point in the history
  • Loading branch information
gfournieriExec committed May 29, 2024
1 parent 783f99d commit 5e269d5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions contracts/VoucherHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,38 +214,26 @@ contract VoucherHub is
}
}

// TODO make view functions external whenever possible.

/**
* Get iExec Poco address used by vouchers.
*/
function getIexecPoco() public view returns (address) {
function getIexecPoco() external view returns (address) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $._iexecPoco;
}

/**
* Get voucher beacon address.
*/
function getVoucherBeacon() public view returns (address) {
function getVoucherBeacon() external view returns (address) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $._voucherBeacon;
}

/**
* Get the voucher type details by ID.
*/
function getVoucherType(
uint256 id
) external view whenVoucherTypeExists(id) returns (VoucherType memory) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $.voucherTypes[id];
}

/**
* Get voucher types count.
*/
function getVoucherTypeCount() public view returns (uint256) {
function getVoucherTypeCount() external view returns (uint256) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $.voucherTypes.length;
}
Expand All @@ -258,7 +246,7 @@ contract VoucherHub is
function isAssetEligibleToMatchOrdersSponsoring(
uint256 voucherTypeId,
address asset
) public view returns (bool) {
) external view returns (bool) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $.matchOrdersEligibility[voucherTypeId][asset];
}
Expand All @@ -268,7 +256,7 @@ contract VoucherHub is
* Returns address(0) if voucher is not found.
* @param account voucher's owner address.
*/
function getVoucher(address account) public view returns (address voucherAddress) {
function getVoucher(address account) external view returns (address voucherAddress) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
voucherAddress = Create2.computeAddress(
_getCreate2Salt(account), // salt
Expand All @@ -277,6 +265,16 @@ contract VoucherHub is
return voucherAddress.code.length > 0 ? voucherAddress : address(0);
}

/**
* Get the voucher type details by ID.
*/
function getVoucherType(
uint256 id
) public view whenVoucherTypeExists(id) returns (VoucherType memory) {
VoucherHubStorage storage $ = _getVoucherHubStorage();
return $.voucherTypes[id];
}

function _authorizeUpgrade(
address newImplementation
) internal override onlyRole(UPGRADE_MANAGER_ROLE) {}
Expand Down

0 comments on commit 5e269d5

Please sign in to comment.