Skip to content

Commit

Permalink
fixup!: wip gateway refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
  • Loading branch information
RafaelAPB committed Apr 19, 2024
1 parent 724c652 commit 72d63ab
Show file tree
Hide file tree
Showing 28 changed files with 833 additions and 526 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.gitignore
.openapi-generator-ignore
.travis.yml
README.md
api/openapi.yaml
Expand Down Expand Up @@ -119,6 +118,4 @@ model_transact_default_response.go
model_transact_request.go
model_transact_response.go
response.go
test/api_admin_test.go
test/api_transaction_test.go
utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package cacti.satp.v02.common;
import "cacti/satp/v02/common/message.proto";

message HealthCheckRequest {}

service HealthService {
rpc CheckHealth(HealthCheckRequest) returns (Ack);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message TransferProposalRequestMessage {
bool multiple_cancels_allowed = 6;
}

message TransferProposalReceiptRejectMessage {
message TransferProposalReceiptMessage {
cacti.satp.v02.common.CommonSatp common = 1;
string hash_transfer_init_claims = 2;
cacti.satp.v02.common.TransferClaims transfer_counter_claims = 3;
Expand All @@ -31,6 +31,6 @@ message TransferCommenceResponseMessage {
}

service SatpStage1Service {
rpc TransferProposal(TransferProposalRequestMessage) returns (TransferProposalReceiptRejectMessage) {}
rpc TransferProposal(TransferProposalRequestMessage) returns (TransferProposalReceiptMessage) {}
rpc TransferCommence(TransferCommenceRequestMessage) returns (TransferCommenceResponseMessage) {}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { v4 as uuidv4 } from "uuid";
import { SessionData } from "../generated/proto/cacti/satp/v02/common/session_pb";


export interface ISATPSessionOptions {
contextID: string;
}

export class SATPSession {
private static readonly CLASS_NAME = "SATPSession";
private sessionData: SessionData;

constructor(ops: ISATPSessionOptions) {
this.sessionData = new SessionData();
this.sessionData.transferContextId = ops.contextID;

// TODO algorithm to create session ID from context ID
this.sessionData.id = ops.contextID + "-" + uuidv4();

}

private initializeSessionID(): void {
if (this.sessionData.id === undefined) {
this.sessionData.id = uuidv4() + "-" + this.sessionData.transferContextId;
} else {
throw new Error("Session ID already initialized");
}
}

public getSessionData(): SessionData {
return this.sessionData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { SATPGateway } from "../../gateway-refactor";
import { Stage1ServerService } from "../stage-services/server/stage1-server-service";
import { TimestampType, saveTimestamp } from "../session-utils";
import { MessageType } from "../../generated/proto/cacti/satp/v02/common/message_pb";
import { SATPSession } from "../satp-session";
import { Stage1ClientService } from "../stage-services/client/stage1-client-service";
import { ServiceType } from "@bufbuild/protobuf";

export default (gateway: SATPGateway, service: Stage1ServerService) =>
export const Stage1Handler = (session: SATPSession | undefined, serverService: Stage1ServerService, clientService: Stage1ClientService, connectClients: ServiceType[]) =>
(router: ConnectRouter) =>
router.service(SatpStage1Service, {
async transferProposal(
Expand All @@ -20,8 +23,8 @@ export default (gateway: SATPGateway, service: Stage1ServerService) =>
console.log("Received TransferProposalRequest", req, context);
const recvTimestamp: string = Date.now().toString();

const [sessionData, reject] =
await service.checkTransferProposalRequestMessage(req, gateway);
const sessionData =
await serverService.checkTransferProposalRequestMessage(req, session);

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / nuclei-scan

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-api-client

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_lint

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-common

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-cmd-socketio-server

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core-api

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_codegen

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_tools_validate_bundle_names

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_custom_checks

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-frontend

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-backend

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-business-logic-plugin

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-frontend

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-backend

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-coordinator-besu

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-business-logic-plugin

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-consortium-manual

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu-erc20

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-aws-sm

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-azure-kv

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-google-sm

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-vault

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory-wasm

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-sawtooth

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-persistence-ethereum

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-go-ethereum-socketio

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-xdai

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-geth-ledger

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-object-store-ipfs

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-satp-hermes

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-bungee-hermes

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-api-client

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-consortium-manual

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu-erc20

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-verifier-client

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

Check failure on line 27 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-ledger-connector-ethereum

Argument of type 'SATPSession | undefined' is not assignable to parameter of type 'SupportedGatewayImplementations[]'.

saveTimestamp(
sessionData,
Expand All @@ -30,7 +33,7 @@ export default (gateway: SATPGateway, service: Stage1ServerService) =>
recvTimestamp,
);

const message = await service.transferProposalResponse(
const message = await serverService.transferProposalResponse(
req,
reject,

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / nuclei-scan

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-api-client

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_lint

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-common

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-cmd-socketio-server

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core-api

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_codegen

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_tools_validate_bundle_names

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_custom_checks

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-frontend

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-backend

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-business-logic-plugin

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-frontend

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-backend

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-coordinator-besu

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-business-logic-plugin

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-consortium-manual

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu-erc20

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-aws-sm

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-azure-kv

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-google-sm

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-vault

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory-wasm

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-sawtooth

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-persistence-ethereum

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-go-ethereum-socketio

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-xdai

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-geth-ledger

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-object-store-ipfs

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-satp-hermes

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-bungee-hermes

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-api-client

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-consortium-manual

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu-erc20

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-verifier-client

Cannot find name 'reject'.

Check failure on line 38 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-ledger-connector-ethereum

Cannot find name 'reject'.
gateway,

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / nuclei-scan

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-api-client

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_lint

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-common

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-cmd-socketio-server

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-core-api

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_codegen

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_tools_validate_bundle_names

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / yarn_custom_checks

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-frontend

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-backend

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-carbon-accounting-business-logic-plugin

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-frontend

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-backend

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-coordinator-besu

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-example-supply-chain-business-logic-plugin

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-consortium-manual

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-htlc-eth-besu-erc20

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-aws-sm

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-azure-kv

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-google-sm

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-vault

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-keychain-memory-wasm

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-sawtooth

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-persistence-ethereum

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-go-ethereum-socketio

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-ledger-connector-xdai

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-geth-ledger

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-object-store-ipfs

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-satp-hermes

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-plugin-bungee-hermes

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-api-client

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-consortium-manual

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-htlc-eth-besu-erc20

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-verifier-client

Cannot find name 'gateway'.

Check failure on line 39 in packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

View workflow job for this annotation

GitHub Actions / cactus-test-plugin-ledger-connector-ethereum

Cannot find name 'gateway'.
Expand Down Expand Up @@ -65,9 +68,9 @@ export default (gateway: SATPGateway, service: Stage1ServerService) =>
console.log("Received TransferCommenceRequest", req, context);
const recvTimestamp: string = Date.now().toString();

const sessionData = await service.checkTransferCommenceRequestMessage(
const sessionData = await serverService.checkTransferCommenceRequestMessage(
req,
gateway,
session,
);

saveTimestamp(
Expand All @@ -77,7 +80,7 @@ export default (gateway: SATPGateway, service: Stage1ServerService) =>
recvTimestamp,
);

const message = await service.transferCommenceResponse(req, gateway);
const message = await serverService.transferCommenceResponse(req, session);

if (!message) {
throw new Error("No message returned from transferProposalResponse");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Stage2ServerService } from "../stage-services/server/stage2-server-serv
import { TimestampType, saveTimestamp } from "../session-utils";
import { MessageType } from "../../generated/proto/cacti/satp/v02/common/message_pb";

export default (gateway: SATPGateway, service: Stage2ServerService) =>
export const Stage2Handler = (gateway: SATPGateway, service: Stage2ServerService) =>
(router: ConnectRouter) =>
router.service(SatpStage2Service, {
async lockAssertion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SATPGateway } from "../../gateway-refactor";
import { TimestampType, saveTimestamp } from "../session-utils";
import { MessageType } from "../../generated/proto/cacti/satp/v02/common/message_pb";

export default (gateway: SATPGateway, service: Stage3ServerService) =>
export const Stage3Handler = (gateway: SATPGateway, service: Stage3ServerService) =>
(router: ConnectRouter) =>
router.service(SatpStage3Service, {
async commitPreparation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { JsObjectSigner, Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { SATPGateway } from "../../../gateway-refactor";
import {
TransferCommenceRequestMessage,
TransferProposalRequestMessage,
TransferProposalReceiptRejectMessage,
TransferProposalReceiptMessage,
} from "../../../generated/proto/cacti/satp/v02/stage_1_pb";
import {
MessageType,
Expand All @@ -25,15 +25,20 @@ import {
saveSignature,
checkSessionData,
} from "../../session-utils";
import { SupportedGatewayImplementations } from "../../types";
import { SATPSession } from "../../../core/satp-session";
import { SATPService, ISATPClientServiceOptions } from "../../../types/satp-protocol";

export class Stage1ClientService {
export class Stage1ClientService implements SATPService {
public static readonly CLASS_NAME = "Stage1Service-Client";
private _log: Logger;

constructor() {
private signer: JsObjectSigner;

constructor(ops: ISATPClientServiceOptions) {
const level = "INFO";
const label = Stage1ClientService.CLASS_NAME;
this._log = LoggerProvider.getOrCreate({ level, label });
this.signer = ops.signer;
}

public get className(): string {
Expand All @@ -46,20 +51,21 @@ export class Stage1ClientService {

async transferProposalRequest(
sessionID: string,
gateway: SATPGateway,
session: SATPSession,
supportedDLTs: SupportedGatewayImplementations[],
): Promise<void | TransferProposalRequestMessage> {
const fnTag = `${this.className}#transferProposalRequest()`;

const sessionData = gateway.getSession(sessionID);
const sessionData = session.getSessionData();

if (sessionData == undefined || !checkSessionData(sessionData)) {
throw new Error(`${fnTag}, session data is not correctly initialized`);
}

if (
!gateway.getSupportedDltIDs().includes(sessionData.senderGatewayNetworkId)
!supportedDLTs.includes(sessionData.senderGatewayNetworkId as SupportedGatewayImplementations)
) {
throw new Error(
throw new Error( //todo change this to the transferClaims check
`${fnTag}, recipient gateway dlt system is not supported by this gateway`,
);
}
Expand Down Expand Up @@ -170,7 +176,7 @@ export class Stage1ClientService {

const messageSignature = bufArray2HexStr(
sign(
gateway.gatewaySigner,
this.signer,
JSON.stringify(transferProposalRequestMessage),
),
);
Expand All @@ -185,29 +191,30 @@ export class Stage1ClientService {
getHash(transferProposalRequestMessage),
);

/*
await storeLog(gateway, {
sessionID: sessionID,
type: "transferProposalRequest",
operation: "validate",
data: JSON.stringify(sessionData),
});

*/
this.log.info(`${fnTag}, sending TransferProposalRequest...`);

return transferProposalRequestMessage;
}

async transferCommenceRequest(
response: TransferProposalReceiptRejectMessage,
gateway: SATPGateway,
response: TransferProposalReceiptMessage,
session: SATPSession,
): Promise<void | TransferCommenceRequestMessage> {
const fnTag = `${this.className}#transferCommenceRequest()`;

if (!response || !response.common) {
throw new Error("Response or response.common is undefined");
}

const sessionData = gateway.getSession(response.common.sessionId);
const sessionData = session.getSessionData();

if (sessionData == undefined) {
throw new Error("Session data not loaded successfully");
Expand Down Expand Up @@ -239,7 +246,7 @@ export class Stage1ClientService {

const messageSignature = bufArray2HexStr(
sign(
gateway.gatewaySigner,
this.signer,
JSON.stringify(transferCommenceRequestMessage),
),
);
Expand All @@ -258,23 +265,24 @@ export class Stage1ClientService {
getHash(transferCommenceRequestMessage),
);

/*
await storeLog(gateway, {
sessionID: sessionData.id,
type: "transferCommenceRequest",
operation: "validate",
data: JSON.stringify(sessionData),
});

*/
this.log.info(`${fnTag}, sending TransferCommenceRequest...`);

return transferCommenceRequestMessage;
}

async checkTransferProposalReceiptRejectMessage(
response: TransferProposalReceiptRejectMessage,
gateway: SATPGateway,
async checkTransferProposalReceiptMessage(
response: TransferProposalReceiptMessage,
session: SATPSession,
): Promise<boolean> {
const fnTag = `${this.className}#checkTransferProposalReceiptRejectMessage()`;
const fnTag = `${this.className}#checkTransferProposalReceiptMessage()`;

if (response.common == undefined) {
throw new Error(`${fnTag}, message has no satp common body`);
Expand All @@ -291,7 +299,7 @@ export class Stage1ClientService {

const sessionId = response.common.sessionId;

const sessionData = gateway.getSession(sessionId);
const sessionData = session.getSessionData();

if (sessionData == undefined) {
throw new Error(
Expand Down Expand Up @@ -356,7 +364,7 @@ export class Stage1ClientService {

if (
!verifySignature(
gateway.gatewaySigner,
this.signer,
response,
sessionData.serverGatewayPubkey,
)
Expand Down

0 comments on commit 72d63ab

Please sign in to comment.