Skip to content

Commit

Permalink
feat: ensure right import paths used with tron-solc
Browse files Browse the repository at this point in the history
  • Loading branch information
aurel-fr committed Dec 4, 2023
1 parent d15dd91 commit d291d4e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@layerzerolabs/hardhat-deploy",
"version": "0.11.43-lz.4",
"version": "0.11.43-lz.5",
"description": "Hardhat Plugin For Replicable Deployments And Tests",
"repository": {
"type": "git",
Expand Down
37 changes: 37 additions & 0 deletions src/DeploymentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,13 @@ export class DeploymentsManager {
if (this.env.config.external?.contracts) {
for (const externalContracts of this.env.config.external.contracts) {
if (externalContracts.deploy) {
// make sure we're not deploying on Tron contracts that are not meant to be deployed there
if (
this.env.config.paths.artifacts.endsWith('-tron') && // are we using tron-solc compiler?
externalContracts.artifacts.some((str) => !str.endsWith('-tron')) // are some of the artifacts folder not ending in -tron?
) {
continue;
}
this.db.onlyArtifacts = externalContracts.artifacts;
try {
await this.executeDeployScripts(
Expand Down Expand Up @@ -1385,7 +1392,37 @@ export class DeploymentsManager {
}
}

/**
* Retrieves import paths for Tron-specific contracts.
*
* This method enforces a safety check to ensure that only contracts compiled for Tron are deployed.
* It requires that import paths for external folders must end with '-tron'. The method checks both
* the project's own import paths and any external contracts specified in the configuration.
*
* @returns {string[]} An array of import paths that conform to the Tron-specific naming convention.
*/
private getTronImportPaths() {
const importPaths = [];
if (this.env.config.paths.imports.endsWith('-tron')) {
importPaths.push(this.env.config.paths.imports);
}
if (this.env.config.external && this.env.config.external.contracts) {
for (const externalContracts of this.env.config.external.contracts) {
for (const artifact of externalContracts.artifacts) {
if (artifact.endsWith('-tron')) {
importPaths.push(artifact);
}
}
}
}
return importPaths;
}

private getImportPaths() {
// this check is true when the hardhat-tron-solc plugin is used
if (this.env.config.paths.artifacts.endsWith('-tron')) {
return this.getTronImportPaths();
}
const importPaths = [this.env.config.paths.imports];
if (this.env.config.external && this.env.config.external.contracts) {
for (const externalContracts of this.env.config.external.contracts) {
Expand Down

0 comments on commit d291d4e

Please sign in to comment.