Skip to content

Commit

Permalink
Feat/add peaq support (#53)
Browse files Browse the repository at this point in the history
* add peaq support

* improve installation

* update packages for verification

* Update packages/contracts/hardhat.config.ts

Co-authored-by: Jør∂¡ <[email protected]>

---------

Co-authored-by: Jør∂¡ <[email protected]>
  • Loading branch information
Rekard0 and brickpop authored Feb 26, 2025
1 parent 2177e56 commit 3e7003c
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 61 deletions.
14 changes: 11 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,24 @@ ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
# Note that addresses will be also used for testing so ensure they are valid on the network you are running the forking tests on.

# optional, address if not provided will get it from the latest deployment on the network or from the ens registrar
# defined in the framework if it supports it. In case it is not found will create a new one.
PLUGIN_REPO_ADDRESS=0x0000000000000000000000000000000000000000
# not optional, if not provided will not be able to deploy the plugin or run the forking tests.
# defined in the framework if it supports it. In case it is not found will create a new one.
# For example for mainnet:
# 0x8c278e37D0817210E18A7958524b7D0a1fAA6F7b
PLUGIN_REPO_ADDRESS=0x0000000000000000000000000000000000000000
# not optional, if not provided will not be able to deploy the plugin or run the forking tests.
# For example for mainnet:
# 0xaac9E9cdb8C1eb42d881ADd59Ee9c53847a3a4f3
PLUGIN_REPO_FACTORY_ADDRESS=0x0000000000000000000000000000000000000000
# optional, only needed when a latest versions of the plugin are going to be deploy on a new network.
PLACEHOLDER_SETUP=0x0000000000000000000000000000000000000000
# not optional, if not provided will not be able to transfer the ownership of the plugin when deploying
# the plugin or running the forking tests, or when the plugin is going to be installed on the management dao.
# for example for mainnet:
# 0xf2d594F3C93C19D7B1a6F15B5489FFcE4B01f7dA
MANAGEMENT_DAO_ADDRESS=0x0000000000000000000000000000000000000000
# optional, only needed when the plugin is going to be installed on the management dao.
# for example for mainnet:
# 0xE978942c691e43f65c1B7c7F8f1dc8cDF061B13f
PLUGIN_SETUP_PROCESSOR_ADDRESS=0x0000000000000000000000000000000000000000

## Plugin installation in management DAO
Expand Down
28 changes: 16 additions & 12 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,24 @@ func.skip = async (hre: HardhatRuntimeEnvironment) => {
throw `PluginRepo '${pluginEnsDomain(hre)}' does not exist yet.`;
}

const pastVersions = await getPastVersionCreatedEvents(pluginRepo);
try {
const pastVersions = await getPastVersionCreatedEvents(pluginRepo);

// Check if the version was published already
const filteredLogs = pastVersions.filter(
items =>
items.event.args.release === VERSION.release &&
items.event.args.build === VERSION.build
);

if (filteredLogs.length !== 0) {
console.log(
`Build number ${VERSION.build} has already been published for release ${VERSION.release}. Skipping publication...`
// Check if the version was published already
const filteredLogs = pastVersions.filter(
items =>
items.event.args.release === VERSION.release &&
items.event.args.build === VERSION.build
);
return true;

if (filteredLogs.length !== 0) {
console.log(
`Build number ${VERSION.build} has already been published for release ${VERSION.release}. Skipping publication...`
);
return true;
}
} catch (error) {
console.log(`Error in geting previouse version ${error}.`);
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
{
pluginSetupRef,
data,
},
{
gasLimit: 30000000,
}
);

Expand Down Expand Up @@ -133,23 +130,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
},
];

await managementDAO.applyMultiTargetPermissions(permissionsToGrant);
const applyPermissionTx = await managementDAO.applyMultiTargetPermissions(
permissionsToGrant
);
await applyPermissionTx.wait();

// Apply multisig plugin to the managementDAO
const applyTx = await pspContract.applyInstallation(
managementDAO.address,
{
helpersHash: hashHelpers(
installationPreparedEvent.preparedSetupData.helpers
),
permissions: installationPreparedEvent.preparedSetupData.permissions,
plugin: installationPreparedEvent.plugin,
pluginSetupRef,
},
{
gasLimit: 30000000,
}
);
const applyTx = await pspContract.applyInstallation(managementDAO.address, {
helpersHash: hashHelpers(
installationPreparedEvent.preparedSetupData.helpers
),
permissions: installationPreparedEvent.preparedSetupData.permissions,
plugin: installationPreparedEvent.plugin,
pluginSetupRef,
});
await applyTx.wait();

const multisigPluginPermission = {
Expand Down Expand Up @@ -184,15 +178,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// ROOT_PERMISSION permission on the management dao from deployer
// ROOT_PERMISSION permission on the management dao from psp
// APPLY_INSTALLATION_PERMISSION permission on the PSP from deployer
// EXECUTE_PERMISSION permission on the management dao from deployer
const permissionsToRevoke: DAOStructs.MultiTargetPermissionStruct[] = [
{
operation: Operation.Revoke,
where: managementDAO.address,
who: deployer.address,
condition: ethers.constants.AddressZero,
permissionId: DAO_PERMISSIONS.ROOT_PERMISSION_ID,
},
{
operation: Operation.Revoke,
where: managementDAO.address,
Expand All @@ -213,11 +199,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
where: managementDAO.address,
who: deployer.address,
condition: ethers.constants.AddressZero,
permissionId: DAO_PERMISSIONS.EXECUTE_PERMISSION_ID,
permissionId: DAO_PERMISSIONS.ROOT_PERMISSION_ID,
},
];

await managementDAO.applyMultiTargetPermissions(permissionsToRevoke);
const revokePermissionsTx = await managementDAO.applyMultiTargetPermissions(
permissionsToRevoke
);
await revokePermissionsTx.wait();

console.log('Permissions revoked....');

Expand Down
27 changes: 24 additions & 3 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
SupportedNetworks,
} from '@aragon/osx-commons-configs';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-etherscan';
import '@nomicfoundation/hardhat-network-helpers';
import '@nomicfoundation/hardhat-verify';
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import {config as dotenvConfig} from 'dotenv';
Expand Down Expand Up @@ -88,7 +88,18 @@ function getHardhatNetworkAccountsConfig(
}

// Add the accounts specified in the `.env` file to the networks from osx-commons-configs
const networks: {[index: string]: NetworkUserConfig} = osxCommonsConfigNetworks;
const networks: {[index: string]: NetworkUserConfig} = {
...osxCommonsConfigNetworks,
agungTestnet: {
url: 'https://wss-async.agung.peaq.network',
chainId: 9990,
gasPrice: 35000000000,
},
peaq: {
url: 'https://erpc-mpfn1.peaq.network',
chainId: 3338,
},
};
for (const network of Object.keys(networks) as SupportedNetworks[]) {
networks[network].accounts = specifiedAccounts();
}
Expand Down Expand Up @@ -136,6 +147,7 @@ const config: HardhatUserConfig = {
polygon: process.env.POLYGONSCAN_API_KEY || '',
base: process.env.BASESCAN_API_KEY || '',
arbitrumOne: process.env.ARBISCAN_API_KEY || '',
peaq: '1',
},
customChains: [
{
Expand All @@ -154,6 +166,15 @@ const config: HardhatUserConfig = {
browserURL: 'https://basescan.org',
},
},
{
network: 'peaq',
chainId: 3338,
urls: {
apiURL:
'https://peaq.api.subscan.io/api/scan/evm/contract/verifysource',
browserURL: 'https://peaq.subscan.io/',
},
},
],
},

Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"@matterlabs/hardhat-zksync-solc": "1.2.5",
"@matterlabs/hardhat-zksync-upgradable": "0.4.0",
"@matterlabs/hardhat-zksync-verify": "0.7.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@openzeppelin/hardhat-upgrades": "^1.28.0",
"@nomicfoundation/hardhat-verify": "^1.0.4",
"@typechain/ethers-v5": "^10.1.1",
"@typechain/hardhat": "^6.1.4",
"@types/chai": "^4.3.4",
Expand Down
56 changes: 44 additions & 12 deletions packages/contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@
"@nomicfoundation/ethereumjs-rlp" "5.0.4"
ethereum-cryptography "0.1.3"

"@nomicfoundation/hardhat-chai-matchers@^1.0.6":
"@nomicfoundation/hardhat-chai-matchers@^1.0.5":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-chai-matchers/-/hardhat-chai-matchers-1.0.6.tgz#72a2e312e1504ee5dd73fe302932736432ba96bc"
integrity sha512-f5ZMNmabZeZegEfuxn/0kW+mm7+yV7VNDxLpMOMGXWFJ2l/Ct3QShujzDRF9cOkK9Ui/hbDeOWGZqyQALDXVCQ==
Expand All @@ -915,10 +915,20 @@
dependencies:
ethereumjs-util "^7.1.4"

"@nomicfoundation/hardhat-toolbox@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-toolbox/-/hardhat-toolbox-2.0.2.tgz#ec95f23b53cb4e71a1a7091380fa223aad18f156"
integrity sha512-vnN1AzxbvpSx9pfdRHbUzTRIXpMLPXnUlkW855VaDk6N1pwRaQ2gNzEmFAABk4lWf11E00PKwFd/q27HuwYrYg==
"@nomicfoundation/hardhat-verify@^1.0.4":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-1.1.1.tgz#6a433d777ce0172d1f0edf7f2d3e1df14b3ecfc1"
integrity sha512-9QsTYD7pcZaQFEA3tBb/D/oCStYDiEVDN7Dxeo/4SCyHRSm86APypxxdOMEPlGmXsAvd+p1j/dTODcpxb8aztA==
dependencies:
"@ethersproject/abi" "^5.1.2"
"@ethersproject/address" "^5.0.2"
cbor "^8.1.0"
chalk "^2.4.2"
debug "^4.1.1"
lodash.clonedeep "^4.5.0"
semver "^6.3.0"
table "^6.8.0"
undici "^5.14.0"

"@nomicfoundation/hardhat-verify@^2.0.8":
version "2.0.12"
Expand Down Expand Up @@ -999,7 +1009,7 @@
fs-extra "^7.0.1"
node-fetch "^2.6.0"

"@nomiclabs/hardhat-ethers@^2.2.3":
"@nomiclabs/hardhat-ethers@^2.2.1":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0"
integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg==
Expand Down Expand Up @@ -7043,8 +7053,7 @@ string-format@^2.0.0:
resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b"
integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
name string-width-cjs
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -7070,6 +7079,15 @@ string-width@^2.1.1:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -7098,8 +7116,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -7120,6 +7137,13 @@ strip-ansi@^4.0.0:
dependencies:
ansi-regex "^3.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -8327,8 +8351,7 @@ workerpool@^6.5.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -8345,6 +8368,15 @@ wrap-ansi@^2.0.0:
string-width "^1.0.1"
strip-ansi "^3.0.1"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 3e7003c

Please sign in to comment.