@skalenetwork/upgrade-tools 4.0.0-update-verify.6 → 4.0.0-update-gnosis-service.1
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/src/contractVerifier.d.ts +24 -12
- package/dist/src/contractVerifier.js +47 -43
- package/dist/src/contractVerifier.js.map +1 -1
- package/dist/src/gnosis-safe.js +6 -37
- package/dist/src/gnosis-safe.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ownership-transfer/constants.d.ts +8 -0
- package/dist/src/ownership-transfer/constants.js +33 -0
- package/dist/src/ownership-transfer/constants.js.map +1 -0
- package/dist/src/ownership-transfer/contractAdmin.d.ts +55 -0
- package/dist/src/ownership-transfer/contractAdmin.js +206 -0
- package/dist/src/ownership-transfer/contractAdmin.js.map +1 -0
- package/dist/src/ownership-transfer/instanceAdmin.d.ts +51 -0
- package/dist/src/ownership-transfer/instanceAdmin.js +223 -0
- package/dist/src/ownership-transfer/instanceAdmin.js.map +1 -0
- package/dist/src/ownership-transfer/permission-utils.d.ts +32 -0
- package/dist/src/ownership-transfer/permission-utils.js +192 -0
- package/dist/src/ownership-transfer/permission-utils.js.map +1 -0
- package/dist/src/ownership-transfer/utils.d.ts +19 -0
- package/dist/src/ownership-transfer/utils.js +201 -0
- package/dist/src/ownership-transfer/utils.js.map +1 -0
- package/dist/src/proxyUpgrader.d.ts +18 -0
- package/dist/src/proxyUpgrader.js +72 -0
- package/dist/src/proxyUpgrader.js.map +1 -0
- package/dist/src/upgrader.d.ts +11 -6
- package/dist/src/upgrader.js +61 -61
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upgraders/abstractTransparentProxyUpgrader.d.ts +19 -0
- package/dist/src/upgraders/abstractTransparentProxyUpgrader.js +57 -0
- package/dist/src/upgraders/abstractTransparentProxyUpgrader.js.map +1 -0
- package/dist/src/upgraders/beaconUpgrader.d.ts +8 -0
- package/dist/src/upgraders/beaconUpgrader.js +37 -0
- package/dist/src/upgraders/beaconUpgrader.js.map +1 -0
- package/dist/src/upgraders/transparentProxyUpgrader.d.ts +5 -0
- package/dist/src/upgraders/transparentProxyUpgrader.js +20 -0
- package/dist/src/upgraders/transparentProxyUpgrader.js.map +1 -0
- package/dist/src/upgraders/v4TransparentProxyUpgrader.d.ts +5 -0
- package/dist/src/upgraders/v4TransparentProxyUpgrader.js +19 -0
- package/dist/src/upgraders/v4TransparentProxyUpgrader.js.map +1 -0
- package/dist/src/verification.d.ts +2 -17
- package/dist/src/verification.js +60 -210
- package/dist/src/verification.js.map +1 -1
- package/dist/src/verifiers/blockscoutVerifier.d.ts +11 -0
- package/dist/src/verifiers/blockscoutVerifier.js +69 -0
- package/dist/src/verifiers/blockscoutVerifier.js.map +1 -0
- package/dist/src/verifiers/etherscanVerifier.d.ts +19 -0
- package/dist/src/verifiers/etherscanVerifier.js +105 -0
- package/dist/src/verifiers/etherscanVerifier.js.map +1 -0
- package/dist/src/verifiers/skaleBlockscoutVerifier.d.ts +7 -0
- package/dist/src/verifiers/skaleBlockscoutVerifier.js +60 -0
- package/dist/src/verifiers/skaleBlockscoutVerifier.js.map +1 -0
- package/package.json +5 -5
- package/dist/src/proxyAdmin.d.ts +0 -4
- package/dist/src/proxyAdmin.js +0 -56
- package/dist/src/proxyAdmin.js.map +0 -1
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { ValidationResponse } from "@nomicfoundation/hardhat-verify/internal/utilities";
|
|
2
|
+
export interface VerificationTarget {
|
|
3
|
+
contractName: string;
|
|
4
|
+
contractAddress: string;
|
|
5
|
+
constructorArguments?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VerificationRequestParameters {
|
|
8
|
+
solcInputJson: string;
|
|
9
|
+
fullContractName: string;
|
|
10
|
+
compilerVersion: string;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class ContractVerifier {
|
|
13
|
+
abstract name: string;
|
|
14
|
+
private readonly PROXY_CONTRACT_NAME;
|
|
15
|
+
verify: (verificationTarget: VerificationTarget, attempts?: number) => Promise<void>;
|
|
16
|
+
attemptVerification(verificationTarget: VerificationTarget): Promise<boolean>;
|
|
17
|
+
protected abstract isAlreadyVerified(verificationTarget: VerificationTarget): Promise<boolean>;
|
|
18
|
+
protected abstract submitVerificationRequest(target: VerificationTarget, params: VerificationRequestParameters): Promise<ValidationResponse>;
|
|
19
|
+
protected abstract getContractUrl(verificationTarget: VerificationTarget): string;
|
|
20
|
+
protected getVerifyParameters(contractName: string): Promise<{
|
|
21
|
+
compilerVersion: string;
|
|
22
|
+
fullContractName: string;
|
|
23
|
+
solcInputJson: string;
|
|
24
|
+
}>;
|
|
12
25
|
private checkVerificationStatus;
|
|
13
|
-
attempt(): Promise<boolean>;
|
|
14
26
|
}
|
|
@@ -4,63 +4,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ContractVerifier = void 0;
|
|
7
|
-
const
|
|
8
|
-
const etherscan_1 = require("@nomicfoundation/hardhat-verify/etherscan");
|
|
7
|
+
const hardhat_1 = require("hardhat");
|
|
9
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const TransparentUpgradeableProxy_json_1 = __importDefault(require("@openzeppelin/upgrades-core/artifacts/@openzeppelin/contracts-v5/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json"));
|
|
10
|
+
const build_info_v5_json_1 = __importDefault(require("@openzeppelin/upgrades-core/artifacts/build-info-v5.json"));
|
|
11
|
+
const DEFAULT_RETRIES_AMOUNT = 5;
|
|
10
12
|
class ContractVerifier {
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
constructor() {
|
|
14
|
+
this.PROXY_CONTRACT_NAME = "TransparentUpgradeableProxy";
|
|
15
|
+
this.verify = async (verificationTarget, attempts = DEFAULT_RETRIES_AMOUNT) => {
|
|
16
|
+
const limit = 0;
|
|
17
|
+
if (attempts > limit) {
|
|
18
|
+
if (!await this.attemptVerification(verificationTarget)) {
|
|
19
|
+
const failedAttempts = 1;
|
|
20
|
+
await this.verify(verificationTarget, attempts - failedAttempts);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
|
-
async
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (!verified) {
|
|
25
|
-
verified = await (0, verification_1.isVerifiedOnBlockscout)(this.apiURL, this.contractAddress);
|
|
26
|
-
}
|
|
27
|
-
if (verified) {
|
|
28
|
-
console.log(`${this.contractName} is already verified on: ${this.etherscan.getContractUrl(this.contractAddress)}`);
|
|
25
|
+
async attemptVerification(verificationTarget) {
|
|
26
|
+
if (await this.isAlreadyVerified(verificationTarget)) {
|
|
27
|
+
console.log(chalk_1.default.cyan(`${verificationTarget.contractName} is already verified on ${this.name}:\n${this.getContractUrl(verificationTarget)}`));
|
|
28
|
+
return true;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
async submitVerification(params) {
|
|
30
|
+
const params = await this.getVerifyParameters(verificationTarget.contractName);
|
|
33
31
|
try {
|
|
34
|
-
const
|
|
35
|
-
return
|
|
32
|
+
const response = await this.submitVerificationRequest(verificationTarget, params);
|
|
33
|
+
return this.checkVerificationStatus(verificationTarget, response);
|
|
36
34
|
}
|
|
37
35
|
catch (error) {
|
|
38
|
-
console.log(chalk_1.default.yellow(`Verification attempt for ${
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async checkVerificationStatus(guid) {
|
|
43
|
-
const status = await this.etherscan.getVerificationStatus(guid);
|
|
44
|
-
if (status.isFailure()) {
|
|
45
|
-
console.log(chalk_1.default.red(`Failed to verify contract ${this.contractName}`));
|
|
36
|
+
console.log(chalk_1.default.yellow(`Verification attempt for ${verificationTarget.contractName} failed on ${this.name} with error: ${error}`));
|
|
46
37
|
return false;
|
|
47
38
|
}
|
|
48
|
-
console.log(`${this.contractName} is successfully verified on: ${this.etherscan.getContractUrl(this.contractAddress)}`);
|
|
49
|
-
return true;
|
|
50
39
|
}
|
|
51
|
-
async
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
40
|
+
async getVerifyParameters(contractName) {
|
|
41
|
+
if (contractName === this.PROXY_CONTRACT_NAME) {
|
|
42
|
+
return {
|
|
43
|
+
compilerVersion: build_info_v5_json_1.default.solcLongVersion,
|
|
44
|
+
fullContractName: `${TransparentUpgradeableProxy_json_1.default.sourceName}:${contractName}`,
|
|
45
|
+
solcInputJson: JSON.stringify(build_info_v5_json_1.default.input)
|
|
46
|
+
};
|
|
54
47
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
const artifact = await hardhat_1.artifacts.readArtifact(contractName);
|
|
49
|
+
const fullContractName = `${artifact.sourceName}:${contractName}`;
|
|
50
|
+
const buildInfo = await hardhat_1.artifacts.getBuildInfo(fullContractName);
|
|
51
|
+
if (!buildInfo) {
|
|
52
|
+
throw new Error(`No build-info for ${contractName}`);
|
|
58
53
|
}
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
return {
|
|
55
|
+
compilerVersion: buildInfo.solcLongVersion,
|
|
56
|
+
fullContractName,
|
|
57
|
+
solcInputJson: JSON.stringify(buildInfo.input)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Private
|
|
61
|
+
checkVerificationStatus(verificationTarget, response) {
|
|
62
|
+
if (response.isFailure()) {
|
|
63
|
+
console.log(chalk_1.default.red(`Failed to verify contract ${verificationTarget.contractName}`));
|
|
61
64
|
return false;
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
console.log(chalk_1.default.cyan(`${verificationTarget.contractName} is successfully verified on ${this.name}:\n${this.getContractUrl(verificationTarget)}`));
|
|
67
|
+
return true;
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
exports.ContractVerifier = ContractVerifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractVerifier.js","sourceRoot":"","sources":["../../src/contractVerifier.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"contractVerifier.js","sourceRoot":"","sources":["../../src/contractVerifier.ts"],"names":[],"mappings":";;;;;;AACA,qCAAkC;AAClC,kDAA0B;AAC1B,2NACsJ;AACtJ,kHAAsF;AAEtF,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAcjC,MAAsB,gBAAgB;IAAtC;QAEqB,wBAAmB,GAAG,6BAA6B,CAAC;QAE9D,WAAM,GAAG,KAAK,EACjB,kBAAsC,EACtC,WAAmB,sBAAsB,EAC3C,EAAE;YACA,MAAM,KAAK,GAAG,CAAC,CAAC;YAChB,IAAI,QAAQ,GAAG,KAAK,EAAE,CAAC;gBACnB,IAAI,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,CAAC;oBACtD,MAAM,cAAc,GAAG,CAAC,CAAC;oBACzB,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAChC,QAAQ,GAAG,cAAc,CAC5B,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC,CAAC;IA+EN,CAAC;IA7EU,KAAK,CAAC,mBAAmB,CAAC,kBAAsC;QACnE,IAAI,MAAM,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CACP,eAAK,CAAC,IAAI,CACN,GAAG,kBAAkB,CAAC,YAAY,2BAA2B,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC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,eAAe,EAAE,SAAS,CAAC,eAAe;YAC1C,gBAAgB;YAChB,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;SACjD,CAAC;IACN,CAAC;IAED,UAAU;IAEF,uBAAuB,CAAC,kBAAsC,EAAC,QAA4B;QAC/F,IAAI,QAAQ,CAAC,SAAS,EAAwB,EAAE,CAAC;YAC7C,OAAO,CAAC,GAAG,CACP,eAAK,CAAC,GAAG,CAAC,6BAA6B,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAC5E,CAAC;YACF,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,GAAG,CACP,eAAK,CAAC,IAAI,CACN,GAAG,kBAAkB,CAAC,YAAY,gCAAgC,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,cAAc,CAChG,kBAAkB,CACrB,EAAE,CACN,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAhGD,4CAgGC"}
|
package/dist/src/gnosis-safe.js
CHANGED
|
@@ -5,38 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createMultiSendTransaction = void 0;
|
|
7
7
|
const safe_core_sdk_types_1 = require("@safe-global/safe-core-sdk-types");
|
|
8
|
-
const ethers_1 = require("ethers");
|
|
9
8
|
const hardhat_1 = require("hardhat");
|
|
10
9
|
const protocol_kit_1 = __importDefault(require("@safe-global/protocol-kit"));
|
|
11
10
|
const api_kit_1 = __importDefault(require("@safe-global/api-kit"));
|
|
12
11
|
// Cspell:words arbitrum celo sepolia xdai holesky
|
|
13
|
-
// Constants
|
|
14
|
-
const URLS = {
|
|
15
|
-
"safe_transaction": {
|
|
16
|
-
[ethers_1.Network.from("mainnet").chainId.toString()]: "https://safe-transaction-mainnet.safe.global/api",
|
|
17
|
-
[ethers_1.Network.from("arbitrum").chainId.toString()]: "https://safe-transaction-arbitrum.safe.global/api",
|
|
18
|
-
[ethers_1.Network.from("base").chainId.toString()]: "https://safe-transaction-base.safe.global/api",
|
|
19
|
-
[ethers_1.Network.from("base-sepolia").chainId.toString()]: "https://safe-transaction-base-sepolia.safe.global/api",
|
|
20
|
-
[ethers_1.Network.from("bnb").chainId.toString()]: "https://safe-transaction-bsc.safe.global/api",
|
|
21
|
-
[ethers_1.Network.from("xdai").chainId.toString()]: "https://safe-transaction-gnosis-chain.safe.global/api",
|
|
22
|
-
[ethers_1.Network.from("optimism").chainId.toString()]: "https://safe-transaction-optimism.safe.global/api",
|
|
23
|
-
[ethers_1.Network.from("matic").chainId.toString()]: "https://safe-transaction-polygon.safe.global/api",
|
|
24
|
-
[ethers_1.Network.from("sepolia").chainId.toString()]: "https://safe-transaction-sepolia.safe.global/api",
|
|
25
|
-
[ethers_1.Network.from("holesky").chainId.toString()]: "https://transaction-holesky.holesky-safe.protofire.io/api",
|
|
26
|
-
// Aurora
|
|
27
|
-
"0x4e454152": "https://safe-transaction-aurora.safe.global/api",
|
|
28
|
-
// Polygon zkEVM
|
|
29
|
-
"1101": "https://safe-transaction-zkevm.safe.global/api",
|
|
30
|
-
// ZkSync Era Mainnet
|
|
31
|
-
"324": "https://safe-transaction-zksync.safe.global/api",
|
|
32
|
-
// Celo
|
|
33
|
-
"42220": "https://safe-transaction-celo.safe.global/api",
|
|
34
|
-
// Avalanche
|
|
35
|
-
"43114": "https://safe-transaction-avalanche.safe.global/api",
|
|
36
|
-
// Scroll
|
|
37
|
-
"534352": "https://safe-transaction-scroll.safe.global/api",
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
12
|
const defaultOptions = {
|
|
41
13
|
/*
|
|
42
14
|
* Gas costs not related to the transaction execution
|
|
@@ -69,17 +41,14 @@ const getSafeTransactionData = (transactions) => {
|
|
|
69
41
|
}
|
|
70
42
|
return safeTransactionData;
|
|
71
43
|
};
|
|
72
|
-
const getSafeTransactionUrl = (chainId) => {
|
|
73
|
-
if (Object.keys(URLS.safe_transaction).includes(chainId.toString())) {
|
|
74
|
-
return URLS.safe_transaction[Number(chainId)];
|
|
75
|
-
}
|
|
76
|
-
throw Error("Can't get Safe Transaction Service url" +
|
|
77
|
-
` at network with chainId = ${chainId}`);
|
|
78
|
-
};
|
|
79
44
|
const getSafeService = (chainId) => {
|
|
45
|
+
if (!process.env.GNOSIS_API_KEY) {
|
|
46
|
+
throw new Error("GNOSIS_API_KEY is not set");
|
|
47
|
+
}
|
|
80
48
|
const safeService = new api_kit_1.default({
|
|
49
|
+
apiKey: process.env.GNOSIS_API_KEY,
|
|
81
50
|
chainId,
|
|
82
|
-
|
|
51
|
+
// Does not need the URL - chainId is enough
|
|
83
52
|
});
|
|
84
53
|
return safeService;
|
|
85
54
|
};
|
|
@@ -111,7 +80,7 @@ const createMultiSendTransaction = async (safeAddress, chainId, transactions) =>
|
|
|
111
80
|
* Transaction cannot be executed until
|
|
112
81
|
* Safe's nonce is not equal to this nonce
|
|
113
82
|
*/
|
|
114
|
-
nonce
|
|
83
|
+
nonce: parseInt(nonce, 10)
|
|
115
84
|
}
|
|
116
85
|
};
|
|
117
86
|
const safeSdk = await protocol_kit_1.default.init({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gnosis-safe.js","sourceRoot":"","sources":["../../src/gnosis-safe.ts"],"names":[],"mappings":";;;;;;AAAA,0EAI0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"gnosis-safe.js","sourceRoot":"","sources":["../../src/gnosis-safe.ts"],"names":[],"mappings":";;;;;;AAAA,0EAI0C;AAC1C,qCAAwC;AACxC,6EAA6C;AAC7C,mEAA8C;AAG9C,kDAAkD;AAElD,MAAM,cAAc,GAAG;IAEnB;;;OAGG;IACH,SAAS,EAAE,GAAG;IAEd,4CAA4C;IAC5C,UAAU,EAAE,GAAG;IAEf;;;;OAIG;IACH,UAAU,EAAE,gBAAM,CAAC,WAAW;IAE9B,8DAA8D;IAC9D,gBAAgB,EAAE,gBAAM,CAAC,WA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from "./abi";
|
|
2
2
|
export * from "./deploy";
|
|
3
3
|
export * from "./gnosis-safe";
|
|
4
|
+
export * from "./proxyUpgrader";
|
|
4
5
|
export * from "./submitters";
|
|
5
6
|
export * from "./verification";
|
|
6
7
|
export * from "./version";
|
|
7
8
|
export * from "./upgrader";
|
|
9
|
+
export * from "./upgraders/abstractTransparentProxyUpgrader";
|
|
10
|
+
export * from "./upgraders/beaconUpgrader";
|
|
11
|
+
export * from "./ownership-transfer/instanceAdmin";
|
package/dist/src/index.js
CHANGED
|
@@ -17,8 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./abi"), exports);
|
|
18
18
|
__exportStar(require("./deploy"), exports);
|
|
19
19
|
__exportStar(require("./gnosis-safe"), exports);
|
|
20
|
+
__exportStar(require("./proxyUpgrader"), exports);
|
|
20
21
|
__exportStar(require("./submitters"), exports);
|
|
21
22
|
__exportStar(require("./verification"), exports);
|
|
22
23
|
__exportStar(require("./version"), exports);
|
|
23
24
|
__exportStar(require("./upgrader"), exports);
|
|
25
|
+
__exportStar(require("./upgraders/abstractTransparentProxyUpgrader"), exports);
|
|
26
|
+
__exportStar(require("./upgraders/beaconUpgrader"), exports);
|
|
27
|
+
__exportStar(require("./ownership-transfer/instanceAdmin"), exports);
|
|
24
28
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,gDAA8B;AAC9B,kDAAgC;AAChC,+CAA6B;AAC7B,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B;AAC3B,+EAA6D;AAC7D,6DAA0C;AAC1C,qEAAmD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const ERC1967_ADMIN_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
2
|
+
export declare const ERC1967_IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
|
|
3
|
+
export declare const UPGRADEABLE_BEACON_ABI: string[];
|
|
4
|
+
export declare const OWNABLE_ABI: string[];
|
|
5
|
+
export declare const ACCESS_CONTROL_ABI: string[];
|
|
6
|
+
export declare const ACCESS_MANAGER_ABI: string[];
|
|
7
|
+
export declare const ACCESS_MANAGED_ABI: string[];
|
|
8
|
+
export declare const MULTISIG_ABI: string[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MULTISIG_ABI = exports.ACCESS_MANAGED_ABI = exports.ACCESS_MANAGER_ABI = exports.ACCESS_CONTROL_ABI = exports.OWNABLE_ABI = exports.UPGRADEABLE_BEACON_ABI = exports.ERC1967_IMPLEMENTATION_SLOT = exports.ERC1967_ADMIN_SLOT = void 0;
|
|
4
|
+
exports.ERC1967_ADMIN_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
5
|
+
exports.ERC1967_IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
|
|
6
|
+
exports.UPGRADEABLE_BEACON_ABI = [
|
|
7
|
+
"function owner() view returns (address)",
|
|
8
|
+
"function implementation() view returns (address)",
|
|
9
|
+
"function upgradeTo(address newImplementation)"
|
|
10
|
+
];
|
|
11
|
+
exports.OWNABLE_ABI = [
|
|
12
|
+
"function transferOwnership(address newOwner)",
|
|
13
|
+
"function owner() view returns (address)"
|
|
14
|
+
];
|
|
15
|
+
exports.ACCESS_CONTROL_ABI = [
|
|
16
|
+
"function hasRole(bytes32 role, address account) view returns (bool)",
|
|
17
|
+
"function grantRole(bytes32 role, address account)",
|
|
18
|
+
"function renounceRole(bytes32 role, address account)",
|
|
19
|
+
"function getRoleMemberCount(bytes32 role) view returns (uint256)"
|
|
20
|
+
];
|
|
21
|
+
exports.ACCESS_MANAGER_ABI = [
|
|
22
|
+
"function hasRole(uint64 role, address account) view returns (bool)",
|
|
23
|
+
"function grantRole(uint64 role, address account, uint32 executionDelay)",
|
|
24
|
+
"function renounceRole(uint64 role, address account)"
|
|
25
|
+
];
|
|
26
|
+
exports.ACCESS_MANAGED_ABI = [
|
|
27
|
+
"function authority() view returns (address)"
|
|
28
|
+
];
|
|
29
|
+
exports.MULTISIG_ABI = [
|
|
30
|
+
"function getOwners() view returns (address[])",
|
|
31
|
+
"function getThreshold() view returns (uint256)"
|
|
32
|
+
];
|
|
33
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/ownership-transfer/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,kBAAkB,GAAG,oEAAoE,CAAC;AAC1F,QAAA,2BAA2B,GAAG,oEAAoE,CAAC;AAGnG,QAAA,sBAAsB,GAAG;IAClC,yCAAyC;IACzC,kDAAkD;IAClD,+CAA+C;CAClD,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,8CAA8C;IAC9C,yCAAyC;CAC5C,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAC9B,qEAAqE;IACrE,mDAAmD;IACnD,sDAAsD;IACtD,kEAAkE;CACrE,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAC9B,oEAAoE;IACpE,yEAAyE;IACzE,qDAAqD;CACxD,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAC9B,6CAA6C;CAChD,CAAC;AAEW,QAAA,YAAY,GAAG;IACxB,+CAA+C;IAC/C,gDAAgD;CACnD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Pattern } from "./utils";
|
|
2
|
+
import { PermissionModel } from "./permission-utils";
|
|
3
|
+
import { Transaction } from "ethers";
|
|
4
|
+
export interface BytesRole {
|
|
5
|
+
name: string;
|
|
6
|
+
identifier: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UintRole {
|
|
9
|
+
name: string;
|
|
10
|
+
identifier: bigint;
|
|
11
|
+
}
|
|
12
|
+
export interface ContractMetadataDetails {
|
|
13
|
+
name: string;
|
|
14
|
+
address: string;
|
|
15
|
+
pattern?: Pattern;
|
|
16
|
+
permissionModel?: PermissionModel[];
|
|
17
|
+
}
|
|
18
|
+
export interface TransactionData {
|
|
19
|
+
transaction: Transaction;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class ContractAdmin {
|
|
23
|
+
contractName: string;
|
|
24
|
+
pattern?: Pattern;
|
|
25
|
+
address: string;
|
|
26
|
+
permissionModel: PermissionModel[];
|
|
27
|
+
private oldOwner;
|
|
28
|
+
private newOwner;
|
|
29
|
+
private grantOwnershipRoleTxs;
|
|
30
|
+
private renounceOwnershipTxs;
|
|
31
|
+
constructor(details: ContractMetadataDetails, oldOwner: string, newOwner: string);
|
|
32
|
+
scanPatternAndPermissionModels(): Promise<void>;
|
|
33
|
+
createGrantOwnershipTransactions(bytes32RolesToCheck: BytesRole[], managerRolesToCheck: UintRole[]): Promise<void>;
|
|
34
|
+
createRenounceOwnershipTransactions(bytes32RolesToCheck: BytesRole[], managerRolesToCheck: UintRole[]): Promise<void>;
|
|
35
|
+
getGrantOwnershipTransactions(): TransactionData[];
|
|
36
|
+
getRenounceOwnershipTransactions(): TransactionData[];
|
|
37
|
+
clearRenounceTransactions(): void;
|
|
38
|
+
clearGrantTransactions(): void;
|
|
39
|
+
requiresGrantingOwnership(): boolean;
|
|
40
|
+
requiresRenouncingOwnership(): boolean;
|
|
41
|
+
displayData(columnWidths: {
|
|
42
|
+
maxNameWidth: number;
|
|
43
|
+
maxAddressWidth: number;
|
|
44
|
+
maxPermissionsWidth: number;
|
|
45
|
+
}): void;
|
|
46
|
+
private checkFindings;
|
|
47
|
+
private createTUPPGrantOwnershipTransaction;
|
|
48
|
+
private createOwnableOwnershipTransaction;
|
|
49
|
+
private createAssignUint64RolesTransactions;
|
|
50
|
+
private handleRenounceOwnershipTransaction;
|
|
51
|
+
private createRenounceUint64RolesTransactions;
|
|
52
|
+
private createAssignBytes32RolesTransactions;
|
|
53
|
+
private createRenounceBytes32RolesTransactions;
|
|
54
|
+
private isDuplicateTransaction;
|
|
55
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ContractAdmin = void 0;
|
|
7
|
+
// Cspell:words TUPP
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const permission_utils_1 = require("./permission-utils");
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
class ContractAdmin {
|
|
12
|
+
constructor(details, oldOwner, newOwner) {
|
|
13
|
+
this.permissionModel = [];
|
|
14
|
+
this.grantOwnershipRoleTxs = [];
|
|
15
|
+
this.renounceOwnershipTxs = [];
|
|
16
|
+
this.contractName = details.name;
|
|
17
|
+
this.pattern = details.pattern;
|
|
18
|
+
this.address = details.address;
|
|
19
|
+
this.permissionModel = details.permissionModel ?? [];
|
|
20
|
+
this.oldOwner = oldOwner;
|
|
21
|
+
this.newOwner = newOwner;
|
|
22
|
+
// Validate manual inputs if any
|
|
23
|
+
this.checkFindings();
|
|
24
|
+
}
|
|
25
|
+
async scanPatternAndPermissionModels() {
|
|
26
|
+
if (!this.pattern || !this.permissionModel.length) {
|
|
27
|
+
this.pattern = await (0, utils_1.detectPattern)(this.address);
|
|
28
|
+
this.permissionModel = await (0, permission_utils_1.getPermissionModels)(this.address);
|
|
29
|
+
this.checkFindings();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async createGrantOwnershipTransactions(bytes32RolesToCheck, managerRolesToCheck) {
|
|
33
|
+
this.clearGrantTransactions();
|
|
34
|
+
console.log(chalk_1.default.white(`* Creating Transactions to grant Ownership in ${this.contractName}.`));
|
|
35
|
+
if (this.pattern === utils_1.Pattern.TUPP) {
|
|
36
|
+
await this.createTUPPGrantOwnershipTransaction();
|
|
37
|
+
}
|
|
38
|
+
// UpgradeableBeacon is detected also as OWNABLE
|
|
39
|
+
if (this.permissionModel.includes(permission_utils_1.PermissionModel.OWNABLE)) {
|
|
40
|
+
await this.createOwnableOwnershipTransaction();
|
|
41
|
+
}
|
|
42
|
+
if (this.permissionModel.includes(permission_utils_1.PermissionModel.ROLE_BASED)) {
|
|
43
|
+
await this.createAssignBytes32RolesTransactions(bytes32RolesToCheck);
|
|
44
|
+
}
|
|
45
|
+
if (this.permissionModel.includes(permission_utils_1.PermissionModel.ACCESS_MANAGER)) {
|
|
46
|
+
await this.createAssignUint64RolesTransactions(managerRolesToCheck);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async createRenounceOwnershipTransactions(bytes32RolesToCheck, managerRolesToCheck) {
|
|
50
|
+
this.clearRenounceTransactions();
|
|
51
|
+
console.log(chalk_1.default.white(`* Creating Transactions to renounce Ownership in ${this.contractName}.`));
|
|
52
|
+
if (this.permissionModel.includes(permission_utils_1.PermissionModel.ROLE_BASED)) {
|
|
53
|
+
await this.createRenounceBytes32RolesTransactions(bytes32RolesToCheck);
|
|
54
|
+
}
|
|
55
|
+
if (this.permissionModel.includes(permission_utils_1.PermissionModel.ACCESS_MANAGER)) {
|
|
56
|
+
await this.createRenounceUint64RolesTransactions(managerRolesToCheck);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getGrantOwnershipTransactions() {
|
|
60
|
+
return this.grantOwnershipRoleTxs;
|
|
61
|
+
}
|
|
62
|
+
getRenounceOwnershipTransactions() {
|
|
63
|
+
return this.renounceOwnershipTxs;
|
|
64
|
+
}
|
|
65
|
+
clearRenounceTransactions() {
|
|
66
|
+
this.renounceOwnershipTxs = [];
|
|
67
|
+
}
|
|
68
|
+
clearGrantTransactions() {
|
|
69
|
+
this.grantOwnershipRoleTxs = [];
|
|
70
|
+
}
|
|
71
|
+
requiresGrantingOwnership() {
|
|
72
|
+
return Boolean(this.grantOwnershipRoleTxs.length);
|
|
73
|
+
}
|
|
74
|
+
requiresRenouncingOwnership() {
|
|
75
|
+
return Boolean(this.renounceOwnershipTxs.length);
|
|
76
|
+
}
|
|
77
|
+
displayData(columnWidths) {
|
|
78
|
+
const { maxNameWidth, maxAddressWidth, maxPermissionsWidth } = columnWidths;
|
|
79
|
+
const name = this.contractName.padEnd(maxNameWidth);
|
|
80
|
+
const address = this.address.padEnd(maxAddressWidth);
|
|
81
|
+
const permissions = (this.permissionModel?.join(", ") || "None").padEnd(maxPermissionsWidth);
|
|
82
|
+
let status = chalk_1.default.green("ALL DONE");
|
|
83
|
+
if (this.grantOwnershipRoleTxs.length) {
|
|
84
|
+
status = chalk_1.default.yellow("GRANT OWNERSHIP REQUIRED");
|
|
85
|
+
}
|
|
86
|
+
else if (this.renounceOwnershipTxs.length) {
|
|
87
|
+
status = chalk_1.default.yellow("REVOKE ROLES REQUIRED");
|
|
88
|
+
}
|
|
89
|
+
console.log(chalk_1.default.gray(` ${name} ${address} ${permissions} `) + status);
|
|
90
|
+
}
|
|
91
|
+
checkFindings() {
|
|
92
|
+
const maxPermissionsIfBeacon = 1;
|
|
93
|
+
if (this.pattern === utils_1.Pattern.BEACON &&
|
|
94
|
+
!this.permissionModel?.includes(permission_utils_1.PermissionModel.OWNABLE) &&
|
|
95
|
+
this.permissionModel?.length !== maxPermissionsIfBeacon) {
|
|
96
|
+
throw new Error(`UpgradeableBeacon at address ${this.address} should ONLY have OWNABLE permission model.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async createTUPPGrantOwnershipTransaction() {
|
|
100
|
+
const admin = await (0, utils_1.getAdminAddress)(this.address);
|
|
101
|
+
await this.createOwnableOwnershipTransaction({ address: admin, name: `${this.contractName} Proxy Admin` });
|
|
102
|
+
}
|
|
103
|
+
async createOwnableOwnershipTransaction(contractId = { address: this.address, name: this.contractName }) {
|
|
104
|
+
const tx = await (0, permission_utils_1.transferOwnership)(contractId.address, this.newOwner, this.oldOwner);
|
|
105
|
+
if (tx) {
|
|
106
|
+
if (this.isDuplicateTransaction({ transaction: tx })) {
|
|
107
|
+
throw new Error(`Error: Duplicate transaction to transfer ownership of ${contractId.name} at ${contractId.address} was already created.`);
|
|
108
|
+
}
|
|
109
|
+
const description = `-> Tx to change ${contractId.name} Owner at ${contractId.address} to ${this.newOwner}`;
|
|
110
|
+
console.log(chalk_1.default.yellow(` ${description} created.`));
|
|
111
|
+
this.grantOwnershipRoleTxs.push({
|
|
112
|
+
description,
|
|
113
|
+
transaction: tx
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async createAssignUint64RolesTransactions(managerRolesToCheck) {
|
|
118
|
+
for (const role of managerRolesToCheck) {
|
|
119
|
+
// Required to process sequentially as it access shared memory state and RPC rate limits
|
|
120
|
+
// eslint-disable-next-line no-await-in-loop
|
|
121
|
+
const tx = await (0, permission_utils_1.grantAccessManagerRole)({
|
|
122
|
+
contractAddress: this.address,
|
|
123
|
+
newAccount: this.newOwner,
|
|
124
|
+
oldAccount: this.oldOwner,
|
|
125
|
+
role: role.identifier,
|
|
126
|
+
});
|
|
127
|
+
if (tx) {
|
|
128
|
+
if (this.isDuplicateTransaction({ transaction: tx })) {
|
|
129
|
+
throw new Error(`Error: Transaction to grant manager role ${role.name} in ${this.contractName} was already created.`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const description = `-> Tx to grant role ${role.name} to ${this.newOwner} in ${this.contractName}`;
|
|
133
|
+
console.log(chalk_1.default.yellow(` ${description} created.`));
|
|
134
|
+
this.grantOwnershipRoleTxs.push({ description, transaction: tx });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
handleRenounceOwnershipTransaction(tx, roleName) {
|
|
140
|
+
if (typeof tx !== "boolean" && tx) {
|
|
141
|
+
if (this.isDuplicateTransaction({ transaction: tx })) {
|
|
142
|
+
throw new Error(`Error: Transaction to renounce role ${roleName} in ${this.contractName} was already created.`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const description = `-> Tx to renounce role ${roleName} from ${this.oldOwner} in ${this.contractName}`;
|
|
146
|
+
console.log(chalk_1.default.yellow(` ${description} created.`));
|
|
147
|
+
this.renounceOwnershipTxs.push({ description, transaction: tx });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else if (!tx) {
|
|
151
|
+
console.log(chalk_1.default.yellow(` WARNING: Skipping revocation of role ${roleName} in ${this.contractName} as it requires at least 1 member left.`));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async createRenounceUint64RolesTransactions(managerRolesToCheck) {
|
|
155
|
+
for (const role of managerRolesToCheck) {
|
|
156
|
+
// Required to process sequentially as it access shared memory state and RPC rate limits
|
|
157
|
+
// eslint-disable-next-line no-await-in-loop
|
|
158
|
+
const tx = await (0, permission_utils_1.renounceAccessManagerRole)({
|
|
159
|
+
contractAddress: this.address,
|
|
160
|
+
newAccount: this.newOwner,
|
|
161
|
+
oldAccount: this.oldOwner,
|
|
162
|
+
role: role.identifier,
|
|
163
|
+
});
|
|
164
|
+
this.handleRenounceOwnershipTransaction(tx, role.name);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async createAssignBytes32RolesTransactions(bytes32RolesToCheck) {
|
|
168
|
+
for (const role of bytes32RolesToCheck) {
|
|
169
|
+
// Required to process sequentially as it access shared memory state and RPC rate limits
|
|
170
|
+
// eslint-disable-next-line no-await-in-loop
|
|
171
|
+
const tx = await (0, permission_utils_1.grantRole)({
|
|
172
|
+
contractAddress: this.address,
|
|
173
|
+
newAccount: this.newOwner,
|
|
174
|
+
oldAccount: this.oldOwner,
|
|
175
|
+
role: role.identifier,
|
|
176
|
+
});
|
|
177
|
+
if (tx) {
|
|
178
|
+
if (this.isDuplicateTransaction({ transaction: tx })) {
|
|
179
|
+
throw new Error(`Error: Transaction to grant role ${role.name} in ${this.contractName} was already created.`);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const description = `-> Tx to grant role ${role.name} to ${this.newOwner} in ${this.contractName}`;
|
|
183
|
+
console.log(chalk_1.default.yellow(` ${description} created.`));
|
|
184
|
+
this.grantOwnershipRoleTxs.push({ description, transaction: tx });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async createRenounceBytes32RolesTransactions(bytes32RolesToCheck) {
|
|
190
|
+
for (const role of bytes32RolesToCheck) {
|
|
191
|
+
// Required to process sequentially as it access shared memory state and due to RPC rate limits
|
|
192
|
+
// eslint-disable-next-line no-await-in-loop
|
|
193
|
+
const tx = await (0, permission_utils_1.renounceRole)(this.address, role.identifier, this.oldOwner);
|
|
194
|
+
this.handleRenounceOwnershipTransaction(tx, role.name);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
isDuplicateTransaction(transaction) {
|
|
198
|
+
const isGrantDuplicate = this.grantOwnershipRoleTxs.some((existingTx) => existingTx.transaction.to === transaction.transaction.to &&
|
|
199
|
+
existingTx.transaction.data === transaction.transaction.data);
|
|
200
|
+
const isRenounceDuplicate = this.renounceOwnershipTxs.some((existingTx) => existingTx.transaction.to === transaction.transaction.to &&
|
|
201
|
+
existingTx.transaction.data === transaction.transaction.data);
|
|
202
|
+
return isGrantDuplicate || isRenounceDuplicate;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.ContractAdmin = ContractAdmin;
|
|
206
|
+
//# sourceMappingURL=contractAdmin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractAdmin.js","sourceRoot":"","sources":["../../../src/ownership-transfer/contractAdmin.ts"],"names":[],"mappings":";;;;;;AAAA,oBAAoB;AACpB,mCAAgE;AAChE,yDAQ4B;AAE5B,kDAA0B;AAwB1B,MAAa,aAAa;IAWtB,YAAY,OAAgC,EAAE,QAAgB,EAAE,QAAgB;QAPzE,oBAAe,GAAsB,EAAE,CAAC;QAIvC,0BAAqB,GAAsB,EAAE,CAAC;QAC9C,yBAAoB,GAAsB,EAAE,CAAC;QAGjD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,gCAAgC;QAChC,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,8BAA8B;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;YAChD,IAAI,CAAC,OAAO,GAAG,MAAM,IAAA,qBAAa,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,GAAG,MAAM,IAAA,sCAAmB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/D,IAAI,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,gCAAgC,CACzC,mBAAgC,EAChC,mBAA+B;QAE/B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