@gearbox-protocol/deploy-tools 1.6.0-next.4 → 1.6.0-next.6
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/index.js +94 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200247,8 +200247,7 @@ var require_git = __commonJS({
|
|
|
200247
200247
|
"router-v3",
|
|
200248
200248
|
"router"
|
|
200249
200249
|
];
|
|
200250
|
-
function getGithubUrl(repo) {
|
|
200251
|
-
const https = !!process.env.GITHUB_HTTPS;
|
|
200250
|
+
function getGithubUrl(repo, https = false) {
|
|
200252
200251
|
const path = repo.replace(/^@/, "").replace(/\/$/, "");
|
|
200253
200252
|
return https ? `https://github.com/${path}.git` : `git@github.com:${path}.git`;
|
|
200254
200253
|
}
|
|
@@ -205655,10 +205654,25 @@ var require_utils9 = __commonJS({
|
|
|
205655
205654
|
}
|
|
205656
205655
|
exports2.decodeBatchTx = decodeBatchTx;
|
|
205657
205656
|
function extractFilesFromJSON(files) {
|
|
205658
|
-
return Object.entries(files).map(([path, file]) =>
|
|
205659
|
-
|
|
205660
|
-
|
|
205661
|
-
|
|
205657
|
+
return Object.entries(files).map(([path, file]) => {
|
|
205658
|
+
let buffer = null;
|
|
205659
|
+
if (Buffer.isBuffer(file)) {
|
|
205660
|
+
buffer = file;
|
|
205661
|
+
} else if (typeof file === "string") {
|
|
205662
|
+
buffer = Buffer.from(file, "utf8");
|
|
205663
|
+
} else if (typeof file === "object") {
|
|
205664
|
+
if (file && "content" in file && typeof file.content === "string") {
|
|
205665
|
+
buffer = Buffer.from(file.content);
|
|
205666
|
+
}
|
|
205667
|
+
}
|
|
205668
|
+
if (!buffer) {
|
|
205669
|
+
throw new Error(`cannot convert ${typeof file} into buffer`);
|
|
205670
|
+
}
|
|
205671
|
+
return {
|
|
205672
|
+
path,
|
|
205673
|
+
buffer
|
|
205674
|
+
};
|
|
205675
|
+
});
|
|
205662
205676
|
}
|
|
205663
205677
|
exports2.extractFilesFromJSON = extractFilesFromJSON;
|
|
205664
205678
|
function stringifyInvalidAndMissing(contract) {
|
|
@@ -205791,7 +205805,7 @@ var require_Auditor = __commonJS({
|
|
|
205791
205805
|
* checks audit of etherscan verification result
|
|
205792
205806
|
*/
|
|
205793
205807
|
async auditEtherscanVerified(contract) {
|
|
205794
|
-
const input =
|
|
205808
|
+
const input = parseEtherscanSourceCode(contract);
|
|
205795
205809
|
const files = (0, utils_1.extractFilesFromJSON)(input.sources).map(({ path, buffer }) => {
|
|
205796
205810
|
const p = path.replace("node_modules/", "");
|
|
205797
205811
|
const gearbox = p.startsWith("@gearbox-protocol");
|
|
@@ -205871,6 +205885,20 @@ var require_Auditor = __commonJS({
|
|
|
205871
205885
|
}
|
|
205872
205886
|
};
|
|
205873
205887
|
exports2.Auditor = Auditor2;
|
|
205888
|
+
function parseEtherscanSourceCode(contract) {
|
|
205889
|
+
let substr = contract.SourceCode;
|
|
205890
|
+
if (!substr.startsWith("{")) {
|
|
205891
|
+
return { language: "", sources: { [contract.ContractName]: substr } };
|
|
205892
|
+
}
|
|
205893
|
+
try {
|
|
205894
|
+
const first = contract.SourceCode.indexOf("{{");
|
|
205895
|
+
const last = contract.SourceCode.lastIndexOf("}}");
|
|
205896
|
+
substr = contract.SourceCode.substring(first + 1, last + 1);
|
|
205897
|
+
return JSON.parse(substr);
|
|
205898
|
+
} catch (e) {
|
|
205899
|
+
throw new Error(`failed to parse '${substr}': ${e}`);
|
|
205900
|
+
}
|
|
205901
|
+
}
|
|
205874
205902
|
}
|
|
205875
205903
|
});
|
|
205876
205904
|
|
|
@@ -206695,6 +206723,9 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206695
206723
|
__privateAdd(this, _cachePolicy, void 0);
|
|
206696
206724
|
__privateAdd(this, _result, /* @__PURE__ */ new Map());
|
|
206697
206725
|
__privateSet(this, _cachePolicy, opts.cachePolicy);
|
|
206726
|
+
if (!opts.etherscanApiKey) {
|
|
206727
|
+
throw new Error("etherscan api key not specified");
|
|
206728
|
+
}
|
|
206698
206729
|
__privateSet(this, _etherscanApi, axios_1.default.create({
|
|
206699
206730
|
baseURL: "https://api.etherscan.io",
|
|
206700
206731
|
headers: {
|
|
@@ -206723,16 +206754,7 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206723
206754
|
__privateSet(this, _cacheDir, node_path_1.default.resolve(opts.sandboxDir, "etherscan"));
|
|
206724
206755
|
(0, node_fs_1.mkdirSync)(__privateGet(this, _cacheDir), { recursive: true });
|
|
206725
206756
|
}
|
|
206726
|
-
async
|
|
206727
|
-
var _a;
|
|
206728
|
-
if (!((_a = input.addresses) == null ? void 0 : _a.length) && !input.addressesFile) {
|
|
206729
|
-
throw new Error("please specify addresses or addresses file");
|
|
206730
|
-
}
|
|
206731
|
-
let addresses = input.addresses ?? [];
|
|
206732
|
-
if (addresses.length === 0) {
|
|
206733
|
-
const content = await (0, promises_1.readFile)(input.addressesFile, "utf-8");
|
|
206734
|
-
addresses = Object.keys(JSON.parse(content));
|
|
206735
|
-
}
|
|
206757
|
+
async verifyMany(addresses) {
|
|
206736
206758
|
for (const address of addresses) {
|
|
206737
206759
|
if (!address.startsWith("0x")) {
|
|
206738
206760
|
throw new Error(`invalid addresses detected: ${address}`);
|
|
@@ -206749,6 +206771,10 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206749
206771
|
__privateGet(this, _logger).info(`verification completed: ${goodCnt}/${addresses.length} are verified`);
|
|
206750
206772
|
return __privateGet(this, _result);
|
|
206751
206773
|
}
|
|
206774
|
+
async verify(address) {
|
|
206775
|
+
await __privateMethod(this, _verify, verify_fn).call(this, address.toLowerCase());
|
|
206776
|
+
return this.check(address);
|
|
206777
|
+
}
|
|
206752
206778
|
check(address) {
|
|
206753
206779
|
const result = __privateGet(this, _result).get(address.toLowerCase());
|
|
206754
206780
|
return result ?? { verified: false };
|
|
@@ -219548,7 +219574,7 @@ var require_CliRenderer = __commonJS({
|
|
|
219548
219574
|
console.log(`use ${chalk_1.default.cyan("arrows")} for navigation, ${(0, chalk_1.default)("a")} to print all and exit, ${chalk_1.default.cyan("ESC")} to exit`);
|
|
219549
219575
|
}
|
|
219550
219576
|
const { safeTxHash, batchFile, actions } = tx;
|
|
219551
|
-
const prefix = total > 1 ? ` ${i}/${total}` : "";
|
|
219577
|
+
const prefix = total > 1 ? ` ${i + 1}/${total}` : "";
|
|
219552
219578
|
if (safeTxHash) {
|
|
219553
219579
|
console.log(`Safe tx${prefix} ${chalk_1.default.green(safeTxHash)}:`);
|
|
219554
219580
|
}
|
|
@@ -294218,11 +294244,13 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294218
294244
|
var orderBy_1 = __importDefault2(require_orderBy());
|
|
294219
294245
|
var queue_1 = __importDefault2((init_queue(), __toCommonJS(queue_exports)));
|
|
294220
294246
|
var table_1 = require_src3();
|
|
294247
|
+
var Auditor_1 = require_Auditor();
|
|
294248
|
+
var EtherscanVerifier_1 = require_EtherscanVerifier();
|
|
294221
294249
|
var log_1 = __importDefault2(require_log());
|
|
294222
294250
|
var contracts_1 = require_contracts2();
|
|
294223
294251
|
var constants_1 = require_constants9();
|
|
294224
294252
|
var visitors_1 = require_visitors();
|
|
294225
|
-
var _logger, _provider, _outFile, _queue, _visited, _create2, _loadCache, loadCache_fn, _process, process_fn, _addToQueue, addToQueue_fn, _prettyPrint, prettyPrint_fn;
|
|
294253
|
+
var _logger, _provider, _etherscan, _auditor, _outFile, _queue, _visited, _create2, _loadCache, loadCache_fn, _process, process_fn, _addToQueue, addToQueue_fn, _prettyPrint, prettyPrint_fn;
|
|
294226
294254
|
var GearboxAddressTree3 = class {
|
|
294227
294255
|
constructor(options) {
|
|
294228
294256
|
__privateAdd(this, _loadCache);
|
|
@@ -294231,14 +294259,19 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294231
294259
|
__privateAdd(this, _prettyPrint);
|
|
294232
294260
|
__privateAdd(this, _logger, log_1.default.getSubLogger({ name: "tree" }));
|
|
294233
294261
|
__privateAdd(this, _provider, void 0);
|
|
294262
|
+
__privateAdd(this, _etherscan, void 0);
|
|
294263
|
+
__privateAdd(this, _auditor, void 0);
|
|
294234
294264
|
__privateAdd(this, _outFile, void 0);
|
|
294235
294265
|
__privateAdd(this, _queue, new queue_1.default({ concurrency: 5 }));
|
|
294236
294266
|
__privateAdd(this, _visited, /* @__PURE__ */ new Map());
|
|
294237
294267
|
__privateAdd(this, _create2, /* @__PURE__ */ new Map());
|
|
294238
294268
|
__privateSet(this, _provider, new ethers_1.ethers.providers.StaticJsonRpcProvider(options.mainnetRpc));
|
|
294239
294269
|
__privateSet(this, _outFile, node_path_1.default.resolve(options.sandboxDir, "tree.json"));
|
|
294270
|
+
__privateSet(this, _etherscan, new EtherscanVerifier_1.EtherscanVerifier(options));
|
|
294271
|
+
__privateSet(this, _auditor, new Auditor_1.Auditor(options));
|
|
294240
294272
|
}
|
|
294241
294273
|
async build(cachePolicy) {
|
|
294274
|
+
await __privateGet(this, _auditor).setup();
|
|
294242
294275
|
let queued = [];
|
|
294243
294276
|
if (cachePolicy !== "never") {
|
|
294244
294277
|
queued = await __privateMethod(this, _loadCache, loadCache_fn).call(this);
|
|
@@ -294319,6 +294352,8 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294319
294352
|
};
|
|
294320
294353
|
_logger = new WeakMap();
|
|
294321
294354
|
_provider = new WeakMap();
|
|
294355
|
+
_etherscan = new WeakMap();
|
|
294356
|
+
_auditor = new WeakMap();
|
|
294322
294357
|
_outFile = new WeakMap();
|
|
294323
294358
|
_queue = new WeakMap();
|
|
294324
294359
|
_visited = new WeakMap();
|
|
@@ -294351,6 +294386,18 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294351
294386
|
throw new Error(`detected ${entry.contract} with zero address`);
|
|
294352
294387
|
}
|
|
294353
294388
|
const newEntries = await (0, visitors_1.visitorFor)(entry).visit(entry, __privateGet(this, _provider), block);
|
|
294389
|
+
const etherscanEntry = await __privateGet(this, _etherscan).verify(entry.address);
|
|
294390
|
+
if (etherscanEntry.verified) {
|
|
294391
|
+
entry.etherscan = [];
|
|
294392
|
+
for (const contract of etherscanEntry.data) {
|
|
294393
|
+
const audits = await __privateGet(this, _auditor).auditEtherscanVerified(contract);
|
|
294394
|
+
entry.etherscan.push(...audits.map((a) => ({
|
|
294395
|
+
repo: a.repo,
|
|
294396
|
+
path: a.path,
|
|
294397
|
+
audits: a.audits
|
|
294398
|
+
})));
|
|
294399
|
+
}
|
|
294400
|
+
}
|
|
294354
294401
|
__privateGet(this, _visited).set(entry.address.toLowerCase(), entry);
|
|
294355
294402
|
let cnt = 0;
|
|
294356
294403
|
for (const newEntry of newEntries) {
|
|
@@ -346211,6 +346258,14 @@ var require_deploy = __commonJS({
|
|
|
346211
346258
|
}
|
|
346212
346259
|
});
|
|
346213
346260
|
|
|
346261
|
+
// ../../packages/lib/dist/types/etherscan.js
|
|
346262
|
+
var require_etherscan = __commonJS({
|
|
346263
|
+
"../../packages/lib/dist/types/etherscan.js"(exports2) {
|
|
346264
|
+
"use strict";
|
|
346265
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
346266
|
+
}
|
|
346267
|
+
});
|
|
346268
|
+
|
|
346214
346269
|
// ../../packages/lib/dist/types/forge.js
|
|
346215
346270
|
var require_forge = __commonJS({
|
|
346216
346271
|
"../../packages/lib/dist/types/forge.js"(exports2) {
|
|
@@ -346248,6 +346303,7 @@ var require_types23 = __commonJS({
|
|
|
346248
346303
|
__exportStar2(require_commands(), exports2);
|
|
346249
346304
|
__exportStar2(require_contracts2(), exports2);
|
|
346250
346305
|
__exportStar2(require_deploy(), exports2);
|
|
346306
|
+
__exportStar2(require_etherscan(), exports2);
|
|
346251
346307
|
__exportStar2(require_forge(), exports2);
|
|
346252
346308
|
__exportStar2(require_types22(), exports2);
|
|
346253
346309
|
}
|
|
@@ -365168,7 +365224,7 @@ var require_package3 = __commonJS({
|
|
|
365168
365224
|
module2.exports = {
|
|
365169
365225
|
name: "@gearbox-protocol/deploy-tools",
|
|
365170
365226
|
description: "Gearbox deploy tools",
|
|
365171
|
-
version: "1.6.0-next.
|
|
365227
|
+
version: "1.6.0-next.5",
|
|
365172
365228
|
homepage: "https://gearbox.fi",
|
|
365173
365229
|
keywords: [
|
|
365174
365230
|
"gearbox"
|
|
@@ -365350,21 +365406,30 @@ if no options are provided, will verify all pending transactions from safe multi
|
|
|
365350
365406
|
}
|
|
365351
365407
|
|
|
365352
365408
|
// src/commands/verify-etherscan.ts
|
|
365409
|
+
var import_promises = require("fs/promises");
|
|
365353
365410
|
var import_deploy_tools_lib4 = __toESM(require_dist10());
|
|
365354
365411
|
function verifyEtherscan() {
|
|
365355
365412
|
return new Command().name("verify-etherscan").description(
|
|
365356
365413
|
"performs bulk verification of gearbox contracts using etherscan"
|
|
365357
|
-
).addOption(
|
|
365358
|
-
new Option("--etherscan-api-key <key>", "etherscan api key").env(
|
|
365359
|
-
"ETHERSCAN_API_KEY"
|
|
365360
|
-
)
|
|
365361
365414
|
).addOption(
|
|
365362
365415
|
new Option(
|
|
365363
365416
|
"--addresses-file [json]",
|
|
365364
365417
|
"json file where keys are addresses to verify, e.g. gearbox contracts tree"
|
|
365365
365418
|
)
|
|
365366
365419
|
).addOption(new Option("--addresses [addr...]", "addresses to verify")).action(async (opts) => {
|
|
365367
|
-
|
|
365420
|
+
var _a;
|
|
365421
|
+
if (!((_a = opts.addresses) == null ? void 0 : _a.length) && !opts.addressesFile) {
|
|
365422
|
+
throw new Error("please specify addresses or addresses file");
|
|
365423
|
+
}
|
|
365424
|
+
let addresses = opts.addresses ?? [];
|
|
365425
|
+
if (addresses.length === 0 && opts.addressesFile) {
|
|
365426
|
+
const content = await (0, import_promises.readFile)(opts.addressesFile, "utf-8");
|
|
365427
|
+
addresses = Object.keys(JSON.parse(content));
|
|
365428
|
+
}
|
|
365429
|
+
if (!addresses.length) {
|
|
365430
|
+
throw new Error("no addresses provided");
|
|
365431
|
+
}
|
|
365432
|
+
await new import_deploy_tools_lib4.EtherscanVerifier(opts).verifyMany(addresses);
|
|
365368
365433
|
});
|
|
365369
365434
|
}
|
|
365370
365435
|
|
|
@@ -365397,6 +365462,10 @@ program2.commands.forEach((cmd) => {
|
|
|
365397
365462
|
new Option("--multisig <string>", "multisig contract address").default("0xA7D5DDc1b8557914F158076b228AA91eF613f1D5").env("MULTISIG")
|
|
365398
365463
|
).addOption(
|
|
365399
365464
|
new Option("--safe-api <string>", "safe api endpoint").default("https://safe-transaction-mainnet.safe.global").env("SAFE_API")
|
|
365465
|
+
).addOption(
|
|
365466
|
+
new Option("--etherscan-api-key [key]", "etherscan api key").env(
|
|
365467
|
+
"ETHERSCAN_API_KEY"
|
|
365468
|
+
)
|
|
365400
365469
|
);
|
|
365401
365470
|
});
|
|
365402
365471
|
program2.parse();
|