-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connector-tcs-huawei): add initial version
Signed-off-by: wangyinglun <wangyinglun3@huawei.com>
- Loading branch information
Showing
52 changed files
with
2,799 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MeterInfo.json | ||
|
||
# BLP artifacts | ||
etc/ | ||
|
||
# don't commit package-lock | ||
package-lock.json |
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,65 @@ | ||
/* | ||
* Copyright 2020-2021 Hyperledger Cactus Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* BalanceManagement.ts | ||
*/ | ||
|
||
import { | ||
LPInfoHolder, | ||
ConfigUtil, | ||
} from "@hyperledger/cactus-cmd-socketio-server"; | ||
import { | ||
VerifierFactory, | ||
VerifierFactoryConfig, | ||
} from "@hyperledger/cactus-verifier-client"; | ||
|
||
const config: any = ConfigUtil.getConfig(); | ||
import { getLogger } from "log4js"; | ||
const moduleName = "BalanceManagement"; | ||
const logger = getLogger(`${moduleName}`); | ||
logger.level = config.logLevel; | ||
|
||
export class BalanceManagement { | ||
private connectInfo: LPInfoHolder = null; // connection information | ||
private readonly verifierFactory: VerifierFactory; | ||
|
||
constructor() { | ||
this.connectInfo = new LPInfoHolder(); | ||
this.verifierFactory = new VerifierFactory( | ||
this.connectInfo.ledgerPluginInfo as VerifierFactoryConfig, | ||
config.logLevel, | ||
); | ||
} | ||
|
||
getBalance(account: string): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
// for LedgerOperation | ||
// const execData = {"referedAddress": account}; | ||
// const ledgerOperation: LedgerOperation = new LedgerOperation("getNumericBalance", "", execData); | ||
|
||
// for Neo | ||
const contract = {}; // NOTE: Since contract does not need to be specified, specify an empty object. | ||
const method = { type: "web3Eth", command: "getBalance" }; | ||
const template = "default"; | ||
const args = { args: [account] }; | ||
// const method = "default"; | ||
// const args = {"method": {type: "web3Eth", command: "getBalance"}, "args": {"args": [account]}}; | ||
|
||
this.verifierFactory | ||
.getVerifier("84jUisrs") | ||
.sendSyncRequest(contract, method, args) | ||
.then((result) => { | ||
const response = { | ||
status: result.status, | ||
amount: parseFloat(result.data), | ||
}; | ||
resolve(response); | ||
}) | ||
.catch((err) => { | ||
logger.error(err); | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.