diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ac28f..3d88d1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/package.json b/package.json index 9e89ffa..d6f5da4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/deployer/adapters/AbstractEthersAdapter.ts b/src/deployer/adapters/AbstractEthersAdapter.ts index 5f699d3..7499f1f 100644 --- a/src/deployer/adapters/AbstractEthersAdapter.ts +++ b/src/deployer/adapters/AbstractEthersAdapter.ts @@ -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"; @@ -187,9 +189,10 @@ 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!, @@ -197,4 +200,12 @@ export abstract class AbstractEthersAdapter extends Adapter { to: tx.to, }; } + + private _getTransactionName(tx: ContractTransaction): string { + if (tx.customData === undefined || tx.customData.txName === undefined) { + return UNKNOWN_TRANSACTION_NAME; + } + + return tx.customData.txName; + } }