Skip to content

Commit

Permalink
feat(fabric): add sequence diagram of run transaction endpoint
Browse files Browse the repository at this point in the history
	Primary Change
	--------------

	1. Added plantuml diagrams and corresponding pngs to describe the run transaction endpoint and are located under cactus-plugin-ledger-connector-fabric/docs/architecture
	2. Modified the Readme to incorporate the pngs created above.

Resolve #756

Signed-off-by: Jagpreet Singh Sasan <jagpreet.singh.sasan@accenture.com>
  • Loading branch information
jagpreetsinghsasan authored and petermetz committed Apr 26, 2021
1 parent 890007f commit 155cbab
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/cactus-plugin-ledger-connector-fabric/README.md
Expand Up @@ -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)
Expand All @@ -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**.
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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<string>(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
@@ -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

0 comments on commit 155cbab

Please sign in to comment.