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

Create voucher with , VoucherHub address, Set account as owner, expiration and deal with Authorization #6

Merged
merged 64 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a172953
start implementing voucher with type and split test files
gfournieriExec Mar 26, 2024
3a335d6
update test and plug voucher with type
gfournieriExec Mar 27, 2024
2459613
clean and add test to get full coverage
gfournieriExec Mar 27, 2024
b460510
set creditERC20 as voucherHub
gfournieriExec Mar 27, 2024
2a303d0
update interfaces
gfournieriExec Mar 28, 2024
b12c70c
Merge branch 'develop' into feature/create-typed-voucher
gfournieriExec Mar 29, 2024
f65b38e
add get voucher test for coverage
gfournieriExec Mar 29, 2024
6e3fb6e
Update naming files
gfournieriExec Mar 29, 2024
67847b9
update interface voucher
gfournieriExec Mar 29, 2024
d7ad6a0
add set authorisation
gfournieriExec Mar 29, 2024
31f130c
add unauthorization for not owner coverage
gfournieriExec Mar 29, 2024
b6db8db
create common function file in script
gfournieriExec Mar 29, 2024
0c1c650
back spdx
gfournieriExec Mar 29, 2024
8aebbb0
clean unused function in VH test
gfournieriExec Mar 29, 2024
f658893
modify IT name
gfournieriExec Apr 2, 2024
3670867
compute voucherExpiration with block timestamp first
gfournieriExec Apr 2, 2024
26160e9
Erase comment
gfournieriExec Apr 2, 2024
cf631e7
update return in getter functions
gfournieriExec Apr 2, 2024
0e58e98
update name of storage variable here
gfournieriExec Apr 2, 2024
b81040b
remove duration0 mistack in IT title
gfournieriExec Apr 2, 2024
574b403
change revert with custom error on voucher IT
gfournieriExec Apr 2, 2024
ca53968
remove useless override function
gfournieriExec Apr 2, 2024
46ac1c5
update coverage to check if owner is authorized
gfournieriExec Apr 2, 2024
abb77b7
update Changelog
gfournieriExec Apr 2, 2024
6a40912
added back blank line
gfournieriExec Apr 2, 2024
b96a993
Update contracts/IVoucherHub.sol
gfournieriExec Apr 2, 2024
8bd50fb
Update contracts/IVoucherHub.sol
gfournieriExec Apr 2, 2024
584a62b
Apply suggestions from code review
gfournieriExec Apr 2, 2024
cf49ac9
update comments
gfournieriExec Apr 2, 2024
0166523
add voucher type to event on VoucherCreated
gfournieriExec Apr 2, 2024
55d206b
update voucher authorization event name and add emit checks in UT
gfournieriExec Apr 2, 2024
1f45c8c
modify name of authorizations functions
gfournieriExec Apr 2, 2024
c472e15
update get voucher hub function name and remove return name argument
gfournieriExec Apr 2, 2024
8df087b
factorize set unset authorization
gfournieriExec Apr 2, 2024
0a4de00
update voucher type init arg name
gfournieriExec Apr 2, 2024
3f5f5f4
update voucher V2 mock
gfournieriExec Apr 2, 2024
be417d1
Erase double UT, merge voucher Type x
gfournieriExec Apr 3, 2024
a1f64df
clean functions description only in implem
gfournieriExec Apr 3, 2024
945824b
add function descriptions on voucher
gfournieriExec Apr 3, 2024
c90061a
erase comment
gfournieriExec Apr 3, 2024
9d63a0a
erase interface title mention
gfournieriExec Apr 3, 2024
048240d
move up pragma mention
gfournieriExec Apr 3, 2024
1e972ff
erase return name argument on interfaces
gfournieriExec Apr 3, 2024
a38b5ec
update isAuthorized in internal function
gfournieriExec Apr 3, 2024
72a8765
move private functions at the bottom of the file
gfournieriExec Apr 3, 2024
bb714a9
erase event emission on voucher init + revert when owner setAuthorize
gfournieriExec Apr 3, 2024
c81c4fe
moved back create voucher in voucherHub test
gfournieriExec Apr 3, 2024
b4fd967
remove useless transaction
gfournieriExec Apr 3, 2024
eaf789a
reorganise voucher init arg disposition and emited event on creation
gfournieriExec Apr 3, 2024
6e02605
remove blank line
gfournieriExec Apr 4, 2024
e47eac3
modify unauthorize test with non owner voucher
gfournieriExec Apr 4, 2024
80984b8
update voucher initialize voucherType Id arg name and add it in inter…
gfournieriExec Apr 4, 2024
c1ea7f7
remove initialize from i voucher
gfournieriExec Apr 4, 2024
df8886c
commenting test for CI
gfournieriExec Apr 4, 2024
657a535
uncomment
gfournieriExec Apr 4, 2024
36eb1d6
testing for CI
gfournieriExec Apr 4, 2024
0b1446f
remove debug CI
gfournieriExec Apr 4, 2024
1b3e0e4
comment test to pass CI
gfournieriExec Apr 4, 2024
76f5195
test only init
gfournieriExec Apr 4, 2024
6d351a5
remove init
gfournieriExec Apr 4, 2024
f815043
add clean workspace and test it
gfournieriExec Apr 4, 2024
ce443af
erase bad stage
gfournieriExec Apr 4, 2024
65bb9e0
re-add tests after clean ws CI
gfournieriExec Apr 4, 2024
2c764ec
voucher 2 should have duration1
gfournieriExec Apr 4, 2024
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: 0 additions & 2 deletions contracts/VoucherHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ contract VoucherHub is OwnableUpgradeable, UUPSUpgradeable, IVoucherHub {
* @dev Note: the same account could have 2 voucher instances if the "beaconAddress"
* changes, but this should not happen since the beacon is upgradeable, hence the
* address should never be changed.
*

* @param owner The address of the voucher owner.
* @param voucherType The ID of the voucher type.
* @return voucherAddress The address of the created voucher contract.
Expand Down
13 changes: 8 additions & 5 deletions contracts/beacon/IVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ interface IVoucher {
event AccountAuthorized(address indexed account);
event AccountUnauthorized(address indexed account);

function getExpiration() external view returns (uint256);

function getType() external view returns (uint256);
function initialize(
zguesmi marked this conversation as resolved.
Show resolved Hide resolved
address owner,
address voucherHub,
uint256 expiration,
uint256 voucherTypeId
) external;

function getVoucherHub() external view returns (address);
function getExpiration() external view returns (uint256);
function getType() external view returns (uint256);

function authorizeAccount(address account) external;

function unauthorizeAccount(address account) external;

function isAccountAuthorized(address account) external view returns (bool);
}
6 changes: 3 additions & 3 deletions contracts/beacon/Voucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ contract Voucher is OwnableUpgradeable, IVoucher {
/**
* Initialize implementation contract.
* @param owner The owner of the contract.
* @param voucherType The type of the voucher.
* @param voucherTypeId The type Id of the voucher.
* @param expiration The expiration timestamp of the voucher.
* @param voucherHub The address of the voucher hub.
*/
function initialize(
address owner,
jeremyjams marked this conversation as resolved.
Show resolved Hide resolved
address voucherHub,
uint256 expiration,
uint256 voucherType
uint256 voucherTypeId
) external initializer {
__Ownable_init(owner);
VoucherStorage storage $ = _getVoucherStorage();
$._voucherHub = voucherHub;
$._expiration = expiration;
$._type = voucherType;
$._type = voucherTypeId;
// TODO: deposit sRLC.
}

Expand Down
8 changes: 6 additions & 2 deletions test/beacon/Voucher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,15 @@ describe('Voucher', function () {
await createVoucherTx.wait();
const voucherAddress = await voucherHub.getVoucher(voucherOwner1);
const voucher: Voucher = await commonUtils.getVoucher(voucherAddress);


await voucher.connect(voucherOwner1).authorizeAccount(anyone.address);
const anyoneIsAuthorized = await voucher.isAccountAuthorized(anyone.address);
// unauthorize the account
await expect(
voucher.connect(anyone).unauthorizeAccount(anyone.address),
).to.be.revertedWithCustomError(voucher, 'OwnableUnauthorizedAccount');
// Check that the state of mapping is not modified from.
expect(await voucher.isAccountAuthorized(anyone.address)).to.equal(anyoneIsAuthorized)
.to.be.true;
});

it('Should not authorize owner account', async () => {
Expand Down