Hi guys, im kind of new to programming and i am testing out UUPS
I have my implementation contract set up, however, when i try to migrate, or test. i keep running into this error TypeError: Cannot read property 'networks' of undefined
Code to reproduce
// Contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract LogicV1 is Initializable, OwnableUpgradeable, UUPSUpgradeable {
string private name;
string private birthDate;
uint private luckyNumber;
event SetBirthDate(string _birth);
event RetrieveBirthDate(string _birth);
event SetLuckyNumber(uint _luckyN);
event RetrieveLuckyNumber(uint _luckyN);
event SetName(string _name);
event RetrieveName(string _name);
constructor () initializer {}
function initialize(string calldata _name, string calldata _birthDate, uint _lucky) internal initializer {
__Ownable_init(); // intializes owner function
// sets name
this.setName(_name);
// sets lucky number
this.setLuckyNumber(_lucky);
// sets birthdate
this.setBirth(_birthDate);
}
function getBirth() external onlyOwner returns (string memory) {
emit RetrieveBirthDate(birthDate);
return birthDate;
}
function setBirth(string calldata _birth) external onlyOwner returns (string memory) {
(bool birthSet) = _setBirth(_birth);
require(birthSet);
emit SetBirthDate(birthDate);
return _birth;
}
function getLuckyNumber() external onlyOwner returns (uint) {
emit RetrieveLuckyNumber(luckyNumber);
return luckyNumber;
}
function _setBirth(string calldata _birth) private returns (bool) {
birthDate = _birth;
return true;
}
function _setLuckyNumber(uint _luckyN) private returns (bool) {
luckyNumber = _luckyN;
return true;
}
function setLuckyNumber(uint _luckyN) external onlyOwner returns (uint) {
(bool numberSet) = _setLuckyNumber(_luckyN);
require(numberSet);
emit SetLuckyNumber(_luckyN);
return _luckyN;
}
function getName() external onlyOwner returns (string memory) {
emit RetrieveName(name);
return name;
}
function setName(string calldata _name) external onlyOwner returns (string memory) {
(bool nameSet) = _setName(_name);
require(nameSet);
emit SetName(_name);
return _name;
}
function _setName(string calldata _name) private returns (bool) {
name = _name;
return true;
}
function _authorizeUpgrade(address) internal override onlyOwner {}
}
// migrations
const { lv1 } = artifacts.require('LogicV1');
const { deployProxy, upgradeProxy} = require('@openzeppelin/truffle-upgrades');
module.exports = async function (deployer, network, accounts){
const lv1Proxy = await deployProxy(lv1, ['some name', '15/06/1972', '6'], {deployer, kind: 'uups'}); // will deploy the box and initialize initialize with some stuff
const inst = await lv1Proxy.deployed();
console.log(inst); // just logging to see
}
Environment
I'm using truffle v5.4.11
truffle/upgrades.
furthermore, the OS that im using is fedora34