-
Notifications
You must be signed in to change notification settings - Fork 10
feat(sharing): Deploy contracts using Hardhat Ignition #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
56ca934
Remove result proxy address from sharing contract
zguesmi e1de79b
Add cleanup todos
zguesmi 6696d42
Update changelog
zguesmi ca5bd50
Update abis
zguesmi a11ae61
Merge branch 'develop' into feature/deprecated-result-proxy-config
zguesmi 08a92dd
Add upgrade unit test
zguesmi 519e9c0
Format
zguesmi 32028df
Fix linting error
zguesmi 2813cc8
Clean
zguesmi 826b1cd
Clean
zguesmi c501af8
Include review
zguesmi 8dac743
Add PR number to changelog
zguesmi 0c2f2e7
Fix tests on the CI
zguesmi 32fd0e5
Run tests on hardhat network (forked)
zguesmi ad9ff43
Fix CI
zguesmi 25ebadb
Debug CI
zguesmi 14c94f1
Debug CI
zguesmi 62f0d1e
Debug CI
zguesmi 25f7d1f
Remove debugging flags
zguesmi 74e1c91
Clean
zguesmi 65e07fe
Debug upgrade tests on CI
zguesmi 7afc0af
Debug upgrade tests on CI
zguesmi ae4f26e
Remove upgrade tests as it interferes with local-fork script
zguesmi e330b35
Revert naming changes
zguesmi af797bd
Run tests on hardhat fork
zguesmi 2760952
Debug upgrade tests on CI
zguesmi c2e94d6
Merge branch 'develop' into feature/hardhat-ignition
zguesmi df06547
Install HH dep compiler
zguesmi 64e5c1e
Compile transparent proxy to create artifact
zguesmi 64822c9
Create ESM and Commonjs flavor of config and env files
zguesmi d9f50e3
Add ignition module to deploy contracts
zguesmi eaace5c
Remove old deployment file
zguesmi 35307ba
Update README
zguesmi e7393c7
Add create2 strategy to ignition config
zguesmi c47f370
Add new chains config
zguesmi 6c64506
Clean
zguesmi d7f31d6
Fix deployment
zguesmi 5513328
Clean
zguesmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. | ||
| // TODO refactor this to use ESM syntax when Hardhat Ignition supports it. | ||
|
|
||
| module.exports = { | ||
| POCO_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f', | ||
| DATASET_REGISTRY_ADDRESS: '0x799DAa22654128d0C64d5b79eac9283008158730', | ||
| APP_REGISTRY_ADDRESS: '0xB1C52075b276f87b1834919167312221d50c9D16', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export const SMART_CONTRACT_ADDRESS_FILE = '.smart-contract-address'; | ||
| export const POCO_ADDRESS = '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'; | ||
| export const DATASET_REGISTRY_ADDRESS = '0x799DAa22654128d0C64d5b79eac9283008158730'; | ||
| export const APP_REGISTRY_ADDRESS = '0xB1C52075b276f87b1834919167312221d50c9D16'; | ||
| import config from './config.cjs'; | ||
|
|
||
| export const POCO_ADDRESS = config.POCO_ADDRESS; | ||
| export const DATASET_REGISTRY_ADDRESS = config.DATASET_REGISTRY_ADDRESS; | ||
| export const APP_REGISTRY_ADDRESS = config.APP_REGISTRY_ADDRESS; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Hardhat Ignition does not support ESM modules, so we use CommonJS syntax. | ||
| // TODO refactor this to use ESM syntax when Hardhat Ignition supports it. | ||
|
|
||
| require('dotenv/config.js'); | ||
| const { z } = require('zod'); | ||
|
|
||
| const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{40}(\b|$)/; | ||
| const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; | ||
|
|
||
| const envSchema = z.object({ | ||
| // Private key of the wallet used for transactions | ||
| PRIVATE_KEY: z | ||
| .string() | ||
| .regex(privateKeyRegex, 'Invalid private key format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // environment to use for configuration (prod/staging) | ||
| ENV: z.enum(['prod', 'staging'], 'ENV must be either "prod" or "staging"').default('prod'), | ||
|
|
||
| // Address of the PoCo contract | ||
| POCO_ADDRESS: z | ||
| .string() | ||
| .regex(addressRegex, 'Invalid Ethereum address format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // Address of the DatasetRegistry | ||
| DATASET_REGISTRY_ADDRESS: z | ||
| .string() | ||
| .regex(addressRegex, 'Invalid Ethereum address format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // URL of the RPC used for network connection | ||
| RPC_URL: z.string().url('RPC_URL must be a valid URL').optional().or(z.literal('')), | ||
|
|
||
| // Mnemonic for deployment or network interaction | ||
| MNEMONIC: z.string().min(1, 'MNEMONIC cannot be empty').optional().or(z.literal('')), | ||
|
|
||
| FUJI_RPC_URL: z.string().url('FUJI_RPC_URL must be a valid URL').optional(), | ||
|
|
||
| ARBITRUM_SEPOLIA_RPC_URL: z | ||
| .string() | ||
| .url('ARBITRUM_SEPOLIA_RPC_URL must be a valid URL') | ||
| .optional(), | ||
| }); | ||
|
|
||
| module.exports = { | ||
| env: envSchema.parse(process.env), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,3 @@ | ||
| import 'dotenv/config.js'; | ||
| import { z } from 'zod'; | ||
| import _env from './env.cjs'; | ||
|
|
||
| const addressRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; | ||
| const privateKeyRegex = /(^|\b)(0x)?[0-9a-fA-F]{64}(\b|$)/; | ||
|
|
||
| const envSchema = z.object({ | ||
| // Private key of the wallet used for transactions | ||
| WALLET_PRIVATE_KEY: z | ||
| .string() | ||
| .regex(privateKeyRegex, 'Invalid private key format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // environment to use for configuration (prod/staging) | ||
| ENV: z.enum(['prod', 'staging'], 'ENV must be either "prod" or "staging"').default('prod'), | ||
|
|
||
| // Address of the PoCo contract | ||
| POCO_ADDRESS: z | ||
| .string() | ||
| .regex(addressRegex, 'Invalid Ethereum address format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // Address of the DatasetRegistry | ||
| DATASET_REGISTRY_ADDRESS: z | ||
| .string() | ||
| .regex(addressRegex, 'Invalid Ethereum address format') | ||
| .optional() | ||
| .or(z.literal('')), | ||
|
|
||
| // URL of the RPC used for network connection | ||
| RPC_URL: z.string().url('RPC_URL must be a valid URL').optional().or(z.literal('')), | ||
|
|
||
| // Mnemonic for deployment or network interaction | ||
| MNEMONIC: z.string().min(1, 'MNEMONIC cannot be empty').optional().or(z.literal('')), | ||
| }); | ||
|
|
||
| export const env = envSchema.parse(process.env); | ||
| export const env = _env.env; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); | ||
|
|
||
| const { | ||
| DATASET_REGISTRY_ADDRESS: defaultDatasetRegistryAddress, | ||
| POCO_ADDRESS: defaultPocoAddress, | ||
| } = require('../../config/config.cjs'); | ||
| const { env } = require('../../config/env.cjs'); | ||
|
|
||
| // Hardhat Ignition does not support ESM yet. | ||
|
|
||
| // @ts-ignore | ||
| module.exports = buildModule('DataProtectorSharingModule', (m) => { | ||
| const proxyAdminOwner = m.getAccount(0); | ||
| const pocoAddress = env.POCO_ADDRESS || defaultPocoAddress; | ||
| const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS || defaultDatasetRegistryAddress; | ||
|
|
||
| // Whitelist | ||
| const addOnlyAppWhitelistRegistryImpl = m.contract('AddOnlyAppWhitelistRegistry', [], { | ||
| id: 'AddOnlyAppWhitelistRegistryImpl', | ||
| }); | ||
| const addOnlyAppWhitelistRegistryProxy = m.contract( | ||
| 'TransparentUpgradeableProxy', | ||
| [ | ||
| addOnlyAppWhitelistRegistryImpl, | ||
| proxyAdminOwner, | ||
| '0x', // No initialization data. | ||
| ], | ||
| { | ||
| id: 'AddOnlyAppWhitelistRegistryProxy', | ||
| }, | ||
| ); | ||
| const addOnlyAppWhitelistRegistry = m.contractAt( | ||
| 'AddOnlyAppWhitelistRegistry', | ||
| addOnlyAppWhitelistRegistryProxy, | ||
| ); | ||
|
|
||
| // DPS | ||
| const dataProtectorSharingImpl = m.contract( | ||
| 'DataProtectorSharing', | ||
| [pocoAddress, datasetRegistryAddress, addOnlyAppWhitelistRegistryProxy], | ||
| { | ||
| id: 'DataProtectorSharingImpl', | ||
| }, | ||
| ); | ||
| const dataProtectorSharingProxy = m.contract( | ||
| 'TransparentUpgradeableProxy', | ||
| [ | ||
| dataProtectorSharingImpl, | ||
| proxyAdminOwner, | ||
| '0x', // No initialization data. | ||
| ], | ||
| { | ||
| id: 'DataProtectorSharingProxy', | ||
| }, | ||
| ); | ||
| const dataProtectorSharing = m.contractAt('DataProtectorSharing', dataProtectorSharingProxy); | ||
|
|
||
| return { addOnlyAppWhitelistRegistry, dataProtectorSharing }; | ||
| }); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can keep the logs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignition modules do not support
console.log, actions are automatically logged by Hardhat, cf logs in the PR description.