-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rafael Belchior <[email protected]>
- Loading branch information
1 parent
8a46774
commit ac5a55a
Showing
40 changed files
with
2,582 additions
and
2,197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/cactus-plugin-satp-hermes/docs/initialization-standalone-plugin.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@startuml | ||
title Hyperledger Cacti SATP-Hermes\nInitialization (standalone) | ||
|
||
skinparam sequenceArrowThickness 2 | ||
skinparam roundcorner 20 | ||
skinparam maxmessagesize 120 | ||
skinparam sequenceParticipant underline | ||
skinparam autonumber true | ||
|
||
entity "SATPGateway" as g | ||
entity "Orchestrator (GOL)" as gol | ||
entity "Counterparty SATP Gateway" as cg | ||
entity "WebServices" as web | ||
entity "Dispatcher (BLO)" as dispatcher | ||
entity "SATPManager" as manager | ||
component "SATP Core" as core | ||
|
||
|
||
g --> g: constructor(options) | ||
g --> g: ProcessGatewayCoordinatorConfig() | ||
g --> g: basic initialization (logger, signer, etc) | ||
|
||
== GOL Init == | ||
g -> gol: initialize GatewayOrchestrator(GOLoptions) | ||
group #Yellow if { get GOLoptions.CounterpartyGateways() } | ||
gol -> gol: basic initialization (logger, etc) | ||
gol -> gol: connectToCounterPartyGateways() | ||
gol -> gol: createChannel(counterpartyGateway) | ||
gol -> gol: createConnectClients(counterpartyGateway) | ||
gol -> cg: call healthcheck endpoint <color:red>(TBD 🚨) | ||
else #Pink else only do basic initialization | ||
end | ||
gol --> g: GatewayOrchestrator | ||
|
||
== BLO and SATP Manager Init == | ||
g --> bol: initialize BLODispatcher(options, GatewayOrchestrator) | ||
bol --> bol: expose endpoints via getOrCreateWebServices() | ||
bol --> manager: initialize SATPManager(options) | ||
manager --> core: get SATP Service classes | ||
core --> manager: services | ||
manager --> manager: instantiate services (options) | ||
manager --> core: get SATP Handler classes | ||
core --> manager: handlers | ||
manager --> manager: instatiate handlers (services, options) | ||
manager --> bol: SATP manager | ||
|
||
== Misc == | ||
|
||
g --> g: setup OpenAPI UI server | ||
|
||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ages/cactus-plugin-satp-hermes/src/main/typescript/blo/admin/get-audit-handler-service.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...s/cactus-plugin-satp-hermes/src/main/typescript/blo/transaction/cancel-handler-service.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...s/cactus-plugin-satp-hermes/src/main/typescript/blo/transaction/routes-handler-service.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/cactus-plugin-satp-hermes/src/main/typescript/core/satp-session.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 79 additions & 37 deletions
116
packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,92 @@ | ||
import { ConnectRouter, HandlerContext } from "@connectrpc/connect"; | ||
import { SatpStage1Service } from "../../generated/proto/cacti/satp/v02/stage_1_connect"; | ||
import { TransferCommenceRequestMessage, TransferProposalRequestMessage } from "../../generated/proto/cacti/satp/v02/stage_1_pb"; | ||
import { | ||
TransferCommenceRequestMessage, | ||
TransferCommenceResponseMessage, | ||
TransferProposalReceiptMessage, | ||
TransferProposalRequestMessage, | ||
} from "../../generated/proto/cacti/satp/v02/stage_1_pb"; | ||
import { SATPSession } from "../satp-session"; | ||
import { Stage1ServerService } from "../stage-services/server/stage1-server-service"; | ||
import { Stage1ClientService } from "../stage-services/client/stage1-client-service"; | ||
import { SupportedGatewayImplementations } from "../types"; | ||
import { SATPHandler } from './SATPHandler'; // Assuming the interface is exported from this path | ||
import { SupportedChain } from "../types"; | ||
import { SATPHandler, SATPHandlerOptions } from "../../types/satp-protocol"; | ||
import { Logger, LoggerProvider } from "@hyperledger/cactus-common"; | ||
|
||
export class Stage1SATPHandler implements SATPHandler { | ||
constructor( | ||
private session: SATPSession | undefined, | ||
private serverService: Stage1ServerService, | ||
private clientService: Stage1ClientService, | ||
private supportedDLTs: SupportedGatewayImplementations[] | ||
) {} | ||
public static readonly CLASS_NAME = "Stage1SATPHandler"; | ||
private session: SATPSession; | ||
private serverService: Stage1ServerService; | ||
private clientService: Stage1ClientService; | ||
private supportedDLTs: SupportedChain[]; | ||
private logger: Logger; | ||
|
||
setupRouter(router: ConnectRouter): void { | ||
router.service(SatpStage1Service, { | ||
transferProposal: async (req: TransferProposalRequestMessage, context: HandlerContext) => { | ||
try { | ||
console.log("Received TransferProposalRequest", req, context); | ||
const sessionData = await this.serverService.checkTransferProposalRequestMessage(req, this.session, this.supportedDLTs); | ||
const message = await this.serverService.transferProposalResponse(req, this.session); | ||
console.log("Returning response", message); | ||
return message; | ||
} catch (error) { | ||
console.error("Error handling TransferProposalRequest:", error); | ||
throw new Error("Failed to process TransferProposalRequest"); | ||
} | ||
}, | ||
transferCommence: async (req: TransferCommenceRequestMessage, context: HandlerContext) => { | ||
try { | ||
console.log("Received TransferCommenceRequest", req, context); | ||
const sessionData = await this.serverService.checkTransferCommenceRequestMessage(req, this.session); | ||
const message = await this.serverService.transferCommenceResponse(req, this.session); | ||
console.log("Returning response", message); | ||
return message; | ||
} catch (error) { | ||
console.error("Error handling TransferCommenceRequest:", error); | ||
throw new Error("Failed to process TransferCommenceRequest"); | ||
} | ||
} | ||
}); | ||
constructor(ops: SATPHandlerOptions) { | ||
this.session = ops.session; | ||
this.serverService = ops.serverService as Stage1ServerService; | ||
this.clientService = ops.clientService as Stage1ClientService; | ||
this.supportedDLTs = ops.supportedDLTs; | ||
this.logger = LoggerProvider.getOrCreate(ops.loggerOptions); | ||
this.logger.trace(`Initialized ${Stage1SATPHandler.CLASS_NAME}`); | ||
} | ||
|
||
getHandlerIdentifier(): string { | ||
return "Stage1SATPHandler"; | ||
return Stage1SATPHandler.CLASS_NAME; | ||
} | ||
|
||
async TransferProposalImplementation( | ||
req: TransferProposalRequestMessage, | ||
): Promise<TransferProposalReceiptMessage> { | ||
try { | ||
console.log("Received TransferProposalRequest", req); | ||
const sessionData = | ||
await this.serverService.checkTransferProposalRequestMessage( | ||
req, | ||
this.session, | ||
this.supportedDLTs, | ||
); | ||
const message = await this.serverService.transferProposalResponse( | ||
req, | ||
this.session, | ||
); | ||
console.log("message", message); | ||
console.log("Returning response", sessionData); | ||
const response = new TransferProposalReceiptMessage(); | ||
return response; | ||
} catch (error) { | ||
console.error("Error handling TransferProposalRequest:", error); | ||
throw new Error("Failed to process TransferProposalRequest"); | ||
} | ||
} | ||
|
||
async TransferCommenceImplementation( | ||
req: TransferCommenceRequestMessage, | ||
): Promise<TransferCommenceResponseMessage> { | ||
try { | ||
console.log("Received TransferCommenceRequest", req); | ||
const sessionData = | ||
await this.serverService.checkTransferCommenceRequestMessage( | ||
req, | ||
this.session, | ||
); | ||
const message = await this.serverService.transferCommenceResponse( | ||
req, | ||
this.session, | ||
); | ||
console.log("Returning response", message); | ||
console.log("Returning response", sessionData); | ||
const response = new TransferProposalReceiptMessage(); | ||
return response; | ||
} catch (error) { | ||
console.error("Error handling TransferCommenceRequest:", error); | ||
throw new Error("Failed to process TransferCommenceRequest"); | ||
} | ||
} | ||
|
||
setupRouter(router: ConnectRouter): void { | ||
router.service(SatpStage1Service, { | ||
transferProposal: this.TransferProposalImplementation, | ||
transferCommence: this.TransferCommenceImplementation, | ||
}); | ||
} | ||
} |
Oops, something went wrong.