From 2f7623420b7ec55bad2fe33754498a231d7501a6 Mon Sep 17 00:00:00 2001 From: "Mark.B" Date: Thu, 5 Dec 2024 12:35:31 +0100 Subject: [PATCH] when deploying oracle, transfer old price to new oracle --- deploy/main/002_deploy_oracle.ts | 6 +++++- deploy/test/002_deploy_oracle.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/deploy/main/002_deploy_oracle.ts b/deploy/main/002_deploy_oracle.ts index 2bf32861..fd475700 100644 --- a/deploy/main/002_deploy_oracle.ts +++ b/deploy/main/002_deploy_oracle.ts @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types'; import { networkConfig } from '../../helper-hardhat-config'; const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { - const { deploy, get, log } = deployments; + const { deploy, get, read, execute, log } = deployments; const { deployer } = await getNamedAccounts(); + const oldOraclePrice = await read('PriceOracle', 'currentPrice'); + const args = [(await get('PostageStamp')).address]; await deploy('PriceOracle', { from: deployer, @@ -13,6 +15,8 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, ne waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, }); + await execute('PriceOracle', { from: deployer }, 'setPrice', oldOraclePrice); + log('----------------------------------------------------'); }; diff --git a/deploy/test/002_deploy_oracle.ts b/deploy/test/002_deploy_oracle.ts index 2bf32861..fd475700 100644 --- a/deploy/test/002_deploy_oracle.ts +++ b/deploy/test/002_deploy_oracle.ts @@ -2,9 +2,11 @@ import { DeployFunction } from 'hardhat-deploy/types'; import { networkConfig } from '../../helper-hardhat-config'; const func: DeployFunction = async function ({ deployments, getNamedAccounts, network }) { - const { deploy, get, log } = deployments; + const { deploy, get, read, execute, log } = deployments; const { deployer } = await getNamedAccounts(); + const oldOraclePrice = await read('PriceOracle', 'currentPrice'); + const args = [(await get('PostageStamp')).address]; await deploy('PriceOracle', { from: deployer, @@ -13,6 +15,8 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, ne waitConfirmations: networkConfig[network.name]?.blockConfirmations || 6, }); + await execute('PriceOracle', { from: deployer }, 'setPrice', oldOraclePrice); + log('----------------------------------------------------'); };