Skip to content

Commit

Permalink
feat(cactus-plugin-ledger-connector-ethereum): refactor connector API
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
outSH authored and petermetz committed Oct 10, 2023
1 parent e2812f4 commit cda279f
Show file tree
Hide file tree
Showing 31 changed files with 997 additions and 1,475 deletions.
11 changes: 11 additions & 0 deletions packages/cactus-common/src/main/typescript/error-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,16 @@ export function safeStringifyException(error: unknown): string {
return sanitizeHtml(error.stack || error.message);
}

// Axios and possibly other lib errors produce nicer output with toJSON() method.
// Use it if available
if (
error &&
typeof error === "object" &&
"toJSON" in error &&
typeof error.toJSON === "function"
) {
return sanitizeHtml(error.toJSON());
}

return sanitizeHtml(safeStringify(error));
}
4 changes: 2 additions & 2 deletions packages/cactus-plugin-ledger-connector-ethereum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async transact(req: RunTransactionRequest): Promise<RunTransactionResponse>;
async transactSigned(rawTransaction: string): Promise<RunTransactionResponse>;
async transactGethKeychain(txIn: RunTransactionRequest): Promise<RunTransactionResponse>;
async transactPrivateKey(req: RunTransactionRequest): Promise<RunTransactionResponse>;
async transactCactusKeychainRef(req: RunTransactionRequest):Promise<RunTransactionResponse>;
async transactCactiKeychainRef(req: RunTransactionRequest):Promise<RunTransactionResponse>;
async deployContract(req: DeployContractSolidityBytecodeV1Request :Promise<DeployContractSolidityBytecodeV1Response>;
async deployContractJsonObject(req: DeployContractSolidityBytecodeJsonObjectV1Request): Promise<DeployContractSolidityBytecodeV1Response>
async invokeRawWeb3EthMethod(req: InvokeRawWeb3EthMethodV1Request): Promise<any>;
Expand All @@ -77,7 +77,7 @@ The field "type" can have the following values:
```typescript
enum Web3SigningCredentialType {
CACTUSKEYCHAINREF = "CACTUS_KEYCHAIN_REF",
CACTUSKEYCHAINREF = "CACTI_KEYCHAIN_REF",
GETHKEYCHAINPASSWORD = "GETH_KEYCHAIN_PASSWORD",
PRIVATEKEYHEX = "PRIVATE_KEY_HEX",
NONE = "NONE",
Expand Down
7 changes: 4 additions & 3 deletions packages/cactus-plugin-ledger-connector-ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Allows Cactus nodes to connect to a Ethereum ledger.",
"keywords": [
"Hyperledger",
"Cacti",
"Cactus",
"Integration",
"Blockchain",
Expand All @@ -19,9 +20,9 @@
},
"license": "Apache-2.0",
"author": {
"name": "Hyperledger Cactus Contributors",
"email": "cactus@lists.hyperledger.org",
"url": "https://www.hyperledger.org/use/cactus"
"name": "Hyperledger Cacti Contributors",
"email": "cacti@lists.hyperledger.org",
"url": "https://www.hyperledger.org/use/cacti"
},
"contributors": [
{
Expand Down
Loading

0 comments on commit cda279f

Please sign in to comment.