From add9cd94ed7fe4a7facda89749895f7b04de89a8 Mon Sep 17 00:00:00 2001 From: Jordi Giron Date: Fri, 5 Feb 2021 11:40:08 +0100 Subject: [PATCH] feat(connector-besu): added ether value in contract invoke request Signed-off-by: Jordi Giron --- .../src/main/json/openapi.json | 10 +++ .../.openapi-generator/VERSION | 2 +- .../generated/openapi/typescript-axios/api.ts | 86 +++++++++++++------ .../openapi/typescript-axios/configuration.ts | 25 ++++++ 4 files changed, 94 insertions(+), 29 deletions(-) diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json index 154bc7c76a..992e6c5aaa 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json @@ -461,6 +461,16 @@ "default": [], "items": {} }, + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ] + }, "gas": { "oneOf": [ { diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION index 1a487e1a2e..28cbf7c0aa 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION @@ -1 +1 @@ -5.0.0-beta2 \ No newline at end of file +5.0.0 \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts index 893f63fa02..4d188b2da3 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -172,6 +172,12 @@ export interface InvokeContractV1Request { * @memberof InvokeContractV1Request */ params: Array; + /** + * + * @type {string | number} + * @memberof InvokeContractV1Request + */ + value?: string | number; /** * * @type {string | number} @@ -525,6 +531,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati if (configuration) { baseOptions = configuration.baseOptions; } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -533,18 +540,23 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati localVarHeaderParameter['Content-Type'] = 'application/json'; - const query = new URLSearchParams(localVarUrlObj.search); + const queryParameters = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { - query.set(key, localVarQueryParameter[key]); + queryParameters.set(key, localVarQueryParameter[key]); } for (const key in options.query) { - query.set(key, options.query[key]); + queryParameters.set(key, options.query[key]); } - localVarUrlObj.search = (new URLSearchParams(query)).toString(); + localVarUrlObj.search = (new URLSearchParams(queryParameters)).toString(); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - const needsSerialization = (typeof deployContractSolidityBytecodeV1Request !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(deployContractSolidityBytecodeV1Request !== undefined ? deployContractSolidityBytecodeV1Request : {}) : (deployContractSolidityBytecodeV1Request || ""); + const nonString = typeof deployContractSolidityBytecodeV1Request !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(localVarRequestOptions.headers['Content-Type']) + : nonString; + localVarRequestOptions.data = needsSerialization + ? JSON.stringify(deployContractSolidityBytecodeV1Request !== undefined ? deployContractSolidityBytecodeV1Request : {}) + : (deployContractSolidityBytecodeV1Request || ""); return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, @@ -566,6 +578,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati if (configuration) { baseOptions = configuration.baseOptions; } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -574,18 +587,23 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati localVarHeaderParameter['Content-Type'] = 'application/json'; - const query = new URLSearchParams(localVarUrlObj.search); + const queryParameters = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { - query.set(key, localVarQueryParameter[key]); + queryParameters.set(key, localVarQueryParameter[key]); } for (const key in options.query) { - query.set(key, options.query[key]); + queryParameters.set(key, options.query[key]); } - localVarUrlObj.search = (new URLSearchParams(query)).toString(); + localVarUrlObj.search = (new URLSearchParams(queryParameters)).toString(); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - const needsSerialization = (typeof invokeContractV1Request !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(invokeContractV1Request !== undefined ? invokeContractV1Request : {}) : (invokeContractV1Request || ""); + const nonString = typeof invokeContractV1Request !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(localVarRequestOptions.headers['Content-Type']) + : nonString; + localVarRequestOptions.data = needsSerialization + ? JSON.stringify(invokeContractV1Request !== undefined ? invokeContractV1Request : {}) + : (invokeContractV1Request || ""); return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, @@ -607,6 +625,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati if (configuration) { baseOptions = configuration.baseOptions; } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -615,18 +634,23 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati localVarHeaderParameter['Content-Type'] = 'application/json'; - const query = new URLSearchParams(localVarUrlObj.search); + const queryParameters = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { - query.set(key, localVarQueryParameter[key]); + queryParameters.set(key, localVarQueryParameter[key]); } for (const key in options.query) { - query.set(key, options.query[key]); + queryParameters.set(key, options.query[key]); } - localVarUrlObj.search = (new URLSearchParams(query)).toString(); + localVarUrlObj.search = (new URLSearchParams(queryParameters)).toString(); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - const needsSerialization = (typeof runTransactionRequest !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; - localVarRequestOptions.data = needsSerialization ? JSON.stringify(runTransactionRequest !== undefined ? runTransactionRequest : {}) : (runTransactionRequest || ""); + const nonString = typeof runTransactionRequest !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(localVarRequestOptions.headers['Content-Type']) + : nonString; + localVarRequestOptions.data = needsSerialization + ? JSON.stringify(runTransactionRequest !== undefined ? runTransactionRequest : {}) + : (runTransactionRequest || ""); return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, @@ -652,6 +676,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati if (configuration) { baseOptions = configuration.baseOptions; } + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; @@ -660,18 +685,23 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati localVarHeaderParameter['Content-Type'] = 'application/json'; - const query = new URLSearchParams(localVarUrlObj.search); + const queryParameters = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { - query.set(key, localVarQueryParameter[key]); + queryParameters.set(key, localVarQueryParameter[key]); } for (const key in options.query) { - query.set(key, options.query[key]); + queryParameters.set(key, options.query[key]); } - localVarUrlObj.search = (new URLSearchParams(query)).toString(); + localVarUrlObj.search = (new URLSearchParams(queryParameters)).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 || ""); + const nonString = typeof signTransactionRequest !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(localVarRequestOptions.headers['Content-Type']) + : nonString; + localVarRequestOptions.data = needsSerialization + ? JSON.stringify(signTransactionRequest !== undefined ? signTransactionRequest : {}) + : (signTransactionRequest || ""); return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, @@ -697,7 +727,7 @@ export const DefaultApiFp = function(configuration?: Configuration) { async apiV1BesuDeployContractSolidityBytecode(deployContractSolidityBytecodeV1Request?: DeployContractSolidityBytecodeV1Request, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).apiV1BesuDeployContractSolidityBytecode(deployContractSolidityBytecodeV1Request, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + const axiosRequestArgs = {...localVarAxiosArgs.options, url: (configuration?.basePath || basePath) + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, @@ -711,7 +741,7 @@ export const DefaultApiFp = function(configuration?: Configuration) { async apiV1BesuInvokeContract(invokeContractV1Request?: InvokeContractV1Request, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).apiV1BesuInvokeContract(invokeContractV1Request, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + const axiosRequestArgs = {...localVarAxiosArgs.options, url: (configuration?.basePath || basePath) + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, @@ -725,7 +755,7 @@ export const DefaultApiFp = function(configuration?: Configuration) { async apiV1BesuRunTransaction(runTransactionRequest?: RunTransactionRequest, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).apiV1BesuRunTransaction(runTransactionRequest, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + const axiosRequestArgs = {...localVarAxiosArgs.options, url: (configuration?.basePath || basePath) + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, @@ -739,7 +769,7 @@ export const DefaultApiFp = function(configuration?: Configuration) { async signTransactionV1(signTransactionRequest: SignTransactionRequest, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).signTransactionV1(signTransactionRequest, options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + const axiosRequestArgs = {...localVarAxiosArgs.options, url: (configuration?.basePath || basePath) + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/configuration.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/configuration.ts index 15244eaa83..64dbb46b9b 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/configuration.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/configuration.ts @@ -20,6 +20,7 @@ export interface ConfigurationParameters { accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); basePath?: string; baseOptions?: any; + formDataCtor?: new () => any; } export class Configuration { @@ -64,6 +65,14 @@ export class Configuration { * @memberof Configuration */ baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; constructor(param: ConfigurationParameters = {}) { this.apiKey = param.apiKey; @@ -72,5 +81,21 @@ export class Configuration { this.accessToken = param.accessToken; this.basePath = param.basePath; this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); } }