Skip to content

Commit cda279f

Browse files
outSHpetermetz
authored andcommitted
feat(cactus-plugin-ledger-connector-ethereum): refactor connector API
- Refactor to single `invokeContract` endpoint that can accept multiple methods of supplying contract definition (directly, from keychain, etc..). - Same for `deployContract` method. - Update cactus-common `safeStringifyException` function to better handle axios errors (and other custom exceptions that support `toJSON()` method.). - Use common error handling in all connector endpoints (except prometheus). - Fix the tests. - Switch to `Cacti` work in entire connector (except for package name) Co-authored-by: Peter Somogyvari <[email protected]> 1. Updated the yarn.lock file to reflect the changes in the package.json Depends on: #2630 Signed-off-by: Michal Bajer <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
1 parent e2812f4 commit cda279f

31 files changed

+997
-1475
lines changed

packages/cactus-common/src/main/typescript/error-utils.ts

+11
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,16 @@ export function safeStringifyException(error: unknown): string {
2828
return sanitizeHtml(error.stack || error.message);
2929
}
3030

31+
// Axios and possibly other lib errors produce nicer output with toJSON() method.
32+
// Use it if available
33+
if (
34+
error &&
35+
typeof error === "object" &&
36+
"toJSON" in error &&
37+
typeof error.toJSON === "function"
38+
) {
39+
return sanitizeHtml(error.toJSON());
40+
}
41+
3142
return sanitizeHtml(safeStringify(error));
3243
}

packages/cactus-plugin-ledger-connector-ethereum/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async transact(req: RunTransactionRequest): Promise<RunTransactionResponse>;
5252
async transactSigned(rawTransaction: string): Promise<RunTransactionResponse>;
5353
async transactGethKeychain(txIn: RunTransactionRequest): Promise<RunTransactionResponse>;
5454
async transactPrivateKey(req: RunTransactionRequest): Promise<RunTransactionResponse>;
55-
async transactCactusKeychainRef(req: RunTransactionRequest):Promise<RunTransactionResponse>;
55+
async transactCactiKeychainRef(req: RunTransactionRequest):Promise<RunTransactionResponse>;
5656
async deployContract(req: DeployContractSolidityBytecodeV1Request :Promise<DeployContractSolidityBytecodeV1Response>;
5757
async deployContractJsonObject(req: DeployContractSolidityBytecodeJsonObjectV1Request): Promise<DeployContractSolidityBytecodeV1Response>
5858
async invokeRawWeb3EthMethod(req: InvokeRawWeb3EthMethodV1Request): Promise<any>;
@@ -77,7 +77,7 @@ The field "type" can have the following values:
7777
7878
```typescript
7979
enum Web3SigningCredentialType {
80-
CACTUSKEYCHAINREF = "CACTUS_KEYCHAIN_REF",
80+
CACTUSKEYCHAINREF = "CACTI_KEYCHAIN_REF",
8181
GETHKEYCHAINPASSWORD = "GETH_KEYCHAIN_PASSWORD",
8282
PRIVATEKEYHEX = "PRIVATE_KEY_HEX",
8383
NONE = "NONE",

packages/cactus-plugin-ledger-connector-ethereum/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Allows Cactus nodes to connect to a Ethereum ledger.",
55
"keywords": [
66
"Hyperledger",
7+
"Cacti",
78
"Cactus",
89
"Integration",
910
"Blockchain",
@@ -19,9 +20,9 @@
1920
},
2021
"license": "Apache-2.0",
2122
"author": {
22-
"name": "Hyperledger Cactus Contributors",
23-
"email": "cactus@lists.hyperledger.org",
24-
"url": "https://www.hyperledger.org/use/cactus"
23+
"name": "Hyperledger Cacti Contributors",
24+
"email": "cacti@lists.hyperledger.org",
25+
"url": "https://www.hyperledger.org/use/cacti"
2526
},
2627
"contributors": [
2728
{

0 commit comments

Comments
 (0)