From 394323e91e3bd0df57c87d6bae406298c559fc7f Mon Sep 17 00:00:00 2001 From: ruzell22 Date: Thu, 15 Aug 2024 13:27:28 +0800 Subject: [PATCH] fix(connector-besu): do not crash if ledger unreachable - send HTTP 503 Primary Changes --------------- 1. Yarn patch to web3-eth-accounts@1.6.1 so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: #3406 Co-authored-by: Peter Somogyvari Signed-off-by: ruzell22 Signed-off-by: Peter Somogyvari --- .cspell.json | 4 +- ...b3-eth-accounts-npm-1.6.1-c95f31ca81.patch | 13 + package.json | 1 + .../src/main/typescript/http/http-header.ts | 157 +++++++++++ .../src/main/typescript/public-api.ts | 2 + .../package.json | 6 +- .../go-client/.openapi-generator/FILES | 1 + .../go/generated/openapi/go-client/README.md | 1 + .../openapi/go-client/api/openapi.yaml | 83 ++++++ .../openapi/go-client/api_default.go | 144 +++++++++- .../model_backing_ledger_unavailable_error.go | 126 +++++++++ .../src/main/json/openapi.json | 128 +++++++++ .../src/main/json/openapi.tpl.json | 128 +++++++++ .../openapi/.openapi-generator/FILES | 1 + .../backing_ledger_unavailable_error_pb.proto | 22 ++ .../openapi/services/default_service.proto | 1 + ...bsocket-provider-abnormal-closure-error.ts | 38 +++ .../generated/openapi/typescript-axios/api.ts | 13 + .../backing_ledger_unavailable_error_pb.ts | 76 +++++ .../protoc-gen-ts/services/default_service.ts | 259 +++++++++--------- .../web-services/run-transaction-endpoint.ts | 37 ++- ...et-provider-abnormal-closure-error.test.ts | 41 +++ .../run-transaction-endpoint.test.ts | 125 +++++++++ yarn.lock | 77 ++++-- 24 files changed, 1311 insertions(+), 173 deletions(-) create mode 100644 .yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch create mode 100644 packages/cactus-common/src/main/typescript/http/http-header.ts create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_backing_ledger_unavailable_error.go create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/backing_ledger_unavailable_error_pb.proto create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/main/typescript/common/is-web3-websocket-provider-abnormal-closure-error.ts create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/backing_ledger_unavailable_error_pb.ts create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/test/typescript/unit/common/is-web3-websocket-provider-abnormal-closure-error.test.ts create mode 100644 packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/run-transaction-endpoint.test.ts diff --git a/.cspell.json b/.cspell.json index 3037dab87e..183af22e39 100644 --- a/.cspell.json +++ b/.cspell.json @@ -202,6 +202,7 @@ "trivyignores", "txid", "txqueue", + "UIDH", "Uisrs", "undici", "unixfs", @@ -214,7 +215,8 @@ "websocat", "WSPROVIDER", "Xdai", - "xeipuuv" + "xeipuuv", + "XUIDH" ], "dictionaries": [ "typescript,node,npm,go,rust" diff --git a/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch b/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch new file mode 100644 index 0000000000..984e901693 --- /dev/null +++ b/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch @@ -0,0 +1,13 @@ +diff --git a/lib/index.js b/lib/index.js +index de2853c247b334e6b22cee42b3e597281c44efdc..787aecf6758228c092f1a3cd8097f64e76cc573d 100644 +--- a/lib/index.js ++++ b/lib/index.js +@@ -344,7 +344,7 @@ function _handleTxPricing(_this, tx) { + throw Error("Network doesn't support eip-1559"); + resolve({ gasPrice }); + } +- }); ++ }).catch((ex) => reject(ex)); + } + } + catch (error) { diff --git a/package.json b/package.json index 5ac95bdafe..860cd0543f 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,7 @@ "ws": ">=1.1.5", "xml2js": ">=0.5.0", "yargs-parser": ">=18.1.1", + "web3-eth-accounts@npm:1.6.1": "patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch", "zod": ">=3.22.3" }, "devDependencies": { diff --git a/packages/cactus-common/src/main/typescript/http/http-header.ts b/packages/cactus-common/src/main/typescript/http/http-header.ts new file mode 100644 index 0000000000..d1a77e1010 --- /dev/null +++ b/packages/cactus-common/src/main/typescript/http/http-header.ts @@ -0,0 +1,157 @@ +/** + * A list of well-known headers as published on Wikipedia. + * @see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields + * + * TODO Finish documenting each enum item and make sure to also include + * the examples provided on the linked Wikipedia page above. The first + * few headers are documented this way but we need all of them like that. + * + * TODO Ensure that there are no typos in the header names. + */ +export enum HttpHeader { + // Standard request fields + + /** + * Acceptable instance-manipulations for the request. + * @example A-IM: feed + * @see https://datatracker.ietf.org/doc/html/rfc3229 + */ + A_IM = "A-IM", + /** + * Media type(s) that is/are acceptable for the response. See Content negotiation. + * @example Accept: text/html + * @see https://datatracker.ietf.org/doc/html/rfc9110 + */ + Accept = "Accept", + /** + * Character sets that are acceptable. + * @example Accept-Charset: utf-8 + * @see https://datatracker.ietf.org/doc/html/rfc9110 + */ + AcceptCharset = "Accept-Charset", + /** + * Acceptable version in time. + * @example Accept-Datetime: Thu, 31 May 2007 20:35:00 GMT + * @see https://datatracker.ietf.org/doc/html/rfc7089 + */ + AcceptDatetime = "Accept-Datetime", + AcceptEncoding = "Accept-Encoding", + AcceptLanguage = "Accept-Language", + AccessControlAllowOrigin = "Access-Control-Allow-Origin", + AccessControlAllowCredentials = "Access-Control-Allow-Credentials", + AccessControlExposeHeaders = "Access-Control-Expose-Headers", + AccessControlMaxAge = "Access-Control-Max-Age", + AccessControlAllowMethods = "Access-Control-Allow-Methods", + AccessControlAllowHeaders = "Access-Control-Allow-Headers", + Authorization = "Authorization", + CacheControl = "Cache-Control", + Connection = "Connection", + ContentDisposition = "Content-Disposition", + ContentEncoding = "Content-Encoding", + ContentLength = "Content-Length", + ContentLocation = "Content-Location", + ContentMD5 = "Content-MD5", + ContentType = "Content-Type", + Cookie = "Cookie", + Date = "Date", + Expect = "Expect", + Forwarded = "Forwarded", + From = "From", + Host = "Host", + IfMatch = "If-Match", + IfModifiedSince = "If-Modified-Since", + IfNoneMatch = "If-None-Match", + IfRange = "If-Range", + IfUnmodifiedSince = "If-Unmodified-Since", + MaxForwards = "Max-Forwards", + Origin = "Origin", + Pragma = "Pragma", + Prefer = "Prefer", + ProxyAuthorization = "Proxy-Authorization", + Range = "Range", + Referer = "Referer", + TE = "TE", + Trailer = "Trailer", + TransferEncoding = "Transfer-Encoding", + Upgrade = "Upgrade", + UserAgent = "User-Agent", + + // Common non-standard request fields + UpgradeInsecureRequests = "Upgrade-Insecure-Requests", + XRequestedWith = "X-Requested-With", + DNT = "DNT", + XForwardedFor = "X-Forwarded-For", + XForwardedHost = "X-Forwarded-Host", + XForwardedProto = "X-Forwarded-Proto", + FrontEndHttps = "Front-End-Https", + XHttpMethodOverride = "X-Http-Method-Override", + XAttDeviceId = "X-Att-DeviceId", + XWapProfile = "X-Wap-Profile", + ProxyConnection = "Proxy-Connection", + XUIDH = "X-UIDH", + XCsrfToken = "X-Csrf-Token", + XRequestId = "X-Request-ID", // Alternative X-Request-Id + CorrelationId = "X-Correlation-ID", // Alternative Correlation-ID + SaveData = "Save-Data", + SecGpc = "Sec-GPC", + + // Standard response fields + AcceptCH = "Accept-CH", + AcceptPatch = "Accept-Patch", + AltSvc = "Alt-Svc", + Age = "Age", + Allow = "Allow", + Expires = "Expires", + IM = "IM", + LastModified = "Last-Modified", + Link = "Link", + Location = "Location", + P3P = "P3P", + ProxyAuthenticate = "Proxy-Authenticate", + PublicKeyPins = "Public-Key-Pins", + /** + * f an entity is temporarily unavailable, this instructs the client + * to try again later. Value could be a specified period of time + * (in seconds) or a HTTP-date. + * + * There are two accepted formats when it comes to the values of the header: + * ```http + * Retry-After: + * Retry-After: + * ``` + * + * `` + * A date after which to retry. See the Date header for more details on the HTTP date format. + * + * `` + * A non-negative decimal integer indicating the seconds to delay after the response is received. + * + * @example Retry-After: 120 + * @example Retry-After: Fri, 07 Nov 2014 23:59:59 GMT + * + * @see https://datatracker.ietf.org/doc/html/rfc9110#section-10.2.3 + */ + RetryAfter = "Retry-After", + Server = "Server", + SetCookie = "Set-Cookie", + StrictTransportSecurity = "Strict-Transport-Security", + Tk = "Tk", + Vary = "Vary", + Via = "Via", // Same as request field + /** + * Indicates the authentication scheme that should be used to access the requested entity. + * @example WWW-Authenticate: Basic + * @see https://datatracker.ietf.org/doc/html/rfc9110 + */ + WWWAuthenticate = "WWW-Authenticate", + XFrameOptions = "X-Frame-Options", + + // Common non-standard response fields + ContentSecurityPolicy = "Content-Security-Policy", + ExpectCT = "Expect-CT", + NEL = "NEL", + PermissionsPolicy = "Permissions-Policy", + Refresh = "Refresh", + ReportTo = "Report-To", + Timing_Allow_Origin = "Timing-Allow-Origin", +} diff --git a/packages/cactus-common/src/main/typescript/public-api.ts b/packages/cactus-common/src/main/typescript/public-api.ts index 18e4ceb6c8..6dd0e177d0 100755 --- a/packages/cactus-common/src/main/typescript/public-api.ts +++ b/packages/cactus-common/src/main/typescript/public-api.ts @@ -47,3 +47,5 @@ export { } from "./http/express-http-verb-method-name"; export { isGrpcStatusObjectWithCode } from "./grpc/is-grpc-status-object-with-code"; + +export { HttpHeader } from "./http/http-header"; diff --git a/packages/cactus-plugin-ledger-connector-besu/package.json b/packages/cactus-plugin-ledger-connector-besu/package.json index 432992f5c7..025b74d2c1 100644 --- a/packages/cactus-plugin-ledger-connector-besu/package.json +++ b/packages/cactus-plugin-ledger-connector-besu/package.json @@ -80,7 +80,8 @@ "web3-eth": "1.6.1", "web3-eth-contract": "1.6.1", "web3-utils": "1.6.1", - "web3js-quorum": "22.4.0" + "web3js-quorum": "22.4.0", + "websocket-event-codes": "1.1.0" }, "devDependencies": { "@hyperledger/cactus-plugin-keychain-memory": "2.0.0", @@ -105,7 +106,8 @@ "tsx": "4.16.2", "uuid": "10.0.0", "web3-core": "1.6.1", - "web3-eth": "1.6.1" + "web3-eth": "1.6.1", + "web3-eth-accounts": "patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch" }, "engines": { "node": ">=18", diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/.openapi-generator/FILES b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/.openapi-generator/FILES index 5281a8735b..1dba19b945 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/.openapi-generator/FILES +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/.openapi-generator/FILES @@ -6,6 +6,7 @@ client.go configuration.go go.mod go.sum +model_backing_ledger_unavailable_error.go model_besu_private_transaction_config.go model_besu_transaction_config.go model_besu_transaction_config_to.go diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/README.md b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/README.md index b251cc4c7d..0cf69a908c 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/README.md +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/README.md @@ -93,6 +93,7 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [BackingLedgerUnavailableError](docs/BackingLedgerUnavailableError.md) - [BesuPrivateTransactionConfig](docs/BesuPrivateTransactionConfig.md) - [BesuTransactionConfig](docs/BesuTransactionConfig.md) - [BesuTransactionConfigTo](docs/BesuTransactionConfigTo.md) diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml index 50e642bff4..1441ac22c7 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml @@ -20,6 +20,12 @@ paths: schema: type: string description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Retrieves the .json file that contains the OpenAPI specification for the plugin. x-hyperledger-cacti: @@ -42,6 +48,12 @@ paths: schema: $ref: '#/components/schemas/DeployContractSolidityBytecodeV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Deploys the bytecode of a Solidity contract. x-hyperledger-cacti: http: @@ -63,6 +75,12 @@ paths: schema: $ref: '#/components/schemas/DeployContractSolidityBytecodeV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Deploys the bytecode of a Solidity contract without the need of keychain x-hyperledger-cacti: http: @@ -84,6 +102,12 @@ paths: schema: $ref: '#/components/schemas/GetBalanceV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Return balance of an address of a given block x-hyperledger-cacti: http: @@ -105,6 +129,12 @@ paths: schema: $ref: '#/components/schemas/GetBlockV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Returns a block matching the block x-hyperledger-cacti: http: @@ -126,6 +156,12 @@ paths: schema: $ref: '#/components/schemas/RunTransactionResponse' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Executes a transaction on a besu ledger x-hyperledger-cacti: http: @@ -147,6 +183,12 @@ paths: schema: $ref: '#/components/schemas/GetTransactionV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Executes a transaction on a besu ledger x-hyperledger-cacti: http: @@ -168,6 +210,12 @@ paths: schema: $ref: '#/components/schemas/GetPastLogsV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: "Gets past logs, matching the given options." x-hyperledger-cacti: http: @@ -189,6 +237,12 @@ paths: schema: $ref: '#/components/schemas/InvokeContractV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Invokes a contract on a besu ledger x-hyperledger-cacti: http: @@ -216,6 +270,12 @@ paths: "404": description: Not able to find the corresponding tranaction from the transaction hash + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Obtain signatures of ledger from the corresponding transaction hash. x-hyperledger-cacti: http: @@ -232,6 +292,12 @@ paths: schema: $ref: '#/components/schemas/PrometheusExporterMetricsResponse' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: Get the Prometheus Metrics x-hyperledger-cacti: http: @@ -253,6 +319,12 @@ paths: schema: $ref: '#/components/schemas/GetBesuRecordV1Response' description: OK + "503": + content: + '*/*': + schema: + $ref: '#/components/schemas/BackingLedgerUnavailableError' + description: API is unable to reach the validator summary: "Retrieves an arbitrary record (any piece of information) from the\ \ ledger. Ledger records can be call outputs, transaction input, etc." x-hyperledger-cacti: @@ -1284,6 +1356,11 @@ components: type: string type: object GetBesuRecordV1Response: + example: + ledgerId: ledgerId + transactionInputData: "" + callOutput: "" + stateContract: stateContract properties: ledgerId: type: string @@ -1292,6 +1369,12 @@ components: transactionInputData: {} callOutput: {} type: object + BackingLedgerUnavailableError: + properties: + message: + example: | + Backing Ledger Unavailable + type: string Web3BlockHeader_timestamp: oneOf: - type: string diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api_default.go b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api_default.go index fc28f440ca..55f27a9fd4 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api_default.go +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api_default.go @@ -81,7 +81,7 @@ func (a *DefaultApiService) DeployContractSolBytecodeNoKeychainV1Execute(r ApiDe } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -112,6 +112,16 @@ func (a *DefaultApiService) DeployContractSolBytecodeNoKeychainV1Execute(r ApiDe body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -186,7 +196,7 @@ func (a *DefaultApiService) DeployContractSolBytecodeV1Execute(r ApiDeployContra } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -217,6 +227,16 @@ func (a *DefaultApiService) DeployContractSolBytecodeV1Execute(r ApiDeployContra body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -291,7 +311,7 @@ func (a *DefaultApiService) GetBalanceV1Execute(r ApiGetBalanceV1Request) (*GetB } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -322,6 +342,16 @@ func (a *DefaultApiService) GetBalanceV1Execute(r ApiGetBalanceV1Request) (*GetB body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -396,7 +426,7 @@ func (a *DefaultApiService) GetBesuRecordV1Execute(r ApiGetBesuRecordV1Request) } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"text/plain"} + localVarHTTPHeaderAccepts := []string{"text/plain", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -427,6 +457,16 @@ func (a *DefaultApiService) GetBesuRecordV1Execute(r ApiGetBesuRecordV1Request) body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -501,7 +541,7 @@ func (a *DefaultApiService) GetBlockV1Execute(r ApiGetBlockV1Request) (*GetBlock } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -532,6 +572,16 @@ func (a *DefaultApiService) GetBlockV1Execute(r ApiGetBlockV1Request) (*GetBlock body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -600,7 +650,7 @@ func (a *DefaultApiService) GetOpenApiSpecV1Execute(r ApiGetOpenApiSpecV1Request } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -629,6 +679,16 @@ func (a *DefaultApiService) GetOpenApiSpecV1Execute(r ApiGetOpenApiSpecV1Request body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -703,7 +763,7 @@ func (a *DefaultApiService) GetPastLogsV1Execute(r ApiGetPastLogsV1Request) (*Ge } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -734,6 +794,16 @@ func (a *DefaultApiService) GetPastLogsV1Execute(r ApiGetPastLogsV1Request) (*Ge body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -802,7 +872,7 @@ func (a *DefaultApiService) GetPrometheusMetricsV1Execute(r ApiGetPrometheusMetr } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"text/plain"} + localVarHTTPHeaderAccepts := []string{"text/plain", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -831,6 +901,16 @@ func (a *DefaultApiService) GetPrometheusMetricsV1Execute(r ApiGetPrometheusMetr body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -905,7 +985,7 @@ func (a *DefaultApiService) GetTransactionV1Execute(r ApiGetTransactionV1Request } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -936,6 +1016,16 @@ func (a *DefaultApiService) GetTransactionV1Execute(r ApiGetTransactionV1Request body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -1010,7 +1100,7 @@ func (a *DefaultApiService) InvokeContractV1Execute(r ApiInvokeContractV1Request } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -1041,6 +1131,16 @@ func (a *DefaultApiService) InvokeContractV1Execute(r ApiInvokeContractV1Request body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -1115,7 +1215,7 @@ func (a *DefaultApiService) RunTransactionV1Execute(r ApiRunTransactionV1Request } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -1146,6 +1246,16 @@ func (a *DefaultApiService) RunTransactionV1Execute(r ApiRunTransactionV1Request body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } @@ -1225,7 +1335,7 @@ func (a *DefaultApiService) SignTransactionV1Execute(r ApiSignTransactionV1Reque } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} + localVarHTTPHeaderAccepts := []string{"application/json", "*/*"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -1256,6 +1366,16 @@ func (a *DefaultApiService) SignTransactionV1Execute(r ApiSignTransactionV1Reque body: localVarBody, error: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 503 { + var v BackingLedgerUnavailableError + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } return localVarReturnValue, localVarHTTPResponse, newErr } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_backing_ledger_unavailable_error.go b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_backing_ledger_unavailable_error.go new file mode 100644 index 0000000000..459478bccb --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_backing_ledger_unavailable_error.go @@ -0,0 +1,126 @@ +/* +Hyperledger Cactus Plugin - Connector Besu + +Can perform basic tasks on a Besu ledger + +API version: 2.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cactus-plugin-ledger-connector-besu + +import ( + "encoding/json" +) + +// checks if the BackingLedgerUnavailableError type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &BackingLedgerUnavailableError{} + +// BackingLedgerUnavailableError struct for BackingLedgerUnavailableError +type BackingLedgerUnavailableError struct { + Message *string `json:"message,omitempty"` +} + +// NewBackingLedgerUnavailableError instantiates a new BackingLedgerUnavailableError object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBackingLedgerUnavailableError() *BackingLedgerUnavailableError { + this := BackingLedgerUnavailableError{} + return &this +} + +// NewBackingLedgerUnavailableErrorWithDefaults instantiates a new BackingLedgerUnavailableError object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBackingLedgerUnavailableErrorWithDefaults() *BackingLedgerUnavailableError { + this := BackingLedgerUnavailableError{} + return &this +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *BackingLedgerUnavailableError) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BackingLedgerUnavailableError) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *BackingLedgerUnavailableError) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *BackingLedgerUnavailableError) SetMessage(v string) { + o.Message = &v +} + +func (o BackingLedgerUnavailableError) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o BackingLedgerUnavailableError) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + return toSerialize, nil +} + +type NullableBackingLedgerUnavailableError struct { + value *BackingLedgerUnavailableError + isSet bool +} + +func (v NullableBackingLedgerUnavailableError) Get() *BackingLedgerUnavailableError { + return v.value +} + +func (v *NullableBackingLedgerUnavailableError) Set(val *BackingLedgerUnavailableError) { + v.value = val + v.isSet = true +} + +func (v NullableBackingLedgerUnavailableError) IsSet() bool { + return v.isSet +} + +func (v *NullableBackingLedgerUnavailableError) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBackingLedgerUnavailableError(val *BackingLedgerUnavailableError) *NullableBackingLedgerUnavailableError { + return &NullableBackingLedgerUnavailableError{value: val, isSet: true} +} + +func (v NullableBackingLedgerUnavailableError) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBackingLedgerUnavailableError) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + 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 545d518403..50f7b3457a 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 @@ -1013,6 +1013,14 @@ "transactionInputData": {}, "callOutput": {} } + }, + "BackingLedgerUnavailableError": { + "properties": { + "message": { + "type": "string", + "example": "Backing Ledger Unavailable\n" + } + } } } }, @@ -1038,6 +1046,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1072,6 +1090,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1106,6 +1134,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1140,6 +1178,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1174,6 +1222,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1208,6 +1266,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1242,6 +1310,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1276,6 +1354,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1310,6 +1398,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1349,6 +1447,16 @@ }, "404": { "description": "Not able to find the corresponding tranaction from the transaction hash" + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1374,6 +1482,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1408,6 +1526,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } 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 545d518403..50f7b3457a 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 @@ -1013,6 +1013,14 @@ "transactionInputData": {}, "callOutput": {} } + }, + "BackingLedgerUnavailableError": { + "properties": { + "message": { + "type": "string", + "example": "Backing Ledger Unavailable\n" + } + } } } }, @@ -1038,6 +1046,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1072,6 +1090,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1106,6 +1134,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1140,6 +1178,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1174,6 +1222,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1208,6 +1266,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1242,6 +1310,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1276,6 +1354,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1310,6 +1398,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1349,6 +1447,16 @@ }, "404": { "description": "Not able to find the corresponding tranaction from the transaction hash" + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1374,6 +1482,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } @@ -1408,6 +1526,16 @@ } } } + }, + "503": { + "description": "API is unable to reach the validator", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/BackingLedgerUnavailableError" + } + } + } } } } 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 54faef8d5c..0d0cebd7a4 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 @@ -1,4 +1,5 @@ README.md +models/backing_ledger_unavailable_error_pb.proto models/besu_private_transaction_config_pb.proto models/besu_transaction_config_pb.proto models/besu_transaction_config_to_pb.proto diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/backing_ledger_unavailable_error_pb.proto b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/backing_ledger_unavailable_error_pb.proto new file mode 100644 index 0000000000..80f514f2f7 --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/backing_ledger_unavailable_error_pb.proto @@ -0,0 +1,22 @@ +/* + Hyperledger Cactus Plugin - Connector Besu + + Can perform basic tasks on a Besu ledger + + The version of the OpenAPI document: 2.0.0 + + Generated by OpenAPI Generator: https://openapi-generator.tech +*/ + +syntax = "proto3"; + +package org.hyperledger.cacti.plugin.ledger.connector.besu; + +import "google/protobuf/any.proto"; + + +message BackingLedgerUnavailableErrorPB { + + string message = 418054152; + +} 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 65405d44e2..9dcde570bb 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/backing_ledger_unavailable_error_pb.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"; diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/common/is-web3-websocket-provider-abnormal-closure-error.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/common/is-web3-websocket-provider-abnormal-closure-error.ts new file mode 100644 index 0000000000..82739d2ffe --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/common/is-web3-websocket-provider-abnormal-closure-error.ts @@ -0,0 +1,38 @@ +import { ABNORMAL_CLOSURE } from "websocket-event-codes"; + +export const WEB3_CONNECTION_NOT_OPEN_ON_SEND = "connection not open on send()"; + +/** + * Checks if an error was thrown due to the web3js websocket provider disconnecting. + * + * @param err - The error object to check. + * @returns `true` if the error is an instance of `Error`, has a `message` + * property indicating a websocket provider abnormal closure error. + * Otherwise, returns `false`. + * + * **Example:** + * ```typescript + * try { + * // ... code that might throw an error + * } catch (err: unknown) { + * if (isWeb3WebsocketProviderAbnormalClosureError(err)) { + * // Error is specifically due to websocket provider abnormal closure + * console.error("Websocket provider abnormal closure error:", err); + * } else { + * // Handle other types of errors + * console.error("Unknown error:", err); + * } + * } + * ``` + */ +export function isWeb3WebsocketProviderAbnormalClosureError( + err: unknown, +): err is Error & { code: typeof ABNORMAL_CLOSURE } { + if (!err) { + return false; + } + if (!(err instanceof Error)) { + return false; + } + return err.message.includes(WEB3_CONNECTION_NOT_OPEN_ON_SEND); +} 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 31cb240ce2..cdc1e95961 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 @@ -23,6 +23,19 @@ import type { RequestArgs } from './base'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base'; +/** + * + * @export + * @interface BackingLedgerUnavailableError + */ +export interface BackingLedgerUnavailableError { + /** + * + * @type {string} + * @memberof BackingLedgerUnavailableError + */ + 'message'?: string; +} /** * * @export diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/backing_ledger_unavailable_error_pb.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/backing_ledger_unavailable_error_pb.ts new file mode 100644 index 0000000000..ffafc464ef --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/proto/protoc-gen-ts/models/backing_ledger_unavailable_error_pb.ts @@ -0,0 +1,76 @@ +/** + * Generated by the protoc-gen-ts. DO NOT EDIT! + * compiler version: 3.19.1 + * source: models/backing_ledger_unavailable_error_pb.proto + * git: https://github.com/thesayyn/protoc-gen-ts */ +import * as dependency_1 from "./../google/protobuf/any"; +import * as pb_1 from "google-protobuf"; +export namespace org.hyperledger.cacti.plugin.ledger.connector.besu { + export class BackingLedgerUnavailableErrorPB extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + message?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("message" in data && data.message != undefined) { + this.message = data.message; + } + } + } + get message() { + return pb_1.Message.getFieldWithDefault(this, 418054152, "") as string; + } + set message(value: string) { + pb_1.Message.setField(this, 418054152, value); + } + static fromObject(data: { + message?: string; + }): BackingLedgerUnavailableErrorPB { + const message = new BackingLedgerUnavailableErrorPB({}); + if (data.message != null) { + message.message = data.message; + } + return message; + } + toObject() { + const data: { + message?: string; + } = {}; + if (this.message != null) { + data.message = this.message; + } + 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.message.length) + writer.writeString(418054152, this.message); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): BackingLedgerUnavailableErrorPB { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new BackingLedgerUnavailableErrorPB(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 418054152: + message.message = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): BackingLedgerUnavailableErrorPB { + return BackingLedgerUnavailableErrorPB.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 d469d422aa..a0dcb5099c 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,32 +4,33 @@ * 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_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 dependency_2 from "./../models/backing_ledger_unavailable_error_pb"; +import * as dependency_3 from "./../models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb"; +import * as dependency_4 from "./../models/deploy_contract_solidity_bytecode_v1_request_pb"; +import * as dependency_5 from "./../models/deploy_contract_solidity_bytecode_v1_response_pb"; +import * as dependency_6 from "./../models/get_balance_v1_request_pb"; +import * as dependency_7 from "./../models/get_balance_v1_response_pb"; +import * as dependency_8 from "./../models/get_besu_record_v1_request_pb"; +import * as dependency_9 from "./../models/get_besu_record_v1_response_pb"; +import * as dependency_10 from "./../models/get_block_v1_request_pb"; +import * as dependency_11 from "./../models/get_block_v1_response_pb"; +import * as dependency_12 from "./../models/get_past_logs_v1_request_pb"; +import * as dependency_13 from "./../models/get_past_logs_v1_response_pb"; +import * as dependency_14 from "./../models/get_transaction_v1_request_pb"; +import * as dependency_15 from "./../models/get_transaction_v1_response_pb"; +import * as dependency_16 from "./../models/invoke_contract_v1_request_pb"; +import * as dependency_17 from "./../models/invoke_contract_v1_response_pb"; +import * as dependency_18 from "./../models/run_transaction_request_pb"; +import * as dependency_19 from "./../models/run_transaction_response_pb"; +import * as dependency_20 from "./../models/sign_transaction_request_pb"; +import * as dependency_21 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; + deployContractSolidityBytecodeNoKeychainV1RequestPB?: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -40,26 +41,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } 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; + return pb_1.Message.getWrapperField(this, dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB, 1) as dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB; } - set deployContractSolidityBytecodeNoKeychainV1RequestPB(value: dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB) { + set deployContractSolidityBytecodeNoKeychainV1RequestPB(value: dependency_3.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; + 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); + message.deployContractSolidityBytecodeNoKeychainV1RequestPB = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB.fromObject(data.deployContractSolidityBytecodeNoKeychainV1RequestPB); } return message; } toObject() { const data: { - deployContractSolidityBytecodeNoKeychainV1RequestPB?: ReturnType; + deployContractSolidityBytecodeNoKeychainV1RequestPB?: ReturnType; } = {}; if (this.deployContractSolidityBytecodeNoKeychainV1RequestPB != null) { data.deployContractSolidityBytecodeNoKeychainV1RequestPB = this.deployContractSolidityBytecodeNoKeychainV1RequestPB.toObject(); @@ -82,7 +83,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def break; switch (reader.getFieldNumber()) { case 1: - reader.readMessage(message.deployContractSolidityBytecodeNoKeychainV1RequestPB, () => message.deployContractSolidityBytecodeNoKeychainV1RequestPB = dependency_2.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB.deserialize(reader)); + reader.readMessage(message.deployContractSolidityBytecodeNoKeychainV1RequestPB, () => message.deployContractSolidityBytecodeNoKeychainV1RequestPB = dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeNoKeychainV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -99,7 +100,7 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def export class DeployContractSolBytecodeV1Request extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { - deployContractSolidityBytecodeV1RequestPB?: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; + deployContractSolidityBytecodeV1RequestPB?: dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -110,26 +111,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB, 1) as dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB; } - set deployContractSolidityBytecodeV1RequestPB(value: dependency_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB) { + set deployContractSolidityBytecodeV1RequestPB(value: dependency_4.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_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.fromObject(data.deployContractSolidityBytecodeV1RequestPB); + message.deployContractSolidityBytecodeV1RequestPB = dependency_4.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(); @@ -152,7 +153,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_3.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.deserialize(reader)); + reader.readMessage(message.deployContractSolidityBytecodeV1RequestPB, () => message.deployContractSolidityBytecodeV1RequestPB = dependency_4.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -169,7 +170,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_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; + getBalanceV1RequestPB?: dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -180,26 +181,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB, 1) as dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB; } - set getBalanceV1RequestPB(value: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB) { + set getBalanceV1RequestPB(value: dependency_6.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_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.fromObject(data.getBalanceV1RequestPB); + message.getBalanceV1RequestPB = dependency_6.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(); @@ -222,7 +223,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_5.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBalanceV1RequestPB, () => message.getBalanceV1RequestPB = dependency_6.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -239,7 +240,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_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; + getBesuRecordV1RequestPB?: dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -250,26 +251,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB, 1) as dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB; } - set getBesuRecordV1RequestPB(value: dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB) { + set getBesuRecordV1RequestPB(value: dependency_8.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_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.fromObject(data.getBesuRecordV1RequestPB); + message.getBesuRecordV1RequestPB = dependency_8.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(); @@ -292,7 +293,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_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBesuRecordV1RequestPB, () => message.getBesuRecordV1RequestPB = dependency_8.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -309,7 +310,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_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; + getBlockV1RequestPB?: dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -320,26 +321,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB, 1) as dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB; } - set getBlockV1RequestPB(value: dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB) { + set getBlockV1RequestPB(value: dependency_10.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_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.fromObject(data.getBlockV1RequestPB); + message.getBlockV1RequestPB = dependency_10.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(); @@ -362,7 +363,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_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.deserialize(reader)); + reader.readMessage(message.getBlockV1RequestPB, () => message.getBlockV1RequestPB = dependency_10.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -446,7 +447,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_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; + getPastLogsV1RequestPB?: dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -457,26 +458,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB, 1) as dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB; } - set getPastLogsV1RequestPB(value: dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB) { + set getPastLogsV1RequestPB(value: dependency_12.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_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.fromObject(data.getPastLogsV1RequestPB); + message.getPastLogsV1RequestPB = dependency_12.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(); @@ -499,7 +500,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_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.deserialize(reader)); + reader.readMessage(message.getPastLogsV1RequestPB, () => message.getPastLogsV1RequestPB = dependency_12.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -583,7 +584,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_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; + getTransactionV1RequestPB?: dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -594,26 +595,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB, 1) as dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB; } - set getTransactionV1RequestPB(value: dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB) { + set getTransactionV1RequestPB(value: dependency_14.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_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.fromObject(data.getTransactionV1RequestPB); + message.getTransactionV1RequestPB = dependency_14.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(); @@ -636,7 +637,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_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.deserialize(reader)); + reader.readMessage(message.getTransactionV1RequestPB, () => message.getTransactionV1RequestPB = dependency_14.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -653,7 +654,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_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; + invokeContractV1RequestPB?: dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -664,26 +665,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB, 1) as dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB; } - set invokeContractV1RequestPB(value: dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB) { + set invokeContractV1RequestPB(value: dependency_16.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_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.fromObject(data.invokeContractV1RequestPB); + message.invokeContractV1RequestPB = dependency_16.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(); @@ -706,7 +707,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_15.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.deserialize(reader)); + reader.readMessage(message.invokeContractV1RequestPB, () => message.invokeContractV1RequestPB = dependency_16.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1RequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -723,7 +724,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_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; + runTransactionRequestPB?: dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -734,26 +735,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB, 1) as dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB; } - set runTransactionRequestPB(value: dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB) { + set runTransactionRequestPB(value: dependency_18.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_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.fromObject(data.runTransactionRequestPB); + message.runTransactionRequestPB = dependency_18.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(); @@ -776,7 +777,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_17.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.deserialize(reader)); + reader.readMessage(message.runTransactionRequestPB, () => message.runTransactionRequestPB = dependency_18.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionRequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -793,7 +794,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_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; + signTransactionRequestPB?: dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -804,26 +805,26 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def } } get 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; + return pb_1.Message.getWrapperField(this, dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB, 1) as dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB; } - set signTransactionRequestPB(value: dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB) { + set signTransactionRequestPB(value: dependency_20.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_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.fromObject(data.signTransactionRequestPB); + message.signTransactionRequestPB = dependency_20.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(); @@ -846,7 +847,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_19.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.deserialize(reader)); + reader.readMessage(message.signTransactionRequestPB, () => message.signTransactionRequestPB = dependency_20.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionRequestPB.deserialize(reader)); break; default: reader.skipField(); } @@ -892,8 +893,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def 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)) + responseSerialize: (message: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_5.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", @@ -901,8 +902,8 @@ export namespace org.hyperledger.cacti.plugin.ledger.connector.besu.services.def responseStream: false, requestSerialize: (message: DeployContractSolBytecodeV1Request) => Buffer.from(message.serialize()), requestDeserialize: (bytes: Buffer) => DeployContractSolBytecodeV1Request.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)) + responseSerialize: (message: dependency_5.org.hyperledger.cacti.plugin.ledger.connector.besu.DeployContractSolidityBytecodeV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_5.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", @@ -910,8 +911,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_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)) + responseSerialize: (message: dependency_7.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBalanceV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_7.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", @@ -919,8 +920,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_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)) + responseSerialize: (message: dependency_9.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBesuRecordV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_9.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", @@ -928,8 +929,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_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)) + responseSerialize: (message: dependency_11.org.hyperledger.cacti.plugin.ledger.connector.besu.GetBlockV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_11.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", @@ -946,8 +947,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_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)) + responseSerialize: (message: dependency_13.org.hyperledger.cacti.plugin.ledger.connector.besu.GetPastLogsV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_13.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", @@ -964,8 +965,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_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)) + responseSerialize: (message: dependency_15.org.hyperledger.cacti.plugin.ledger.connector.besu.GetTransactionV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_15.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", @@ -973,8 +974,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_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)) + responseSerialize: (message: dependency_17.org.hyperledger.cacti.plugin.ledger.connector.besu.InvokeContractV1ResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_17.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", @@ -982,8 +983,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_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)) + responseSerialize: (message: dependency_19.org.hyperledger.cacti.plugin.ledger.connector.besu.RunTransactionResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_19.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", @@ -991,62 +992,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_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)) + responseSerialize: (message: dependency_21.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => dependency_21.org.hyperledger.cacti.plugin.ledger.connector.besu.SignTransactionResponsePB.deserialize(new Uint8Array(bytes)) } }; [method: string]: grpc_1.UntypedHandleCall; - 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 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); } - 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 => { + 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 => { + 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/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts index 096be62d00..6387906209 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -1,4 +1,5 @@ import { Express, Request, Response } from "express"; +import { HttpStatusCode } from "axios"; import { Logger, @@ -6,18 +7,23 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, + HttpHeader, } from "@hyperledger/cactus-common"; import { IEndpointAuthzOptions, IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; import OAS from "../../json/openapi.json"; import { RunTransactionRequest } from "../generated/openapi/typescript-axios"; +import { isWeb3WebsocketProviderAbnormalClosureError } from "../common/is-web3-websocket-provider-abnormal-closure-error"; export interface IRunTransactionEndpointOptions { logLevel?: LogLevelDesc; @@ -82,19 +88,36 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { return this.handleRequest.bind(this); } + private handleLedgerNotAccessibleError(res: Response): void { + const fn = "handleLedgerNotAccessibleError()"; + this.log.debug( + "%s WebSocketProvider disconnected from ledger. Sending HttpStatusCode.ServiceUnavailable...", + fn, + ); + + res + .header(HttpHeader.RetryAfter, "5") + .status(HttpStatusCode.ServiceUnavailable) + .json({ + success: false, + error: "Could not establish connection to the backing ledger.", + }); + } + public async handleRequest(req: Request, res: Response): Promise { const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; + const { log } = this; this.log.debug(reqTag); const reqBody: RunTransactionRequest = req.body; try { const resBody = await this.options.connector.transact(reqBody); res.json({ success: true, data: resBody }); - } catch (ex) { - this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex?.stack || ex?.message, - }); + } catch (ex: unknown) { + if (isWeb3WebsocketProviderAbnormalClosureError(ex)) { + return this.handleLedgerNotAccessibleError(res); + } + const errorMsg = `request handler fn crashed for: ${reqTag}`; + await handleRestEndpointException({ errorMsg, log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/unit/common/is-web3-websocket-provider-abnormal-closure-error.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/unit/common/is-web3-websocket-provider-abnormal-closure-error.test.ts new file mode 100644 index 0000000000..99182e239d --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/unit/common/is-web3-websocket-provider-abnormal-closure-error.test.ts @@ -0,0 +1,41 @@ +import "jest-extended"; + +import { isWeb3WebsocketProviderAbnormalClosureError } from "../../../../main/typescript/common/is-web3-websocket-provider-abnormal-closure-error"; +import { WEB3_CONNECTION_NOT_OPEN_ON_SEND } from "../../../../main/typescript/common/is-web3-websocket-provider-abnormal-closure-error"; + +describe("isWeb3WebsocketProviderAbnormalClosureError", () => { + it("should return false for non-error values", () => { + expect(isWeb3WebsocketProviderAbnormalClosureError(null)).toBe(false); + expect(isWeb3WebsocketProviderAbnormalClosureError(undefined)).toBe(false); + expect(isWeb3WebsocketProviderAbnormalClosureError(123)).toBe(false); + expect(isWeb3WebsocketProviderAbnormalClosureError("some string")).toBe( + false, + ); + expect(isWeb3WebsocketProviderAbnormalClosureError(Symbol("symbol"))).toBe( + false, + ); + }); + + it("should return false for error objects without code property", () => { + const errorWithoutCode = new Error("Some generic error"); + expect(isWeb3WebsocketProviderAbnormalClosureError(errorWithoutCode)).toBe( + false, + ); + }); + + it("should return false for error objects with incorrect code property", () => { + const errorWithIncorrectCode: Error = new Error("Some error"); + + (errorWithIncorrectCode as unknown as Record).code = + "some_other_code"; + + expect( + isWeb3WebsocketProviderAbnormalClosureError(errorWithIncorrectCode), + ).toBe(false); + }); + + it("it returns true when the correct error message is set", () => { + const err = new Error(WEB3_CONNECTION_NOT_OPEN_ON_SEND); + expect(isWeb3WebsocketProviderAbnormalClosureError(err)).toBeTrue(); + }); +}); diff --git a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/run-transaction-endpoint.test.ts b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/run-transaction-endpoint.test.ts new file mode 100644 index 0000000000..9a548a5903 --- /dev/null +++ b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/run-transaction-endpoint.test.ts @@ -0,0 +1,125 @@ +import "jest-extended"; +import { v4 as uuidv4 } from "uuid"; +import { createServer } from "http"; +import { AddressInfo } from "net"; +import HttpStatus from "http-status-codes"; + +import { + ApiServer, + AuthorizationProtocol, + ConfigService, +} from "@hyperledger/cactus-cmd-api-server"; + +import { + BesuTestLedger, + pruneDockerAllIfGithubAction, +} from "@hyperledger/cactus-test-tooling"; + +import { + BesuApiClientOptions, + BesuApiClient, + IPluginLedgerConnectorBesuOptions, + PluginLedgerConnectorBesu, + Web3SigningCredentialType, + ReceiptType, + RunTransactionRequest, +} from "@hyperledger/cactus-plugin-ledger-connector-besu"; + +import { PluginRegistry } from "@hyperledger/cactus-core"; + +describe("ApiServer:PluginLedgerConnectorBesu", () => { + const logLevel = "TRACE"; + let apiServer: ApiServer; + let apiClient: BesuApiClient; + let ledger: BesuTestLedger; + + beforeAll(async () => { + const pruning = pruneDockerAllIfGithubAction({ logLevel }); + await expect(pruning).resolves.toBeTruthy(); + + // Initialize Besu test ledger + ledger = new BesuTestLedger({}); + await ledger.start(); + + // Setup HTTP server and ApiServer + const httpServer = createServer(); + await new Promise((resolve, reject) => { + httpServer.once("error", reject); + httpServer.once("listening", resolve); + httpServer.listen(0, "127.0.0.1"); + }); + const addressInfo = httpServer.address() as AddressInfo; + + const rpcApiHttpHost = await ledger.getRpcApiHttpHost(); + const rpcApiWsHost = await ledger.getRpcApiWsHost(); + + const pluginRegistry = new PluginRegistry(); + const options: IPluginLedgerConnectorBesuOptions = { + instanceId: uuidv4(), + rpcApiHttpHost, + rpcApiWsHost, + pluginRegistry, + logLevel, + }; + const pluginConnectorBesu = new PluginLedgerConnectorBesu(options); + pluginRegistry.add(pluginConnectorBesu); + + const configService = new ConfigService(); + const apiSrvOpts = await configService.newExampleConfig(); + apiSrvOpts.authorizationProtocol = AuthorizationProtocol.NONE; + apiSrvOpts.configFile = ""; + apiSrvOpts.apiCorsDomainCsv = "*"; + apiSrvOpts.apiPort = addressInfo.port; + apiSrvOpts.cockpitPort = 0; + apiSrvOpts.apiTlsEnabled = false; + + const config = await configService.newExampleConfigConvict(apiSrvOpts); + apiServer = new ApiServer({ + httpServerApi: httpServer, + config: config.getProperties(), + pluginRegistry, + }); + + await apiServer.start(); + + const apiClientCfg = new BesuApiClientOptions({ + basePath: `http://${addressInfo.address}:${addressInfo.port}`, + }); + apiClient = new BesuApiClient(apiClientCfg); + }); + + afterAll(async () => { + await apiServer.shutdown(); + }); + + test("API server does not crash if backing ledger is unavailable.", async () => { + const testEthAccount1 = await ledger.createEthTestAccount(); + const testEthAccount2 = await ledger.createEthTestAccount(); + const req: RunTransactionRequest = { + web3SigningCredential: { + ethAccount: testEthAccount1.address, + secret: testEthAccount1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + transactionConfig: { + from: testEthAccount1.address, + to: testEthAccount2.address, + value: 10e7, + gas: 1000000, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: 5000, + }, + }; + + await ledger.stop(); + await ledger.destroy(); + + const runTxRequest = apiClient.runTransactionV1(req); + await expect(runTxRequest).rejects.toMatchObject({ + response: { status: HttpStatus.SERVICE_UNAVAILABLE }, + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index 1bcf0ecd68..590decc863 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10383,9 +10383,11 @@ __metadata: web3: "npm:1.6.1" web3-core: "npm:1.6.1" web3-eth: "npm:1.6.1" + web3-eth-accounts: "patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch" web3-eth-contract: "npm:1.6.1" web3-utils: "npm:1.6.1" web3js-quorum: "npm:22.4.0" + websocket-event-codes: "npm:1.1.0" languageName: unknown linkType: soft @@ -28780,7 +28782,7 @@ __metadata: languageName: node linkType: hard -"ethereumjs-util@npm:^7.0.10, ethereumjs-util@npm:^7.1.0, ethereumjs-util@npm:^7.1.1, ethereumjs-util@npm:^7.1.4": +"ethereumjs-util@npm:^7.0.10, ethereumjs-util@npm:^7.1.0, ethereumjs-util@npm:^7.1.4": version: 7.1.4 resolution: "ethereumjs-util@npm:7.1.4" dependencies: @@ -28793,7 +28795,7 @@ __metadata: languageName: node linkType: hard -"ethereumjs-util@npm:^7.0.2, ethereumjs-util@npm:^7.1.2, ethereumjs-util@npm:^7.1.5": +"ethereumjs-util@npm:^7.0.2, ethereumjs-util@npm:^7.1.1, ethereumjs-util@npm:^7.1.2, ethereumjs-util@npm:^7.1.5": version: 7.1.5 resolution: "ethereumjs-util@npm:7.1.5" dependencies: @@ -54153,7 +54155,7 @@ __metadata: languageName: node linkType: hard -"web3-eth-accounts@npm:4.1.1, web3-eth-accounts@npm:^4.1.1": +"web3-eth-accounts@npm:4.1.1": version: 4.1.1 resolution: "web3-eth-accounts@npm:4.1.1" dependencies: @@ -54168,33 +54170,37 @@ __metadata: languageName: node linkType: hard -"web3-eth-accounts@npm:^4.0.3, web3-eth-accounts@npm:^4.0.5": - version: 4.0.5 - resolution: "web3-eth-accounts@npm:4.0.5" +"web3-eth-accounts@npm:^4.0.3, web3-eth-accounts@npm:^4.0.5, web3-eth-accounts@npm:^4.1.0, web3-eth-accounts@npm:^4.1.1": + version: 4.1.3 + resolution: "web3-eth-accounts@npm:4.1.3" dependencies: "@ethereumjs/rlp": "npm:^4.0.1" crc-32: "npm:^1.2.2" ethereum-cryptography: "npm:^2.0.0" - web3-errors: "npm:^1.1.1" - web3-types: "npm:^1.1.1" - web3-utils: "npm:^4.0.5" - web3-validator: "npm:^2.0.1" - checksum: 10/37e9e2d909544e3d9b8b9bf3168365cd068653b18880cb65835c9b2a3acefc885ecb18de52ead56f7a3663b33a6bb58d19e4e9fc21f2618cd9cb262a355a7dc1 + web3-errors: "npm:^1.2.0" + web3-types: "npm:^1.7.0" + web3-utils: "npm:^4.3.1" + web3-validator: "npm:^2.0.6" + checksum: 10/c5d4aa7b82517372666833e1752ffb2e768932833284de9388d710399dbdb609b129af76e4f658a0679ae18190b627e2b2331ad616ab3109c741dcd75a9e9524 languageName: node linkType: hard -"web3-eth-accounts@npm:^4.1.0": - version: 4.1.0 - resolution: "web3-eth-accounts@npm:4.1.0" +"web3-eth-accounts@patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch": + version: 1.6.1 + resolution: "web3-eth-accounts@patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch::version=1.6.1&hash=f41816" dependencies: - "@ethereumjs/rlp": "npm:^4.0.1" - crc-32: "npm:^1.2.2" - ethereum-cryptography: "npm:^2.0.0" - web3-errors: "npm:^1.1.3" - web3-types: "npm:^1.3.0" - web3-utils: "npm:^4.0.7" - web3-validator: "npm:^2.0.3" - checksum: 10/2048b3d1211593a44921a7cf200a2a407d82f832eae5751aa3b193012f4c084038814878c9423988636435f9b41967769a854ab643fb7d3cda8d898ad070be26 + "@ethereumjs/common": "npm:^2.5.0" + "@ethereumjs/tx": "npm:^3.3.2" + crypto-browserify: "npm:3.12.0" + eth-lib: "npm:0.2.8" + ethereumjs-util: "npm:^7.0.10" + scrypt-js: "npm:^3.0.1" + uuid: "npm:3.3.2" + web3-core: "npm:1.6.1" + web3-core-helpers: "npm:1.6.1" + web3-core-method: "npm:1.6.1" + web3-utils: "npm:1.6.1" + checksum: 10/5446cb368d4a6f72b85c7d0f7f1a894ae1090749d660ee0289d82b5e77f10ff885d36f2cc857ddb2c6e1a84b8081bddec3203ecc390bba43d39919e0e066502b languageName: node linkType: hard @@ -55222,6 +55228,13 @@ __metadata: languageName: node linkType: hard +"web3-types@npm:^1.7.0": + version: 1.7.0 + resolution: "web3-types@npm:1.7.0" + checksum: 10/fcd5d7a9a94579fcd01fa86dfa70e6afb269f66a7ce60e6786849e64ff6e4a107f1c25cb2784343a48952ac36d4bf3093a73b75de6ebcc971308e6b44abb211f + languageName: node + linkType: hard + "web3-utils@npm:1.10.0": version: 1.10.0 resolution: "web3-utils@npm:1.10.0" @@ -55340,6 +55353,19 @@ __metadata: languageName: node linkType: hard +"web3-utils@npm:^4.3.1": + version: 4.3.1 + resolution: "web3-utils@npm:4.3.1" + dependencies: + ethereum-cryptography: "npm:^2.0.0" + eventemitter3: "npm:^5.0.1" + web3-errors: "npm:^1.2.0" + web3-types: "npm:^1.7.0" + web3-validator: "npm:^2.0.6" + checksum: 10/88e39a6d43b756e965226b25ddc54855f26a7c13f6240b99fb521e1bae35a20a24f637f09fd0f4ef5d3f5a9e46b7f843bb5fd7ac2c9f99cfe18bb71817390f6e + languageName: node + linkType: hard + "web3-validator@npm:2.0.2": version: 2.0.2 resolution: "web3-validator@npm:2.0.2" @@ -55946,6 +55972,13 @@ __metadata: languageName: node linkType: hard +"websocket-event-codes@npm:1.1.0": + version: 1.1.0 + resolution: "websocket-event-codes@npm:1.1.0" + checksum: 10/97db632273f3de620856f984f7d17672c7c221ca80af3d2790681947f029bfc3128dd16c9ddc82e62251e0537eb0d4567ce4a5609776c09bf3996e1fc21a9332 + languageName: node + linkType: hard + "websocket-extensions@npm:>=0.1.1": version: 0.1.4 resolution: "websocket-extensions@npm:0.1.4"