-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connector-iroha2): update to the new LTS image as of 28.07.2023
- Change iroha2 setup docker and helper classes to work with the new LTS image. - Update Iroha SDK packages to the newest. - Fix some tests that were failing after upgrade. - Adjust SDK usage (new version doesn't create Torii client, arguments are provided with each method instead) - Use pinned iroha2 container version in all in one image. - Use skopeo to pre-download pinend image version. Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
- Loading branch information
Showing
21 changed files
with
682 additions
and
287 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
67 changes: 67 additions & 0 deletions
67
...r-connector-iroha2/src/main/typescript/cactus-iroha-sdk-wrapper/prerequisites-provider.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Provider for IrohaV2 ToriiRequirements needed by Iroha2 SDK. | ||
*/ | ||
|
||
import { | ||
IsomorphicWebSocketAdapter, | ||
ToriiRequirementsForApiWebSocket, | ||
ToriiRequirementsForApiHttp, | ||
} from "@iroha2/client"; | ||
|
||
// This module can't be imported unless we use `nodenext` moduleResolution | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { adapter: irohaWSAdapter } = require("@iroha2/client/web-socket/node"); | ||
import { fetch as undiciFetch } from "undici"; | ||
|
||
/** | ||
* Helper class that returns ToriiRequirements for different Iroha2 commands. | ||
* Can be created with missing parameters, if they are required for requested requirement | ||
* an exception will be thrown. | ||
*/ | ||
export class IrohaV2PrerequisitesProvider { | ||
/** | ||
* IrohaV2 isomorphic ws adapter | ||
*/ | ||
public webSocketAdapter: IsomorphicWebSocketAdapter = irohaWSAdapter; | ||
|
||
/** | ||
* IrohaV2 isomorphic fetch adapter | ||
*/ | ||
public fetchAdapter = (undiciFetch as any) as typeof fetch; | ||
|
||
constructor(public apiURL?: string, public telemetryURL?: string) {} | ||
|
||
/** | ||
* Get requirements for executing API calls on web socket protocol. | ||
* @returns `ToriiRequirementsForApiWebSocket` | ||
*/ | ||
getApiWebSocketProperties(): ToriiRequirementsForApiWebSocket { | ||
if (!this.apiURL || !this.webSocketAdapter) { | ||
throw new Error( | ||
"Missing required arguments: apiURL and iroha ws adapter", | ||
); | ||
} | ||
|
||
return { | ||
apiURL: this.apiURL, | ||
ws: this.webSocketAdapter, | ||
}; | ||
} | ||
|
||
/** | ||
* Get requirements for executing API calls on HTTP protocol. | ||
* @returns `ToriiRequirementsForApiHttp` | ||
*/ | ||
getApiHttpProperties(): ToriiRequirementsForApiHttp { | ||
if (!this.apiURL || !this.fetchAdapter) { | ||
throw new Error( | ||
"Missing required arguments: apiURL and iroha fetch adapter", | ||
); | ||
} | ||
|
||
return { | ||
apiURL: this.apiURL, | ||
fetch: this.fetchAdapter, | ||
}; | ||
} | ||
} |
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.