Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/patch token decimals into voucher hub #50

Merged
merged 13 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 11 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Changelog

## vNEXT

- Remove references to blockscout v5. (#49)
- Override the decimals function of ERC-20 to set the token's decimal precision to 9, aligning with RLC standards. (#50)
- Verify VoucherProxy contracts. (#51)

## v1.0.0

### What's new?

- Allow users to access resources of the iExec network via a sponsorship voucher.

### More details

- Upgrade Solidity Compiler to `v0.8.27`. (#45)
- Bump dependencies: (#44)
- `@openzeppelin/hardhat-upgrades`, `hardhat`, `ethers`, `prettier`, and others [minor version bump]
- `prettier-plugin-organize-imports@4`
- `@openzeppelin/hardhat-upgrades`, `hardhat`, `ethers`, `prettier`, and others [minor version bump]
- `prettier-plugin-organize-imports@4`
- Add `getVoucherProxyCodeHash(..)` & `isRefundedTask(..)` view functions. (#43)
- Add `predictVoucher(..)` & `isVoucher(..)` functions. (#42)
- Generate UML class diagram for contracts. (#41)
Expand Down Expand Up @@ -44,12 +48,12 @@
- Match orders through voucher. (#12)
- Add external-hardhat network configuration. (#11)
- Add voucher credit and SRLC manipulation. (#10)
- SRLC and iExec poco is mocked.
- set voucher credit as VoucherHub is ERC20.
zguesmi marked this conversation as resolved.
Show resolved Hide resolved
- SRLC and iExec poco is mocked.
- set voucher credit as VoucherHub is ERC20.
- Upgrade configuration: (#9)
- Upgrade dependencies: hardhat, husky, iExec Poco.
- Ignore mocks in coverage.
- Add solidity optimizer and use Bellecour network config.
- Upgrade dependencies: hardhat, husky, iExec Poco.
- Ignore mocks in coverage.
- Add solidity optimizer and use Bellecour network config.
- Add role-based access control to VoucherHub. (#8)
- Create voucher from VoucherHub with : type, expiration, authorize list. (#6)
- Create vouchers with create2. (#5)
Expand Down
14 changes: 14 additions & 0 deletions contracts/NonTransferableERC20Upgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/
* @notice This contracts follows the standard ERC-20 Upgradeable model, but it cannot be transferred.
*/
contract NonTransferableERC20Upgradeable is ERC20Upgradeable {
/**
* @dev By default, the standard ERC-20 `decimals` value is `18`. However, this value
* is overridden here to `9` to align with the number of decimal places used by
* the RLC token. This ensures consistency in how input values are handled
* when a voucher is minted.
*
* See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L78
*
* @return The number of decimal places (9) used for token representation.
*/
function decimals() public pure override returns (uint8) {
return 9;
}

/**
* @notice NonTransferableERC20Upgradeable is not transferable.
*/
Expand Down
6 changes: 6 additions & 0 deletions contracts/VoucherHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ contract VoucherHub is
emit VoucherTypeCreated($._voucherTypes.length - 1, description, duration);
}

/**
* This function only updates the duration for newly minted vouchers and not the existing ones to provide
Le-Caignec marked this conversation as resolved.
Show resolved Hide resolved
* guarantees regarding the expiration of vouchers. When a voucher is delivered, its credits should not expire
* before the original expiration date.
* As mentioned in Halborn audit report (HAL-01), this is not a bug, but rather, an intended feature.
*/
function updateVoucherTypeDescription(
uint256 id,
string memory description
Expand Down
5 changes: 5 additions & 0 deletions docs/VoucherHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ function createVoucherType(string description, uint256 duration) external
function updateVoucherTypeDescription(uint256 id, string description) external
```

This function only updates the duration for newly minted vouchers and not the existing ones to provide
guarantees regarding the expiration of vouchers. When a voucher is delivered, its credits should not expire
before the original expiration date.
As mentioned in Halborn audit report (HAL-01), this is not a bug, but rather, an intended feature.

### updateVoucherTypeDuration

```solidity
Expand Down
7 changes: 7 additions & 0 deletions test/VoucherHub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,13 @@ describe('VoucherHub', function () {
'NonTransferableERC20Upgradeable: Unsupported transferFrom',
);
});

it('Should return 9 as the number of decimals', async function () {
const { voucherHub } = await loadFixture(deployFixture);

// Call the decimals function and check the returned value
expect(await voucherHub.decimals()).to.equal(9);
});
});
});

Expand Down
Loading