Skip to content

Commit

Permalink
feat(connector-besu): implemented contract instance map
Browse files Browse the repository at this point in the history
Signed-off-by: Jordi Giron <jordi.giron.amezcua@accenture.com>
  • Loading branch information
AzaharaC authored and jordigiam committed Mar 18, 2021
1 parent 4cbed45 commit 17fdd94
Show file tree
Hide file tree
Showing 8 changed files with 988 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@
},
"BesuTransactionConfig": {
"type": "object",
"required": [],
"additionalProperties": true,
"properties": {
"rawTransaction": {
Expand Down Expand Up @@ -515,6 +514,100 @@
"callOutput": {}
}
},
"InvokeContractV2Request": {
"type": "object",
"required": [
"contractName",
"signingCredential",
"invocationType",
"methodName",
"params"
],
"properties": {
"contractName": {
"type": "string",
"nullable": false
},
"signingCredential": {
"$ref": "#/components/schemas/Web3SigningCredential",
"nullable": false
},
"invocationType": {
"$ref": "#/components/schemas/EthContractInvocationType",
"nullable": false,
"description": "Indicates wether it is a CALL or a SEND type of invocation where only SEND ends up creating an actual transaction on the ledger."
},
"methodName": {
"description": "The name of the contract method to invoke.",
"type": "string",
"nullable": false,
"minLength": 1,
"maxLength": 2048
},
"params": {
"description": "The list of arguments to pass in to the contract method being invoked.",
"type": "array",
"default": [],
"items": {}
},
"value": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"gas": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"gasPrice": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"nonce": {
"type": "number"
},
"timeoutMs": {
"type": "number",
"description": "The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND",
"minimum": 0,
"default": 60000,
"nullable": false
}
}
},
"InvokeContractV2Response": {
"type": "object",
"required": [
"success"
],
"properties": {
"transactionReceipt": {
"$ref": "#/components/schemas/Web3TransactionReceipt"
},
"callOutput": {},
"success": {
"type": "boolean",
"nullable": false
}
}
},
"SignTransactionRequest": {
"type": "object",
"required": [
Expand Down Expand Up @@ -664,6 +757,40 @@
}
}
},
"/api/v2/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/invoke-contract": {
"post": {
"x-hyperledger-cactus": {
"http": {
"verbLowerCase": "post",
"path": "/api/v2/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/invoke-contract"
}
},
"operationId": "apiV2BesuInvokeContract",
"summary": "Invokeds a contract on a besu ledger",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InvokeContractV2Request"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InvokeContractV2Response"
}
}
}
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/sign-transaction": {
"post": {
"x-hyperledger-cactus": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,98 @@ export interface InvokeContractV1Response {
*/
callOutput?: any | null;
}
/**
*
* @export
* @interface InvokeContractV2Request
*/
export interface InvokeContractV2Request {
/**
*
* @type {string}
* @memberof InvokeContractV2Request
*/
contractName: string;
/**
*
* @type {Web3SigningCredential}
* @memberof InvokeContractV2Request
*/
signingCredential: Web3SigningCredential;
/**
*
* @type {EthContractInvocationType}
* @memberof InvokeContractV2Request
*/
invocationType: EthContractInvocationType;
/**
* The name of the contract method to invoke.
* @type {string}
* @memberof InvokeContractV2Request
*/
methodName: string;
/**
* The list of arguments to pass in to the contract method being invoked.
* @type {Array<any>}
* @memberof InvokeContractV2Request
*/
params: Array<any>;
/**
*
* @type {string | number}
* @memberof InvokeContractV2Request
*/
value?: string | number;
/**
*
* @type {string | number}
* @memberof InvokeContractV2Request
*/
gas?: string | number;
/**
*
* @type {string | number}
* @memberof InvokeContractV2Request
*/
gasPrice?: string | number;
/**
*
* @type {number}
* @memberof InvokeContractV2Request
*/
nonce?: number;
/**
* The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND
* @type {number}
* @memberof InvokeContractV2Request
*/
timeoutMs?: number;
}
/**
*
* @export
* @interface InvokeContractV2Response
*/
export interface InvokeContractV2Response {
/**
*
* @type {Web3TransactionReceipt}
* @memberof InvokeContractV2Response
*/
transactionReceipt?: Web3TransactionReceipt;
/**
*
* @type {any}
* @memberof InvokeContractV2Response
*/
callOutput?: any | null;
/**
*
* @type {boolean}
* @memberof InvokeContractV2Response
*/
success: boolean;
}
/**
*
* @export
Expand Down Expand Up @@ -651,6 +743,47 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
options: localVarRequestOptions,
};
},
/**
*
* @summary Invokeds a contract on a besu ledger
* @param {InvokeContractV2Request} [invokeContractV2Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV2BesuInvokeContract: async (invokeContractV2Request?: InvokeContractV2Request, options: any = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v2/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/invoke-contract`;
// 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 invokeContractV2Request !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(invokeContractV2Request !== undefined ? invokeContractV2Request : {}) : (invokeContractV2Request || "");

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.
Expand Down Expand Up @@ -747,6 +880,20 @@ export const DefaultApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary Invokeds a contract on a besu ledger
* @param {InvokeContractV2Request} [invokeContractV2Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiV2BesuInvokeContract(invokeContractV2Request?: InvokeContractV2Request, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<InvokeContractV2Response>> {
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).apiV2BesuInvokeContract(invokeContractV2Request, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
* Obtain signatures of ledger from the corresponding transaction hash.
* @summary Obtain signatures of ledger from the corresponding transaction hash.
Expand Down Expand Up @@ -800,6 +947,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));
},
/**
*
* @summary Invokeds a contract on a besu ledger
* @param {InvokeContractV2Request} [invokeContractV2Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiV2BesuInvokeContract(invokeContractV2Request?: InvokeContractV2Request, options?: any): AxiosPromise<InvokeContractV2Response> {
return DefaultApiFp(configuration).apiV2BesuInvokeContract(invokeContractV2Request, 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.
Expand Down Expand Up @@ -856,6 +1013,18 @@ export class DefaultApi extends BaseAPI {
return DefaultApiFp(this.configuration).apiV1BesuRunTransaction(runTransactionRequest, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Invokeds a contract on a besu ledger
* @param {InvokeContractV2Request} [invokeContractV2Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public apiV2BesuInvokeContract(invokeContractV2Request?: InvokeContractV2Request, options?: any) {
return DefaultApiFp(this.configuration).apiV2BesuInvokeContract(invokeContractV2Request, 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.
Expand Down

0 comments on commit 17fdd94

Please sign in to comment.