Skip to content

Commit

Permalink
refactor(transaction): add SendTransactionResponse type and update me…
Browse files Browse the repository at this point in the history
…thod signatures
  • Loading branch information
Rudy-Perrin authored and samuelmanzanera committed Dec 12, 2023
1 parent f1f67d2 commit 99fcf12
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TransactionSender from "./transaction_sender.js";
import * as API from "./api.js";
import Archethic from "./index.js";
import { Ownership, TransactionFee } from "./types.js";
import { SendTransactionResponse } from "./api/types.js";

export default class Transaction {
core: Archethic;
Expand All @@ -16,7 +17,7 @@ export default class Transaction {
return new this.builder(this.core);
}

send(tx: TransactionBuilder) {
send(tx: TransactionBuilder): Promise<SendTransactionResponse> {
return this.core.rpcNode!.sendTransaction(tx);
}

Expand All @@ -43,17 +44,17 @@ export class ExtendedTransactionBuilder extends TransactionBuilder {
}

//Override TransactionSender.send to use the node resolution
send(confirmationThreshold?: number, timeout?: number) {
send(confirmationThreshold?: number, timeout?: number): void {
this.core.requestNode((endpoint) => this.sender.send(this, endpoint, confirmationThreshold, timeout));
}

//Use of composition as multi inheritance model
on(eventName: string, fun: Function) {
on(eventName: string, fun: Function): this {
this.sender.on(eventName, fun);
return this;
}

unsubscribe(eventName: string) {
unsubscribe(eventName: string): this {
this.sender.unsubscribe(eventName);
return this;
}
Expand Down

0 comments on commit 99fcf12

Please sign in to comment.