I have deployed my contracts using deployProxy and saved proxy addresses.
I am running upgradeProxy by looping though all of these proxy addresses and running this:
The redeployImplementation: 'onchange' option just means that the implementation contract will be redeployed if it was changed. So since you are running upgradeProxy multiple times without changing the implementation in between, it won't keep redeploying the same implementation to separate addresses.
But upgradeProxy always sends the tx to upgrade the proxy, regardless of what its current implementation is.
Proxy points to a contract. How can the proxy point to a new contract only if the new contract is different from the old one? I though this is what upgradeProxy did.
If you want to prevent upgradeProxy from doing anything if the implementation address is not changed, you could code this into your script by comparing the implementation addresses. For example, something like:
By doing that, I will deploy the implementation contract even if it has not changed. Can I check whether deployed contract has changed comparing to the current one?
I'm not sure what you mean.
If the implementation source code has not changed, then by default the Hardhat Upgrades plugin will not redeploy the implementation, even if you call prepareUpgrade.
And if you check that the implementation address has not changed, then it will not submit the transaction to upgrade the proxy.
So with what I suggested above, it should do nothing if the implementation has not changed.