@mapprotocol/common-contracts 0.4.1 → 0.4.3
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/factory.js +4 -2
- package/utils/dist/verifier.d.ts +7 -0
- package/utils/dist/verifier.js +2 -2
- package/utils/factory.ts +4 -2
- package/utils/verifier.ts +9 -2
package/package.json
CHANGED
package/utils/dist/factory.js
CHANGED
|
@@ -71,7 +71,8 @@ async function evmDeployByFactory(ethers, salt, bytecode, constructorArgs = "0x"
|
|
|
71
71
|
if (code === "0x")
|
|
72
72
|
throw new Error("factory not deployed on this chain");
|
|
73
73
|
const saltHash = ethers.keccak256(ethers.toUtf8Bytes(salt));
|
|
74
|
-
|
|
74
|
+
// Use getFunction: ethers v6 Contract has a built-in getAddress() that shadows the ABI method
|
|
75
|
+
const predicted = await factory.getFunction("getAddress")(saltHash);
|
|
75
76
|
const existingCode = await ethers.provider.getCode(predicted);
|
|
76
77
|
if (existingCode !== "0x") {
|
|
77
78
|
console.log(`already deployed at ${predicted}`);
|
|
@@ -98,7 +99,8 @@ async function evmDeployByFactory(ethers, salt, bytecode, constructorArgs = "0x"
|
|
|
98
99
|
async function evmGetFactoryAddress(ethers, salt) {
|
|
99
100
|
const factory = new ethers.Contract(EVM_FACTORY, EVM_FACTORY_ABI, await ethers.provider);
|
|
100
101
|
const saltHash = ethers.keccak256(ethers.toUtf8Bytes(salt));
|
|
101
|
-
|
|
102
|
+
// Use getFunction: ethers v6 Contract has a built-in getAddress() that shadows the ABI method
|
|
103
|
+
return factory.getFunction("getAddress")(saltHash);
|
|
102
104
|
}
|
|
103
105
|
// ============================================================
|
|
104
106
|
// Tron Factory (CREATE2, tronweb)
|
package/utils/dist/verifier.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export interface VerifyOptions {
|
|
|
17
17
|
compiler?: string;
|
|
18
18
|
optimizer?: boolean;
|
|
19
19
|
optimizerRuns?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Reuse an existing verify-output/<contract>_flatten.sol instead of regenerating it.
|
|
22
|
+
* Off by default: the flatten is always regenerated from current source, because a
|
|
23
|
+
* cached file keyed only on the contract name silently verifies STALE source after
|
|
24
|
+
* the contract changes. Only enable this when you intentionally hand-edited the flatten.
|
|
25
|
+
*/
|
|
26
|
+
reuseFlatten?: boolean;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Unified contract verification — auto-routes to EVM (hardhat verify) or Tron (TronScan API)
|
package/utils/dist/verifier.js
CHANGED
|
@@ -81,8 +81,8 @@ async function verifyTron(hre, opts) {
|
|
|
81
81
|
// Generate flattened source
|
|
82
82
|
const outputDir = path.join(process.cwd(), "verify-output");
|
|
83
83
|
const flattenPath = path.join(outputDir, `${opts.contractName}_flatten.sol`);
|
|
84
|
-
if (fs.existsSync(flattenPath)) {
|
|
85
|
-
console.log(`
|
|
84
|
+
if (opts.reuseFlatten && fs.existsSync(flattenPath)) {
|
|
85
|
+
console.log(`reusing existing flatten: ${flattenPath}`);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
88
|
console.log(`generating flatten for ${opts.contractName}...`);
|
package/utils/factory.ts
CHANGED
|
@@ -76,7 +76,8 @@ export async function evmDeployByFactory(
|
|
|
76
76
|
if (code === "0x") throw new Error("factory not deployed on this chain");
|
|
77
77
|
|
|
78
78
|
const saltHash = ethers.keccak256(ethers.toUtf8Bytes(salt));
|
|
79
|
-
|
|
79
|
+
// Use getFunction: ethers v6 Contract has a built-in getAddress() that shadows the ABI method
|
|
80
|
+
const predicted = await factory.getFunction("getAddress")(saltHash);
|
|
80
81
|
|
|
81
82
|
const existingCode = await ethers.provider.getCode(predicted);
|
|
82
83
|
if (existingCode !== "0x") {
|
|
@@ -108,7 +109,8 @@ export async function evmDeployByFactory(
|
|
|
108
109
|
export async function evmGetFactoryAddress(ethers: any, salt: string): Promise<string> {
|
|
109
110
|
const factory = new ethers.Contract(EVM_FACTORY, EVM_FACTORY_ABI, await ethers.provider);
|
|
110
111
|
const saltHash = ethers.keccak256(ethers.toUtf8Bytes(salt));
|
|
111
|
-
|
|
112
|
+
// Use getFunction: ethers v6 Contract has a built-in getAddress() that shadows the ABI method
|
|
113
|
+
return factory.getFunction("getAddress")(saltHash);
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
// ============================================================
|
package/utils/verifier.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface VerifyOptions {
|
|
|
29
29
|
compiler?: string; // override solc version (auto-read from build-info if omitted)
|
|
30
30
|
optimizer?: boolean; // override optimizer enabled (auto-read from build-info if omitted)
|
|
31
31
|
optimizerRuns?: number; // override optimizer runs (auto-read from build-info if omitted)
|
|
32
|
+
/**
|
|
33
|
+
* Reuse an existing verify-output/<contract>_flatten.sol instead of regenerating it.
|
|
34
|
+
* Off by default: the flatten is always regenerated from current source, because a
|
|
35
|
+
* cached file keyed only on the contract name silently verifies STALE source after
|
|
36
|
+
* the contract changes. Only enable this when you intentionally hand-edited the flatten.
|
|
37
|
+
*/
|
|
38
|
+
reuseFlatten?: boolean;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -108,8 +115,8 @@ async function verifyTron(hre: any, opts: VerifyOptions): Promise<void> {
|
|
|
108
115
|
const outputDir = path.join(process.cwd(), "verify-output");
|
|
109
116
|
const flattenPath = path.join(outputDir, `${opts.contractName}_flatten.sol`);
|
|
110
117
|
|
|
111
|
-
if (fs.existsSync(flattenPath)) {
|
|
112
|
-
console.log(`
|
|
118
|
+
if (opts.reuseFlatten && fs.existsSync(flattenPath)) {
|
|
119
|
+
console.log(`reusing existing flatten: ${flattenPath}`);
|
|
113
120
|
} else {
|
|
114
121
|
console.log(`generating flatten for ${opts.contractName}...`);
|
|
115
122
|
let sourcePath = "";
|