Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dagger module for token service #6249

Merged
merged 6 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.hedera.node.app.service.mono.throttling.ThrottlingModule;
import com.hedera.node.app.service.mono.txns.TransactionsModule;
import com.hedera.node.app.service.mono.txns.submission.SubmissionModule;
import com.hedera.node.app.service.token.impl.components.TokenServiceModule;
import com.hedera.node.app.services.ServiceModule;
import com.hedera.node.app.solvency.SolvencyModule;
import com.hedera.node.app.state.HederaStateModule;
Expand All @@ -70,10 +71,9 @@
import javax.inject.Singleton;

/**
* The infrastructure used to implement the platform contract for a Hedera Services node.
* This is needed for adding dagger subcomponents.
* Currently, it extends {@link com.hedera.node.app.service.mono.ServicesApp}. But,
* in the future this class will be cleaned up to not have multiple module dependencies
* The infrastructure used to implement the platform contract for a Hedera Services node. This is needed for adding
* dagger subcomponents. Currently, it extends {@link com.hedera.node.app.service.mono.ServicesApp}. But, in the future
* this class will be cleaned up to not have multiple module dependencies
*/
@Singleton
@Component(
Expand Down Expand Up @@ -110,7 +110,8 @@
AuthorizerDaggerModule.class,
InfoDaggerModule.class,
ThrottleModule.class,
SolvencyModule.class
SolvencyModule.class,
TokenServiceModule.class
})
public interface HederaApp extends ServicesApp {
/* Needed by ServicesState */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import com.hedera.node.app.service.network.impl.components.NetworkComponent;
import com.hedera.node.app.service.schedule.impl.components.DaggerScheduleComponent;
import com.hedera.node.app.service.schedule.impl.components.ScheduleComponent;
import com.hedera.node.app.service.token.impl.components.DaggerTokenComponent;
import com.hedera.node.app.service.token.impl.components.TokenComponent;
import com.hedera.node.app.service.util.impl.components.DaggerUtilComponent;
import com.hedera.node.app.service.util.impl.components.UtilComponent;
import dagger.Module;
Expand Down Expand Up @@ -79,10 +77,4 @@ static ContractComponent provideContractComponent() {
static ScheduleComponent provideScheduleComponent() {
return DaggerScheduleComponent.create();
}

@Provides
@Singleton
static TokenComponent provideTokenComponent() {
return DaggerTokenComponent.create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.hedera.node.app.service.file.impl.components.FileComponent;
import com.hedera.node.app.service.network.impl.components.NetworkComponent;
import com.hedera.node.app.service.schedule.impl.components.ScheduleComponent;
import com.hedera.node.app.service.token.impl.components.TokenComponent;
import com.hedera.node.app.service.token.impl.handlers.TokenComponent;
import com.hedera.node.app.service.util.impl.components.UtilComponent;
import com.hedera.node.app.workflows.dispatcher.TransactionHandlers;
import dagger.Module;
Expand All @@ -35,14 +35,14 @@ public interface HandlersModule {
@Provides
@Singleton
static TransactionHandlers provideTransactionHandlers(
@NonNull AdminComponent adminComponent,
@NonNull ConsensusComponent consensusComponent,
@NonNull FileComponent fileComponent,
@NonNull NetworkComponent networkComponent,
@NonNull ContractComponent contractComponent,
@NonNull ScheduleComponent scheduleComponent,
@NonNull TokenComponent tokenComponent,
@NonNull UtilComponent utilComponent) {
@NonNull final AdminComponent adminComponent,
@NonNull final ConsensusComponent consensusComponent,
@NonNull final FileComponent fileComponent,
@NonNull final NetworkComponent networkComponent,
@NonNull final ContractComponent contractComponent,
@NonNull final ScheduleComponent scheduleComponent,
@NonNull final TokenComponent tokenComponent,
@NonNull final UtilComponent utilComponent) {
return new TransactionHandlers(
consensusComponent.consensusCreateTopicHandler(),
consensusComponent.consensusUpdateTopicHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.hedera.node.app.service.file.impl.components.FileComponent;
import com.hedera.node.app.service.network.impl.components.NetworkComponent;
import com.hedera.node.app.service.schedule.impl.components.ScheduleComponent;
import com.hedera.node.app.service.token.impl.components.TokenComponent;
import com.hedera.node.app.service.token.impl.handlers.TokenComponent;
import com.hedera.node.app.state.HederaState;
import com.hedera.pbj.runtime.Codec;
import com.swirlds.common.system.Platform;
Expand Down Expand Up @@ -62,12 +62,12 @@ static Function<ResponseType, AutoCloseableWrapper<HederaState>> provideStateAcc

@Provides
static QueryHandlers provideQueryHandlers(
@NonNull ConsensusComponent consensusComponent,
@NonNull FileComponent fileComponent,
@NonNull NetworkComponent networkComponent,
@NonNull ContractComponent contractComponent,
@NonNull ScheduleComponent scheduleComponent,
@NonNull TokenComponent tokenComponent) {
@NonNull final ConsensusComponent consensusComponent,
@NonNull final FileComponent fileComponent,
@NonNull final NetworkComponent networkComponent,
@NonNull final ContractComponent contractComponent,
@NonNull final ScheduleComponent scheduleComponent,
@NonNull final TokenComponent tokenComponent) {
return new QueryHandlers(
consensusComponent.consensusGetTopicInfoHandler(),
contractComponent.contractGetBySolidityIDHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.hedera.node.app.workflows.handle;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.mockito.BDDMockito.given;

import com.hedera.node.app.service.admin.impl.components.AdminComponent;
Expand Down Expand Up @@ -47,7 +47,6 @@
import com.hedera.node.app.service.schedule.impl.handlers.ScheduleCreateHandler;
import com.hedera.node.app.service.schedule.impl.handlers.ScheduleDeleteHandler;
import com.hedera.node.app.service.schedule.impl.handlers.ScheduleSignHandler;
import com.hedera.node.app.service.token.impl.components.TokenComponent;
import com.hedera.node.app.service.token.impl.handlers.CryptoAddLiveHashHandler;
import com.hedera.node.app.service.token.impl.handlers.CryptoApproveAllowanceHandler;
import com.hedera.node.app.service.token.impl.handlers.CryptoCreateHandler;
Expand All @@ -59,6 +58,7 @@
import com.hedera.node.app.service.token.impl.handlers.TokenAccountWipeHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenAssociateToAccountHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenBurnHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenComponent;
import com.hedera.node.app.service.token.impl.handlers.TokenCreateHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenDeleteHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenDissociateFromAccountHandler;
Expand Down
4 changes: 2 additions & 2 deletions hedera-node/hedera-token-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ configurations.all {
}

dependencies {
implementation(project(":hedera-node:hapi"))
annotationProcessor(libs.dagger.compiler)
api(project(":hedera-node:hedera-token-service"))
implementation(project(":hedera-node:hapi"))
implementation(project(":hedera-node:hedera-mono-service"))
implementation(libs.bundles.di)
implementation(libs.pbj.runtime)

implementation(libs.swirlds.virtualmap)
implementation(libs.swirlds.jasperdb)

testImplementation(testLibs.bundles.testing)
testImplementation(testFixtures(project(":hedera-node:hedera-mono-service")))
testImplementation(testFixtures(project(":hedera-node:hedera-app-spi")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
import com.hedera.node.app.service.token.TokenService;
import com.hedera.node.app.spi.numbers.HederaAccountNumbers;
import edu.umd.cs.findbugs.annotations.NonNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.NotImplementedException;

/**
* A Singleton implementation of signature waivers needed for transactions in {@link TokenService}.
* NOTE: FUTURE - These will be implemented in the coming PR and this class should be a singleton.
* A Singleton implementation of signature waivers needed for transactions in {@link TokenService}. NOTE: FUTURE - These
* will be implemented in the coming PR and this class should be a singleton.
*/
@Singleton
public class CryptoSignatureWaiversImpl implements CryptoSignatureWaivers {

@Inject
public CryptoSignatureWaiversImpl(@NonNull final HederaAccountNumbers accountNumbers) {
requireNonNull(accountNumbers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.hedera.node.app.service.token.impl.components;

import com.hedera.node.app.service.token.CryptoSignatureWaivers;
import com.hedera.node.app.service.token.impl.CryptoSignatureWaiversImpl;
import com.hedera.node.app.service.token.impl.handlers.CryptoAddLiveHashHandler;
import com.hedera.node.app.service.token.impl.handlers.CryptoApproveAllowanceHandler;
import com.hedera.node.app.service.token.impl.handlers.CryptoCreateHandler;
Expand All @@ -32,6 +34,7 @@
import com.hedera.node.app.service.token.impl.handlers.TokenAccountWipeHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenAssociateToAccountHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenBurnHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenComponent;
import com.hedera.node.app.service.token.impl.handlers.TokenCreateHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenDeleteHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenDissociateFromAccountHandler;
Expand All @@ -48,16 +51,17 @@
import com.hedera.node.app.service.token.impl.handlers.TokenUnfreezeAccountHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenUnpauseHandler;
import com.hedera.node.app.service.token.impl.handlers.TokenUpdateHandler;
import dagger.Component;
import javax.inject.Singleton;
import dagger.Binds;
import dagger.Module;

@Singleton
@Component
public interface TokenComponent {
@Component.Factory
interface Factory {
TokenComponent create();
}
/**
* Dagger module of the token service
*/
@Module
public interface TokenServiceModule {

@Binds
CryptoSignatureWaivers cryptoSignatureWaivers(CryptoSignatureWaiversImpl impl);

CryptoAddLiveHashHandler cryptoAddLiveHashHandler();

Expand Down Expand Up @@ -122,4 +126,6 @@ interface Factory {
TokenUnpauseHandler tokenUnpauseHandler();

TokenUpdateHandler tokenUpdateHandler();

TokenComponent tokenComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ public class CryptoUpdateHandler implements TransactionHandler {

private final CryptoSignatureWaivers waivers;

/**
* @deprecated Exists until I figured out how to configure Dagger to inject the waivers
*/
@Inject
@Deprecated(forRemoval = true)
public CryptoUpdateHandler() {
this.waivers = null;
}

public CryptoUpdateHandler(@NonNull final CryptoSignatureWaivers waivers) {
this.waivers = requireNonNull(waivers, "The supplied argument 'waivers' must not be null");
}
Expand Down