Files
openzeppelin-contracts/test/helpers/enums.js
Hadrien Croubois cffb2f1ddc Migrate math tests to ethers.js v6 (#4769)
Co-authored-by: Ernesto García <ernestognw@gmail.com>
2023-12-04 13:00:00 -06:00

22 lines
687 B
JavaScript

function Enum(...options) {
return Object.fromEntries(options.map((key, i) => [key, web3.utils.toBN(i)]));
}
function EnumBigInt(...options) {
return Object.fromEntries(options.map((key, i) => [key, BigInt(i)]));
}
// TODO: remove web3, simplify code
function createExport(Enum) {
return {
Enum,
ProposalState: Enum('Pending', 'Active', 'Canceled', 'Defeated', 'Succeeded', 'Queued', 'Expired', 'Executed'),
VoteType: Enum('Against', 'For', 'Abstain'),
Rounding: Enum('Floor', 'Ceil', 'Trunc', 'Expand'),
OperationState: Enum('Unset', 'Waiting', 'Ready', 'Done'),
};
}
module.exports = createExport(Enum);
module.exports.bigint = createExport(EnumBigInt);