Skip to content

Commit

Permalink
Changed the way of naming for Truffle transactions to txName
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Dec 23, 2023
1 parent 4746ab7 commit 5d0f17d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 2.0.1

* Fixed a bug where an instance of a storage object overwrote the state of another object in the file.
* Changed the way of naming for Truffle transactions to `txName`.

## Version 2.0.0

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,17 @@ A special field, `txName`, is dedicated for this purpose.
Here’s an example of how to set a transaction name using Ethers.js:

```javascript
await contract.runner.sendTransaction({ customData: { txName: "Funding Transaction" }});
await govToken.transferOwnership(TOKEN_OWNER, { customData: { txName: "Transfer Ownership" }});
```

This method helps avoid potential collisions and ensures a smoother recovery process.

#### Truffle Usage:

For those using Truffle, the transaction name can be specified using the `hardfork` field. Here's how you can do it:
For those using Truffle, the transaction name can be specified using the `txName` field. Here's how you can do it:

``` javascript
await contract.send(1, { hardfork: "Funding Transaction" });
await govToken.transferOwnership(TOKEN_OWNER, { txName: "Transfer Ownership" });
```

#### Purpose
Expand Down
2 changes: 1 addition & 1 deletion src/deployer/adapters/TruffleAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class TruffleAdapter extends Adapter {

private _getTransactionName(contractMethod: ethers.ContractMethod<any[], any, any>, args: any[]): string {
if (contractMethod.fragment.inputs.length + 1 === args.length) {
return args[args.length - 1].hardfork || UNKNOWN_TRANSACTION_NAME;
return args[args.length - 1].txName || UNKNOWN_TRANSACTION_NAME;
}

return UNKNOWN_TRANSACTION_NAME;
Expand Down
9 changes: 9 additions & 0 deletions src/type-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ declare module "ethers" {
customData: any & { txName?: string };
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Truffle {
interface TransactionDetails {
txName?: string;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export = async (deployer: Deployer) => {
},
});

await govToken.transferOwnership(TOKEN_OWNER);
await govToken.transferOwnership(TOKEN_OWNER, { customData: { txName: "Transfer Ownership" } });

const fundingTransaction = await deployer.sendNative(TOKEN_OWNER, 100n, "Funding Governance Token Owner #1");
await Reporter.reportTransactionByHash(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export = async (deployer: Deployer) => {
},
});

await govToken.transferOwnership(TOKEN_OWNER);
await govToken.transferOwnership(TOKEN_OWNER, { txName: "Transfer Ownership" });

const fundingTransaction = await deployer.sendNative(TOKEN_OWNER, 100n, "Funding Governance Token Owner #1");
await Reporter.reportTransactionByHash(
Expand Down

0 comments on commit 5d0f17d

Please sign in to comment.