forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(connector-go-eth): upgrade web3.js to recent version
- Upgrade web3 package used by go-ethereum-socketio connector from "0.20.7" to "1.8.1" - Major cleanup and refactor of go-ethereum-socketio logic, without affecting the current functionalities. - Add safety checking of method called in web3Eth and contract functions. Add tests to check if it works. - Add websocket eth RPC support and some helper functions in openethereum-test-ledger. - Expose WS RPC in geth-testnet, use this port in sample apps (required to monitor new blocks in updated web3.js) - Change raw use of sendRawTransaction to sendSignedTransaction in sample apps in order to conform to new web3.js version. - Add safeStringifyException to cactus-common that can be used by validators to sanitize response errors. - Refactor socketio-based validators to use safeStringifyException. - Adjust connector README files. - Improve cleanup after running sample apps - Fix discounted-cartrade sample ethereum transfer and checking Closes hyperledger-cacti#2088 Depends on hyperledger-cacti#2053 Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
- Loading branch information
Showing
29 changed files
with
1,025 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import safeStringify from "fast-safe-stringify"; | ||
import sanitizeHtml from "sanitize-html"; | ||
|
||
/** | ||
* Utility class for better exception handling by way of having a code property | ||
* which is designated to uniquely identify the type of exception that was | ||
* thrown, essentially acting as a discriminator property. | ||
*/ | ||
export class CodedError extends Error { | ||
constructor(public readonly message: string, public readonly code: string) { | ||
super(message); | ||
} | ||
|
||
sameCode(codedError: CodedError): boolean { | ||
return this.code === codedError?.code; | ||
} | ||
} | ||
|
||
/** | ||
* Return secure string representation of error from the input. | ||
* Handles circular structures and removes HTML. | ||
* | ||
* @param error Any object to return as an error, preferable `Error` | ||
* @returns Safe string representation of an error. | ||
*/ | ||
export function safeStringifyException(error: unknown): string { | ||
if (error instanceof Error) { | ||
return sanitizeHtml(error.stack || error.message); | ||
} | ||
|
||
return sanitizeHtml(safeStringify(error)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cactus-common/src/test/typescript/unit/coded-error.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.