diff --git a/packages/cactus-core-api/src/main/json/generated/openapi-spec.json b/packages/cactus-core-api/src/main/json/generated/openapi-spec.json index e7c2b65aaf..4f2e18f416 100644 --- a/packages/cactus-core-api/src/main/json/generated/openapi-spec.json +++ b/packages/cactus-core-api/src/main/json/generated/openapi-spec.json @@ -27,6 +27,15 @@ ], "components": { "schemas": { + "ConsensusAlgorithmFamily": { + "type": "string", + "description": "Enumerates a list of consensus algorithm families in existence. Does not intend to be an exhaustive list, just a practical one, meaning that we only include items here that are relevant to Hyperledger Cactus in fulfilling its own duties. This can be extended later as more sophisticated features of Cactus get implemented. This enum is meant to be first and foremest a useful abstraction for achieving practical tasks, not an encyclopedia and therefore we ask of everyone that this to be extended only in ways that serve a practical purpose for the runtime behavior of Cactus or Cactus plugins in general. The bottom line is that we can accept this enum being not 100% accurate as long as it 100% satisfies what it was designed to do.", + "enum": [ + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY", + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE", + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK" + ] + }, "PrimaryKey": { "type": "string", "minLength": 1, diff --git a/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts index 94e4d86caf..56da7bffed 100644 --- a/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -124,6 +124,17 @@ export interface CactusNodeMeta { */ publicKeyPem: string; } +/** + * Enumerates a list of consensus algorithm families in existence. Does not intend to be an exhaustive list, just a practical one, meaning that we only include items here that are relevant to Hyperledger Cactus in fulfilling its own duties. This can be extended later as more sophisticated features of Cactus get implemented. This enum is meant to be first and foremest a useful abstraction for achieving practical tasks, not an encyclopedia and therefore we ask of everyone that this to be extended only in ways that serve a practical purpose for the runtime behavior of Cactus or Cactus plugins in general. The bottom line is that we can accept this enum being not 100% accurate as long as it 100% satisfies what it was designed to do. + * @export + * @enum {string} + */ +export enum ConsensusAlgorithmFamily { + AUTHORITY = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY', + STAKE = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE', + WORK = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK' +} + /** * * @export diff --git a/packages/cactus-core-api/src/main/typescript/openapi-spec.ts b/packages/cactus-core-api/src/main/typescript/openapi-spec.ts index 71a156200b..c5ebeffd73 100644 --- a/packages/cactus-core-api/src/main/typescript/openapi-spec.ts +++ b/packages/cactus-core-api/src/main/typescript/openapi-spec.ts @@ -35,6 +35,28 @@ export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = { ], components: { schemas: { + ConsensusAlgorithmFamily: { + type: "string", + description: + "Enumerates a list of consensus algorithm families in " + + "existence. Does not intend to be an exhaustive list, just a " + + "practical one, meaning that we only include items here that are " + + "relevant to Hyperledger Cactus in fulfilling its own duties. " + + "This can be extended later as more sophisticated features " + + "of Cactus get implemented. " + + "This enum is meant to be first and foremest a useful abstraction " + + "for achieving practical tasks, not an encyclopedia and therefore " + + "we ask of everyone that this to be extended only in ways that " + + "serve a practical purpose for the runtime behavior of Cactus or " + + "Cactus plugins in general. The bottom line is that we can accept " + + "this enum being not 100% accurate as long as it 100% satisfies " + + "what it was designed to do.", + enum: [ + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY", + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE", + "org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK", + ], + }, PrimaryKey: { type: "string", minLength: 1, diff --git a/packages/cactus-core-api/src/main/typescript/plugin/ledger-connector/i-plugin-ledger-connector.ts b/packages/cactus-core-api/src/main/typescript/plugin/ledger-connector/i-plugin-ledger-connector.ts index 30ed1a154b..f700d1b803 100644 --- a/packages/cactus-core-api/src/main/typescript/plugin/ledger-connector/i-plugin-ledger-connector.ts +++ b/packages/cactus-core-api/src/main/typescript/plugin/ledger-connector/i-plugin-ledger-connector.ts @@ -1,4 +1,5 @@ import { ICactusPlugin } from "../i-cactus-plugin"; +import { ConsensusAlgorithmFamily } from "../../generated/openapi/typescript-axios/api"; /** * Common interface to be implemented by plugins which are implementing the connection to ledgers. @@ -21,4 +22,12 @@ export interface IPluginLedgerConnector< * type of ledger this connectir is targeted at. */ transact(options?: TransactIn): Promise; + + /** + * Returns the family of algorithms in which the consensus algorithm used + * by the ledger (this connector is associated with) belongs in. + * + * @see {ConsensusAlgorithmFamily} + */ + getConsensusAlgorithmFamily(): Promise; } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts index 663ce87a0f..1281523630 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts @@ -10,6 +10,7 @@ import { ContractSendMethod } from "web3-eth-contract"; import { TransactionReceipt } from "web3-eth"; import { + ConsensusAlgorithmFamily, IPluginLedgerConnector, IWebServiceEndpoint, IPluginWebService, @@ -168,6 +169,12 @@ export class PluginLedgerConnectorBesu return PluginAspect.LEDGER_CONNECTOR; } + public async getConsensusAlgorithmFamily(): Promise< + ConsensusAlgorithmFamily + > { + return ConsensusAlgorithmFamily.AUTHORITY; + } + public async invokeContract( req: InvokeContractV1Request ): Promise { diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts index 4b99a88359..bd8f43025a 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts @@ -16,6 +16,7 @@ import { import { Optional } from "typescript-optional"; import { + ConsensusAlgorithmFamily, IPluginLedgerConnector, PluginAspect, IPluginWebService, @@ -116,6 +117,12 @@ export class PluginLedgerConnectorFabric return Optional.empty(); } + public async getConsensusAlgorithmFamily(): Promise< + ConsensusAlgorithmFamily + > { + return ConsensusAlgorithmFamily.AUTHORITY; + } + /** * FIXME: Implement this feature of the connector. * diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts index 8dea603118..f36dba8b21 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts @@ -10,6 +10,7 @@ import { ContractSendMethod } from "web3-eth-contract"; import { TransactionReceipt } from "web3-eth"; import { + ConsensusAlgorithmFamily, IPluginLedgerConnector, IWebServiceEndpoint, IPluginWebService, @@ -152,6 +153,12 @@ export class PluginLedgerConnectorQuorum return PluginAspect.LEDGER_CONNECTOR; } + public async getConsensusAlgorithmFamily(): Promise< + ConsensusAlgorithmFamily + > { + return ConsensusAlgorithmFamily.AUTHORITY; + } + public async invokeContract( req: InvokeContractV1Request ): Promise {