Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the potentially undefined tx.customData.txName field #62

Merged
merged 3 commits into from
Dec 11, 2023
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 2.0.0-alpha.19

* Handle the potentially undefined tx.customData.txName field

## Version 2.0.0-alpha.18

* Handle the partially linked Bytecode in the Truffle Adapter.
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": "@solarity/hardhat-migrate",
"version": "2.0.0-alpha.18",
"version": "2.0.0-alpha.19",
"description": "Automatic deployment and verification of smart contracts",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion src/deployer/adapters/AbstractEthersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { MinimalContract } from "../MinimalContract";

import "../../type-extensions";

import { UNKNOWN_TRANSACTION_NAME } from "../../constants";

import { bytecodeToString, fillParameters, getMethodString, getSignerHelper } from "../../utils";

import { OverridesAndLibs, OverridesAndName } from "../../types/deployer";
Expand Down Expand Up @@ -187,14 +189,23 @@ export abstract class AbstractEthersAdapter extends Adapter {
} as unknown as ContractTransactionResponse;
}

// TODO: run normal migrations in tests.
private _getKeyFieldsFromTransaction(tx: ContractTransaction): KeyTransactionFields {
return {
name: tx.customData.txName,
name: this._getTransactionName(tx),
data: tx.data,
from: tx.from!,
chainId: tx.chainId!,
value: tx.value!,
to: tx.to,
};
}

private _getTransactionName(tx: ContractTransaction): string {
if (tx.customData === undefined || tx.customData.txName === undefined) {
return UNKNOWN_TRANSACTION_NAME;
}

return tx.customData.txName;
}
}