@mapprotocol/common-contracts 0.4.0 → 0.4.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/package.json +1 -1
- package/utils/dist/verifier.js +15 -3
- package/utils/verifier.ts +14 -3
package/package.json
CHANGED
package/utils/dist/verifier.js
CHANGED
|
@@ -27,7 +27,17 @@ async function verify(hre, opts) {
|
|
|
27
27
|
// EVM verification via hardhat-verify
|
|
28
28
|
// ============================================================
|
|
29
29
|
async function verifyEvm(hre, opts) {
|
|
30
|
-
|
|
30
|
+
// Resolve contractPath from hardhat artifact (authoritative) instead of guessing
|
|
31
|
+
let contractPath = opts.contractPath;
|
|
32
|
+
if (!contractPath) {
|
|
33
|
+
try {
|
|
34
|
+
const artifact = await hre.artifacts.readArtifact(opts.contractName);
|
|
35
|
+
contractPath = `${artifact.sourceName}:${opts.contractName}`;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
contractPath = `contracts/${opts.contractName}.sol:${opts.contractName}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
console.log(`verifying ${opts.contractName} at ${opts.address} ...`);
|
|
32
42
|
try {
|
|
33
43
|
await hre.run("verify:verify", {
|
|
@@ -76,9 +86,10 @@ async function verifyTron(hre, opts) {
|
|
|
76
86
|
}
|
|
77
87
|
else {
|
|
78
88
|
console.log(`generating flatten for ${opts.contractName}...`);
|
|
89
|
+
let sourcePath = "";
|
|
79
90
|
try {
|
|
80
91
|
const artifact = await hre.artifacts.readArtifact(opts.contractName);
|
|
81
|
-
|
|
92
|
+
sourcePath = artifact.sourceName;
|
|
82
93
|
let flattenedSource = await hre.run("flatten:get-flattened-sources", {
|
|
83
94
|
files: [sourcePath],
|
|
84
95
|
});
|
|
@@ -88,7 +99,8 @@ async function verifyTron(hre, opts) {
|
|
|
88
99
|
console.log(`flatten saved to: ${flattenPath}`);
|
|
89
100
|
}
|
|
90
101
|
catch (e) {
|
|
91
|
-
|
|
102
|
+
const hint = sourcePath || `contracts/${opts.contractName}.sol`;
|
|
103
|
+
console.log(`flatten failed, generate manually: npx hardhat flatten ${hint} > ${flattenPath}`);
|
|
92
104
|
return;
|
|
93
105
|
}
|
|
94
106
|
}
|
package/utils/verifier.ts
CHANGED
|
@@ -49,7 +49,16 @@ export async function verify(hre: any, opts: VerifyOptions): Promise<void> {
|
|
|
49
49
|
// ============================================================
|
|
50
50
|
|
|
51
51
|
async function verifyEvm(hre: any, opts: VerifyOptions): Promise<void> {
|
|
52
|
-
|
|
52
|
+
// Resolve contractPath from hardhat artifact (authoritative) instead of guessing
|
|
53
|
+
let contractPath = opts.contractPath;
|
|
54
|
+
if (!contractPath) {
|
|
55
|
+
try {
|
|
56
|
+
const artifact = await hre.artifacts.readArtifact(opts.contractName);
|
|
57
|
+
contractPath = `${artifact.sourceName}:${opts.contractName}`;
|
|
58
|
+
} catch {
|
|
59
|
+
contractPath = `contracts/${opts.contractName}.sol:${opts.contractName}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
53
62
|
|
|
54
63
|
console.log(`verifying ${opts.contractName} at ${opts.address} ...`);
|
|
55
64
|
|
|
@@ -103,9 +112,10 @@ async function verifyTron(hre: any, opts: VerifyOptions): Promise<void> {
|
|
|
103
112
|
console.log(`using existing flatten: ${flattenPath}`);
|
|
104
113
|
} else {
|
|
105
114
|
console.log(`generating flatten for ${opts.contractName}...`);
|
|
115
|
+
let sourcePath = "";
|
|
106
116
|
try {
|
|
107
117
|
const artifact = await hre.artifacts.readArtifact(opts.contractName);
|
|
108
|
-
|
|
118
|
+
sourcePath = artifact.sourceName;
|
|
109
119
|
let flattenedSource = await hre.run("flatten:get-flattened-sources", {
|
|
110
120
|
files: [sourcePath],
|
|
111
121
|
});
|
|
@@ -114,7 +124,8 @@ async function verifyTron(hre: any, opts: VerifyOptions): Promise<void> {
|
|
|
114
124
|
fs.writeFileSync(flattenPath, flattenedSource);
|
|
115
125
|
console.log(`flatten saved to: ${flattenPath}`);
|
|
116
126
|
} catch (e) {
|
|
117
|
-
|
|
127
|
+
const hint = sourcePath || `contracts/${opts.contractName}.sol`;
|
|
128
|
+
console.log(`flatten failed, generate manually: npx hardhat flatten ${hint} > ${flattenPath}`);
|
|
118
129
|
return;
|
|
119
130
|
}
|
|
120
131
|
}
|