@skalenetwork/upgrade-tools 1.0.0-develop.6 → 1.0.0-develop.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hardhat.config.js +1 -1
- package/dist/src/deploy.js +3 -1
- package/dist/src/upgrade.d.ts +2 -1
- package/dist/src/upgrade.js +24 -1
- package/package.json +1 -1
package/dist/hardhat.config.js
CHANGED
package/dist/src/deploy.js
CHANGED
|
@@ -90,7 +90,9 @@ function getContractFactory(contract) {
|
|
|
90
90
|
Object.assign(libraryArtifacts, manifest.libraries);
|
|
91
91
|
}
|
|
92
92
|
finally {
|
|
93
|
-
|
|
93
|
+
if (manifest !== undefined) {
|
|
94
|
+
Object.assign(manifest, { libraries: libraryArtifacts });
|
|
95
|
+
}
|
|
94
96
|
yield fs_1.promises.writeFile(yield getManifestFile(), JSON.stringify(manifest, null, 4));
|
|
95
97
|
}
|
|
96
98
|
return yield getLinkedContractFactory(contract, libraries);
|
package/dist/src/upgrade.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import { Contract } from "ethers";
|
|
|
3
3
|
import { OwnableUpgradeable } from "../typechain-types";
|
|
4
4
|
export declare function getContractFactoryAndUpdateManifest(contract: string): Promise<import("ethers").ContractFactory>;
|
|
5
5
|
declare type DeploymentAction<ContractManagerType extends Contract> = (safeTransactions: string[], abi: SkaleABIFile, contractManager: ContractManagerType) => Promise<void>;
|
|
6
|
-
|
|
6
|
+
declare type MultiTransactionAction<ContractManagerType extends Contract> = (abi: SkaleABIFile, contractManager: ContractManagerType) => Promise<string[][]>;
|
|
7
|
+
export declare function upgrade<ContractManagerType extends OwnableUpgradeable>(projectName: string, targetVersion: string, getDeployedVersion: (abi: SkaleABIFile) => Promise<string | undefined>, setVersion: (safeTransaction: string[], abi: SkaleABIFile, newVersion: string) => Promise<void>, safeMockAccessRequirements: string[], contractNamesToUpgrade: string[], deployNewContracts: DeploymentAction<ContractManagerType>, initialize: DeploymentAction<ContractManagerType>, afterUpgrade?: MultiTransactionAction<ContractManagerType>): Promise<void>;
|
|
7
8
|
export {};
|
package/dist/src/upgrade.js
CHANGED
|
@@ -62,7 +62,7 @@ function getContractFactoryAndUpdateManifest(contract) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
exports.getContractFactoryAndUpdateManifest = getContractFactoryAndUpdateManifest;
|
|
65
|
-
function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, safeMockAccessRequirements, contractNamesToUpgrade, deployNewContracts, initialize) {
|
|
65
|
+
function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, safeMockAccessRequirements, contractNamesToUpgrade, deployNewContracts, initialize, afterUpgrade) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
if (!process.env.ABI) {
|
|
68
68
|
console.log(chalk_1.default.red("Set path to file with ABI and addresses to ABI environment variables"));
|
|
@@ -172,9 +172,22 @@ function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, saf
|
|
|
172
172
|
privateKey = hardhat_1.ethers.Wallet.createRandom().privateKey;
|
|
173
173
|
}
|
|
174
174
|
const safeTx = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, safeTransactions, safeMock !== undefined);
|
|
175
|
+
let transactionsBatches;
|
|
176
|
+
if (afterUpgrade !== undefined) {
|
|
177
|
+
transactionsBatches = yield afterUpgrade(abi, contractManager);
|
|
178
|
+
for (const { index, batch } of transactionsBatches.map((batch, index) => ({ index, batch }))) {
|
|
179
|
+
yield fs_1.promises.writeFile(`data/after-transactions-${index}-${version}-${hardhat_1.network.name}.json`, JSON.stringify(batch, null, 4));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
175
182
|
if (!safeMock) {
|
|
176
183
|
const chainId = (yield hardhat_1.ethers.provider.getNetwork()).chainId;
|
|
177
184
|
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, safeTx);
|
|
185
|
+
if (transactionsBatches !== undefined) {
|
|
186
|
+
for (const batch of transactionsBatches) {
|
|
187
|
+
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, safeMock !== undefined);
|
|
188
|
+
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, multiSendTransaction);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
178
191
|
}
|
|
179
192
|
else {
|
|
180
193
|
console.log(chalk_1.default.blue("Send upgrade transactions to safe mock"));
|
|
@@ -184,6 +197,16 @@ function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, saf
|
|
|
184
197
|
value: safeTx.value,
|
|
185
198
|
data: safeTx.data,
|
|
186
199
|
})).wait();
|
|
200
|
+
if (transactionsBatches !== undefined) {
|
|
201
|
+
for (const batch of transactionsBatches) {
|
|
202
|
+
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, safeMock !== undefined);
|
|
203
|
+
yield (yield deployer.sendTransaction({
|
|
204
|
+
to: safeMock.address,
|
|
205
|
+
value: multiSendTransaction.value,
|
|
206
|
+
data: multiSendTransaction.data,
|
|
207
|
+
})).wait();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
187
210
|
console.log(chalk_1.default.blue("Transactions have been sent"));
|
|
188
211
|
}
|
|
189
212
|
finally {
|