Simplify class constructors

This commit is contained in:
Tornado Contrib 2024-10-16 15:19:31 +00:00
parent f3a8438187
commit 0e2da438ca
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
8 changed files with 102 additions and 411 deletions

10
dist/events/base.d.ts vendored

@ -103,7 +103,7 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
currency: string;
batchTransactionService: BatchTransactionService;
batchBlockService: BatchBlockService;
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, tovarishClient, }: BaseTornadoServiceConstructor);
constructor(serviceConstructor: BaseTornadoServiceConstructor);
getInstanceName(): string;
getGraphMethod(): string;
getGraphParams(): DepositsGraphParams;
@ -119,7 +119,7 @@ export interface BaseEchoServiceConstructor extends Omit<BaseEventsServiceConstr
Echoer: Echoer;
}
export declare class BaseEchoService extends BaseEventsService<EchoEvents> {
constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEchoServiceConstructor);
constructor(serviceConstructor: BaseEchoServiceConstructor);
getInstanceName(): string;
getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<EchoEvents[]>;
@ -131,7 +131,7 @@ export interface BaseEncryptedNotesServiceConstructor extends Omit<BaseEventsSer
Router: TornadoRouter | TornadoProxyLight;
}
export declare class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesEvents> {
constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEncryptedNotesServiceConstructor);
constructor(serviceConstructor: BaseEncryptedNotesServiceConstructor);
getInstanceName(): string;
getTovarishType(): string;
getGraphMethod(): string;
@ -142,7 +142,7 @@ export interface BaseGovernanceServiceConstructor extends Omit<BaseEventsService
}
export declare class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> {
batchTransactionService: BatchTransactionService;
constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, tovarishClient, }: BaseGovernanceServiceConstructor);
constructor(serviceConstructor: BaseGovernanceServiceConstructor);
getInstanceName(): string;
getTovarishType(): string;
getGraphMethod(): string;
@ -180,7 +180,7 @@ export declare class BaseRegistryService extends BaseEventsService<RegistersEven
Aggregator: Aggregator;
relayerEnsSubdomains: SubdomainMap;
updateInterval: number;
constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, Aggregator, relayerEnsSubdomains, deployedBlock, fetchDataOptions, tovarishClient, }: BaseRegistryServiceConstructor);
constructor(serviceConstructor: BaseRegistryServiceConstructor);
getInstanceName(): string;
getTovarishType(): string;
getGraphMethod(): string;

126
dist/index.js vendored

@ -2977,29 +2977,11 @@ class BaseTornadoService extends BaseEventsService {
currency;
batchTransactionService;
batchBlockService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Tornado,
type,
amount,
currency,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Tornado: contract, amount, currency, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Tornado,
type,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract
});
this.amount = amount;
this.currency = currency;
@ -3102,26 +3084,11 @@ class BaseTornadoService extends BaseEventsService {
}
}
class BaseEchoService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Echoer,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Echoer,
type: "Echo",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Echoer,
type: "Echo"
});
}
getInstanceName() {
@ -3158,26 +3125,11 @@ class BaseEchoService extends BaseEventsService {
}
}
class BaseEncryptedNotesService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Router,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Router,
type: "EncryptedNote",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Router,
type: "EncryptedNote"
});
}
getInstanceName() {
@ -3208,26 +3160,12 @@ class BaseEncryptedNotesService extends BaseEventsService {
}
class BaseGovernanceService extends BaseEventsService {
batchTransactionService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Governance,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Governance: contract, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Governance,
type: "*",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "*"
});
this.batchTransactionService = new BatchTransactionService({
provider,
@ -3353,28 +3291,12 @@ class BaseRegistryService extends BaseEventsService {
Aggregator;
relayerEnsSubdomains;
updateInterval;
constructor({
netId,
provider,
graphApi,
subgraphName,
RelayerRegistry,
Aggregator,
relayerEnsSubdomains,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { RelayerRegistry: contract, Aggregator, relayerEnsSubdomains } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: RelayerRegistry,
type: "RelayerRegistered",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "RelayerRegistered"
});
this.Aggregator = Aggregator;
this.relayerEnsSubdomains = relayerEnsSubdomains;
@ -7079,8 +7001,8 @@ async function getTokenBalances({
const MAX_TOVARISH_EVENTS = 5e3;
class TovarishClient extends RelayerClient {
constructor({ netId, config, fetchDataOptions }) {
super({ netId, config, fetchDataOptions });
constructor(clientConstructor) {
super(clientConstructor);
this.tovarish = true;
}
async askRelayerStatus({

126
dist/index.mjs vendored

@ -2956,29 +2956,11 @@ class BaseTornadoService extends BaseEventsService {
currency;
batchTransactionService;
batchBlockService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Tornado,
type,
amount,
currency,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Tornado: contract, amount, currency, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Tornado,
type,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract
});
this.amount = amount;
this.currency = currency;
@ -3081,26 +3063,11 @@ class BaseTornadoService extends BaseEventsService {
}
}
class BaseEchoService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Echoer,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Echoer,
type: "Echo",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Echoer,
type: "Echo"
});
}
getInstanceName() {
@ -3137,26 +3104,11 @@ class BaseEchoService extends BaseEventsService {
}
}
class BaseEncryptedNotesService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Router,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Router,
type: "EncryptedNote",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Router,
type: "EncryptedNote"
});
}
getInstanceName() {
@ -3187,26 +3139,12 @@ class BaseEncryptedNotesService extends BaseEventsService {
}
class BaseGovernanceService extends BaseEventsService {
batchTransactionService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Governance,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Governance: contract, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Governance,
type: "*",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "*"
});
this.batchTransactionService = new BatchTransactionService({
provider,
@ -3332,28 +3270,12 @@ class BaseRegistryService extends BaseEventsService {
Aggregator;
relayerEnsSubdomains;
updateInterval;
constructor({
netId,
provider,
graphApi,
subgraphName,
RelayerRegistry,
Aggregator,
relayerEnsSubdomains,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { RelayerRegistry: contract, Aggregator, relayerEnsSubdomains } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: RelayerRegistry,
type: "RelayerRegistered",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "RelayerRegistered"
});
this.Aggregator = Aggregator;
this.relayerEnsSubdomains = relayerEnsSubdomains;
@ -7058,8 +6980,8 @@ async function getTokenBalances({
const MAX_TOVARISH_EVENTS = 5e3;
class TovarishClient extends RelayerClient {
constructor({ netId, config, fetchDataOptions }) {
super({ netId, config, fetchDataOptions });
constructor(clientConstructor) {
super(clientConstructor);
this.tovarish = true;
}
async askRelayerStatus({

126
dist/tornado.umd.js vendored

@ -59290,29 +59290,11 @@ class BaseTornadoService extends BaseEventsService {
currency;
batchTransactionService;
batchBlockService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Tornado,
type,
amount,
currency,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Tornado: contract, amount, currency, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Tornado,
type,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract
});
this.amount = amount;
this.currency = currency;
@ -59415,26 +59397,11 @@ class BaseTornadoService extends BaseEventsService {
}
}
class BaseEchoService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Echoer,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Echoer,
type: "Echo",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Echoer,
type: "Echo"
});
}
getInstanceName() {
@ -59471,26 +59438,11 @@ class BaseEchoService extends BaseEventsService {
}
}
class BaseEncryptedNotesService extends BaseEventsService {
constructor({
netId,
provider,
graphApi,
subgraphName,
Router,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Router,
type: "EncryptedNote",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract: serviceConstructor.Router,
type: "EncryptedNote"
});
}
getInstanceName() {
@ -59521,26 +59473,12 @@ class BaseEncryptedNotesService extends BaseEventsService {
}
class BaseGovernanceService extends BaseEventsService {
batchTransactionService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Governance,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { Governance: contract, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Governance,
type: "*",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "*"
});
this.batchTransactionService = new _batch__WEBPACK_IMPORTED_MODULE_1__/* .BatchTransactionService */ .AF({
provider,
@ -59666,28 +59604,12 @@ class BaseRegistryService extends BaseEventsService {
Aggregator;
relayerEnsSubdomains;
updateInterval;
constructor({
netId,
provider,
graphApi,
subgraphName,
RelayerRegistry,
Aggregator,
relayerEnsSubdomains,
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
}) {
constructor(serviceConstructor) {
const { RelayerRegistry: contract, Aggregator, relayerEnsSubdomains } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: RelayerRegistry,
type: "RelayerRegistered",
deployedBlock,
fetchDataOptions: fetchDataOptions2,
tovarishClient
...serviceConstructor,
contract,
type: "RelayerRegistered"
});
this.Aggregator = Aggregator;
this.relayerEnsSubdomains = relayerEnsSubdomains;
@ -72845,8 +72767,8 @@ async function getTokenBalances({
const MAX_TOVARISH_EVENTS = 5e3;
class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .RelayerClient */ .OR {
constructor({ netId, config, fetchDataOptions }) {
super({ netId, config, fetchDataOptions });
constructor(clientConstructor) {
super(clientConstructor);
this.tovarish = true;
}
async askRelayerStatus({

File diff suppressed because one or more lines are too long

@ -56,7 +56,7 @@ export interface BaseTovarishEvents<T> {
}
export declare class TovarishClient extends RelayerClient {
selectedRelayer?: TovarishInfo;
constructor({ netId, config, fetchDataOptions }: RelayerClientConstructor);
constructor(clientConstructor: RelayerClientConstructor);
askRelayerStatus({ hostname, url, relayerAddress, }: {
hostname?: string;
url?: string;

@ -364,29 +364,12 @@ export class BaseTornadoService extends BaseEventsService<DepositsEvents | Withd
batchTransactionService: BatchTransactionService;
batchBlockService: BatchBlockService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Tornado,
type,
amount,
currency,
deployedBlock,
fetchDataOptions,
tovarishClient,
}: BaseTornadoServiceConstructor) {
constructor(serviceConstructor: BaseTornadoServiceConstructor) {
const { Tornado: contract, amount, currency, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Tornado,
type,
deployedBlock,
fetchDataOptions,
tovarishClient,
...serviceConstructor,
contract,
});
this.amount = amount;
@ -516,26 +499,11 @@ export interface BaseEchoServiceConstructor extends Omit<BaseEventsServiceConstr
}
export class BaseEchoService extends BaseEventsService<EchoEvents> {
constructor({
netId,
provider,
graphApi,
subgraphName,
Echoer,
deployedBlock,
fetchDataOptions,
tovarishClient,
}: BaseEchoServiceConstructor) {
constructor(serviceConstructor: BaseEchoServiceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Echoer,
...serviceConstructor,
contract: serviceConstructor.Echoer,
type: 'Echo',
deployedBlock,
fetchDataOptions,
tovarishClient,
});
}
@ -587,26 +555,11 @@ export interface BaseEncryptedNotesServiceConstructor extends Omit<BaseEventsSer
}
export class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesEvents> {
constructor({
netId,
provider,
graphApi,
subgraphName,
Router,
deployedBlock,
fetchDataOptions,
tovarishClient,
}: BaseEncryptedNotesServiceConstructor) {
constructor(serviceConstructor: BaseEncryptedNotesServiceConstructor) {
super({
netId,
provider,
graphApi,
subgraphName,
contract: Router,
...serviceConstructor,
contract: serviceConstructor.Router,
type: 'EncryptedNote',
deployedBlock,
fetchDataOptions,
tovarishClient,
});
}
@ -651,26 +604,13 @@ export interface BaseGovernanceServiceConstructor extends Omit<BaseEventsService
export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> {
batchTransactionService: BatchTransactionService;
constructor({
netId,
provider,
graphApi,
subgraphName,
Governance,
deployedBlock,
fetchDataOptions,
tovarishClient,
}: BaseGovernanceServiceConstructor) {
constructor(serviceConstructor: BaseGovernanceServiceConstructor) {
const { Governance: contract, provider } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: Governance,
...serviceConstructor,
contract,
type: '*',
deployedBlock,
fetchDataOptions,
tovarishClient,
});
this.batchTransactionService = new BatchTransactionService({
@ -860,28 +800,13 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
relayerEnsSubdomains: SubdomainMap;
updateInterval: number;
constructor({
netId,
provider,
graphApi,
subgraphName,
RelayerRegistry,
Aggregator,
relayerEnsSubdomains,
deployedBlock,
fetchDataOptions,
tovarishClient,
}: BaseRegistryServiceConstructor) {
constructor(serviceConstructor: BaseRegistryServiceConstructor) {
const { RelayerRegistry: contract, Aggregator, relayerEnsSubdomains } = serviceConstructor;
super({
netId,
provider,
graphApi,
subgraphName,
contract: RelayerRegistry,
...serviceConstructor,
contract,
type: 'RelayerRegistered',
deployedBlock,
fetchDataOptions,
tovarishClient,
});
this.Aggregator = Aggregator;

@ -84,8 +84,8 @@ export interface BaseTovarishEvents<T> {
export class TovarishClient extends RelayerClient {
declare selectedRelayer?: TovarishInfo;
constructor({ netId, config, fetchDataOptions }: RelayerClientConstructor) {
super({ netId, config, fetchDataOptions });
constructor(clientConstructor: RelayerClientConstructor) {
super(clientConstructor);
this.tovarish = true;
}