@gearbox-protocol/deploy-tools 1.6.0-next.5 → 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 +92 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -205654,10 +205654,25 @@ var require_utils9 = __commonJS({
|
|
|
205654
205654
|
}
|
|
205655
205655
|
exports2.decodeBatchTx = decodeBatchTx;
|
|
205656
205656
|
function extractFilesFromJSON(files) {
|
|
205657
|
-
return Object.entries(files).map(([path, file]) =>
|
|
205658
|
-
|
|
205659
|
-
|
|
205660
|
-
|
|
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
|
+
});
|
|
205661
205676
|
}
|
|
205662
205677
|
exports2.extractFilesFromJSON = extractFilesFromJSON;
|
|
205663
205678
|
function stringifyInvalidAndMissing(contract) {
|
|
@@ -205790,7 +205805,7 @@ var require_Auditor = __commonJS({
|
|
|
205790
205805
|
* checks audit of etherscan verification result
|
|
205791
205806
|
*/
|
|
205792
205807
|
async auditEtherscanVerified(contract) {
|
|
205793
|
-
const input =
|
|
205808
|
+
const input = parseEtherscanSourceCode(contract);
|
|
205794
205809
|
const files = (0, utils_1.extractFilesFromJSON)(input.sources).map(({ path, buffer }) => {
|
|
205795
205810
|
const p = path.replace("node_modules/", "");
|
|
205796
205811
|
const gearbox = p.startsWith("@gearbox-protocol");
|
|
@@ -205870,6 +205885,20 @@ var require_Auditor = __commonJS({
|
|
|
205870
205885
|
}
|
|
205871
205886
|
};
|
|
205872
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
|
+
}
|
|
205873
205902
|
}
|
|
205874
205903
|
});
|
|
205875
205904
|
|
|
@@ -206694,6 +206723,9 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206694
206723
|
__privateAdd(this, _cachePolicy, void 0);
|
|
206695
206724
|
__privateAdd(this, _result, /* @__PURE__ */ new Map());
|
|
206696
206725
|
__privateSet(this, _cachePolicy, opts.cachePolicy);
|
|
206726
|
+
if (!opts.etherscanApiKey) {
|
|
206727
|
+
throw new Error("etherscan api key not specified");
|
|
206728
|
+
}
|
|
206697
206729
|
__privateSet(this, _etherscanApi, axios_1.default.create({
|
|
206698
206730
|
baseURL: "https://api.etherscan.io",
|
|
206699
206731
|
headers: {
|
|
@@ -206722,16 +206754,7 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206722
206754
|
__privateSet(this, _cacheDir, node_path_1.default.resolve(opts.sandboxDir, "etherscan"));
|
|
206723
206755
|
(0, node_fs_1.mkdirSync)(__privateGet(this, _cacheDir), { recursive: true });
|
|
206724
206756
|
}
|
|
206725
|
-
async
|
|
206726
|
-
var _a;
|
|
206727
|
-
if (!((_a = input.addresses) == null ? void 0 : _a.length) && !input.addressesFile) {
|
|
206728
|
-
throw new Error("please specify addresses or addresses file");
|
|
206729
|
-
}
|
|
206730
|
-
let addresses = input.addresses ?? [];
|
|
206731
|
-
if (addresses.length === 0) {
|
|
206732
|
-
const content = await (0, promises_1.readFile)(input.addressesFile, "utf-8");
|
|
206733
|
-
addresses = Object.keys(JSON.parse(content));
|
|
206734
|
-
}
|
|
206757
|
+
async verifyMany(addresses) {
|
|
206735
206758
|
for (const address of addresses) {
|
|
206736
206759
|
if (!address.startsWith("0x")) {
|
|
206737
206760
|
throw new Error(`invalid addresses detected: ${address}`);
|
|
@@ -206748,6 +206771,10 @@ var require_EtherscanVerifier = __commonJS({
|
|
|
206748
206771
|
__privateGet(this, _logger).info(`verification completed: ${goodCnt}/${addresses.length} are verified`);
|
|
206749
206772
|
return __privateGet(this, _result);
|
|
206750
206773
|
}
|
|
206774
|
+
async verify(address) {
|
|
206775
|
+
await __privateMethod(this, _verify, verify_fn).call(this, address.toLowerCase());
|
|
206776
|
+
return this.check(address);
|
|
206777
|
+
}
|
|
206751
206778
|
check(address) {
|
|
206752
206779
|
const result = __privateGet(this, _result).get(address.toLowerCase());
|
|
206753
206780
|
return result ?? { verified: false };
|
|
@@ -294217,11 +294244,13 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294217
294244
|
var orderBy_1 = __importDefault2(require_orderBy());
|
|
294218
294245
|
var queue_1 = __importDefault2((init_queue(), __toCommonJS(queue_exports)));
|
|
294219
294246
|
var table_1 = require_src3();
|
|
294247
|
+
var Auditor_1 = require_Auditor();
|
|
294248
|
+
var EtherscanVerifier_1 = require_EtherscanVerifier();
|
|
294220
294249
|
var log_1 = __importDefault2(require_log());
|
|
294221
294250
|
var contracts_1 = require_contracts2();
|
|
294222
294251
|
var constants_1 = require_constants9();
|
|
294223
294252
|
var visitors_1 = require_visitors();
|
|
294224
|
-
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;
|
|
294225
294254
|
var GearboxAddressTree3 = class {
|
|
294226
294255
|
constructor(options) {
|
|
294227
294256
|
__privateAdd(this, _loadCache);
|
|
@@ -294230,14 +294259,19 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294230
294259
|
__privateAdd(this, _prettyPrint);
|
|
294231
294260
|
__privateAdd(this, _logger, log_1.default.getSubLogger({ name: "tree" }));
|
|
294232
294261
|
__privateAdd(this, _provider, void 0);
|
|
294262
|
+
__privateAdd(this, _etherscan, void 0);
|
|
294263
|
+
__privateAdd(this, _auditor, void 0);
|
|
294233
294264
|
__privateAdd(this, _outFile, void 0);
|
|
294234
294265
|
__privateAdd(this, _queue, new queue_1.default({ concurrency: 5 }));
|
|
294235
294266
|
__privateAdd(this, _visited, /* @__PURE__ */ new Map());
|
|
294236
294267
|
__privateAdd(this, _create2, /* @__PURE__ */ new Map());
|
|
294237
294268
|
__privateSet(this, _provider, new ethers_1.ethers.providers.StaticJsonRpcProvider(options.mainnetRpc));
|
|
294238
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));
|
|
294239
294272
|
}
|
|
294240
294273
|
async build(cachePolicy) {
|
|
294274
|
+
await __privateGet(this, _auditor).setup();
|
|
294241
294275
|
let queued = [];
|
|
294242
294276
|
if (cachePolicy !== "never") {
|
|
294243
294277
|
queued = await __privateMethod(this, _loadCache, loadCache_fn).call(this);
|
|
@@ -294318,6 +294352,8 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294318
294352
|
};
|
|
294319
294353
|
_logger = new WeakMap();
|
|
294320
294354
|
_provider = new WeakMap();
|
|
294355
|
+
_etherscan = new WeakMap();
|
|
294356
|
+
_auditor = new WeakMap();
|
|
294321
294357
|
_outFile = new WeakMap();
|
|
294322
294358
|
_queue = new WeakMap();
|
|
294323
294359
|
_visited = new WeakMap();
|
|
@@ -294350,6 +294386,18 @@ var require_GearboxAddressTree = __commonJS({
|
|
|
294350
294386
|
throw new Error(`detected ${entry.contract} with zero address`);
|
|
294351
294387
|
}
|
|
294352
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
|
+
}
|
|
294353
294401
|
__privateGet(this, _visited).set(entry.address.toLowerCase(), entry);
|
|
294354
294402
|
let cnt = 0;
|
|
294355
294403
|
for (const newEntry of newEntries) {
|
|
@@ -346210,6 +346258,14 @@ var require_deploy = __commonJS({
|
|
|
346210
346258
|
}
|
|
346211
346259
|
});
|
|
346212
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
|
+
|
|
346213
346269
|
// ../../packages/lib/dist/types/forge.js
|
|
346214
346270
|
var require_forge = __commonJS({
|
|
346215
346271
|
"../../packages/lib/dist/types/forge.js"(exports2) {
|
|
@@ -346247,6 +346303,7 @@ var require_types23 = __commonJS({
|
|
|
346247
346303
|
__exportStar2(require_commands(), exports2);
|
|
346248
346304
|
__exportStar2(require_contracts2(), exports2);
|
|
346249
346305
|
__exportStar2(require_deploy(), exports2);
|
|
346306
|
+
__exportStar2(require_etherscan(), exports2);
|
|
346250
346307
|
__exportStar2(require_forge(), exports2);
|
|
346251
346308
|
__exportStar2(require_types22(), exports2);
|
|
346252
346309
|
}
|
|
@@ -365167,7 +365224,7 @@ var require_package3 = __commonJS({
|
|
|
365167
365224
|
module2.exports = {
|
|
365168
365225
|
name: "@gearbox-protocol/deploy-tools",
|
|
365169
365226
|
description: "Gearbox deploy tools",
|
|
365170
|
-
version: "1.6.0-next.
|
|
365227
|
+
version: "1.6.0-next.5",
|
|
365171
365228
|
homepage: "https://gearbox.fi",
|
|
365172
365229
|
keywords: [
|
|
365173
365230
|
"gearbox"
|
|
@@ -365349,21 +365406,30 @@ if no options are provided, will verify all pending transactions from safe multi
|
|
|
365349
365406
|
}
|
|
365350
365407
|
|
|
365351
365408
|
// src/commands/verify-etherscan.ts
|
|
365409
|
+
var import_promises = require("fs/promises");
|
|
365352
365410
|
var import_deploy_tools_lib4 = __toESM(require_dist10());
|
|
365353
365411
|
function verifyEtherscan() {
|
|
365354
365412
|
return new Command().name("verify-etherscan").description(
|
|
365355
365413
|
"performs bulk verification of gearbox contracts using etherscan"
|
|
365356
|
-
).addOption(
|
|
365357
|
-
new Option("--etherscan-api-key <key>", "etherscan api key").env(
|
|
365358
|
-
"ETHERSCAN_API_KEY"
|
|
365359
|
-
)
|
|
365360
365414
|
).addOption(
|
|
365361
365415
|
new Option(
|
|
365362
365416
|
"--addresses-file [json]",
|
|
365363
365417
|
"json file where keys are addresses to verify, e.g. gearbox contracts tree"
|
|
365364
365418
|
)
|
|
365365
365419
|
).addOption(new Option("--addresses [addr...]", "addresses to verify")).action(async (opts) => {
|
|
365366
|
-
|
|
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);
|
|
365367
365433
|
});
|
|
365368
365434
|
}
|
|
365369
365435
|
|
|
@@ -365396,6 +365462,10 @@ program2.commands.forEach((cmd) => {
|
|
|
365396
365462
|
new Option("--multisig <string>", "multisig contract address").default("0xA7D5DDc1b8557914F158076b228AA91eF613f1D5").env("MULTISIG")
|
|
365397
365463
|
).addOption(
|
|
365398
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
|
+
)
|
|
365399
365469
|
);
|
|
365400
365470
|
});
|
|
365401
365471
|
program2.parse();
|