Hi, I am playing with the vestingWallet contract and am running into something that I don't understand. Any help is greatly appreciated.
So, I am trying to add a cliff to the vestingWallet:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/finance/VestingWalletUpgradeable.sol";
contract DualVestingWallet is Initializable, VestingWalletUpgradeable {
uint64 private _cliff;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize(
address beneficiaryAddress,
uint64 startTimestamp,
uint64 durationSeconds,
uint64 cliff
) public initializer {
_cliff = cliff;
__VestingWallet_init(
beneficiaryAddress,
startTimestamp,
durationSeconds
);
}
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp)
internal
view
virtual
override
returns (uint256)
{
if (timestamp < start() + _cliff) {
return 0;
} else if (timestamp > start() + duration()) {
return totalAllocation;
} else {
return (totalAllocation * (timestamp - start())) / duration();
}
}
}
And I am in the process of writing a test to test the contract:
const { expect } = require('chai');
const { ethers, upgrades, artifacts } = require('hardhat');
const {
BN,
constants,
expectEvent,
expectRevert,
time,
balance,
} = require('@openzeppelin/test-helpers');
const { inTransaction } = require('@openzeppelin/test-helpers/src/expectEvent');
const { ZERO_ADDRESS } = constants;
before(async function () {
// Advance to the next block to correctly read time in the solidity "now" function interpreted by ganache
await time.advanceBlock();
});
beforeEach(async () => {
[owner, user1, user2, ...users] = await ethers.getSigners();
const Token = await ethers.getContractFactory('Token', owner);
dual = await upgrades.deployProxy(Token, ['DualMint', 'DUAL']);
const VestingWallet = await ethers.getContractFactory(
'DualVestingWallet',
owner
);
const startTimestamp = Math.floor(Date.now() / 1000);
vestingWallet = await upgrades.deployProxy(VestingWallet, [
owner.address,
startTimestamp,
7200,
3600,
]);
});
describe('VestingWallet', async () => {
it('release after cliff', async () => {
await dual.mint(vestingWallet.address, 1000);
await time.increase(time.duration.hours(5));
await vestingWallet.release(dual.address);
});
});
For some reason I am getting:
- VestingWallet
release after cliff:
TypeError: vestingWallet.release is not a function
at Context. (test/DualVestingWallet-test.js:43:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5)