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.
- Use eth signing utils from ethereum connector package.
- Fix nodejs setup in indy-sdk-cli docker image.
- Small fixes after recent ethereum connector refactors.

Depends on: #2645

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH authored and petermetz committed Oct 17, 2023
1 parent b8f9b79 commit dcaf9fe
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 532 deletions.
20 changes: 8 additions & 12 deletions examples/cactus-example-discounted-asset-trade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Alice will use credentials and other Indy formats such as schema and definition
### 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 indy-sdk@1.16.0-dev-1649` (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 }
1e+26

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

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


# Fabric:
Expand Down Expand Up @@ -231,13 +227,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.

8 changes: 3 additions & 5 deletions examples/cactus-example-discounted-asset-trade/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@
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));
logger.debug("result(getBalance) = " + result);
res.status(200).json(result);
})
.catch((err) => {
Expand Down
Loading

0 comments on commit dcaf9fe

Please sign in to comment.