Skip to content

Commit

Permalink
feat(cactus-example-discounted-asset-trade): use openapi ethereum con…
Browse files Browse the repository at this point in the history
…nector

- Refactor discounted asset trade sample to use openapi ethereum connector instead
    of ethereum-socketio.
- Sample still uses offline signing from cmd-socketio-server

Depends on: #2645
  • Loading branch information
outSH committed Sep 28, 2023
1 parent 30a0910 commit 5e45a2d
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 515 deletions.
22 changes: 9 additions & 13 deletions examples/cactus-example-discounted-asset-trade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ Alice will use credentials and other Indy formats such as schema and definition

## Setup Overview

### fabric-socketio
### fabric-validator

- Validator for fabric ledger.
- Started as part of discounted asset trade BLP.

### ethereum-validator

- Validator for ethereum ledger.
- Docker network: `geth1net`, `cactus-example-discounted-asset-trade-net`
- Started as part of discounted asset trade BLP.

### indy-sdk-cli-base-image

Expand Down Expand Up @@ -112,7 +112,6 @@ Alice will use credentials and other Indy formats such as schema and definition
This will build and launch all needed containers, the final output should look like this:

```
cactus-example-discounted-asset-trade-ethereum-validator | listening on *:5050
...
cactus-example-discounted-asset-trade-indy-validator | 2022-01-31 16:00:49,552 INFO success: validator entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
...
Expand Down Expand Up @@ -151,10 +150,7 @@ For development purposes, it might be useful to run the sample application outsi
1. Add indy-sdk node package: `yarn add [email protected]` (or edit `package.json` directly)
1. Configure cactus and start the ledgers as described above.
1. Run `./script-dockerless-config-patch.sh` from `cactus-example-discounted-asset-trade/` directory. This will patch the configs and copy it to global location.
1. Start validators (each in separate cmd window).
1. ```bash
cd packages/cactus-plugin-ledger-connector-go-ethereum-socketio/ && npm run start
```
1. Start Indy validator (in separate cmd window).
1. ```bash
docker build tools/docker/indy-sdk-cli -t indy-sdk-cli &&
pushd packages-python/cactus_validator_socketio_indy/ && sh ./setup_indy.sh && popd &&
Expand All @@ -175,13 +171,13 @@ For development purposes, it might be useful to run the sample application outsi
```
# Ethereum fromAccount:
{ status: 200, amount: 1e+26 }
100000105000000000000000000

# Ethereum escrowAccount:
{ status: 200, amount: 0 }
0

# Ethereum toAccount:
{ status: 200, amount: 0 }
0


# Fabric:
Expand Down Expand Up @@ -240,13 +236,13 @@ For development purposes, it might be useful to run the sample application outsi

```
# Ethereum fromAccount:
{ status: 200, amount: 1.00000045e+26 }
100000184999999999999999975
# Ethereum escrowAccount:
{ status: 200, amount: 0 }
0
# Ethereum toAccount:
{ status: 200, amount: 25 }
25
# Fabric:
Expand Down

This file was deleted.

6 changes: 2 additions & 4 deletions examples/cactus-example-discounted-asset-trade/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@
import { Router, NextFunction, Request, Response } from "express";
import { ConfigUtil } from "@hyperledger/cactus-cmd-socketio-server";
import { RIFError } from "@hyperledger/cactus-cmd-socketio-server";
import { BalanceManagement } from "./balance-management";

const config: any = ConfigUtil.getConfig();
import { getLogger } from "log4js";
import { getAccountBalance } from "./transaction-ethereum";
const moduleName = "balance";
const logger = getLogger(`${moduleName}`);
logger.level = config.logLevel;

const router: Router = Router();
const balanceManagement: BalanceManagement = new BalanceManagement();

/* GET balance. */
router.get("/:account", (req: Request, res: Response, next: NextFunction) => {
try {
balanceManagement
.getBalance(req.params.account)
getAccountBalance(req.params.account)
.then((result) => {
logger.debug(`#####[sample/balance.ts]`);
logger.debug("result(getBalance) = " + JSON.stringify(result));
Expand Down
Loading

0 comments on commit 5e45a2d

Please sign in to comment.