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 9824dd8de3c..85a851cffea 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 @@ -761,6 +761,73 @@ } } }, + "DeployContractSolidityBytecodeNoKeychainV1Request": { + "type": "object", + "required": [ + "contractName", + "contractAbi", + "contractJson", + "bytecode", + "web3SigningCredential", + "keychainId", + "constructorArgs" + ], + "additionalProperties": false, + "properties": { + "contractName": { + "type": "string", + "description": "The contract name for retrieve the contracts json on the keychain.", + "minLength": 1, + "maxLength": 100, + "nullable": false + }, + "contractAbi": { + "description": "The application binary interface of the solidity contract", + "type": "array", + "items": {}, + "nullable": false + }, + "contractJSONString": { + "description": "For use when not using keychain, pass the contract in as this string variable", + "nullable": false, + "type": "string" + }, + "constructorArgs": { + "type": "array", + "items": {}, + "default": [] + }, + "web3SigningCredential": { + "$ref": "#/components/schemas/Web3SigningCredential", + "nullable": false + }, + "bytecode": { + "type": "string", + "nullable": false, + "minLength": 1, + "maxLength": 24576, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + }, + "gas": { + "type": "number", + "nullable": false + }, + "gasPrice": { + "type": "string", + "nullable": false + }, + "timeoutMs": { + "type": "number", + "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", + "minimum": 0, + "default": 60000, + "nullable": false + }, + "privateTransactionConfig": { + "$ref": "#/components/schemas/BesuPrivateTransactionConfig" + } + } + }, "DeployContractSolidityBytecodeV1Response": { "type": "object", "required": ["transactionReceipt"], @@ -1016,6 +1083,40 @@ } } }, + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain": { + "post": { + "x-hyperledger-cacti": { + "http": { + "verbLowerCase": "post", + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain" + } + }, + "operationId": "deployContractSolBytecodeNoKeychainV1", + "summary": "Deploys the bytecode of a Solidity contract without the need of keychain", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeployContractSolidityBytecodeNoKeychainV1Request" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" + } + } + } + } + } + } + }, "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/get-balance": { "post": { "x-hyperledger-cacti": { diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json index 9824dd8de3c..85a851cffea 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json @@ -761,6 +761,73 @@ } } }, + "DeployContractSolidityBytecodeNoKeychainV1Request": { + "type": "object", + "required": [ + "contractName", + "contractAbi", + "contractJson", + "bytecode", + "web3SigningCredential", + "keychainId", + "constructorArgs" + ], + "additionalProperties": false, + "properties": { + "contractName": { + "type": "string", + "description": "The contract name for retrieve the contracts json on the keychain.", + "minLength": 1, + "maxLength": 100, + "nullable": false + }, + "contractAbi": { + "description": "The application binary interface of the solidity contract", + "type": "array", + "items": {}, + "nullable": false + }, + "contractJSONString": { + "description": "For use when not using keychain, pass the contract in as this string variable", + "nullable": false, + "type": "string" + }, + "constructorArgs": { + "type": "array", + "items": {}, + "default": [] + }, + "web3SigningCredential": { + "$ref": "#/components/schemas/Web3SigningCredential", + "nullable": false + }, + "bytecode": { + "type": "string", + "nullable": false, + "minLength": 1, + "maxLength": 24576, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + }, + "gas": { + "type": "number", + "nullable": false + }, + "gasPrice": { + "type": "string", + "nullable": false + }, + "timeoutMs": { + "type": "number", + "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", + "minimum": 0, + "default": 60000, + "nullable": false + }, + "privateTransactionConfig": { + "$ref": "#/components/schemas/BesuPrivateTransactionConfig" + } + } + }, "DeployContractSolidityBytecodeV1Response": { "type": "object", "required": ["transactionReceipt"], @@ -1016,6 +1083,40 @@ } } }, + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain": { + "post": { + "x-hyperledger-cacti": { + "http": { + "verbLowerCase": "post", + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain" + } + }, + "operationId": "deployContractSolBytecodeNoKeychainV1", + "summary": "Deploys the bytecode of a Solidity contract without the need of keychain", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeployContractSolidityBytecodeNoKeychainV1Request" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeployContractSolidityBytecodeV1Response" + } + } + } + } + } + } + }, "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/get-balance": { "post": { "x-hyperledger-cacti": { diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/FILES b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/FILES index 2683bce8e5e..54faef8d5c5 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/FILES +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/FILES @@ -3,6 +3,7 @@ models/besu_private_transaction_config_pb.proto models/besu_transaction_config_pb.proto models/besu_transaction_config_to_pb.proto models/consistency_strategy_pb.proto +models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto models/deploy_contract_solidity_bytecode_v1_request_pb.proto models/deploy_contract_solidity_bytecode_v1_response_pb.proto models/eth_contract_invocation_type_pb.proto diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto new file mode 100644 index 00000000000..60dd6798aa1 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto @@ -0,0 +1,47 @@ +/* + Hyperledger Cactus Plugin - Connector Besu + + Can perform basic tasks on a Besu ledger + + The version of the OpenAPI document: 2.0.0-rc.2 + + Generated by OpenAPI Generator: https://openapi-generator.tech +*/ + +syntax = "proto3"; + +package org.hyperledger.cacti.plugin.ledger.connector.besu; + +import "google/protobuf/any.proto"; + +import "models/besu_private_transaction_config_pb.proto"; +import "models/web3_signing_credential_pb.proto"; + +message DeployContractSolidityBytecodeNoKeychainV1RequestPB { + + // The contract name for retrieve the contracts json on the keychain. + string contractName = 328784197; + + // The application binary interface of the solidity contract + repeated google.protobuf.Any contractAbi = 512852493; + + // For use when not using keychain, pass the contract in as this string variable + string contractJSONString = 405816750; + + repeated google.protobuf.Any constructorArgs = 336490508; + + Web3SigningCredentialPB web3SigningCredential = 451211679; + + // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + string bytecode = 256554254; + + float gas = 102105; + + string gasPrice = 5271059; + + // The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. + float timeoutMs = 51479271; + + BesuPrivateTransactionConfigPB privateTransactionConfig = 276796542; + +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/services/default_service.proto b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/services/default_service.proto index 13fc8e2aa92..c8afc489458 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/services/default_service.proto +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/services/default_service.proto @@ -13,6 +13,7 @@ syntax = "proto3"; package org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice; import "google/protobuf/empty.proto"; +import "models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto"; import "models/deploy_contract_solidity_bytecode_v1_request_pb.proto"; import "models/deploy_contract_solidity_bytecode_v1_response_pb.proto"; import "models/get_balance_v1_request_pb.proto"; @@ -33,6 +34,8 @@ import "models/sign_transaction_request_pb.proto"; import "models/sign_transaction_response_pb.proto"; service DefaultService { + rpc DeployContractSolBytecodeNoKeychainV1 (DeployContractSolBytecodeNoKeychainV1Request) returns (DeployContractSolidityBytecodeV1ResponsePB); + rpc DeployContractSolBytecodeV1 (DeployContractSolBytecodeV1Request) returns (DeployContractSolidityBytecodeV1ResponsePB); rpc GetBalanceV1 (GetBalanceV1Request) returns (GetBalanceV1ResponsePB); @@ -57,6 +60,11 @@ service DefaultService { } +message DeployContractSolBytecodeNoKeychainV1Request { + DeployContractSolidityBytecodeNoKeychainV1RequestPB deployContractSolidityBytecodeNoKeychainV1RequestPB = 1; + +} + message DeployContractSolBytecodeV1Request { DeployContractSolidityBytecodeV1RequestPB deployContractSolidityBytecodeV1RequestPB = 1; 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 71f24eaf045..ac8f579a9a7 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 @@ -132,6 +132,73 @@ export interface ConsistencyStrategy { } +/** + * + * @export + * @interface DeployContractSolidityBytecodeNoKeychainV1Request + */ +export interface DeployContractSolidityBytecodeNoKeychainV1Request { + /** + * The contract name for retrieve the contracts json on the keychain. + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractName': string; + /** + * The application binary interface of the solidity contract + * @type {Array} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractAbi': Array; + /** + * For use when not using keychain, pass the contract in as this string variable + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractJSONString'?: string; + /** + * + * @type {Array} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'constructorArgs': Array; + /** + * + * @type {Web3SigningCredential} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'web3SigningCredential': Web3SigningCredential; + /** + * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'bytecode': string; + /** + * + * @type {number} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'gas'?: number; + /** + * + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'gasPrice'?: string; + /** + * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. + * @type {number} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'timeoutMs'?: number; + /** + * + * @type {BesuPrivateTransactionConfig} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'privateTransactionConfig'?: BesuPrivateTransactionConfig; +} /** * * @export @@ -1302,6 +1369,40 @@ export interface Web3TransactionReceipt { */ export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { return { + /** + * + * @summary Deploys the bytecode of a Solidity contract without the need of keychain + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deployContractSolBytecodeNoKeychainV1: async (deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + 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'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(deployContractSolidityBytecodeNoKeychainV1Request, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @summary Deploys the bytecode of a Solidity contract. @@ -1680,6 +1781,17 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati export const DefaultApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration) return { + /** + * + * @summary Deploys the bytecode of a Solidity contract without the need of keychain + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @summary Deploys the bytecode of a Solidity contract. @@ -1809,6 +1921,16 @@ export const DefaultApiFp = function(configuration?: Configuration) { export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = DefaultApiFp(configuration) return { + /** + * + * @summary Deploys the bytecode of a Solidity contract without the need of keychain + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options).then((request) => request(axios, basePath)); + }, /** * * @summary Deploys the bytecode of a Solidity contract. @@ -1927,6 +2049,18 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa * @extends {BaseAPI} */ export class DefaultApi extends BaseAPI { + /** + * + * @summary Deploys the bytecode of a Solidity contract without the need of keychain + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @summary Deploys the bytecode of a Solidity contract. diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.ts new file mode 100644 index 00000000000..df13cc00a0c --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.ts @@ -0,0 +1,291 @@ +/** + * Generated by the protoc-gen-ts. DO NOT EDIT! + * compiler version: 3.19.1 + * source: models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto + * git: https://github.com/thesayyn/protoc-gen-ts */ +import * as dependency_1 from "./../google/protobuf/any"; +import * as dependency_2 from "./besu_private_transaction_config_pb"; +import * as dependency_3 from "./web3_signing_credential_pb"; +import * as pb_1 from "google-protobuf"; +export namespace org.hyperledger.cacti.plugin.ledger.connector.besu { + export class DeployContractSolidityBytecodeNoKeychainV1RequestPB extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + contractName?: string; + contractAbi?: dependency_1.google.protobuf.Any[]; + contractJSONString?: string; + constructorArgs?: dependency_1.google.protobuf.Any[]; + web3SigningCredential?: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB; + bytecode?: string; + gas?: number; + gasPrice?: string; + timeoutMs?: number; + privateTransactionConfig?: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [512852493, 336490508], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("contractName" in data && data.contractName != undefined) { + this.contractName = data.contractName; + } + if ("contractAbi" in data && data.contractAbi != undefined) { + this.contractAbi = data.contractAbi; + } + if ("contractJSONString" in data && data.contractJSONString != undefined) { + this.contractJSONString = data.contractJSONString; + } + if ("constructorArgs" in data && data.constructorArgs != undefined) { + this.constructorArgs = data.constructorArgs; + } + if ("web3SigningCredential" in data && data.web3SigningCredential != undefined) { + this.web3SigningCredential = data.web3SigningCredential; + } + if ("bytecode" in data && data.bytecode != undefined) { + this.bytecode = data.bytecode; + } + if ("gas" in data && data.gas != undefined) { + this.gas = data.gas; + } + if ("gasPrice" in data && data.gasPrice != undefined) { + this.gasPrice = data.gasPrice; + } + if ("timeoutMs" in data && data.timeoutMs != undefined) { + this.timeoutMs = data.timeoutMs; + } + if ("privateTransactionConfig" in data && data.privateTransactionConfig != undefined) { + this.privateTransactionConfig = data.privateTransactionConfig; + } + } + } + get contractName() { + return pb_1.Message.getFieldWithDefault(this, 328784197, "") as string; + } + set contractName(value: string) { + pb_1.Message.setField(this, 328784197, value); + } + get contractAbi() { + return pb_1.Message.getRepeatedWrapperField(this, dependency_1.google.protobuf.Any, 512852493) as dependency_1.google.protobuf.Any[]; + } + set contractAbi(value: dependency_1.google.protobuf.Any[]) { + pb_1.Message.setRepeatedWrapperField(this, 512852493, value); + } + get contractJSONString() { + return pb_1.Message.getFieldWithDefault(this, 405816750, "") as string; + } + set contractJSONString(value: string) { + pb_1.Message.setField(this, 405816750, value); + } + get constructorArgs() { + return pb_1.Message.getRepeatedWrapperField(this, dependency_1.google.protobuf.Any, 336490508) as dependency_1.google.protobuf.Any[]; + } + set constructorArgs(value: dependency_1.google.protobuf.Any[]) { + pb_1.Message.setRepeatedWrapperField(this, 336490508, value); + } + get web3SigningCredential() { + return pb_1.Message.getWrapperField(this, dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB, 451211679) as dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB; + } + set web3SigningCredential(value: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB) { + pb_1.Message.setWrapperField(this, 451211679, value); + } + get has_web3SigningCredential() { + return pb_1.Message.getField(this, 451211679) != null; + } + get bytecode() { + return pb_1.Message.getFieldWithDefault(this, 256554254, "") as string; + } + set bytecode(value: string) { + pb_1.Message.setField(this, 256554254, value); + } + get gas() { + return pb_1.Message.getFieldWithDefault(this, 102105, 0) as number; + } + set gas(value: number) { + pb_1.Message.setField(this, 102105, value); + } + get gasPrice() { + return pb_1.Message.getFieldWithDefault(this, 5271059, "") as string; + } + set gasPrice(value: string) { + pb_1.Message.setField(this, 5271059, value); + } + get timeoutMs() { + return pb_1.Message.getFieldWithDefault(this, 51479271, 0) as number; + } + set timeoutMs(value: number) { + pb_1.Message.setField(this, 51479271, value); + } + get privateTransactionConfig() { + return pb_1.Message.getWrapperField(this, dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB, 276796542) as dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB; + } + set privateTransactionConfig(value: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB) { + pb_1.Message.setWrapperField(this, 276796542, value); + } + get has_privateTransactionConfig() { + return pb_1.Message.getField(this, 276796542) != null; + } + static fromObject(data: { + contractName?: string; + contractAbi?: ReturnType[]; + contractJSONString?: string; + constructorArgs?: ReturnType[]; + web3SigningCredential?: ReturnType; + bytecode?: string; + gas?: number; + gasPrice?: string; + timeoutMs?: number; + privateTransactionConfig?: ReturnType; + }): DeployContractSolidityBytecodeNoKeychainV1RequestPB { + const message = new DeployContractSolidityBytecodeNoKeychainV1RequestPB({}); + if (data.contractName != null) { + message.contractName = data.contractName; + } + if (data.contractAbi != null) { + message.contractAbi = data.contractAbi.map(item => dependency_1.google.protobuf.Any.fromObject(item)); + } + if (data.contractJSONString != null) { + message.contractJSONString = data.contractJSONString; + } + if (data.constructorArgs != null) { + message.constructorArgs = data.constructorArgs.map(item => dependency_1.google.protobuf.Any.fromObject(item)); + } + if (data.web3SigningCredential != null) { + message.web3SigningCredential = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB.fromObject(data.web3SigningCredential); + } + if (data.bytecode != null) { + message.bytecode = data.bytecode; + } + if (data.gas != null) { + message.gas = data.gas; + } + if (data.gasPrice != null) { + message.gasPrice = data.gasPrice; + } + if (data.timeoutMs != null) { + message.timeoutMs = data.timeoutMs; + } + if (data.privateTransactionConfig != null) { + message.privateTransactionConfig = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB.fromObject(data.privateTransactionConfig); + } + return message; + } + toObject() { + const data: { + contractName?: string; + contractAbi?: ReturnType[]; + contractJSONString?: string; + constructorArgs?: ReturnType[]; + web3SigningCredential?: ReturnType; + bytecode?: string; + gas?: number; + gasPrice?: string; + timeoutMs?: number; + privateTransactionConfig?: ReturnType; + } = {}; + if (this.contractName != null) { + data.contractName = this.contractName; + } + if (this.contractAbi != null) { + data.contractAbi = this.contractAbi.map((item: dependency_1.google.protobuf.Any) => item.toObject()); + } + if (this.contractJSONString != null) { + data.contractJSONString = this.contractJSONString; + } + if (this.constructorArgs != null) { + data.constructorArgs = this.constructorArgs.map((item: dependency_1.google.protobuf.Any) => item.toObject()); + } + if (this.web3SigningCredential != null) { + data.web3SigningCredential = this.web3SigningCredential.toObject(); + } + if (this.bytecode != null) { + data.bytecode = this.bytecode; + } + if (this.gas != null) { + data.gas = this.gas; + } + if (this.gasPrice != null) { + data.gasPrice = this.gasPrice; + } + if (this.timeoutMs != null) { + data.timeoutMs = this.timeoutMs; + } + if (this.privateTransactionConfig != null) { + data.privateTransactionConfig = this.privateTransactionConfig.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.contractName.length) + writer.writeString(328784197, this.contractName); + if (this.contractAbi.length) + writer.writeRepeatedMessage(512852493, this.contractAbi, (item: dependency_1.google.protobuf.Any) => item.serialize(writer)); + if (this.contractJSONString.length) + writer.writeString(405816750, this.contractJSONString); + if (this.constructorArgs.length) + writer.writeRepeatedMessage(336490508, this.constructorArgs, (item: dependency_1.google.protobuf.Any) => item.serialize(writer)); + if (this.has_web3SigningCredential) + writer.writeMessage(451211679, this.web3SigningCredential, () => this.web3SigningCredential.serialize(writer)); + if (this.bytecode.length) + writer.writeString(256554254, this.bytecode); + if (this.gas != 0) + writer.writeFloat(102105, this.gas); + if (this.gasPrice.length) + writer.writeString(5271059, this.gasPrice); + if (this.timeoutMs != 0) + writer.writeFloat(51479271, this.timeoutMs); + if (this.has_privateTransactionConfig) + writer.writeMessage(276796542, this.privateTransactionConfig, () => this.privateTransactionConfig.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DeployContractSolidityBytecodeNoKeychainV1RequestPB { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DeployContractSolidityBytecodeNoKeychainV1RequestPB(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 328784197: + message.contractName = reader.readString(); + break; + case 512852493: + reader.readMessage(message.contractAbi, () => pb_1.Message.addToRepeatedWrapperField(message, 512852493, dependency_1.google.protobuf.Any.deserialize(reader), dependency_1.google.protobuf.Any)); + break; + case 405816750: + message.contractJSONString = reader.readString(); + break; + case 336490508: + reader.readMessage(message.constructorArgs, () => pb_1.Message.addToRepeatedWrapperField(message, 336490508, dependency_1.google.protobuf.Any.deserialize(reader), dependency_1.google.protobuf.Any)); + break; + case 451211679: + reader.readMessage(message.web3SigningCredential, () => message.web3SigningCredential = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.Web3SigningCredentialPB.deserialize(reader)); + break; + case 256554254: + message.bytecode = reader.readString(); + break; + case 102105: + message.gas = reader.readFloat(); + break; + case 5271059: + message.gasPrice = reader.readString(); + break; + case 51479271: + message.timeoutMs = reader.readFloat(); + break; + case 276796542: + reader.readMessage(message.privateTransactionConfig, () => message.privateTransactionConfig = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.BesuPrivateTransactionConfigPB.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): DeployContractSolidityBytecodeNoKeychainV1RequestPB { + return DeployContractSolidityBytecodeNoKeychainV1RequestPB.deserialize(bytes); + } + } +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/services/default_service.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/services/default_service.ts index eb183bbef17..d469d422aa8 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/services/default_service.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/services/default_service.ts @@ -4,31 +4,102 @@ * source: services/default_service.proto * git: https://github.com/thesayyn/protoc-gen-ts */ import * as dependency_1 from "./../google/protobuf/empty"; -import * as dependency_2 from "./../models/deploy_contract_solidity_bytecode_v1_request_pb"; -import * as dependency_3 from "./../models/deploy_contract_solidity_bytecode_v1_response_pb"; -import * as dependency_4 from "./../models/get_balance_v1_request_pb"; -import * as dependency_5 from "./../models/get_balance_v1_response_pb"; -import * as dependency_6 from "./../models/get_besu_record_v1_request_pb"; -import * as dependency_7 from "./../models/get_besu_record_v1_response_pb"; -import * as dependency_8 from "./../models/get_block_v1_request_pb"; -import * as dependency_9 from "./../models/get_block_v1_response_pb"; -import * as dependency_10 from "./../models/get_past_logs_v1_request_pb"; -import * as dependency_11 from "./../models/get_past_logs_v1_response_pb"; -import * as dependency_12 from "./../models/get_transaction_v1_request_pb"; -import * as dependency_13 from "./../models/get_transaction_v1_response_pb"; -import * as dependency_14 from "./../models/invoke_contract_v1_request_pb"; -import * as dependency_15 from "./../models/invoke_contract_v1_response_pb"; -import * as dependency_16 from "./../models/run_transaction_request_pb"; -import * as dependency_17 from "./../models/run_transaction_response_pb"; -import * as dependency_18 from "./../models/sign_transaction_request_pb"; -import * as dependency_19 from "./../models/sign_transaction_response_pb"; +import * as dependency_2 from "./../models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb"; +import * as dependency_3 from "./../models/deploy_contract_solidity_bytecode_v1_request_pb"; +import * as dependency_4 from "./../models/deploy_contract_solidity_bytecode_v1_response_pb"; +import * as dependency_5 from "./../models/get_balance_v1_request_pb"; +import * as dependency_6 from "./../models/get_balance_v1_response_pb"; +import * as dependency_7 from "./../models/get_besu_record_v1_request_pb"; +import * as dependency_8 from "./../models/get_besu_record_v1_response_pb"; +import * as dependency_9 from "./../models/get_block_v1_request_pb"; +import * as dependency_10 from "./../models/get_block_v1_response_pb"; +import * as dependency_11 from "./../models/get_past_logs_v1_request_pb"; +import * as dependency_12 from "./../models/get_past_logs_v1_response_pb"; +import * as dependency_13 from "./../models/get_transaction_v1_request_pb"; +import * as dependency_14 from "./../models/get_transaction_v1_response_pb"; +import * as dependency_15 from "./../models/invoke_contract_v1_request_pb"; +import * as dependency_16 from "./../models/invoke_contract_v1_response_pb"; +import * as dependency_17 from "./../models/run_transaction_request_pb"; +import * as dependency_18 from "./../models/run_transaction_response_pb"; +import * as dependency_19 from "./../models/sign_transaction_request_pb"; +import * as dependency_20 from "./../models/sign_transaction_response_pb"; import * as pb_1 from "google-protobuf"; import * as grpc_1 from "@grpc/grpc-js"; export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice { + export class DeployContractSolBytecodeNoKeychainV1Request extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + deployContractSolidityBytecodeNoKeychainV1RequestPB?: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("deployContractSolidityBytecodeNoKeychainV1RequestPB" in data && data.deployContractSolidityBytecodeNoKeychainV1RequestPB != undefined) { + this.deployContractSolidityBytecodeNoKeychainV1RequestPB = data.deployContractSolidityBytecodeNoKeychainV1RequestPB; + } + } + } + get deployContractSolidityBytecodeNoKeychainV1RequestPB() { + return pb_1.Message.getWrapperField(this, dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB, 1) as dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB; + } + set deployContractSolidityBytecodeNoKeychainV1RequestPB(value: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_deployContractSolidityBytecodeNoKeychainV1RequestPB() { + return pb_1.Message.getField(this, 1) != null; + } + static fromObject(data: { + deployContractSolidityBytecodeNoKeychainV1RequestPB?: ReturnType; + }): DeployContractSolBytecodeNoKeychainV1Request { + const message = new DeployContractSolBytecodeNoKeychainV1Request({}); + if (data.deployContractSolidityBytecodeNoKeychainV1RequestPB != null) { + message.deployContractSolidityBytecodeNoKeychainV1RequestPB = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB.fromObject(data.deployContractSolidityBytecodeNoKeychainV1RequestPB); + } + return message; + } + toObject() { + const data: { + deployContractSolidityBytecodeNoKeychainV1RequestPB?: ReturnType; + } = {}; + if (this.deployContractSolidityBytecodeNoKeychainV1RequestPB != null) { + data.deployContractSolidityBytecodeNoKeychainV1RequestPB = this.deployContractSolidityBytecodeNoKeychainV1RequestPB.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_deployContractSolidityBytecodeNoKeychainV1RequestPB) + writer.writeMessage(1, this.deployContractSolidityBytecodeNoKeychainV1RequestPB, () => this.deployContractSolidityBytecodeNoKeychainV1RequestPB.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DeployContractSolBytecodeNoKeychainV1Request { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DeployContractSolBytecodeNoKeychainV1Request(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.deployContractSolidityBytecodeNoKeychainV1RequestPB, () => message.deployContractSolidityBytecodeNoKeychainV1RequestPB = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): DeployContractSolBytecodeNoKeychainV1Request { + return DeployContractSolBytecodeNoKeychainV1Request.deserialize(bytes); + } + } export class DeployContractSolBytecodeV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - deployContractSolidityBytecodeV1RequestPB?: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; + deployContractSolidityBytecodeV1RequestPB?: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -39,26 +110,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get deployContractSolidityBytecodeV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB, 1) as dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB, 1) as dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; } - set deployContractSolidityBytecodeV1RequestPB(value: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB) { + set deployContractSolidityBytecodeV1RequestPB(value: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_deployContractSolidityBytecodeV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - deployContractSolidityBytecodeV1RequestPB?: ReturnType; + deployContractSolidityBytecodeV1RequestPB?: ReturnType; }): DeployContractSolBytecodeV1Request { const message = new DeployContractSolBytecodeV1Request({}); if (data.deployContractSolidityBytecodeV1RequestPB != null) { - message.deployContractSolidityBytecodeV1RequestPB = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.fromObject(data.deployContractSolidityBytecodeV1RequestPB); + message.deployContractSolidityBytecodeV1RequestPB = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.fromObject(data.deployContractSolidityBytecodeV1RequestPB); } return message; } toObject() { const data: { - deployContractSolidityBytecodeV1RequestPB?: ReturnType; + deployContractSolidityBytecodeV1RequestPB?: ReturnType; } = {}; if (this.deployContractSolidityBytecodeV1RequestPB != null) { data.deployContractSolidityBytecodeV1RequestPB = this.deployContractSolidityBytecodeV1RequestPB.toObject(); @@ -81,7 +152,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.deployContractSolidityBytecodeV1RequestPB, () => message.deployContractSolidityBytecodeV1RequestPB = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.deserialize(reader)); + reader.readMessage(message.deployContractSolidityBytecodeV1RequestPB, () => message.deployContractSolidityBytecodeV1RequestPB = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -98,7 +169,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class GetBalanceV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - getBalanceV1RequestPB?: dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; + getBalanceV1RequestPB?: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -109,26 +180,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get getBalanceV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB, 1) as dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB, 1) as dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; } - set getBalanceV1RequestPB(value: dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB) { + set getBalanceV1RequestPB(value: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_getBalanceV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - getBalanceV1RequestPB?: ReturnType; + getBalanceV1RequestPB?: ReturnType; }): GetBalanceV1Request { const message = new GetBalanceV1Request({}); if (data.getBalanceV1RequestPB != null) { - message.getBalanceV1RequestPB = dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.fromObject(data.getBalanceV1RequestPB); + message.getBalanceV1RequestPB = dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.fromObject(data.getBalanceV1RequestPB); } return message; } toObject() { const data: { - getBalanceV1RequestPB?: ReturnType; + getBalanceV1RequestPB?: ReturnType; } = {}; if (this.getBalanceV1RequestPB != null) { data.getBalanceV1RequestPB = this.getBalanceV1RequestPB.toObject(); @@ -151,7 +222,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.getBalanceV1RequestPB, () => message.getBalanceV1RequestPB = dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBalanceV1RequestPB, () => message.getBalanceV1RequestPB = dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -168,7 +239,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class GetBesuRecordV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - getBesuRecordV1RequestPB?: dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; + getBesuRecordV1RequestPB?: dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -179,26 +250,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get getBesuRecordV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB, 1) as dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB, 1) as dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; } - set getBesuRecordV1RequestPB(value: dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB) { + set getBesuRecordV1RequestPB(value: dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_getBesuRecordV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - getBesuRecordV1RequestPB?: ReturnType; + getBesuRecordV1RequestPB?: ReturnType; }): GetBesuRecordV1Request { const message = new GetBesuRecordV1Request({}); if (data.getBesuRecordV1RequestPB != null) { - message.getBesuRecordV1RequestPB = dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.fromObject(data.getBesuRecordV1RequestPB); + message.getBesuRecordV1RequestPB = dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.fromObject(data.getBesuRecordV1RequestPB); } return message; } toObject() { const data: { - getBesuRecordV1RequestPB?: ReturnType; + getBesuRecordV1RequestPB?: ReturnType; } = {}; if (this.getBesuRecordV1RequestPB != null) { data.getBesuRecordV1RequestPB = this.getBesuRecordV1RequestPB.toObject(); @@ -221,7 +292,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.getBesuRecordV1RequestPB, () => message.getBesuRecordV1RequestPB = dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBesuRecordV1RequestPB, () => message.getBesuRecordV1RequestPB = dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -238,7 +309,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class GetBlockV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - getBlockV1RequestPB?: dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; + getBlockV1RequestPB?: dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -249,26 +320,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get getBlockV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB, 1) as dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB, 1) as dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; } - set getBlockV1RequestPB(value: dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB) { + set getBlockV1RequestPB(value: dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_getBlockV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - getBlockV1RequestPB?: ReturnType; + getBlockV1RequestPB?: ReturnType; }): GetBlockV1Request { const message = new GetBlockV1Request({}); if (data.getBlockV1RequestPB != null) { - message.getBlockV1RequestPB = dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.fromObject(data.getBlockV1RequestPB); + message.getBlockV1RequestPB = dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.fromObject(data.getBlockV1RequestPB); } return message; } toObject() { const data: { - getBlockV1RequestPB?: ReturnType; + getBlockV1RequestPB?: ReturnType; } = {}; if (this.getBlockV1RequestPB != null) { data.getBlockV1RequestPB = this.getBlockV1RequestPB.toObject(); @@ -291,7 +362,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.getBlockV1RequestPB, () => message.getBlockV1RequestPB = dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBlockV1RequestPB, () => message.getBlockV1RequestPB = dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -375,7 +446,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class GetPastLogsV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - getPastLogsV1RequestPB?: dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; + getPastLogsV1RequestPB?: dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -386,26 +457,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get getPastLogsV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB, 1) as dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB, 1) as dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; } - set getPastLogsV1RequestPB(value: dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB) { + set getPastLogsV1RequestPB(value: dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_getPastLogsV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - getPastLogsV1RequestPB?: ReturnType; + getPastLogsV1RequestPB?: ReturnType; }): GetPastLogsV1Request { const message = new GetPastLogsV1Request({}); if (data.getPastLogsV1RequestPB != null) { - message.getPastLogsV1RequestPB = dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.fromObject(data.getPastLogsV1RequestPB); + message.getPastLogsV1RequestPB = dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.fromObject(data.getPastLogsV1RequestPB); } return message; } toObject() { const data: { - getPastLogsV1RequestPB?: ReturnType; + getPastLogsV1RequestPB?: ReturnType; } = {}; if (this.getPastLogsV1RequestPB != null) { data.getPastLogsV1RequestPB = this.getPastLogsV1RequestPB.toObject(); @@ -428,7 +499,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.getPastLogsV1RequestPB, () => message.getPastLogsV1RequestPB = dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.deserialize(reader)); + reader.readMessage(message.getPastLogsV1RequestPB, () => message.getPastLogsV1RequestPB = dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -512,7 +583,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class GetTransactionV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - getTransactionV1RequestPB?: dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; + getTransactionV1RequestPB?: dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -523,26 +594,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get getTransactionV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB, 1) as dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB, 1) as dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; } - set getTransactionV1RequestPB(value: dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB) { + set getTransactionV1RequestPB(value: dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_getTransactionV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - getTransactionV1RequestPB?: ReturnType; + getTransactionV1RequestPB?: ReturnType; }): GetTransactionV1Request { const message = new GetTransactionV1Request({}); if (data.getTransactionV1RequestPB != null) { - message.getTransactionV1RequestPB = dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.fromObject(data.getTransactionV1RequestPB); + message.getTransactionV1RequestPB = dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.fromObject(data.getTransactionV1RequestPB); } return message; } toObject() { const data: { - getTransactionV1RequestPB?: ReturnType; + getTransactionV1RequestPB?: ReturnType; } = {}; if (this.getTransactionV1RequestPB != null) { data.getTransactionV1RequestPB = this.getTransactionV1RequestPB.toObject(); @@ -565,7 +636,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.getTransactionV1RequestPB, () => message.getTransactionV1RequestPB = dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.deserialize(reader)); + reader.readMessage(message.getTransactionV1RequestPB, () => message.getTransactionV1RequestPB = dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -582,7 +653,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class InvokeContractV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - invokeContractV1RequestPB?: dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; + invokeContractV1RequestPB?: dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -593,26 +664,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get invokeContractV1RequestPB() { - return pb_1.Message.getWrapperField(this, dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB, 1) as dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; + return pb_1.Message.getWrapperField(this, dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB, 1) as dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; } - set invokeContractV1RequestPB(value: dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB) { + set invokeContractV1RequestPB(value: dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_invokeContractV1RequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - invokeContractV1RequestPB?: ReturnType; + invokeContractV1RequestPB?: ReturnType; }): InvokeContractV1Request { const message = new InvokeContractV1Request({}); if (data.invokeContractV1RequestPB != null) { - message.invokeContractV1RequestPB = dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.fromObject(data.invokeContractV1RequestPB); + message.invokeContractV1RequestPB = dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.fromObject(data.invokeContractV1RequestPB); } return message; } toObject() { const data: { - invokeContractV1RequestPB?: ReturnType; + invokeContractV1RequestPB?: ReturnType; } = {}; if (this.invokeContractV1RequestPB != null) { data.invokeContractV1RequestPB = this.invokeContractV1RequestPB.toObject(); @@ -635,7 +706,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.invokeContractV1RequestPB, () => message.invokeContractV1RequestPB = dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.deserialize(reader)); + reader.readMessage(message.invokeContractV1RequestPB, () => message.invokeContractV1RequestPB = dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -652,7 +723,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class RunTransactionV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - runTransactionRequestPB?: dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; + runTransactionRequestPB?: dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -663,26 +734,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get runTransactionRequestPB() { - return pb_1.Message.getWrapperField(this, dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB, 1) as dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; + return pb_1.Message.getWrapperField(this, dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB, 1) as dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; } - set runTransactionRequestPB(value: dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB) { + set runTransactionRequestPB(value: dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_runTransactionRequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - runTransactionRequestPB?: ReturnType; + runTransactionRequestPB?: ReturnType; }): RunTransactionV1Request { const message = new RunTransactionV1Request({}); if (data.runTransactionRequestPB != null) { - message.runTransactionRequestPB = dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.fromObject(data.runTransactionRequestPB); + message.runTransactionRequestPB = dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.fromObject(data.runTransactionRequestPB); } return message; } toObject() { const data: { - runTransactionRequestPB?: ReturnType; + runTransactionRequestPB?: ReturnType; } = {}; if (this.runTransactionRequestPB != null) { data.runTransactionRequestPB = this.runTransactionRequestPB.toObject(); @@ -705,7 +776,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.runTransactionRequestPB, () => message.runTransactionRequestPB = dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.deserialize(reader)); + reader.readMessage(message.runTransactionRequestPB, () => message.runTransactionRequestPB = dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -722,7 +793,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class SignTransactionV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - signTransactionRequestPB?: dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; + signTransactionRequestPB?: dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -733,26 +804,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get signTransactionRequestPB() { - return pb_1.Message.getWrapperField(this, dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB, 1) as dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; + return pb_1.Message.getWrapperField(this, dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB, 1) as dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; } - set signTransactionRequestPB(value: dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB) { + set signTransactionRequestPB(value: dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB) { pb_1.Message.setWrapperField(this, 1, value); } get has_signTransactionRequestPB() { return pb_1.Message.getField(this, 1) != null; } static fromObject(data: { - signTransactionRequestPB?: ReturnType; + signTransactionRequestPB?: ReturnType; }): SignTransactionV1Request { const message = new SignTransactionV1Request({}); if (data.signTransactionRequestPB != null) { - message.signTransactionRequestPB = dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.fromObject(data.signTransactionRequestPB); + message.signTransactionRequestPB = dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.fromObject(data.signTransactionRequestPB); } return message; } toObject() { const data: { - signTransactionRequestPB?: ReturnType; + signTransactionRequestPB?: ReturnType; } = {}; if (this.signTransactionRequestPB != null) { data.signTransactionRequestPB = this.signTransactionRequestPB.toObject(); @@ -775,7 +846,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.signTransactionRequestPB, () => message.signTransactionRequestPB = dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.deserialize(reader)); + reader.readMessage(message.signTransactionRequestPB, () => message.signTransactionRequestPB = dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -815,14 +886,23 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } export abstract class UnimplementedDefaultServiceService { static definition = { + DeployContractSolBytecodeNoKeychainV1: { + path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/DeployContractSolBytecodeNoKeychainV1", + requestStream: false, + responseStream: false, + requestSerialize: (message: DeployContractSolBytecodeNoKeychainV1Request) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => DeployContractSolBytecodeNoKeychainV1Request.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB.deserialize(new Uint8Array(bytes)) + }, DeployContractSolBytecodeV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/DeployContractSolBytecodeV1", requestStream: false, responseStream: false, requestSerialize: (message: DeployContractSolBytecodeV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => DeployContractSolBytecodeV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB.deserialize(new Uint8Array(bytes)) }, GetBalanceV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/GetBalanceV1", @@ -830,8 +910,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: GetBalanceV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => GetBalanceV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1ResponsePB.deserialize(new Uint8Array(bytes)) }, GetBesuRecordV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/GetBesuRecordV1", @@ -839,8 +919,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: GetBesuRecordV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => GetBesuRecordV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1ResponsePB.deserialize(new Uint8Array(bytes)) }, GetBlockV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/GetBlockV1", @@ -848,8 +928,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: GetBlockV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => GetBlockV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1ResponsePB.deserialize(new Uint8Array(bytes)) }, GetOpenApiSpecV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/GetOpenApiSpecV1", @@ -866,8 +946,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: GetPastLogsV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => GetPastLogsV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1ResponsePB.deserialize(new Uint8Array(bytes)) }, GetPrometheusMetricsV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/GetPrometheusMetricsV1", @@ -884,8 +964,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: GetTransactionV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => GetTransactionV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1ResponsePB.deserialize(new Uint8Array(bytes)) }, InvokeContractV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/InvokeContractV1", @@ -893,8 +973,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: InvokeContractV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => InvokeContractV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1ResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1ResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1ResponsePB.deserialize(new Uint8Array(bytes)) }, RunTransactionV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/RunTransactionV1", @@ -902,8 +982,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: RunTransactionV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => RunTransactionV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionResponsePB.deserialize(new Uint8Array(bytes)) }, SignTransactionV1: { path: "/org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DefaultService/SignTransactionV1", @@ -911,58 +991,62 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: SignTransactionV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => SignTransactionV1Request.deserialize(new Uint8Array(bytes)), - responseSerialize: (message: dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB) => Buffer.from(message.serialize()), - responseDeserialize: (bytes: Buffer) => dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB.deserialize(new Uint8Array(bytes)) + responseSerialize: (message: dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB.deserialize(new Uint8Array(bytes)) } }; [method: string]: grpc_1.UntypedHandleCall; - abstract DeployContractSolBytecodeV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract GetBalanceV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract GetBesuRecordV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract GetBlockV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract DeployContractSolBytecodeNoKeychainV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract DeployContractSolBytecodeV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetBalanceV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetBesuRecordV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetBlockV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetOpenApiSpecV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract GetPastLogsV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetPastLogsV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetPrometheusMetricsV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract GetTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract InvokeContractV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract RunTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; - abstract SignTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract InvokeContractV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract RunTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract SignTransactionV1(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; } export class DefaultServiceClient extends grpc_1.makeGenericClientConstructor(UnimplementedDefaultServiceService.definition, "DefaultService", {}) { constructor(address: string, credentials: grpc_1.ChannelCredentials, options?: Partial) { super(address, credentials, options); } - DeployContractSolBytecodeV1: GrpcUnaryServiceInterface = (message: DeployContractSolBytecodeV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + DeployContractSolBytecodeNoKeychainV1: GrpcUnaryServiceInterface = (message: DeployContractSolBytecodeNoKeychainV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.DeployContractSolBytecodeNoKeychainV1(message, metadata, options, callback); + }; + DeployContractSolBytecodeV1: GrpcUnaryServiceInterface = (message: DeployContractSolBytecodeV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.DeployContractSolBytecodeV1(message, metadata, options, callback); }; - GetBalanceV1: GrpcUnaryServiceInterface = (message: GetBalanceV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + GetBalanceV1: GrpcUnaryServiceInterface = (message: GetBalanceV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetBalanceV1(message, metadata, options, callback); }; - GetBesuRecordV1: GrpcUnaryServiceInterface = (message: GetBesuRecordV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + GetBesuRecordV1: GrpcUnaryServiceInterface = (message: GetBesuRecordV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetBesuRecordV1(message, metadata, options, callback); }; - GetBlockV1: GrpcUnaryServiceInterface = (message: GetBlockV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + GetBlockV1: GrpcUnaryServiceInterface = (message: GetBlockV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetBlockV1(message, metadata, options, callback); }; GetOpenApiSpecV1: GrpcUnaryServiceInterface = (message: dependency_1.google.protobuf.Empty, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetOpenApiSpecV1(message, metadata, options, callback); }; - GetPastLogsV1: GrpcUnaryServiceInterface = (message: GetPastLogsV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + GetPastLogsV1: GrpcUnaryServiceInterface = (message: GetPastLogsV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetPastLogsV1(message, metadata, options, callback); }; GetPrometheusMetricsV1: GrpcUnaryServiceInterface = (message: dependency_1.google.protobuf.Empty, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetPrometheusMetricsV1(message, metadata, options, callback); }; - GetTransactionV1: GrpcUnaryServiceInterface = (message: GetTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + GetTransactionV1: GrpcUnaryServiceInterface = (message: GetTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetTransactionV1(message, metadata, options, callback); }; - InvokeContractV1: GrpcUnaryServiceInterface = (message: InvokeContractV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + InvokeContractV1: GrpcUnaryServiceInterface = (message: InvokeContractV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.InvokeContractV1(message, metadata, options, callback); }; - RunTransactionV1: GrpcUnaryServiceInterface = (message: RunTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + RunTransactionV1: GrpcUnaryServiceInterface = (message: RunTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.RunTransactionV1(message, metadata, options, callback); }; - SignTransactionV1: GrpcUnaryServiceInterface = (message: SignTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + SignTransactionV1: GrpcUnaryServiceInterface = (message: SignTransactionV1Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.SignTransactionV1(message, metadata, options, callback); }; } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/grpc-services/besu-grpc-svc-open-api.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/grpc-services/besu-grpc-svc-open-api.ts index 41e58eb51c3..cad85107957 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/grpc-services/besu-grpc-svc-open-api.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/grpc-services/besu-grpc-svc-open-api.ts @@ -73,6 +73,20 @@ export class BesuGrpcSvcOpenApi extends default_service.org.hyperledger.cacti }); } + public DeployContractSolBytecodeNoKeychainV1( + call: ServerUnaryCall< + default_service.org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.DeployContractSolBytecodeNoKeychainV1Request, + deploy_contract_solidity_bytecode_v1_response_pb.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB + >, + callback: sendUnaryData, + ): void { + return callback({ + message: "Status.UNIMPLEMENTED", + code: status.UNIMPLEMENTED, + details: "Service endpoint not yet implemented.", + }); + } + public GetBalanceV1( call: ServerUnaryCall< default_service.org.hyperledger.cacti.plugin.ledger.connector.besu.services.defaultservice.GetBalanceV1Request, diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-keychain.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-keychain.ts new file mode 100644 index 00000000000..4aaae48d76f --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-keychain.ts @@ -0,0 +1,168 @@ +import { + Checks, + LogLevelDesc, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + DeployContractSolidityBytecodeV1Request, + DeployContractSolidityBytecodeV1Response, + ReceiptType, + Web3SigningCredentialCactusKeychainRef, + Web3SigningCredentialPrivateKeyHex, +} from "../../generated/openapi/typescript-axios"; +import { isWeb3SigningCredentialNone } from "../../model-type-guards"; +import createHttpError from "http-errors"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; +import Web3 from "web3"; +import { transactV1Impl } from "../transact-v1/transact-v1-impl"; +import Contract from "web3-eth-contract"; + +export interface IDeployContractV1KeychainResponse { + status: boolean; + contractAddress: string; + contractName: string; + contract?: Contract.Contract; + deployResponse: DeployContractSolidityBytecodeV1Response; +} + +export async function deployContractV1Keychain( + ctx: { + readonly pluginRegistry: PluginRegistry; + readonly prometheusExporter: PrometheusExporter; + readonly web3: Web3; + readonly logLevel: LogLevelDesc; + }, + req: DeployContractSolidityBytecodeV1Request, +): Promise { + const fnTag = `deployContract()`; + Checks.truthy(req, `${fnTag} req`); + + const log = LoggerProvider.getOrCreate({ + label: "getBlockV1Impl()", + level: ctx.logLevel, + }); + + if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { + throw createHttpError[400]( + `${fnTag} Cannot deploy contract with pre-signed TX`, + ); + } + const { keychainId, contractName } = req; + if (!keychainId || !req.contractName) { + const errorMessage = `${fnTag} Cannot deploy contract without keychainId and the contractName.`; + throw createHttpError[400](errorMessage); + } + + const keychainPlugin = ctx.pluginRegistry.findOneByKeychainId(keychainId); + + if (!keychainPlugin) { + const errorMessage = + `${fnTag} The plugin registry does not contain` + + ` a keychain plugin for ID:"${req.keychainId}"`; + throw createHttpError[400](errorMessage); + } + + if (!keychainPlugin.has(contractName)) { + const errorMessage = + `${fnTag} Cannot create an instance of the contract instance because` + + `the contractName in the request does not exist on the keychain`; + throw new createHttpError[400](errorMessage); + } + + const networkId = await ctx.web3.eth.net.getId(); + + const tmpContract = new ctx.web3.eth.Contract(req.contractAbi); + const deployment = tmpContract.deploy({ + data: req.bytecode, + arguments: req.constructorArgs, + }); + + const abi = deployment.encodeABI(); + const data = abi.startsWith("0x") ? abi : `0x${abi}`; + log.debug(`Deploying "${req.contractName}" with data %o`, data); + + const web3SigningCredential = req.web3SigningCredential as + | Web3SigningCredentialPrivateKeyHex + | Web3SigningCredentialCactusKeychainRef; + + const transactV1ImplCtx = { + prometheusExporter: ctx.prometheusExporter, + pluginRegistry: ctx.pluginRegistry, + logLevel: ctx.logLevel, + web3: ctx.web3, + }; + const transactV1ImplReq = { + transactionConfig: { + data, + from: web3SigningCredential.ethAccount, + gas: req.gas, + gasPrice: req.gasPrice, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: req.timeoutMs || 60000, + }, + web3SigningCredential, + privateTransactionConfig: req.privateTransactionConfig, + }; + const runTransactionResponse = await transactV1Impl( + transactV1ImplCtx, + transactV1ImplReq, + ); + + const keychainHasContract = await keychainPlugin.has(contractName); + + if (!keychainHasContract) { + const errorMessage = + `${fnTag} Cannot create an instance of the contract instance because` + + `the contractName in the request does not exist on the keychain`; + throw new createHttpError[400](errorMessage); + } + + log.debug(`Keychain has the contract, updating networks...`); + + const { transactionReceipt: receipt } = runTransactionResponse; + const { status, contractAddress } = receipt; + + if (status && contractAddress) { + const networkInfo = { address: contractAddress }; + const contractStr = await keychainPlugin.get(contractName); + const contractJSON = JSON.parse(contractStr); + log.debug("Contract JSON: \n%o", JSON.stringify(contractJSON)); + const contract = new ctx.web3.eth.Contract( + contractJSON.abi, + contractAddress, + ); + + const network = { [networkId]: networkInfo }; + contractJSON.networks = network; + + await keychainPlugin.set(contractName, JSON.stringify(contractJSON)); + const deployResponse: DeployContractSolidityBytecodeV1Response = { + transactionReceipt: runTransactionResponse.transactionReceipt, + }; + const deployContractV1KeychainResponse: IDeployContractV1KeychainResponse = + { + status: status, + contractAddress: contractAddress, + contractName: contractName, + contract: contract, + deployResponse: deployResponse, + }; + return deployContractV1KeychainResponse; + } else { + const deployResponse: DeployContractSolidityBytecodeV1Response = { + transactionReceipt: runTransactionResponse.transactionReceipt, + }; + const deployContractV1KeychainResponse: IDeployContractV1KeychainResponse = + { + status: status, + contractAddress: "", + contractName: contractName, + deployResponse: deployResponse, + }; + return deployContractV1KeychainResponse; + } +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-no-keychain.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-no-keychain.ts new file mode 100644 index 00000000000..810b1b81a18 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/deploy-contract-v1/deploy-contract-v1-no-keychain.ts @@ -0,0 +1,129 @@ +import { + Checks, + LogLevelDesc, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + DeployContractSolidityBytecodeNoKeychainV1Request, + DeployContractSolidityBytecodeV1Response, + ReceiptType, + Web3SigningCredentialCactusKeychainRef, + Web3SigningCredentialPrivateKeyHex, +} from "../../generated/openapi/typescript-axios"; +import { isWeb3SigningCredentialNone } from "../../model-type-guards"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; +import Web3 from "web3"; +import { transactV1Impl } from "../transact-v1/transact-v1-impl"; +import createHttpError from "http-errors"; +import { Contract } from "web3-eth-contract"; + +export interface IDeployContractV1NoKeychainResponse { + contractName: string; + contract: Contract; + contractJsonString: string; + deployResponse: DeployContractSolidityBytecodeV1Response; +} + +export async function deployContractV1NoKeychain( + ctx: { + readonly pluginRegistry: PluginRegistry; + readonly prometheusExporter: PrometheusExporter; + readonly web3: Web3; + readonly logLevel: LogLevelDesc; + }, + req: DeployContractSolidityBytecodeNoKeychainV1Request, +): Promise { + const fnTag = `deployContractNoKeychain()`; + Checks.truthy(req, `${fnTag} req`); + + const log = LoggerProvider.getOrCreate({ + label: "getBlockV1Impl()", + level: ctx.logLevel, + }); + + if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { + throw new Error(`${fnTag} Cannot deploy contract with pre-signed TX`); + } + const { contractName, contractJSONString } = req; + const networkId = await ctx.web3.eth.net.getId(); + + const tmpContract = new ctx.web3.eth.Contract(req.contractAbi); + const deployment = tmpContract.deploy({ + data: req.bytecode, + arguments: req.constructorArgs, + }); + + const abi = deployment.encodeABI(); + const data = abi.startsWith("0x") ? abi : `0x${abi}`; + log.debug(`Deploying "${req.contractName}" with data %o`, data); + + const web3SigningCredential = req.web3SigningCredential as + | Web3SigningCredentialPrivateKeyHex + | Web3SigningCredentialCactusKeychainRef; + + const transactV1ImplCtx = { + prometheusExporter: ctx.prometheusExporter, + pluginRegistry: ctx.pluginRegistry, + logLevel: ctx.logLevel, + web3: ctx.web3, + }; + const transactV1ImplReq = { + transactionConfig: { + data, + from: web3SigningCredential.ethAccount, + gas: req.gas, + gasPrice: req.gasPrice, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: req.timeoutMs || 60000, + }, + web3SigningCredential, + privateTransactionConfig: req.privateTransactionConfig, + }; + const runTxResponse = await transactV1Impl( + transactV1ImplCtx, + transactV1ImplReq, + ); + + const { transactionReceipt: receipt } = runTxResponse; + const { status, contractAddress } = receipt; + + Checks.truthy(status, `deployContractNoKeychain():status`); + + Checks.truthy( + contractAddress, + `deployContractNoKeychain():contractAddress`, + ); + + if (contractJSONString) { + const networkInfo = { address: contractAddress }; + const contractJSON = JSON.parse(contractJSONString); + log.debug("Contract JSON: \n%o", JSON.stringify(contractJSON)); + const contract = new ctx.web3.eth.Contract( + contractJSON.abi, + contractAddress || " ", + ); + // this.contracts[contractName] = contract; + const network = { [networkId]: networkInfo }; + contractJSON.networks = network; + + const deployResponse: DeployContractSolidityBytecodeV1Response = { + transactionReceipt: runTxResponse.transactionReceipt, + }; + const deployContractV1NoKeychainResponse: IDeployContractV1NoKeychainResponse = { + contractName: contractName, + contract: contract, + contractJsonString: contractJSONString, + deployResponse: deployResponse, + } + return deployContractV1NoKeychainResponse; + } else { + const errorMessage = + `${fnTag} Cannot create an instance of the contract instance because` + + `the contractName in the request does not exist on the keychain`; + throw new createHttpError[400](errorMessage); + } +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-cactus-keychain-ref.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-cactus-keychain-ref.ts new file mode 100644 index 00000000000..4bf76d8023b --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-cactus-keychain-ref.ts @@ -0,0 +1,53 @@ +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { + ReceiptType, + RunTransactionRequest, + RunTransactionResponse, + Web3SigningCredentialCactusKeychainRef, + Web3SigningCredentialType, +} from "../../generated/openapi/typescript-axios"; +import { Checks, LogLevelDesc } from "@hyperledger/cactus-common"; +import Web3 from "web3"; +import { transactV1PrivateKey } from "./transact-v1-private-key"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; + +export async function transactV1CactusKeychainRef( + ctx: { + readonly pluginRegistry: PluginRegistry; + readonly prometheusExporter: PrometheusExporter; + readonly web3: Web3; + readonly logLevel: LogLevelDesc; + }, + req: RunTransactionRequest, +): Promise { + const fnTag = `transactCactusKeychainRef()`; + const { transactionConfig, web3SigningCredential, privateTransactionConfig } = + req; + const { ethAccount, keychainEntryKey, keychainId } = + web3SigningCredential as Web3SigningCredentialCactusKeychainRef; + + // locate the keychain plugin that has access to the keychain backend + // denoted by the keychainID from the request. + const keychainPlugin = ctx.pluginRegistry.findOneByKeychainId(keychainId); + + Checks.truthy(keychainPlugin, `${fnTag} keychain for ID:"${keychainId}"`); + + // Now use the found keychain plugin to actually perform the lookup of + // the private key that we need to run the transaction. + const privateKeyHex = await keychainPlugin?.get(keychainEntryKey); + + return transactV1PrivateKey(ctx, { + privateTransactionConfig, + transactionConfig, + web3SigningCredential: { + ethAccount, + type: Web3SigningCredentialType.PrivateKeyHex, + secret: privateKeyHex, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: 60000, + }, + }); +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-impl.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-impl.ts new file mode 100644 index 00000000000..908bc562a8d --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-impl.ts @@ -0,0 +1,54 @@ +import { + RunTransactionRequest, + RunTransactionResponse, + Web3SigningCredentialType, +} from "../../generated/openapi/typescript-axios"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { transactV1CactusKeychainRef } from "./transact-v1-cactus-keychain-ref"; +import Web3 from "web3"; +import { transactV1PrivateKey } from "./transact-v1-private-key"; +import { LogLevelDesc } from "@hyperledger/cactus-common"; +import { transactV1Signed } from "./transact-v1-signed"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; + +export async function transactV1Impl( + ctx: { + readonly pluginRegistry: PluginRegistry; + readonly prometheusExporter: PrometheusExporter; + readonly web3: Web3; + readonly logLevel: LogLevelDesc; + }, + req: RunTransactionRequest, +): Promise { + const fnTag = `transact()`; + + switch (req.web3SigningCredential.type) { + // Web3SigningCredentialType.GETHKEYCHAINPASSWORD is removed as Hyperledger Besu doesn't support the PERSONAL api + // for --rpc-http-api as per the discussion mentioned here + // https://chat.hyperledger.org/channel/besu-contributors?msg=GqQXfW3k79ygRtx5Q + case Web3SigningCredentialType.CactusKeychainRef: { + return transactV1CactusKeychainRef(ctx, req); + } + case Web3SigningCredentialType.PrivateKeyHex: { + return transactV1PrivateKey(ctx, req); + } + case Web3SigningCredentialType.None: { + if (req.transactionConfig.rawTransaction) { + return transactV1Signed(ctx, req); + } else { + throw new Error( + `${fnTag} Expected pre-signed raw transaction ` + + ` since signing credential is specified as` + + `Web3SigningCredentialType.NONE`, + ); + } + } + default: { + throw new Error( + `${fnTag} Unrecognized Web3SigningCredentialType: ` + + `${req.web3SigningCredential.type} Supported ones are: ` + + `${Object.values(Web3SigningCredentialType).join(";")}`, + ); + } + } +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-private-key.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-private-key.ts new file mode 100644 index 00000000000..344a296063f --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-private-key.ts @@ -0,0 +1,103 @@ +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { + RunTransactionRequest, + RunTransactionResponse, + Web3SigningCredentialPrivateKeyHex, + Web3TransactionReceipt, +} from "../../generated/openapi/typescript-axios"; +import Web3 from "web3"; +import { transactV1Signed } from "./transact-v1-signed"; +import { LogLevelDesc } from "@hyperledger/cactus-common"; +import Web3JsQuorum from "web3js-quorum"; +import { RuntimeError } from "run-time-error-cjs"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; + +export async function transactV1PrivateKey( + ctx: { + readonly pluginRegistry: PluginRegistry; + readonly prometheusExporter: PrometheusExporter; + readonly web3: Web3; + readonly logLevel: LogLevelDesc; + }, + req: RunTransactionRequest, +): Promise { + const fnTag = `transactPrivateKey()`; + const { transactionConfig, web3SigningCredential } = req; + const { secret } = + web3SigningCredential as Web3SigningCredentialPrivateKeyHex; + + // Run transaction to EEA client here if private transaction + + if (req.privateTransactionConfig) { + const options = { + nonce: transactionConfig.nonce, + gasPrice: transactionConfig.gasPrice, + gasLimit: transactionConfig.gas, + to: transactionConfig.to, + value: transactionConfig.value, + data: transactionConfig.data, + privateKey: secret, + privateFrom: req.privateTransactionConfig.privateFrom, + privateFor: req.privateTransactionConfig.privateFor, + restriction: "restricted", + }; + + return transactPrivate(ctx, options); + } + + const signedTx = await ctx.web3.eth.accounts.signTransaction( + transactionConfig, + secret, + ); + + if (signedTx.rawTransaction) { + req.transactionConfig.rawTransaction = signedTx.rawTransaction; + return transactV1Signed(ctx, req); + } else { + throw new Error( + `${fnTag} Failed to sign eth transaction. ` + + `signedTransaction.rawTransaction is blank after .signTransaction().`, + ); + } +} + +export async function transactPrivate( + ctx: { readonly web3: Web3 }, + options: any, +): Promise { + const fnTag = `transactPrivate()`; + + var web3Quorum = Web3JsQuorum(ctx.web3); + if (!web3Quorum) { + throw new Error(`${fnTag} Web3 EEA client not initialized.`); + } + + const txHash = await web3Quorum.priv.generateAndSendRawTransaction(options); + + if (!txHash) { + throw new Error(`${fnTag} eea.sendRawTransaction provided no tx hash.`); + } + return getPrivateTxReceipt(ctx, options.privateFrom, txHash); +} + +export async function getPrivateTxReceipt( + ctx: { readonly web3: Web3 }, + privateFrom: string, + txHash: string, +): Promise { + const fnTag = `getPrivateTxReceipt()`; + + var web3Quorum = Web3JsQuorum(ctx.web3); + if (!web3Quorum) { + throw new Error(`${fnTag} Web3 Quorum client not initialized.`); + } + + const txPoolReceipt = await web3Quorum.priv.waitForTransactionReceipt(txHash); + if (!txPoolReceipt) { + throw new RuntimeError(`priv.getTransactionReceipt provided no receipt.`); + } + + return { + transactionReceipt: txPoolReceipt as unknown as Web3TransactionReceipt, + }; +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-signed.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-signed.ts new file mode 100644 index 00000000000..b8e6a9ec54d --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/impl/transact-v1/transact-v1-signed.ts @@ -0,0 +1,142 @@ +import { + Checks, + LogLevelDesc, + LoggerProvider, +} from "@hyperledger/cactus-common"; +import { + ConsistencyStrategy, + ReceiptType, + RunTransactionRequest, + RunTransactionResponse, +} from "../../generated/openapi/typescript-axios"; +import Web3 from "web3"; +import type { TransactionReceipt } from "web3-eth"; +import { PrometheusExporter } from "../../prometheus-exporter/prometheus-exporter"; +import { setTimeout } from "timers/promises"; + +export async function transactV1Signed( + ctx: { + readonly web3: Web3; + readonly prometheusExporter: PrometheusExporter; + readonly logLevel: LogLevelDesc; + }, + req: RunTransactionRequest, +): Promise { + const fnTag = `transactSigned()`; + Checks.truthy(req.consistencyStrategy, `${fnTag}:req.consistencyStrategy`); + Checks.truthy( + req.transactionConfig.rawTransaction, + `${fnTag}:req.transactionConfig.rawTransaction`, + ); + const log = LoggerProvider.getOrCreate({ + label: "getBlockGrpc()", + level: ctx.logLevel, + }); + const rawTx = req.transactionConfig.rawTransaction as string; + + log.debug("Starting web3.eth.sendSignedTransaction(rawTransaction) "); + + const txPoolReceipt = await ctx.web3.eth.sendSignedTransaction(rawTx); + + return getTxReceipt(ctx, req, txPoolReceipt); +} + +export async function getTxReceipt( + ctx: { + readonly web3: Web3; + readonly prometheusExporter: PrometheusExporter; + readonly logLevel: LogLevelDesc; + }, + request: RunTransactionRequest, + txPoolReceipt: TransactionReceipt, +): Promise { + const fnTag = `getTxReceipt()`; + + const log = LoggerProvider.getOrCreate({ + label: "getBlockGrpc()", + level: ctx.logLevel, + }); + log.debug("Received preliminary receipt from Besu node."); + + if (txPoolReceipt instanceof Error) { + log.debug(`${fnTag} sendSignedTransaction failed`, txPoolReceipt); + throw txPoolReceipt; + } + ctx.prometheusExporter.addCurrentTransaction(); + + if ( + request.consistencyStrategy.receiptType === ReceiptType.NodeTxPoolAck && + request.consistencyStrategy.blockConfirmations > 0 + ) { + throw new Error( + `${fnTag} Conflicting parameters for consistency` + + ` strategy: Cannot wait for >0 block confirmations AND only wait ` + + ` for the tx pool ACK at the same time.`, + ); + } + + switch (request.consistencyStrategy.receiptType) { + case ReceiptType.NodeTxPoolAck: + return { transactionReceipt: txPoolReceipt }; + case ReceiptType.LedgerBlockAck: + log.debug("Starting poll for ledger TX receipt ..."); + const txHash = txPoolReceipt.transactionHash; + const { consistencyStrategy } = request; + const ledgerReceipt = await pollForTxReceipt( + ctx, + txHash, + consistencyStrategy, + ); + log.debug("Finished poll for ledger TX receipt: %o", ledgerReceipt); + return { transactionReceipt: ledgerReceipt }; + default: + throw new Error( + `${fnTag} Unrecognized ReceiptType: ${request.consistencyStrategy.receiptType}`, + ); + } +} + +export async function pollForTxReceipt( + ctx: { readonly web3: Web3; readonly logLevel: LogLevelDesc }, + txHash: string, + consistencyStrategy: ConsistencyStrategy, +): Promise { + const fnTag = `pollForTxReceipt()`; + const log = LoggerProvider.getOrCreate({ + label: "getBlockGrpc()", + level: ctx.logLevel, + }); + let txReceipt; + let timedOut = false; + let tries = 0; + let confirmationCount = 0; + const timeoutMs = consistencyStrategy.timeoutMs || Number.MAX_SAFE_INTEGER; + const startedAt = new Date(); + + do { + const now = Date.now(); + const elapsedTime = now - startedAt.getTime(); + timedOut = now >= startedAt.getTime() + timeoutMs; + log.debug("%s tries=%n elapsedMs=%n", fnTag, tries, elapsedTime); + if (tries > 0) { + await setTimeout(1000); + } + tries++; + if (timedOut) { + break; + } + + txReceipt = await ctx.web3.eth.getTransactionReceipt(txHash); + if (!txReceipt) { + continue; + } + + const latestBlockNo = await ctx.web3.eth.getBlockNumber(); + confirmationCount = latestBlockNo - txReceipt.blockNumber; + } while (confirmationCount >= consistencyStrategy.blockConfirmations); + + if (!txReceipt) { + throw new Error(`${fnTag} Timed out ${timeoutMs}ms, polls=${tries}`); + } + return txReceipt; +} 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 15b66767bff..85beea03ed3 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 @@ -1,12 +1,10 @@ import type { Server } from "http"; import type { Server as SecureServer } from "https"; -import { setTimeout } from "timers/promises"; import type { Server as SocketIoServer } from "socket.io"; import type { Socket as SocketIoSocket } from "socket.io"; import type { Express } from "express"; import { Optional } from "typescript-optional"; -import createHttpError from "http-errors"; import OAS from "../json/openapi.json"; @@ -16,11 +14,10 @@ import type { WebsocketProvider } from "web3-core"; import Web3JsQuorum, { IWeb3Quorum } from "web3js-quorum"; import { Contract, ContractSendMethod } from "web3-eth-contract"; -import type { TransactionReceipt } from "web3-eth"; import { GetBalanceV1Request, GetBalanceV1Response, - Web3TransactionReceipt, + DeployContractSolidityBytecodeNoKeychainV1Request, } from "./generated/openapi/typescript-axios/index"; import { @@ -56,10 +53,10 @@ import { } from "@hyperledger/cactus-common"; import { DeployContractSolidityBytecodeEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint"; +import { DeployContractSolidityBytecodeNoKeychainEndpoint } from "./web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint"; import { WatchBlocksV1, - ConsistencyStrategy, DeployContractSolidityBytecodeV1Request, DeployContractSolidityBytecodeV1Response, EthContractInvocationType, @@ -107,6 +104,15 @@ import * as besu_grpc_svc_streams from "./generated/proto/protoc-gen-ts/services import { BesuGrpcSvcOpenApi } from "./grpc-services/besu-grpc-svc-open-api"; import { BesuGrpcSvcStreams } from "./grpc-services/besu-grpc-svc-streams"; import { getBlockV1Http } from "./impl/get-block-v1/get-block-v1-http"; +import { transactV1Impl } from "./impl/transact-v1/transact-v1-impl"; +import { + IDeployContractV1KeychainResponse, + deployContractV1Keychain, +} from "./impl/deploy-contract-v1/deploy-contract-v1-keychain"; +import { + IDeployContractV1NoKeychainResponse, + deployContractV1NoKeychain, +} from "./impl/deploy-contract-v1/deploy-contract-v1-no-keychain"; export const E_KEYCHAIN_NOT_FOUND = "cactus.connector.besu.keychain_not_found"; @@ -144,7 +150,6 @@ export class PluginLedgerConnectorBesu } = {}; private endpoints: IWebServiceEndpoint[] | undefined; - private httpServer: Server | SecureServer | null = null; public static readonly CLASS_NAME = "PluginLedgerConnectorBesu"; @@ -283,6 +288,13 @@ export class PluginLedgerConnectorBesu }); endpoints.push(endpoint); } + { + const endpoint = new DeployContractSolidityBytecodeNoKeychainEndpoint({ + connector: this, + logLevel: this.options.logLevel, + }); + endpoints.push(endpoint); + } { const endpoint = new GetBalanceEndpoint({ connector: this, @@ -611,364 +623,55 @@ export class PluginLedgerConnectorBesu req: RunTransactionRequest, ): Promise { const fnTag = `${this.className}#transact()`; - - switch (req.web3SigningCredential.type) { - // Web3SigningCredentialType.GETHKEYCHAINPASSWORD is removed as Hyperledger Besu doesn't support the PERSONAL api - // for --rpc-http-api as per the discussion mentioned here - // https://chat.hyperledger.org/channel/besu-contributors?msg=GqQXfW3k79ygRtx5Q - case Web3SigningCredentialType.CactusKeychainRef: { - return this.transactCactusKeychainRef(req); - } - case Web3SigningCredentialType.PrivateKeyHex: { - return this.transactPrivateKey(req); - } - case Web3SigningCredentialType.None: { - if (req.transactionConfig.rawTransaction) { - return this.transactSigned(req); - } else { - throw new Error( - `${fnTag} Expected pre-signed raw transaction ` + - ` since signing credential is specified as` + - `Web3SigningCredentialType.NONE`, - ); - } - } - default: { - throw new Error( - `${fnTag} Unrecognized Web3SigningCredentialType: ` + - `${req.web3SigningCredential.type} Supported ones are: ` + - `${Object.values(Web3SigningCredentialType).join(";")}`, - ); - } - } - } - - public async transactSigned( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactSigned()`; - - Checks.truthy(req.consistencyStrategy, `${fnTag}:req.consistencyStrategy`); - Checks.truthy( - req.transactionConfig.rawTransaction, - `${fnTag}:req.transactionConfig.rawTransaction`, - ); - const rawTx = req.transactionConfig.rawTransaction as string; - - this.log.debug("Starting web3.eth.sendSignedTransaction(rawTransaction) "); - - const txPoolReceipt = await this.web3.eth.sendSignedTransaction(rawTx); - - return this.getTxReceipt(req, txPoolReceipt); - } - - public async getTxReceipt( - request: RunTransactionRequest, - txPoolReceipt: TransactionReceipt, - ): Promise { - const fnTag = `${this.className}#getTxReceipt()`; - - this.log.debug("Received preliminary receipt from Besu node."); - - if (txPoolReceipt instanceof Error) { - this.log.debug(`${fnTag} sendSignedTransaction failed`, txPoolReceipt); - throw txPoolReceipt; - } - this.prometheusExporter.addCurrentTransaction(); - - if ( - request.consistencyStrategy.receiptType === ReceiptType.NodeTxPoolAck && - request.consistencyStrategy.blockConfirmations > 0 - ) { - throw new Error( - `${fnTag} Conflicting parameters for consistency` + - ` strategy: Cannot wait for >0 block confirmations AND only wait ` + - ` for the tx pool ACK at the same time.`, - ); - } - - switch (request.consistencyStrategy.receiptType) { - case ReceiptType.NodeTxPoolAck: - return { transactionReceipt: txPoolReceipt }; - case ReceiptType.LedgerBlockAck: - this.log.debug("Starting poll for ledger TX receipt ..."); - const txHash = txPoolReceipt.transactionHash; - const { consistencyStrategy } = request; - const ledgerReceipt = await this.pollForTxReceipt( - txHash, - consistencyStrategy, - ); - this.log.debug( - "Finished poll for ledger TX receipt: %o", - ledgerReceipt, - ); - return { transactionReceipt: ledgerReceipt }; - default: - throw new Error( - `${fnTag} Unrecognized ReceiptType: ${request.consistencyStrategy.receiptType}`, - ); - } - } - - public async transactPrivate(options: any): Promise { - const fnTag = `${this.className}#transactPrivate()`; - - if (!this.web3Quorum) { - throw new Error(`${fnTag} Web3 EEA client not initialized.`); - } - - const txHash = - await this.web3Quorum.priv.generateAndSendRawTransaction(options); - - if (!txHash) { - throw new Error(`${fnTag} eea.sendRawTransaction provided no tx hash.`); - } - return this.getPrivateTxReceipt(options.privateFrom, txHash); - } - - public async getPrivateTxReceipt( - privateFrom: string, - txHash: string, - ): Promise { - const fnTag = `${this.className}#getPrivateTxReceipt()`; - - if (!this.web3Quorum) { - throw new Error(`${fnTag} Web3 Quorum client not initialized.`); - } - - const txPoolReceipt = - await this.web3Quorum.priv.waitForTransactionReceipt(txHash); - if (!txPoolReceipt) { - throw new RuntimeError(`priv.getTransactionReceipt provided no receipt.`); - } - - return { - transactionReceipt: txPoolReceipt as unknown as Web3TransactionReceipt, + const ctx = { + prometheusExporter: this.prometheusExporter, + pluginRegistry: this.pluginRegistry, + logLevel: this.logLevel, + web3: this.web3, }; - } - - public async transactPrivateKey( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactPrivateKey()`; - const { transactionConfig, web3SigningCredential } = req; - const { secret } = - web3SigningCredential as Web3SigningCredentialPrivateKeyHex; - - // Run transaction to EEA client here if private transaction - - if (req.privateTransactionConfig) { - const options = { - nonce: transactionConfig.nonce, - gasPrice: transactionConfig.gasPrice, - gasLimit: transactionConfig.gas, - to: transactionConfig.to, - value: transactionConfig.value, - data: transactionConfig.data, - privateKey: secret, - privateFrom: req.privateTransactionConfig.privateFrom, - privateFor: req.privateTransactionConfig.privateFor, - restriction: "restricted", - }; - - return this.transactPrivate(options); - } - - const signedTx = await this.web3.eth.accounts.signTransaction( - transactionConfig, - secret, - ); - - if (signedTx.rawTransaction) { - req.transactionConfig.rawTransaction = signedTx.rawTransaction; - return this.transactSigned(req); - } else { - throw new Error( - `${fnTag} Failed to sign eth transaction. ` + - `signedTransaction.rawTransaction is blank after .signTransaction().`, - ); - } - } - - public async transactCactusKeychainRef( - req: RunTransactionRequest, - ): Promise { - const fnTag = `${this.className}#transactCactusKeychainRef()`; - const { - transactionConfig, - web3SigningCredential, - privateTransactionConfig, - } = req; - const { ethAccount, keychainEntryKey, keychainId } = - web3SigningCredential as Web3SigningCredentialCactusKeychainRef; - - // locate the keychain plugin that has access to the keychain backend - // denoted by the keychainID from the request. - const keychainPlugin = this.pluginRegistry.findOneByKeychainId(keychainId); - - Checks.truthy(keychainPlugin, `${fnTag} keychain for ID:"${keychainId}"`); - - // Now use the found keychain plugin to actually perform the lookup of - // the private key that we need to run the transaction. - const privateKeyHex = await keychainPlugin?.get(keychainEntryKey); - - return this.transactPrivateKey({ - privateTransactionConfig, - transactionConfig, - web3SigningCredential: { - ethAccount, - type: Web3SigningCredentialType.PrivateKeyHex, - secret: privateKeyHex, - }, - consistencyStrategy: { - blockConfirmations: 0, - receiptType: ReceiptType.NodeTxPoolAck, - timeoutMs: 60000, - }, - }); - } - - public async pollForTxReceipt( - txHash: string, - consistencyStrategy: ConsistencyStrategy, - ): Promise { - const fnTag = `${this.className}#pollForTxReceipt()`; - let txReceipt; - let timedOut = false; - let tries = 0; - let confirmationCount = 0; - const timeoutMs = consistencyStrategy.timeoutMs || Number.MAX_SAFE_INTEGER; - const startedAt = new Date(); - - do { - const now = Date.now(); - const elapsedTime = now - startedAt.getTime(); - timedOut = now >= startedAt.getTime() + timeoutMs; - this.log.debug("%s tries=%n elapsedMs=%n", fnTag, tries, elapsedTime); - if (tries > 0) { - await setTimeout(1000); - } - tries++; - if (timedOut) { - break; - } - - txReceipt = await this.web3.eth.getTransactionReceipt(txHash); - if (!txReceipt) { - continue; - } - - const latestBlockNo = await this.web3.eth.getBlockNumber(); - confirmationCount = latestBlockNo - txReceipt.blockNumber; - } while (confirmationCount >= consistencyStrategy.blockConfirmations); - - if (!txReceipt) { - throw new Error(`${fnTag} Timed out ${timeoutMs}ms, polls=${tries}`); - } - return txReceipt; + const runTransactionResponse = transactV1Impl(ctx, req); + return runTransactionResponse; } public async deployContract( req: DeployContractSolidityBytecodeV1Request, ): Promise { - const fnTag = `${this.className}#deployContract()`; - Checks.truthy(req, `${fnTag} req`); - if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { - throw createHttpError[400]( - `${fnTag} Cannot deploy contract with pre-signed TX`, - ); - } - const { keychainId, contractName } = req; - if (!keychainId || !req.contractName) { - const errorMessage = `${fnTag} Cannot deploy contract without keychainId and the contractName.`; - throw createHttpError[400](errorMessage); - } - - const keychainPlugin = this.pluginRegistry.findOneByKeychainId(keychainId); - - if (!keychainPlugin) { - const errorMessage = - `${fnTag} The plugin registry does not contain` + - ` a keychain plugin for ID:"${req.keychainId}"`; - throw createHttpError[400](errorMessage); - } - - if (!keychainPlugin.has(contractName)) { - const errorMessage = - `${fnTag} Cannot create an instance of the contract instance because` + - `the contractName in the request does not exist on the keychain`; - throw new createHttpError[400](errorMessage); - } - - const networkId = await this.web3.eth.net.getId(); - - const tmpContract = new this.web3.eth.Contract(req.contractAbi); - const deployment = tmpContract.deploy({ - data: req.bytecode, - arguments: req.constructorArgs, - }); - - const abi = deployment.encodeABI(); - const data = abi.startsWith("0x") ? abi : `0x${abi}`; - this.log.debug(`Deploying "${req.contractName}" with data %o`, data); - - const web3SigningCredential = req.web3SigningCredential as - | Web3SigningCredentialPrivateKeyHex - | Web3SigningCredentialCactusKeychainRef; - - const runTxResponse = await this.transact({ - transactionConfig: { - data, - from: web3SigningCredential.ethAccount, - gas: req.gas, - gasPrice: req.gasPrice, - }, - consistencyStrategy: { - blockConfirmations: 0, - receiptType: ReceiptType.NodeTxPoolAck, - timeoutMs: req.timeoutMs || 60000, - }, - web3SigningCredential, - privateTransactionConfig: req.privateTransactionConfig, - }); - - const keychainHasContract = await keychainPlugin.has(contractName); - - if (!keychainHasContract) { - const errorMessage = - `${fnTag} Cannot create an instance of the contract instance because` + - `the contractName in the request does not exist on the keychain`; - throw new createHttpError[400](errorMessage); - } - - this.log.debug(`Keychain has the contract, updating networks...`); - - const { transactionReceipt: receipt } = runTxResponse; - const { status, contractAddress } = receipt; - - if (status && contractAddress) { - const networkInfo = { address: contractAddress }; - const contractStr = await keychainPlugin.get(contractName); - const contractJSON = JSON.parse(contractStr); - this.log.debug("Contract JSON: \n%o", JSON.stringify(contractJSON)); - const contract = new this.web3.eth.Contract( - contractJSON.abi, - contractAddress, - ); - this.contracts[contractName] = contract; - - const network = { [networkId]: networkInfo }; - contractJSON.networks = network; + const ctx = { + pluginRegistry: this.pluginRegistry, + prometheusExporter: this.prometheusExporter, + web3: this.web3, + logLevel: this.logLevel, + }; - await keychainPlugin.set(contractName, JSON.stringify(contractJSON)); + const deployContractV1KeychainResponse: IDeployContractV1KeychainResponse = + await deployContractV1Keychain(ctx, req); + if ( + deployContractV1KeychainResponse.status && + deployContractV1KeychainResponse.contractAddress && + deployContractV1KeychainResponse.contract + ) { + this.contracts[deployContractV1KeychainResponse.contractName] = + deployContractV1KeychainResponse.contract; } + return deployContractV1KeychainResponse.deployResponse; + } - // creating solidity byte code response - const deployResponse: DeployContractSolidityBytecodeV1Response = { - transactionReceipt: runTxResponse.transactionReceipt, + public async deployContractNoKeychain( + req: DeployContractSolidityBytecodeNoKeychainV1Request, + ): Promise { + const ctx = { + pluginRegistry: this.pluginRegistry, + prometheusExporter: this.prometheusExporter, + web3: this.web3, + logLevel: this.logLevel, }; - - return deployResponse; + const deployContractV1NoKeychainResponse: IDeployContractV1NoKeychainResponse = + await deployContractV1NoKeychain(ctx, req); + if (deployContractV1NoKeychainResponse.contractJsonString) { + this.contracts[deployContractV1NoKeychainResponse.contractName] = + deployContractV1NoKeychainResponse.contract; + } + return deployContractV1NoKeychainResponse.deployResponse } public async signTransaction( diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts new file mode 100644 index 00000000000..6d34e0a6f31 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts @@ -0,0 +1,109 @@ +import type { Express, Request, Response } from "express"; + +import { + IWebServiceEndpoint, + IExpressRequestHandler, + IEndpointAuthzOptions, +} from "@hyperledger/cactus-core-api"; + +import { + Logger, + Checks, + LogLevelDesc, + LoggerProvider, + IAsyncProvider, +} from "@hyperledger/cactus-common"; + +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; + +import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; +import { DeployContractSolidityBytecodeV1Request } from "../generated/openapi/typescript-axios"; +import OAS from "../../json/openapi.json"; + +export interface IDeployContractSolidityBytecodeNoKeychainOptions { + logLevel?: LogLevelDesc; + connector: PluginLedgerConnectorBesu; +} + +export class DeployContractSolidityBytecodeNoKeychainEndpoint + implements IWebServiceEndpoint +{ + public static readonly CLASS_NAME = + "DeployContractSolidityBytecodeNoKeychainEndpoint"; + + private readonly log: Logger; + + public get className(): string { + return DeployContractSolidityBytecodeNoKeychainEndpoint.CLASS_NAME; + } + + constructor( + public readonly options: IDeployContractSolidityBytecodeNoKeychainOptions, + ) { + const fnTag = `${this.className}#constructor()`; + Checks.truthy(options, `${fnTag} arg options`); + Checks.truthy(options.connector, `${fnTag} arg options.connector`); + + const level = this.options.logLevel || "INFO"; + const label = this.className; + this.log = LoggerProvider.getOrCreate({ level, label }); + } + + public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain"] { + return OAS.paths[ + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-besu/deploy-contract-solidity-bytecode-no-keychain" + ]; + } + + public getPath(): string { + return this.oasPath.post["x-hyperledger-cacti"].http.path; + } + + public getVerbLowerCase(): string { + return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; + } + + public getOperationId(): string { + return this.oasPath.post.operationId; + } + + getAuthorizationOptionsProvider(): IAsyncProvider { + // TODO: make this an injectable dependency in the constructor + return { + get: async () => ({ + isProtected: true, + requiredRoles: [], + }), + }; + } + + public async registerExpress( + expressApp: Express, + ): Promise { + await registerWebServiceEndpoint(expressApp, this); + return this; + } + + public getExpressRequestHandler(): IExpressRequestHandler { + return this.handleRequest.bind(this); + } + + public async handleRequest(req: Request, res: Response): Promise { + const { log } = this; + const fnTag = `${this.className}#handleRequest()`; + const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; + this.log.debug(reqTag); + const reqBody: DeployContractSolidityBytecodeV1Request = req.body; + try { + const resBody = + await this.options.connector.deployContractNoKeychain(reqBody); + res.json(resBody); + } catch (ex) { + const errorMsg = `${reqTag} ${fnTag} Failed to deploy contract:`; + await handleRestEndpointException({ errorMsg, log, error: ex, res }); + } + } +} diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/v21-deploy-contract-from-json-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/v21-deploy-contract-from-json-no-keychain.test.ts new file mode 100644 index 00000000000..c007b695bdb --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/v21-deploy-contract-from-json-no-keychain.test.ts @@ -0,0 +1,479 @@ +import "jest-extended"; +import { v4 as uuidv4 } from "uuid"; +import { Server as SocketIoServer } from "socket.io"; +import { PluginRegistry } from "@hyperledger/cactus-core"; +import { + EthContractInvocationType, + Web3SigningCredentialType, + PluginLedgerConnectorBesu, + PluginFactoryLedgerConnector, + Web3SigningCredentialCactusKeychainRef, + ReceiptType, + BesuApiClient, + WatchBlocksV1Progress, + Web3BlockHeader, +} from "../../../../../main/typescript/public-api"; +import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; +import { + BesuTestLedger, + pruneDockerAllIfGithubAction, +} from "@hyperledger/cactus-test-tooling"; +import { + LogLevelDesc, + IListenOptions, + Servers, +} from "@hyperledger/cactus-common"; +import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; +import Web3 from "web3"; +import { Constants, PluginImportType } from "@hyperledger/cactus-core-api"; +import express from "express"; +import bodyParser from "body-parser"; +import http from "http"; +import { AddressInfo } from "net"; +import { K_CACTUS_BESU_TOTAL_TX_COUNT } from "../../../../../main/typescript/prometheus-exporter/metrics"; +import { BesuApiClientOptions } from "../../../../../main/typescript/api-client/besu-api-client"; +import { Account } from "web3-core"; + +describe("PluginLedgerConnectorBesu", () => { + const testCase = "deploys contract via .json file"; + const logLevel: LogLevelDesc = "INFO"; + const containerImageVersion = "2021-08-24--feat-1244"; + const containerImageName = + "ghcr.io/hyperledger/cactus-besu-21-1-6-all-in-one"; + const besuOptions = { containerImageName, containerImageVersion }; + const besuTestLedger = new BesuTestLedger(besuOptions); + const besuKeyPair = { + privateKey: besuTestLedger.getGenesisAccountPrivKey(), + }; + const keychainEntryKey = uuidv4(); + + const keychainPlugin = new PluginKeychainMemory({ + instanceId: uuidv4(), + keychainId: uuidv4(), + // pre-provision keychain with mock backend holding the private key of the + // test account that we'll reference while sending requests with the + // signing credential pointing to this keychain entry. + backend: new Map(), + logLevel, + }); + + const factory = new PluginFactoryLedgerConnector({ + pluginImportType: PluginImportType.Local, + }); + + const expressApp = express(); + expressApp.use(bodyParser.json({ limit: "250mb" })); + const server = http.createServer(expressApp); + + const pluginRegistry = new PluginRegistry({ plugins: [keychainPlugin] }); + + const wsApi = new SocketIoServer(server, { + path: Constants.SocketIoConnectionPathV1, + }); + + const listenOptions: IListenOptions = { + hostname: "127.0.0.1", + port: 0, + server, + }; + + let rpcApiHttpHost: string; + let rpcApiWsHost: string; + let firstHighNetWorthAccount: string; + let web3: Web3; + let testEthAccount: Account; + let keychainEntryValue: string; + let connector: PluginLedgerConnectorBesu; + let addressInfo: AddressInfo; + let apiClient: BesuApiClient; + let apiHost: string; + let contractAddress: string; + + beforeAll(async () => { + await pruneDockerAllIfGithubAction({ logLevel }); + }); + + beforeAll(async () => { + await besuTestLedger.start(); + rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost(); + rpcApiWsHost = await besuTestLedger.getRpcApiWsHost(); + firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey(); + + web3 = new Web3(rpcApiHttpHost); + testEthAccount = web3.eth.accounts.create(uuidv4()); + keychainEntryValue = testEthAccount.privateKey; + keychainPlugin.set(keychainEntryKey, keychainEntryValue); + + addressInfo = await Servers.listen(listenOptions); + + connector = await factory.create({ + rpcApiHttpHost, + rpcApiWsHost, + logLevel, + instanceId: uuidv4(), + pluginRegistry, + }); + + const { address, port } = addressInfo; + apiHost = `http://${address}:${port}`; + const besuApiClientOptions = new BesuApiClientOptions({ + basePath: apiHost, + }); + apiClient = new BesuApiClient(besuApiClientOptions); + + await connector.getOrCreateWebServices(); + await connector.registerWebServices(expressApp, wsApi); + }); + + afterAll(async () => { + await Servers.shutdown(server); + }); + + afterAll(async () => { + await besuTestLedger.stop(); + await besuTestLedger.destroy(); + }); + + afterAll(async () => { + await pruneDockerAllIfGithubAction({ logLevel }); + }); + + test(testCase, async () => { + await connector.transact({ + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: besuKeyPair.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + transactionConfig: { + from: firstHighNetWorthAccount, + to: testEthAccount.address, + value: 10e9, + gas: 1000000, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: 60000, + }, + }); + + const blocks = await apiClient.watchBlocksV1(); + + const aBlockHeader = await new Promise( + (resolve, reject) => { + let done = false; + const timerId = setTimeout(() => { + if (!done) { + reject("Waiting for block header notification to arrive timed out"); + } + }, 10000); + const subscription = blocks.subscribe((res: WatchBlocksV1Progress) => { + subscription.unsubscribe(); + done = true; + clearTimeout(timerId); + resolve(res.blockHeader); + }); + }, + ); + expect(aBlockHeader).toBeTruthy(); + expect(aBlockHeader).toBeObject(); + expect(aBlockHeader).not.toBeEmptyObject(); + + const balance = await web3.eth.getBalance(testEthAccount.address); + expect(balance).toBeTruthy(); + expect(parseInt(balance, 10)).toEqual(10e9); + }); + + test("deploys contract via .json file", async () => { + const contractJSONString = JSON.stringify(HelloWorldContractJson) + const deployOut = await connector.deployContractNoKeychain({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractJSONString: contractJSONString, + constructorArgs: [], + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: besuKeyPair.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + bytecode: HelloWorldContractJson.bytecode, + gas: 1000000, + }); + expect(deployOut).toBeTruthy(); + expect(deployOut).toBeObject(); + + expect(deployOut.transactionReceipt).toBeTruthy(); + expect(deployOut.transactionReceipt).toBeObject(); + + expect(deployOut.transactionReceipt.contractAddress).toBeTruthy(); + expect(deployOut.transactionReceipt.contractAddress).toBeString(); + + contractAddress = deployOut.transactionReceipt.contractAddress as string; + + const { callOutput: helloMsg } = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Call, + methodName: "sayHello", + params: [], + signingCredential: { + ethAccount: firstHighNetWorthAccount, + secret: besuKeyPair.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + expect(helloMsg).toBeTruthy(); + expect(helloMsg).toBeString(); + expect(helloMsg).not.toBeEmpty(); + }); + + test("invoke Web3SigningCredentialType.NONE", async () => { + const testEthAccount2 = web3.eth.accounts.create(uuidv4()); + + const { rawTransaction } = await web3.eth.accounts.signTransaction( + { + from: testEthAccount.address, + to: testEthAccount2.address, + value: 10e6, + gas: 1000000, + }, + testEthAccount.privateKey, + ); + + await connector.transact({ + web3SigningCredential: { + type: Web3SigningCredentialType.None, + }, + transactionConfig: { + rawTransaction, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: 60000, + }, + }); + + const balance2 = await web3.eth.getBalance(testEthAccount2.address); + expect(parseInt(balance2, 10)).toEqual(10e6); + }); + + test("invoke Web3SigningCredentialType.PrivateKeyHex", async () => { + const newName = `DrCactus${uuidv4()}`; + const setNameOut = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + nonce: 1, + }); + expect(setNameOut).toBeTruthy(); + + const setNameOutPromise1 = connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + nonce: 1, + }); + + await expect(setNameOutPromise1).rejects.toMatchObject>({ + message: expect.stringContaining("Nonce too low"), + }); + + const { callOutput: getNameOut } = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Call, + methodName: "getName", + params: [], + gas: 1000000, + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + expect(getNameOut).toEqual(newName); + + const getNameOut2 = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "getName", + params: [], + gas: 1000000, + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + expect(getNameOut2).toBeTruthy(); + + const response = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "deposit", + params: [], + gas: 1000000, + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + value: 10, + }); + expect(response).toBeTruthy(); + + const { callOutput } = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Call, + methodName: "getNameByIndex", + params: [0], + gas: 1000000, + signingCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + + expect(callOutput).toEqual(newName); + }); + + test("invoke Web3SigningCredentialType.CactusKeychainRef", async () => { + const newName = `DrCactus${uuidv4()}`; + + const signingCredential: Web3SigningCredentialCactusKeychainRef = { + ethAccount: testEthAccount.address, + keychainEntryKey, + keychainId: keychainPlugin.getKeychainId(), + type: Web3SigningCredentialType.CactusKeychainRef, + }; + + const setNameOut = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + signingCredential, + nonce: 4, + }); + expect(setNameOut).toBeTruthy(); + + const setNameOutPromise2 = connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + signingCredential, + nonce: 4, + }); + + await expect(setNameOutPromise2).rejects.toMatchObject>({ + message: expect.stringContaining("Nonce too low"), + }); + + const { callOutput: getNameOut } = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Call, + methodName: "getName", + params: [], + gas: 1000000, + signingCredential, + }); + expect(getNameOut).toEqual(newName); + + const getNameOut2 = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "getName", + params: [], + gas: 1000000, + signingCredential, + }); + + expect(getNameOut2).toBeTruthy(); + + const response = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "deposit", + params: [], + gas: 1000000, + signingCredential, + value: 10, + }); + + expect(response).toBeTruthy(); + + const { callOutput } = await connector.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress, + invocationType: EthContractInvocationType.Call, + methodName: "getNameByIndex", + params: [1], + gas: 1000000, + signingCredential, + }); + + expect(callOutput).toEqual(newName); + }); + + test("get prometheus exporter metrics", async () => { + const res = await apiClient.getPrometheusMetricsV1(); + const promMetricsOutput = + "# HELP " + + K_CACTUS_BESU_TOTAL_TX_COUNT + + " Total transactions executed\n" + + "# TYPE " + + K_CACTUS_BESU_TOTAL_TX_COUNT + + " gauge\n" + + K_CACTUS_BESU_TOTAL_TX_COUNT + + '{type="' + + K_CACTUS_BESU_TOTAL_TX_COUNT + + '"} 9'; + + expect(res).toBeTruthy(); + expect(res.data).toBeTruthy(); + expect(res.status).toEqual(200); + expect(res.data.includes(promMetricsOutput)).toBeTrue(); + }); +});