Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"semi": true
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/).

## [1.4.0] - 2025-12-31

### Added
- Integrated Hardhat compilation error reporting for Solidity and Vyper.
- Enhanced VS Code extension to display compilation diagnostics (red squiggles).
- Refactored Hardhat tasks (audit, compile) into separate module files.

## [1.3.0] - 2025-12-19

### Added
Expand Down
10 changes: 5 additions & 5 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {internalTask, task} from 'hardhat/config';
import { internalTask, task } from 'hardhat/config';
import {
TASK_COMPILE_SOLIDITY_GET_COMPILER_INPUT,
TASK_COMPILE,
} from 'hardhat/builtin-tasks/task-names';
import fs from 'fs-extra';
import path from 'path';
import {Artifact, BuildInfo} from 'hardhat/types';
import { Artifact, BuildInfo } from 'hardhat/types';
import murmur128 from 'murmur-128';
// Somewhat counterintuive, @layerzerolabs/hardhat-deploy is a devDependency of itself.
// It is required by hardhat-tron-solc who lists this package as a peerDependency.
import {HardhatUserConfig} from '@layerzerolabs/hardhat-deploy';
import { HardhatUserConfig } from '@layerzerolabs/hardhat-deploy';

function addIfNotPresent(array: string[], value: string) {
if (array.indexOf(value) === -1) {
Expand All @@ -18,8 +18,8 @@ function addIfNotPresent(array: string[], value: string) {
}

function setupExtraSolcSettings(settings: {
metadata?: {useLiteralContent?: boolean};
outputSelection: {[key: string]: {[key: string]: string[]}};
metadata?: { useLiteralContent?: boolean };
outputSelection: { [key: string]: { [key: string]: string[] } };
}): void {
settings.metadata = settings.metadata || {};
settings.metadata.useLiteralContent = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sun-protocol/sunhat",
"version": "1.3.0",
"version": "1.4.0",
"description": "An All-in-One Toolkit for the Complete TRON Smart Contract Lifecycle",
"repository": "https://github.com/sun-protocol/sunhat.git",
"author": "sun-protocol",
Expand Down
20 changes: 10 additions & 10 deletions src/DeploymentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class DeploymentFactory {
);
} else if (this.isTron) {
let contractName = '';
if ('contractName' in artifact) ({contractName} = artifact);
if ('contractName' in artifact) ({ contractName } = artifact);
this.factory = new TronContractFactory(
artifact.abi,
artifact.bytecode,
Expand Down Expand Up @@ -129,14 +129,14 @@ export class DeploymentFactory {
const prefix = isTron ? '0x41' : '0xff';
return getAddress(
'0x' +
solidityKeccak256(
['bytes'],
[
`${prefix}${create2DeployerAddress.slice(2)}${salt.slice(
2
)}${solidityKeccak256(['bytes'], [deploymentTx.data]).slice(2)}`,
]
).slice(-40)
solidityKeccak256(
['bytes'],
[
`${prefix}${create2DeployerAddress.slice(2)}${salt.slice(
2
)}${solidityKeccak256(['bytes'], [deploymentTx.data]).slice(2)}`,
]
).slice(-40)
);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ export class DeploymentFactory {

return transaction.data !== newData || currentFlattened != newFlattened;
} else if (this.isTron) {
const tronDeployTx = newTransaction as CreateSmartContract;
const tronDeployTx = newTransaction as CreateSmartContract;
const res = await (
this.factory.signer as TronSigner
).getTronWebTransaction(transaction.hash);
Expand Down
58 changes: 29 additions & 29 deletions src/DeploymentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
Export,
DeterministicDeploymentInfo,
} from '../types';
import {ExtendedArtifact} from '../types';
import {PartialExtension} from './internal/types';
import { ExtendedArtifact } from '../types';
import { PartialExtension } from './internal/types';

import fs from 'fs-extra';
import path from 'path';

import {BigNumber} from '@ethersproject/bignumber';
import { BigNumber } from '@ethersproject/bignumber';

import debug from 'debug';
const log = debug('hardhat:sun-protocol:tron-studio');
Expand All @@ -30,11 +30,11 @@ import {
getNetworkName,
getDeployPaths,
} from './utils';
import {addHelpers, waitForTx} from './helpers';
import {TransactionResponse} from '@ethersproject/providers';
import {Artifact, HardhatRuntimeEnvironment, Network} from 'hardhat/types';
import {store} from './globalStore';
import {bnReplacer} from './internal/utils';
import { addHelpers, waitForTx } from './helpers';
import { TransactionResponse } from '@ethersproject/providers';
import { Artifact, HardhatRuntimeEnvironment, Network } from 'hardhat/types';
import { store } from './globalStore';
import { bnReplacer } from './internal/utils';

export class DeploymentsManager {
public deploymentsExtension: DeploymentsExtension;
Expand All @@ -43,7 +43,7 @@ export class DeploymentsManager {
gasUsed: BigNumber;
bandwith: BigNumber;
accountsLoaded: boolean;
namedAccounts: {[name: string]: string};
namedAccounts: { [name: string]: string };
unnamedAccounts: string[];
deploymentsLoaded: boolean;
deployments: Record<string, Deployment>;
Expand All @@ -60,12 +60,12 @@ export class DeploymentsManager {
};
};
logEnabled: boolean;
pendingTransactions: {[hash: string]: any};
pendingTransactions: { [hash: string]: any };
savePendingTx: boolean;
gasPrice?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
migrations: {[id: string]: number};
migrations: { [id: string]: number };
onlyArtifacts?: string[];
runAsNode: boolean;
};
Expand All @@ -75,7 +75,7 @@ export class DeploymentsManager {

public impersonateUnknownAccounts: boolean;
public impersonatedAccounts: string[];
public addressesToProtocol: {[address: string]: string} = {};
public addressesToProtocol: { [address: string]: string } = {};
public readonly isTronNetworkWithTronSolc: boolean = false;

private network: Network;
Expand Down Expand Up @@ -292,7 +292,7 @@ export class DeploymentsManager {
}
) => {
await this.setup(tags === undefined);
options = {fallbackToGlobal: true, ...options};
options = { fallbackToGlobal: true, ...options };
if (typeof tags === 'string') {
tags = [tags];
}
Expand Down Expand Up @@ -413,7 +413,7 @@ export class DeploymentsManager {
maxPriorityFeePerGas = BigNumber.from(this.db.maxPriorityFeePerGas);
}
}
return {gasPrice, maxFeePerGas, maxPriorityFeePerGas};
return { gasPrice, maxFeePerGas, maxPriorityFeePerGas };
},
this.partialExtension.log,
print
Expand Down Expand Up @@ -547,8 +547,8 @@ export class DeploymentsManager {
chainId: tx.chainId,
};
this.db.pendingTransactions[tx.hash] = name
? {name, deployment, rawTx, decoded}
: {rawTx, decoded};
? { name, deployment, rawTx, decoded }
: { rawTx, decoded };
fs.writeFileSync(
pendingTxPath,
JSON.stringify(this.db.pendingTransactions, bnReplacer, ' ')
Expand All @@ -568,7 +568,7 @@ export class DeploymentsManager {
);
}
this.db.gasUsed = this.db.gasUsed.add(receipt.gasUsed);
if(rawTx){
if (rawTx) {
this.db.bandwith = this.db.bandwith.add(rawTx?.length);
}
return receipt;
Expand All @@ -584,7 +584,7 @@ export class DeploymentsManager {
return tx;
}

public async getNamedAccounts(): Promise<{[name: string]: string}> {
public async getNamedAccounts(): Promise<{ [name: string]: string }> {
await this.setupAccounts();
return this.db.namedAccounts;
}
Expand Down Expand Up @@ -632,7 +632,7 @@ export class DeploymentsManager {

public async loadDeployments(
chainIdExpected = true
): Promise<{[name: string]: Deployment}> {
): Promise<{ [name: string]: Deployment }> {
let chainId: string | undefined;
if (chainIdExpected) {
chainId = await this.getChainId();
Expand Down Expand Up @@ -867,7 +867,7 @@ export class DeploymentsManager {

let numDeployments = 1;
const oldDeployment = this.db.deployments[name]
? {...this.db.deployments[name]}
? { ...this.db.deployments[name] }
: undefined;
if (oldDeployment) {
numDeployments = (oldDeployment.numDeployments || 1) + 1;
Expand All @@ -880,7 +880,7 @@ export class DeploymentsManager {
JSON.stringify(
{
address: deployment.address || actualReceipt?.contractAddress,
addressHex : deployment.addressHex,
addressHex: deployment.addressHex,
abi: deployment.abi,
transactionHash:
deployment.transactionHash || actualReceipt?.transactionHash,
Expand Down Expand Up @@ -980,7 +980,7 @@ export class DeploymentsManager {
return true;
}

private companionManagers: {[name: string]: DeploymentsManager} = {};
private companionManagers: { [name: string]: DeploymentsManager } = {};
public addCompanionManager(
name: string,
networkDeploymentsManager: DeploymentsManager
Expand Down Expand Up @@ -1009,7 +1009,7 @@ export class DeploymentsManager {
writeDeploymentsToFiles: true,
savePendingTx: false,
}
): Promise<{[name: string]: Deployment}> {
): Promise<{ [name: string]: Deployment }> {
log('runDeploy');
this.setupNetwork();
if (options.deletePreviousDeployments) {
Expand Down Expand Up @@ -1122,8 +1122,8 @@ export class DeploymentsManager {
});
log('deploy script folder parsed');

const funcByFilePath: {[filename: string]: DeployFunction} = {};
const scriptPathBags: {[tag: string]: string[]} = {};
const funcByFilePath: { [filename: string]: DeployFunction } = {};
const scriptPathBags: { [tag: string]: string[] } = {};
const scriptFilePaths: string[] = [];
for (const filepath of filepaths) {
const scriptFilePath = path.resolve(filepath);
Expand Down Expand Up @@ -1170,7 +1170,7 @@ export class DeploymentsManager {
log('tag collected');

// console.log({ scriptFilePaths });
const scriptsRegisteredToRun: {[filename: string]: boolean} = {};
const scriptsRegisteredToRun: { [filename: string]: boolean } = {};
const scriptsToRun: Array<{
func: DeployFunction;
filePath: string;
Expand Down Expand Up @@ -1483,7 +1483,7 @@ export class DeploymentsManager {
snapshot,
data,
blockHash: latestBlock.hash,
deployments: {...this.db.deployments},
deployments: { ...this.db.deployments },
};
} catch (err) {
log(`failed to create snapshot`);
Expand Down Expand Up @@ -1519,7 +1519,7 @@ export class DeploymentsManager {
);
if (blockRetrieved) {
saved.snapshot = await this.network.provider.send('evm_snapshot', []); // it is necessary to re-snapshot it
this.db.deployments = {...saved.deployments};
this.db.deployments = { ...saved.deployments };
} else {
// TODO or should we throw ?
return false;
Expand Down Expand Up @@ -1569,7 +1569,7 @@ export class DeploymentsManager {
}

public async setupAccounts(): Promise<{
namedAccounts: {[name: string]: string};
namedAccounts: { [name: string]: string };
unnamedAccounts: string[];
}> {
if (!this.db.accountsLoaded) {
Expand Down
Loading