diff --git a/packages/cactus-plugin-ledger-connector-fabric/README.md b/packages/cactus-plugin-ledger-connector-fabric/README.md index f56614ba75..ea8f6b5597 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/README.md +++ b/packages/cactus-plugin-ledger-connector-fabric/README.md @@ -8,6 +8,7 @@ This plugin provides `Cactus` a way to interact with Fabric networks. Using this ## Summary - [Getting Started](#getting-started) + - [Architecture](#architecture) - [Usage](#usage) - [Runing the tests](#running-the-tests) - [Built With](#built-with) @@ -33,6 +34,15 @@ In the project root folder, run this command to compile the plugin and create th ```sh npm run tsc ``` +### Architecture +The sequence diagrams for various endpoints are mentioned below + +#### run-transaction-endpoint +![run-transaction-endpoint sequence diagram](docs/architecture/images/run-transaction-endpoint.png) +The above diagram shows the sequence diagram of run-transaction-endpoint. User A (One of the many Users) interacts with the API Client which in turn, calls the API server. API server then executes transact() method which is explained in detailed in the subsequent diagram. +![run-transaction-endpoint transact() method](docs/architecture/images/run-transaction-endpoint-transact.png) +The above diagram shows the sequence diagraom of transact() method of the PluginLedgerConnectorFabric class. The caller to this function, which in reference to the above sequence diagram is API server, sends RunTransactionRequest object as an argument to the transact() method. Based on the invocationType (FabricContractInvocationType.CALL, FabricCOntractInvocationType.SEND), corresponding responses are send back to the caller. + ## Usage To use this import public-api and create new **PluginLedgerConnectorFabric** and **ChainCodeCompiler**. diff --git a/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint-transact.png b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint-transact.png new file mode 100644 index 0000000000..91a13a4290 Binary files /dev/null and b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint-transact.png differ diff --git a/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint.png b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint.png new file mode 100644 index 0000000000..8e6a76a599 Binary files /dev/null and b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/images/run-transaction-endpoint.png differ diff --git a/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint-transact.puml b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint-transact.puml new file mode 100644 index 0000000000..53f22ff169 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint-transact.puml @@ -0,0 +1,59 @@ +@startuml +title Hyperledger Cactus\nSequence Diagram\nRun Transaction Endpoint\ntransact() method + +skinparam sequenceArrowThickness 2 +skinparam roundcorner 20 +skinparam maxmessagesize 300 +skinparam sequenceParticipant underline + +actor "Caller" as caller +participant "PluginLedgerConnectorFabric" as t << (C,#ADD1B2) class >> + +autoactivate on + +activate caller +caller -> t: transact(req: RunTransactionRequest) + +t -> t: req +t --> t: {signingCredential, channelName, contractName, invocationType, fnName as methodName, params} + +t -> t: InMemoryWallet(new X509WalletMixin()) +t --> t: wallet + +t -> t: opts.pluginRegistry.findOneByKeychainID(signingCredential.keychainId) +t --> t: keychain + +t -> t: keychain.get(signingCredential.keychainRef) +t --> t: fabricX509IdentityJson + +t -> t: JSON.parse(fabricX509IdentityJson) +t --> t: identity + +t -> t: wait for wallter.import(signingCredential.keychainRef, identity) +deactivate t + +t -> t: wait for gateway.connect(connectionProfile, gatewayOptions) +deactivate t + +t -> t: wait gateway.getNetwork(channelName) +t --> t: network + +t -> t: network.getContract(contractName) +t --> t: contract + +group #LightBlue if invocationType == FabricContractInvocationType.CALL + t -> t: wait for contract.evaluateTransaction(fnName, ...params) + t --> t: out, success: true +else #LightYellow if invocationType == FabricContractInvocationType.SEND + t -> t: wait for contract.submitTransaction(fnName, ...params) + t --> t: out, success: true +else #LightCoral default + t --> caller: throw Error('unknown FabricContractInvocationType') +end + +t -> t: out.toString("utf-8") +t --> t: outUtf8 + +t --> caller: return { functionOutput, success } as res + +@enduml \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint.puml b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint.puml new file mode 100644 index 0000000000..83e0858866 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-fabric/docs/architecture/run-transaction-endpoint.puml @@ -0,0 +1,29 @@ +@startuml Sequence Diagram - Transaction + +title Hyperledger Cactus\nSequence Diagram\nRun Transaction Endpoint + +skinparam sequenceArrowThickness 2 +skinparam roundcorner 20 +skinparam maxmessagesize 120 +skinparam sequenceParticipant underline + +box "Users" #LightBlue +actor "User A" as a +end box + +box "Hyperledger Cactus" #LightGray +entity "API Client" as apic +entity "API Server" as apis +end box + +box "Ledger Connector" #LightGreen +database "Besu" as besucon +end box + +a --> apic : Tx Besu Ledger +apic --> apis: Request +apis --> besucon: transact() +besucon --> apis: Response +apis --> apic: Formatted Response + +@enduml \ No newline at end of file