Skip to content

Commit 83863d6

Browse files
committed
feat: enhance deployment process with improved error handling and fallback strategy for CREATE2
1 parent 1c6e10b commit 83863d6

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

packages/sharing-smart-contract/hardhat.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module.exports = {
145145
ignition: {
146146
strategyConfig: {
147147
create2: {
148-
salt: "0x0000000000000000000000000000000000000000000000000000000000000001",
148+
salt: "0x0000000000000000000000000000000000000001000000000000000000000001",
149149
},
150150
},
151151
},

packages/sharing-smart-contract/scripts/deploy.js

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,38 @@ async function main() {
3131
console.log('⚠️ CreateX factory is NOT supported.');
3232
}
3333
// Deploy contracts using Ignition module.
34-
const { addOnlyAppWhitelistRegistry, dataProtectorSharing } = await hre.ignition.deploy(
35-
DataProtectorSharingModule,
36-
{
37-
...(isCreatexSupported && {
38-
strategy: 'create2',
39-
strategyConfig: hre.userConfig.ignition.strategyConfig.create2,
40-
}),
41-
displayUi: true, // for logs.
42-
...(deploymentId && { deploymentId }),
43-
},
44-
);
34+
let deploymentResult;
35+
try {
36+
console.log(`Attempting deployment${isCreatexSupported ? ' with CREATE2 strategy' : ''}...`);
37+
deploymentResult = await hre.ignition.deploy(
38+
DataProtectorSharingModule,
39+
{
40+
...(isCreatexSupported && {
41+
strategy: 'create2',
42+
strategyConfig: hre.userConfig.ignition.strategyConfig.create2,
43+
}),
44+
displayUi: true, // for logs.
45+
...(deploymentId && { deploymentId }),
46+
},
47+
);
48+
console.log(`✅ Deployment successful${isCreatexSupported ? ' with CREATE2' : ''}!`);
49+
} catch (error) {
50+
if (isCreatexSupported && (error.message.includes('FailedContractCreation') || error.message.includes('CREATE2'))) {
51+
console.log('⚠️ CREATE2 deployment failed, falling back to normal deployment...');
52+
console.log(`Error details: ${error.message}`);
53+
deploymentResult = await hre.ignition.deploy(
54+
DataProtectorSharingModule,
55+
{
56+
displayUi: true, // for logs.
57+
...(deploymentId && { deploymentId }),
58+
},
59+
);
60+
console.log('✅ Fallback deployment successful!');
61+
} else {
62+
throw error;
63+
}
64+
}
65+
const { addOnlyAppWhitelistRegistry, dataProtectorSharing } = deploymentResult;
4566
// Import proxies in OZ `upgrades` plugin for future upgrades.
4667
console.log(`Importing proxy contracts in OZ upgrades...`);
4768
const whitelistProxyAddress = await addOnlyAppWhitelistRegistry.getAddress();

0 commit comments

Comments
 (0)