Skip to content

Commit 3142c6f

Browse files
committed
Add bsc support
1 parent 89aeb96 commit 3142c6f

15 files changed

+202
-71
lines changed

packages/contracts/deploy/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export async function populatePluginRepo(
378378
i,
379379
emptyJsonObject,
380380
ethers.utils.hexlify(
381-
ethers.utils.toUtf8Bytes(`ipfs://${hre.placeholderBuildCIDPath}`)
381+
ethers.utils.toUtf8Bytes(`${hre.placeholderBuildCIDPath}`)
382382
)
383383
);
384384
}

packages/contracts/deploy/new/30_plugins/00_plugin-setups/40_placeholder_setup.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {HardhatRuntimeEnvironment} from 'hardhat/types';
22
import {DeployFunction} from 'hardhat-deploy/types';
33
import {uploadToIPFS} from '../../../helpers';
4+
import {uploadToPinata} from '@aragon/osx-commons-sdk';
45

56
import placeholderSetupArtifact from '../../../../artifacts/src/plugins/placeholder-version/PlaceholderSetup.sol/PlaceholderSetup.json';
67
import placeholderBuildMetadata from '../../../../src/plugins/placeholder-version/build-metadata.json';
@@ -17,12 +18,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1718
log: true,
1819
});
1920

20-
const {network} = hre;
21+
let metadataCIDPath = '0x';
22+
23+
if (!process.env.PUB_PINATA_JWT) {
24+
throw new Error('PUB_PINATA_JWT is not set');
25+
}
2126

22-
hre.placeholderBuildCIDPath = await uploadToIPFS(
27+
// Upload the metadata to IPFS
28+
metadataCIDPath = await uploadToPinata(
2329
JSON.stringify(placeholderBuildMetadata),
24-
network.name
30+
`placeholderBuildMetadata`,
31+
process.env.PUB_PINATA_JWT
2532
);
33+
34+
hre.placeholderBuildCIDPath = metadataCIDPath
2635
};
2736

2837
export default func;

packages/contracts/deploy/new/30_plugins/10_plugin-repos/00_create_address_list_voting_repo.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
12
import addresslistBuildMetadata from '../../../../src/plugins/governance/majority-voting/addresslist/build-metadata.json';
23
import addresslistReleaseMetadata from '../../../../src/plugins/governance/majority-voting/addresslist/release-metadata.json';
34
import {
@@ -17,17 +18,24 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1718
'Please make sure pluginRepo is not created more than once with the same name.'
1819
);
1920

20-
const {network} = hre;
21+
if (!process.env.PUB_PINATA_JWT) {
22+
throw new Error('PUB_PINATA_JWT is not set');
23+
}
2124

22-
const addresslistReleaseCIDPath = await uploadToIPFS(
25+
const addresslistReleaseCIDPath = await uploadToPinata(
2326
JSON.stringify(addresslistReleaseMetadata),
24-
network.name
27+
`addresslistReleaseMetadata`,
28+
process.env.PUB_PINATA_JWT
2529
);
26-
const addresslistBuildCIDPath = await uploadToIPFS(
30+
31+
32+
const addresslistBuildCIDPath = await uploadToPinata(
2733
JSON.stringify(addresslistBuildMetadata),
28-
network.name
34+
`addresslistBuildMetadata`,
35+
process.env.PUB_PINATA_JWT
2936
);
3037

38+
3139
const addresslistVotingSetupContract = await getContractAddress(
3240
'AddresslistVotingSetup',
3341
hre
@@ -39,10 +47,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3947
versionTag: [1, 2],
4048
pluginSetupContract: addresslistVotingSetupContract,
4149
releaseMetadata: ethers.utils.hexlify(
42-
ethers.utils.toUtf8Bytes(`ipfs://${addresslistReleaseCIDPath}`)
50+
ethers.utils.toUtf8Bytes(`${addresslistReleaseCIDPath}`)
4351
),
4452
buildMetadata: ethers.utils.hexlify(
45-
ethers.utils.toUtf8Bytes(`ipfs://${addresslistBuildCIDPath}`)
53+
ethers.utils.toUtf8Bytes(`${addresslistBuildCIDPath}`)
4654
),
4755
},
4856
]);

packages/contracts/deploy/new/30_plugins/10_plugin-repos/10_create_token_voting_repo.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
12
import tokenVotingBuildMetadata from '../../../../src/plugins/governance/majority-voting/token/build-metadata.json';
23
import tokenVotingReleaseMetadata from '../../../../src/plugins/governance/majority-voting/token/release-metadata.json';
34
import {
@@ -18,15 +19,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1819
'Please make sure pluginRepo is not created more than once with the same name.'
1920
);
2021

21-
const {network} = hre;
22+
if (!process.env.PUB_PINATA_JWT) {
23+
throw new Error('PUB_PINATA_JWT is not set');
24+
}
2225

23-
const tokenVotingReleaseCIDPath = await uploadToIPFS(
26+
const tokenVotingReleaseCIDPath = await uploadToPinata(
2427
JSON.stringify(tokenVotingReleaseMetadata),
25-
network.name
28+
`tokenVotingReleaseMetadata`,
29+
process.env.PUB_PINATA_JWT
2630
);
27-
const tokenVotingBuildCIDPath = await uploadToIPFS(
31+
32+
const tokenVotingBuildCIDPath = await uploadToPinata(
2833
JSON.stringify(tokenVotingBuildMetadata),
29-
network.name
34+
`tokenVotingBuildMetadata`,
35+
process.env.PUB_PINATA_JWT
3036
);
3137

3238
const tokenVotingSetupContract = await getTokenVotingSetupAddress(hre);
@@ -37,10 +43,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3743
versionTag: [1, 2],
3844
pluginSetupContract: tokenVotingSetupContract,
3945
releaseMetadata: ethers.utils.hexlify(
40-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingReleaseCIDPath}`)
46+
ethers.utils.toUtf8Bytes(`${tokenVotingReleaseCIDPath}`)
4147
),
4248
buildMetadata: ethers.utils.hexlify(
43-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingBuildCIDPath}`)
49+
ethers.utils.toUtf8Bytes(`${tokenVotingBuildCIDPath}`)
4450
),
4551
},
4652
]);

packages/contracts/deploy/new/30_plugins/10_plugin-repos/20_create_admin_repo.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
12
import adminBuildMetadata from '../../../../src/plugins/governance/admin/build-metadata.json';
23
import adminReleaseMetadata from '../../../../src/plugins/governance/admin/release-metadata.json';
34
import {
@@ -18,15 +19,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1819
'Please make sure pluginRepo is not created more than once with the same name.'
1920
);
2021

21-
const {network} = hre;
22+
if (!process.env.PUB_PINATA_JWT) {
23+
throw new Error('PUB_PINATA_JWT is not set');
24+
}
2225

23-
const adminReleaseCIDPath = await uploadToIPFS(
26+
const adminReleaseCIDPath = await uploadToPinata(
2427
JSON.stringify(adminReleaseMetadata),
25-
network.name
28+
`adminReleaseMetadata`,
29+
process.env.PUB_PINATA_JWT
2630
);
27-
const adminBuildCIDPath = await uploadToIPFS(
31+
32+
const adminBuildCIDPath = await uploadToPinata(
2833
JSON.stringify(adminBuildMetadata),
29-
network.name
34+
`adminBuildMetadata`,
35+
process.env.PUB_PINATA_JWT
3036
);
3137

3238
const adminSetupContract = await getContractAddress('AdminSetup', hre);
@@ -37,10 +43,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3743
versionTag: [1, 1],
3844
pluginSetupContract: adminSetupContract,
3945
releaseMetadata: ethers.utils.hexlify(
40-
ethers.utils.toUtf8Bytes(`ipfs://${adminReleaseCIDPath}`)
46+
ethers.utils.toUtf8Bytes(`${adminReleaseCIDPath}`)
4147
),
4248
buildMetadata: ethers.utils.hexlify(
43-
ethers.utils.toUtf8Bytes(`ipfs://${adminBuildCIDPath}`)
49+
ethers.utils.toUtf8Bytes(`${adminBuildCIDPath}`)
4450
),
4551
},
4652
]);

packages/contracts/deploy/new/30_plugins/10_plugin-repos/30_create_multisig_repo.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
uploadToIPFS,
1212
} from '../../../helpers';
1313
import {ethers} from 'ethers';
14+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
1415

1516
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1617
console.log(`\nCreating multisig repo.`);
@@ -19,15 +20,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1920
'Please make sure pluginRepo is not created more than once with the same name.'
2021
);
2122

22-
const {network} = hre;
23+
if (!process.env.PUB_PINATA_JWT) {
24+
throw new Error('PUB_PINATA_JWT is not set');
25+
}
2326

24-
const multisigReleaseCIDPath = await uploadToIPFS(
27+
const multisigReleaseCIDPath = await uploadToPinata(
2528
JSON.stringify(multisigReleaseMetadata),
26-
network.name
29+
`multisigReleaseMetadata`,
30+
process.env.PUB_PINATA_JWT
2731
);
28-
const multisigBuildCIDPath = await uploadToIPFS(
32+
33+
const multisigBuildCIDPath = await uploadToPinata(
2934
JSON.stringify(multisigBuildMetadata),
30-
network.name
35+
`multisigBuildMetadata`,
36+
process.env.PUB_PINATA_JWT
3137
);
3238

3339
const multisigSetupContract = await getContractAddress('MultisigSetup', hre);
@@ -38,10 +44,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3844
versionTag: [1, 2],
3945
pluginSetupContract: multisigSetupContract,
4046
releaseMetadata: ethers.utils.hexlify(
41-
ethers.utils.toUtf8Bytes(`ipfs://${multisigReleaseCIDPath}`)
47+
ethers.utils.toUtf8Bytes(`${multisigReleaseCIDPath}`)
4248
),
4349
buildMetadata: ethers.utils.hexlify(
44-
ethers.utils.toUtf8Bytes(`ipfs://${multisigBuildCIDPath}`)
50+
ethers.utils.toUtf8Bytes(`${multisigBuildCIDPath}`)
4551
),
4652
},
4753
]);

packages/contracts/deploy/new/40_finalize-managing-dao/20_register-managing-dao-on-dao-registry.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {getContractAddress, getENSAddress, uploadToIPFS} from '../../helpers';
77
import {DeployFunction} from 'hardhat-deploy/types';
88
import {HardhatRuntimeEnvironment} from 'hardhat/types';
99
import MANAGING_DAO_METADATA from '../../management-dao-metadata.json';
10+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
1011

1112
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1213
const {ethers, network} = hre;
@@ -72,9 +73,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7273
managingDAOAddress,
7374
deployer
7475
);
75-
const metadataCIDPath = await uploadToIPFS(
76+
77+
if (!process.env.PUB_PINATA_JWT) {
78+
throw new Error('PUB_PINATA_JWT is not set');
79+
}
80+
81+
const metadataCIDPath = await uploadToPinata(
7682
JSON.stringify(MANAGING_DAO_METADATA),
77-
network.name
83+
`MANAGING_DAO_METADATA`,
84+
process.env.PUB_PINATA_JWT
7885
);
7986

8087
const hasMetadataPermission = await managingDaoContract.hasPermission(
@@ -89,7 +96,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
8996
if (hasMetadataPermission) {
9097
const setMetadataTX = await managingDaoContract.setMetadata(
9198
ethers.utils.hexlify(
92-
ethers.utils.toUtf8Bytes(`ipfs://${metadataCIDPath}`)
99+
ethers.utils.toUtf8Bytes(`${metadataCIDPath}`)
93100
)
94101
);
95102
await setMetadataTX.wait();

packages/contracts/deploy/update/to_v1.3.0/31_Multisig_Plugin.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import multisigSetupArtifact from '../../../artifacts/src/plugins/governance/mul
77

88
import multisigReleaseMetadata from '../../../src/plugins/governance/multisig/release-metadata.json';
99
import multisigBuildMetadata from '../../../src/plugins/governance/multisig/build-metadata.json';
10+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
1011

1112
const TARGET_RELEASE = 1;
1213

@@ -23,13 +24,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2324
log: true,
2425
});
2526

26-
const multisigReleaseCIDPath = await uploadToIPFS(
27+
if (!process.env.PUB_PINATA_JWT) {
28+
throw new Error('PUB_PINATA_JWT is not set');
29+
}
30+
31+
const multisigReleaseCIDPath = await uploadToPinata(
2732
JSON.stringify(multisigReleaseMetadata),
28-
network.name
33+
`multisigReleaseMetadata`,
34+
process.env.PUB_PINATA_JWT
2935
);
30-
const multisigBuildCIDPath = await uploadToIPFS(
36+
37+
const multisigBuildCIDPath = await uploadToPinata(
3138
JSON.stringify(multisigBuildMetadata),
32-
network.name
39+
`multisigBuildMetadata`,
40+
process.env.PUB_PINATA_JWT
3341
);
3442

3543
const multisigRepoAddress = await getContractAddress('multisig-repo', hre);
@@ -51,8 +59,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5159
.createVersion(
5260
TARGET_RELEASE,
5361
deployResult.address,
54-
ethers.utils.toUtf8Bytes(`ipfs://${multisigBuildCIDPath}`),
55-
ethers.utils.toUtf8Bytes(`ipfs://${multisigReleaseCIDPath}`)
62+
ethers.utils.toUtf8Bytes(`${multisigBuildCIDPath}`),
63+
ethers.utils.toUtf8Bytes(`${multisigReleaseCIDPath}`)
5664
);
5765
console.log(`Creating new multisig build version with ${tx.hash}`);
5866
await tx.wait();
@@ -64,8 +72,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
6472
.populateTransaction.createVersion(
6573
TARGET_RELEASE,
6674
deployResult.address,
67-
ethers.utils.toUtf8Bytes(`ipfs://${multisigBuildCIDPath}`),
68-
ethers.utils.toUtf8Bytes(`ipfs://${multisigReleaseCIDPath}`)
75+
ethers.utils.toUtf8Bytes(`${multisigBuildCIDPath}`),
76+
ethers.utils.toUtf8Bytes(`${multisigReleaseCIDPath}`)
6977
);
7078

7179
if (!tx.to || !tx.data) {

packages/contracts/deploy/update/to_v1.3.0/41_TokenVoting_Plugin.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import tokenVotingSetupArtifact from '../../../artifacts/src/plugins/governance/
99
import tokenVotingReleaseMetadata from '../../../src/plugins/governance/majority-voting/token/release-metadata.json';
1010
import tokenVotingBuildMetadata from '../../../src/plugins/governance/majority-voting/token/build-metadata.json';
1111
import {MintSettings} from '../../../test/token/erc20/governance-erc20';
12+
import { uploadToPinata } from '@aragon/osx-commons-sdk';
1213

1314
const TARGET_RELEASE = 1;
1415

@@ -56,13 +57,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5657
log: true,
5758
});
5859

59-
const tokenVotingReleaseCIDPath = await uploadToIPFS(
60+
if (!process.env.PUB_PINATA_JWT) {
61+
throw new Error('PUB_PINATA_JWT is not set');
62+
}
63+
64+
const tokenVotingReleaseCIDPath = await uploadToPinata(
6065
JSON.stringify(tokenVotingReleaseMetadata),
61-
network.name
66+
`tokenVotingReleaseMetadata`,
67+
process.env.PUB_PINATA_JWT
6268
);
63-
const tokenVotingBuildCIDPath = await uploadToIPFS(
69+
70+
const tokenVotingBuildCIDPath = await uploadToPinata(
6471
JSON.stringify(tokenVotingBuildMetadata),
65-
network.name
72+
`tokenVotingBuildMetadata`,
73+
process.env.PUB_PINATA_JWT
6674
);
6775

6876
const tokenVotingRepoAddress = await getContractAddress(
@@ -87,8 +95,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
8795
.createVersion(
8896
TARGET_RELEASE,
8997
deployResult.address,
90-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingBuildCIDPath}`),
91-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingReleaseCIDPath}`)
98+
ethers.utils.toUtf8Bytes(`${tokenVotingBuildCIDPath}`),
99+
ethers.utils.toUtf8Bytes(`${tokenVotingReleaseCIDPath}`)
92100
);
93101
console.log(`Creating new TokenVoting build version with ${tx.hash}`);
94102
await tx.wait();
@@ -100,8 +108,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
100108
.populateTransaction.createVersion(
101109
TARGET_RELEASE,
102110
deployResult.address,
103-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingBuildCIDPath}`),
104-
ethers.utils.toUtf8Bytes(`ipfs://${tokenVotingReleaseCIDPath}`)
111+
ethers.utils.toUtf8Bytes(`${tokenVotingBuildCIDPath}`),
112+
ethers.utils.toUtf8Bytes(`${tokenVotingReleaseCIDPath}`)
105113
);
106114

107115
if (!tx.to || !tx.data) {

0 commit comments

Comments
 (0)