From f2ec87a954a2c2b42c4a4d80b293b8c85e37efe7 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Fri, 23 Feb 2024 18:28:51 +0200 Subject: [PATCH] change factories constructor to ensure consistency --- src/transaction.local.net.spec.ts | 2 +- .../smartContractTransactionsFactory.ts | 8 ++++---- .../transferTransactionsFactory.spec.ts | 5 ++++- src/transactionsFactories/transferTransactionsFactory.ts | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/transaction.local.net.spec.ts b/src/transaction.local.net.spec.ts index c00bbaa1..52302c5d 100644 --- a/src/transaction.local.net.spec.ts +++ b/src/transaction.local.net.spec.ts @@ -152,7 +152,7 @@ describe("test transaction", function () { const network = await provider.getNetworkConfig(); const config = new TransactionsFactoryConfig({ chainID: network.ChainID }); - const factory = new NextTransferTransactionsFactory(config, new TokenComputer()); + const factory = new NextTransferTransactionsFactory({ config: config, tokenComputer: new TokenComputer() }); await alice.sync(provider); await bob.sync(provider); diff --git a/src/transactionsFactories/smartContractTransactionsFactory.ts b/src/transactionsFactories/smartContractTransactionsFactory.ts index 329634de..bf077179 100644 --- a/src/transactionsFactories/smartContractTransactionsFactory.ts +++ b/src/transactionsFactories/smartContractTransactionsFactory.ts @@ -35,10 +35,10 @@ export class SmartContractTransactionsFactory { private readonly tokenComputer: TokenComputer; private readonly dataArgsBuilder: TokenTransfersDataBuilder; - constructor({ config, abi, tokenComputer }: { config: Config; abi?: Abi; tokenComputer: TokenComputer }) { - this.config = config; - this.abiRegistry = abi; - this.tokenComputer = tokenComputer; + constructor(options: { config: Config; abi?: Abi; tokenComputer: TokenComputer }) { + this.config = options.config; + this.abiRegistry = options.abi; + this.tokenComputer = options.tokenComputer; this.dataArgsBuilder = new TokenTransfersDataBuilder(); } diff --git a/src/transactionsFactories/transferTransactionsFactory.spec.ts b/src/transactionsFactories/transferTransactionsFactory.spec.ts index 3cc865db..53e0330e 100644 --- a/src/transactionsFactories/transferTransactionsFactory.spec.ts +++ b/src/transactionsFactories/transferTransactionsFactory.spec.ts @@ -7,7 +7,10 @@ import { NextTransferTransactionsFactory } from "./transferTransactionsFactory"; describe("test transfer transcations factory", function () { const config = new TransactionsFactoryConfig({ chainID: "D" }); - const nextTransferFactory = new NextTransferTransactionsFactory(config, new TokenComputer()); + const nextTransferFactory = new NextTransferTransactionsFactory({ + config: config, + tokenComputer: new TokenComputer(), + }); const alice = Address.fromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); const bob = Address.fromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"); diff --git a/src/transactionsFactories/transferTransactionsFactory.ts b/src/transactionsFactories/transferTransactionsFactory.ts index 226e238e..9490647a 100644 --- a/src/transactionsFactories/transferTransactionsFactory.ts +++ b/src/transactionsFactories/transferTransactionsFactory.ts @@ -30,9 +30,9 @@ export class NextTransferTransactionsFactory { private readonly dataArgsBuilder: TokenTransfersDataBuilder; private readonly tokenComputer: TokenComputer; - constructor(config: IConfig, tokenComputer: TokenComputer) { - this.config = config; - this.tokenComputer = tokenComputer; + constructor(options: { config: IConfig; tokenComputer: TokenComputer }) { + this.config = options.config; + this.tokenComputer = options.tokenComputer; this.dataArgsBuilder = new TokenTransfersDataBuilder(); }