Skip to content

Commit

Permalink
feat: store deployment transaction hash in contract storage and add a…
Browse files Browse the repository at this point in the history
… getter
  • Loading branch information
kittybest committed May 22, 2024
1 parent a824632 commit b2d8e18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions contracts/tasks/helpers/ContractStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class ContractStorage {

const logEntry: IStorageInstanceEntry = {
id,
deploymentTxHash: deploymentTx?.hash,
};

if (args !== undefined) {
Expand Down Expand Up @@ -177,6 +178,20 @@ export class ContractStorage {
return address;
}

/**
* Get Contract Deployment Transaction Hash
*/
getDeploymentTxHash(id: EContracts, network: string, address: string): string | undefined {
const collection = this.db.get(`${network}.instance.${address}`);
const instanceEntry = collection.value() as IStorageInstanceEntry | undefined;

if (instanceEntry?.id !== id) {
throw new Error(`Contract ${id} with address ${address} not found.`);
}

return instanceEntry.deploymentTxHash;
}

/**
* Get contract from the json file with sizes and multi count
*
Expand Down
5 changes: 5 additions & 0 deletions contracts/tasks/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ export interface IStorageInstanceEntry {
*/
id: string;

/**
* Deployment Transaction Hash
*/
deploymentTxHash?: string;

/**
* Params for verification
*/
Expand Down

0 comments on commit b2d8e18

Please sign in to comment.