I've been trying to deploy this upgradable contract in a hardhat testing environment and I'm having trouble with the external library linking inside the deployProxy function. I tried many different formats for the opts argument and I get two different types of errors.
If I use { unsafeAllow: "external-library-linking" }
I get the error:
"before each" hook for "tests setUp":
TypeError: unsafeAllow.push is not a function
at withValidationDefaults (node_modules/@openzeppelin/upgrades-core/src/validate/overrides.ts:93:17)
at withDefaults (node_modules/@openzeppelin/hardhat-upgrades/src/utils/options.ts:37:30)
at getDeployData (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:50:32)
at deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:71:22)
at Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:46:28)
at Context.<anonymous> (test/hardhat/setUp.test.js:221:27)
The other format I was trying { unsafeAllow: ["external-library-linking"] }
and it gives me this error:
1) setUp Tests
"before each" hook for "tests setUp":
Error: invalid format type (argument="format", value=true, code=INVALID_ARGUMENT, version=abi/5.7.0)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at Logger.throwArgumentError (node_modules/@ethersproject/logger/src.ts/index.ts:285:21)
at EventFragment.format (node_modules/@ethersproject/abi/src.ts/fragments.ts:493:20)
at /Users/cryptogirl/Documents/Solidity/FluidNFT/protocol/node_modules/@ethersproject/abi/src.ts/interface.ts:165:63
at Array.map (<anonymous>)
at Interface.format (node_modules/@ethersproject/abi/src.ts/interface.ts:165:36)
at /Users/cryptogirl/Documents/Solidity/FluidNFT/protocol/node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:113:41
at resumeOrDeploy (node_modules/@openzeppelin/upgrades-core/src/deployment.ts:76:30)
at /Users/cryptogirl/Documents/Solidity/FluidNFT/protocol/node_modules/@openzeppelin/upgrades-core/src/impl-store.ts:63:23
Also if I use the * /// @custom:oz-upgrades-unsafe-allow external-library-linking
in the NatSpec of the contract it gives me the same error above.
Does anyone have any insight on this? I'd greatly appreciate some help.
Here's the code snippet giving me the error
LendingPoolContract = await ethers.getContractFactory("LendingPool", {
signers: admin,
libraries: {
BorrowLogic: BorrowLogicLib.address,
LiquidateLogic: LiquidateLogicLib.address,
ReserveLogic: ReserveLogicLib.address,
SupplyLogic: SupplyLogicLib.address,
},
});
LendingPoolInstance = await upgrades.deployProxy(
LendingPoolContract,
[AddressProviderInstance.address],
{ unsafeAllow: "external-library-linking" } // error is coming from this line!
);
Environment
Solidity pragma 0.8.16,
@openzeppelin/hardhat-upgrades: ^1.21.0,
@nomiclabs/hardhat-ethers: ^2.0.6