Skip to content

Commit

Permalink
refactor(besu-validator): move code to connector plugin
Browse files Browse the repository at this point in the history
Resolves hyperledger-cacti#363

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Dec 16, 2020
1 parent e6285a6 commit 7d648aa
Show file tree
Hide file tree
Showing 36 changed files with 538 additions and 4,311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,50 @@
},
"callOutput": {}
}
},
"SignTransactionRequest": {
"type": "object",
"required": [
"transactionHash",
"keychainId",
"keychainRef"
],
"properties": {
"keychainId": {
"type": "string",
"minLength": 1,
"maxLength": 100,
"nullable": false
},
"keychainRef": {
"type": "string",
"minLength": 1,
"maxLength": 100,
"nullable": false
},
"transactionHash": {
"description": "The transaction hash of ledger will be used to fetch the contain.",
"type": "string",
"minLength": 0,
"maxLength": 2048,
"nullable": false
}
}
},
"SignTransactionResponse": {
"type": "object",
"required": [
"signature"
],
"properties": {
"signature": {
"description": "The signatures of ledger from the corresponding transaction hash.",
"type": "string",
"minLength": 0,
"maxLength": 2048,
"nullable": false
}
}
}
}
},
Expand Down Expand Up @@ -610,6 +654,39 @@
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/sign-transaction": {
"post": {
"operationId": "signTransactionV1",
"summary": "Obtain signatures of ledger from the corresponding transaction hash.",
"description": "Obtain signatures of ledger from the corresponding transaction hash.",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SignTransactionRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SignTransactionResponse"
}
}
}
},
"404": {
"description": "Not able to find the corresponding tranaction from the transaction hash"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,44 @@ export interface RunTransactionResponse {
*/
transactionReceipt: Web3TransactionReceipt;
}
/**
*
* @export
* @interface SignTransactionRequest
*/
export interface SignTransactionRequest {
/**
*
* @type {string}
* @memberof SignTransactionRequest
*/
keychainId: string;
/**
*
* @type {string}
* @memberof SignTransactionRequest
*/
keychainRef: string;
/**
* The transaction hash of ledger will be used to fetch the contain.
* @type {string}
* @memberof SignTransactionRequest
*/
transactionHash: string;
}
/**
*
* @export
* @interface SignTransactionResponse
*/
export interface SignTransactionResponse {
/**
* The signatures of ledger from the corresponding transaction hash.
* @type {string}
* @memberof SignTransactionResponse
*/
signature: string;
}
/**
*
* @export
Expand Down Expand Up @@ -615,6 +653,51 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
const needsSerialization = (typeof runTransactionRequest !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(runTransactionRequest !== undefined ? runTransactionRequest : {}) : (runTransactionRequest || "");

return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Obtain signatures of ledger from the corresponding transaction hash.
* @summary Obtain signatures of ledger from the corresponding transaction hash.
* @param {SignTransactionRequest} signTransactionRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
signTransactionV1: async (signTransactionRequest: SignTransactionRequest, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'signTransactionRequest' is not null or undefined
if (signTransactionRequest === null || signTransactionRequest === undefined) {
throw new RequiredError('signTransactionRequest','Required parameter signTransactionRequest was null or undefined when calling signTransactionV1.');
}
const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/sign-transaction`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



localVarHeaderParameter['Content-Type'] = 'application/json';

const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.query) {
query.set(key, options.query[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
const needsSerialization = (typeof signTransactionRequest !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(signTransactionRequest !== undefined ? signTransactionRequest : {}) : (signTransactionRequest || "");

return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
Expand Down Expand Up @@ -671,6 +754,20 @@ export const DefaultApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
* Obtain signatures of ledger from the corresponding transaction hash.
* @summary Obtain signatures of ledger from the corresponding transaction hash.
* @param {SignTransactionRequest} signTransactionRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async signTransactionV1(signTransactionRequest: SignTransactionRequest, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SignTransactionResponse>> {
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).signTransactionV1(signTransactionRequest, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};

Expand Down Expand Up @@ -710,6 +807,16 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
apiV1BesuRunTransaction(runTransactionRequest?: RunTransactionRequest, options?: any): AxiosPromise<RunTransactionResponse> {
return DefaultApiFp(configuration).apiV1BesuRunTransaction(runTransactionRequest, options).then((request) => request(axios, basePath));
},
/**
* Obtain signatures of ledger from the corresponding transaction hash.
* @summary Obtain signatures of ledger from the corresponding transaction hash.
* @param {SignTransactionRequest} signTransactionRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
signTransactionV1(signTransactionRequest: SignTransactionRequest, options?: any): AxiosPromise<SignTransactionResponse> {
return DefaultApiFp(configuration).signTransactionV1(signTransactionRequest, options).then((request) => request(axios, basePath));
},
};
};

Expand Down Expand Up @@ -755,6 +862,18 @@ export class DefaultApi extends BaseAPI {
public apiV1BesuRunTransaction(runTransactionRequest?: RunTransactionRequest, options?: any) {
return DefaultApiFp(this.configuration).apiV1BesuRunTransaction(runTransactionRequest, options).then((request) => request(this.axios, this.basePath));
}

/**
* Obtain signatures of ledger from the corresponding transaction hash.
* @summary Obtain signatures of ledger from the corresponding transaction hash.
* @param {SignTransactionRequest} signTransactionRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public signTransactionV1(signTransactionRequest: SignTransactionRequest, options?: any) {
return DefaultApiFp(this.configuration).signTransactionV1(signTransactionRequest, options).then((request) => request(this.axios, this.basePath));
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OpenAPIV3 } from "openapi-types";
import { DeployContractSolidityBytecodeEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint-constants";
import { RunTransactionEndpoint } from "./web-services/run-transaction-endpoint-constants";
import { InvokeContractEndpoint } from "./web-services/invoke-contract-endpoint-constants";
import { BesuSignTransactionEndpointV1 } from "./web-services/sign-transaction-endpoint-constants";

export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = {
openapi: "3.0.3",
Expand Down Expand Up @@ -473,6 +474,46 @@ export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = {
callOutput: {},
},
},
SignTransactionRequest: {
type: "object",
required: ["transactionHash", "keychainId", "keychainRef"],
properties: {
keychainId: {
type: "string",
minLength: 1,
maxLength: 100,
nullable: false,
},
keychainRef: {
type: "string",
minLength: 1,
maxLength: 100,
nullable: false,
},
transactionHash: {
description:
"The transaction hash of ledger will be used to fetch the contain.",
type: "string",
minLength: 0,
maxLength: 2048,
nullable: false,
},
},
},
SignTransactionResponse: {
type: "object",
required: ["signature"],
properties: {
signature: {
description:
"The signatures of ledger from the corresponding transaction hash.",
type: "string",
minLength: 0,
maxLength: 2048,
nullable: false,
},
},
},
},
},
paths: {
Expand Down Expand Up @@ -563,6 +604,42 @@ export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = {
},
},
},
[BesuSignTransactionEndpointV1.HTTP_PATH]: {
[BesuSignTransactionEndpointV1.HTTP_VERB_LOWER_CASE]: {
operationId: BesuSignTransactionEndpointV1.OPENAPI_OPERATION_ID,
summary:
"Obtain signatures of ledger from the corresponding transaction hash.",
description:
"Obtain signatures of ledger from the corresponding transaction hash.",
parameters: [],
requestBody: {
required: true,
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/SignTransactionRequest",
},
},
},
},
responses: {
"200": {
description: "OK",
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/SignTransactionResponse",
},
},
},
},
"404": {
description:
"Not able to find the corresponding tranaction from the transaction hash",
},
},
},
},
},
};

Expand Down
Loading

0 comments on commit 7d648aa

Please sign in to comment.