Skip to content

Commit

Permalink
feat: add tx overrides to non-meta tx creators
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Nov 20, 2024
1 parent 143f782 commit 6add95e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/sdk/src/TxCreator/TxCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type ContractReceipt,
type ContractTransaction,
} from 'ethers';
import { parseLogs } from '@colony/core';
import { type TxOverrides, parseLogs } from '@colony/core';
import {
type MetadataTypeMap,
type VotingReputationEvents,
Expand Down Expand Up @@ -194,7 +194,7 @@ export class TxCreator<
this.txConfig = txConfig;
}

protected async getArgs() {
protected async getArgs(overrides?: TxOverrides) {
let args: unknown[] = [];

if (typeof this.args == 'function') {
Expand All @@ -203,11 +203,15 @@ export class TxCreator<
args = this.args;
}

if (overrides) {
args.push(overrides);
}

return args;
}

private async getTx() {
const args = await this.getArgs();
private async getTx(overrides?: TxOverrides) {
const args = await this.getArgs(overrides);
const tx = (await this.contract.functions[this.method].apply(
this.contract,
args,
Expand Down Expand Up @@ -294,12 +298,12 @@ export class TxCreator<
*/
tx() {
return {
send: async () => {
const tx = await this.getTx();
send: async (overrides?: TxOverrides) => {
const tx = await this.getTx(overrides);
return [tx, this.getMined.bind(this, tx)];
},
mined: async () => {
const tx = await this.getTx();
mined: async (overrides?: TxOverrides) => {
const tx = await this.getTx(overrides);
return this.getMined(tx);
},
encode: async () => {
Expand Down

0 comments on commit 6add95e

Please sign in to comment.