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

126
dist/index.js vendored

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

126
dist/index.mjs vendored

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

126
dist/tornado.umd.js vendored

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

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

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