44import { ZeroAddress } from 'ethers' ;
55import { ethers } from 'hardhat' ;
66import { FacetCutAction } from 'hardhat-deploy/dist/types' ;
7- import type { IDiamond } from '../../../ typechain' ;
7+ import type { IDiamond } from '../../typechain' ;
88import {
99 DiamondCutFacet__factory ,
1010 DiamondLoupeFacet__factory ,
11+ IexecPoco1Facet__factory ,
1112 IexecPocoAccessorsFacet__factory ,
12- } from '../../../ typechain' ;
13- import { Ownable__factory } from '../../../ typechain/factories/rlc-faucet-contract/contracts' ;
14- import { FactoryDeployer } from '../../../ utils/FactoryDeployer' ;
15- import config from '../../../ utils/config' ;
16- import { linkContractToProxy } from '../../../ utils/proxy-tools' ;
17- import { printFunctions } from '.. /upgrade-helper' ;
13+ } from '../../typechain' ;
14+ import { Ownable__factory } from '../../typechain/factories/rlc-faucet-contract/contracts' ;
15+ import { FactoryDeployer } from '../../utils/FactoryDeployer' ;
16+ import config from '../../utils/config' ;
17+ import { linkContractToProxy } from '../../utils/proxy-tools' ;
18+ import { printFunctions } from './upgrade-helper' ;
1819
1920( async ( ) => {
20- console . log ( 'Deploying and updating IexecPocoAccessorsFacet...' ) ;
21+ console . log ( 'Deploying and updating IexecPocoAccessorsFacet & IexecPoco1Facet ...' ) ;
2122
2223 const [ account ] = await ethers . getSigners ( ) ;
2324 const chainId = ( await ethers . provider . getNetwork ( ) ) . chainId ;
@@ -47,18 +48,25 @@ import { printFunctions } from '../upgrade-helper';
4748 proxyOwnerSigner ,
4849 ) ;
4950
50- console . log ( '\n=== Step 1: Deploying new IexecPocoAccessorsFacet ===' ) ;
51+ console . log ( '\n=== Step 1: Deploying all new facets ===' ) ;
5152 const factoryDeployer = new FactoryDeployer ( account , chainId ) ;
5253 const iexecLibOrders = {
5354 [ 'contracts/libs/IexecLibOrders_v5.sol:IexecLibOrders_v5' ] :
5455 deploymentOptions . IexecLibOrders_v5 ,
5556 } ;
5657
57- const newFacetFactory = new IexecPocoAccessorsFacet__factory ( iexecLibOrders ) ;
58- const newFacetAddress = await factoryDeployer . deployContract ( newFacetFactory ) ;
58+ console . log ( 'Deploying new IexecPocoAccessorsFacet...' ) ;
59+ const iexecPocoAccessorsFacetFactory = new IexecPocoAccessorsFacet__factory ( iexecLibOrders ) ;
60+ const iexecPocoAccessorsFacet = await factoryDeployer . deployContract (
61+ new IexecPocoAccessorsFacet__factory ( iexecLibOrders ) ,
62+ ) ;
63+
64+ console . log ( 'Deploying new IexecPoco1Facet...' ) ;
65+ const newIexecPoco1FacetFactory = new IexecPoco1Facet__factory ( iexecLibOrders ) ;
66+ const newIexecPoco1Facet = await factoryDeployer . deployContract ( newIexecPoco1FacetFactory ) ;
5967
6068 console . log (
61- '\n=== Step 2: Remove old facets (remove all functions of old accessors facets ) ===' ,
69+ '\n=== Step 2: Remove old facets (IexecAccessorsFacet & IexecPocoAccessorsFacet & IexecPoco1Facet ) ===' ,
6270 ) ;
6371
6472 const diamondLoupe = DiamondLoupeFacet__factory . connect ( diamondProxyAddress , account ) ;
@@ -99,16 +107,17 @@ import { printFunctions } from '../upgrade-helper';
99107 } ) ;
100108 }
101109
102- const oldAccessorFacets = [
110+ const oldFacets = [
103111 '0xEa232be31ab0112916505Aeb7A2a94b5571DCc6b' , //IexecAccessorsFacet
104112 '0xeb40697b275413241d9b31dE568C98B3EA12FFF0' , //IexecPocoAccessorsFacet
113+ '0x46b555fE117DFd8D4eAC2470FA2d739c6c3a0152' , //IexecPoco1Facet
105114 ] ;
106- // Remove ALL functions from the old accessor facets using diamondLoupe.facetFunctionSelectors() except of constant founctions
107- for ( const facetAddress of oldAccessorFacets ) {
115+ // Remove ALL functions from the old facets using diamondLoupe.facetFunctionSelectors() except of constant founctions
116+ for ( const facetAddress of oldFacets ) {
108117 const selectors = await diamondLoupe . facetFunctionSelectors ( facetAddress ) ;
109118 if ( selectors . length > 0 ) {
110119 console . log (
111- `Removing old accessor facet ${ facetAddress } with ${ selectors . length } functions - will remove ALL` ,
120+ `Removing old facet ${ facetAddress } with ${ selectors . length } functions - will remove ALL` ,
112121 ) ;
113122 removalCuts . push ( {
114123 facetAddress : ZeroAddress ,
@@ -131,12 +140,23 @@ import { printFunctions } from '../upgrade-helper';
131140 console . log ( 'Diamond functions after removing old facets:' ) ;
132141 await printFunctions ( diamondProxyAddress ) ;
133142 }
134- console . log ( '\n=== Step 3: Updating diamond proxy with new facet ===' ) ;
135- await linkContractToProxy ( diamondProxyAsOwner , newFacetAddress , newFacetFactory ) ;
136- console . log ( 'New functions added successfully' ) ;
143+ console . log ( '\n=== Step 3: Updating diamond proxy with all new facets ===' ) ;
144+ console . log ( 'Adding new IexecPocoAccessorsFacet...' ) ;
145+ await linkContractToProxy (
146+ diamondProxyAsOwner ,
147+ iexecPocoAccessorsFacet ,
148+ iexecPocoAccessorsFacetFactory ,
149+ ) ;
150+ console . log ( 'New IexecPocoAccessorsFacet added successfully' ) ;
151+
152+ console . log ( 'Adding new IexecPoco1Facet ...' ) ;
153+ await linkContractToProxy ( diamondProxyAsOwner , newIexecPoco1Facet , newIexecPoco1FacetFactory ) ;
154+ console . log ( 'New IexecPoco1Facet with isDatasetCompatibleWithDeal added successfully' ) ;
137155
138- console . log ( 'Diamond functions after adding new facet :' ) ;
156+ console . log ( 'Diamond functions after adding new facets :' ) ;
139157 await printFunctions ( diamondProxyAddress ) ;
140158
141159 console . log ( '\nUpgrade completed successfully!' ) ;
160+ console . log ( `New IexecPocoAccessorsFacet deployed at: ${ iexecPocoAccessorsFacet } ` ) ;
161+ console . log ( `New IexecPoco1Facet deployed at: ${ newIexecPoco1Facet } ` ) ;
142162} ) ( ) ;
0 commit comments