Skip to content

Commit d8d538d

Browse files
wangyinglunpetermetz
wangyinglun
authored andcommitted
feat(connector-tcs-huawei): add initial version
Signed-off-by: wangyinglun <[email protected]>
1 parent aade510 commit d8d538d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2799
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MeterInfo.json
2+
3+
# BLP artifacts
4+
etc/
5+
6+
# don't commit package-lock
7+
package-lock.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2020-2021 Hyperledger Cactus Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* BalanceManagement.ts
6+
*/
7+
8+
import {
9+
LPInfoHolder,
10+
ConfigUtil,
11+
} from "@hyperledger/cactus-cmd-socketio-server";
12+
import {
13+
VerifierFactory,
14+
VerifierFactoryConfig,
15+
} from "@hyperledger/cactus-verifier-client";
16+
17+
const config: any = ConfigUtil.getConfig();
18+
import { getLogger } from "log4js";
19+
const moduleName = "BalanceManagement";
20+
const logger = getLogger(`${moduleName}`);
21+
logger.level = config.logLevel;
22+
23+
export class BalanceManagement {
24+
private connectInfo: LPInfoHolder = null; // connection information
25+
private readonly verifierFactory: VerifierFactory;
26+
27+
constructor() {
28+
this.connectInfo = new LPInfoHolder();
29+
this.verifierFactory = new VerifierFactory(
30+
this.connectInfo.ledgerPluginInfo as VerifierFactoryConfig,
31+
config.logLevel,
32+
);
33+
}
34+
35+
getBalance(account: string): Promise<any> {
36+
return new Promise((resolve, reject) => {
37+
// for LedgerOperation
38+
// const execData = {"referedAddress": account};
39+
// const ledgerOperation: LedgerOperation = new LedgerOperation("getNumericBalance", "", execData);
40+
41+
// for Neo
42+
const contract = {}; // NOTE: Since contract does not need to be specified, specify an empty object.
43+
const method = { type: "web3Eth", command: "getBalance" };
44+
const template = "default";
45+
const args = { args: [account] };
46+
// const method = "default";
47+
// const args = {"method": {type: "web3Eth", command: "getBalance"}, "args": {"args": [account]}};
48+
49+
this.verifierFactory
50+
.getVerifier("84jUisrs")
51+
.sendSyncRequest(contract, method, args)
52+
.then((result) => {
53+
const response = {
54+
status: result.status,
55+
amount: parseFloat(result.data),
56+
};
57+
resolve(response);
58+
})
59+
.catch((err) => {
60+
logger.error(err);
61+
reject(err);
62+
});
63+
});
64+
}
65+
}

0 commit comments

Comments
 (0)