Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.6.0, use vdrtools indy indypool-client #217

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,859 changes: 2,080 additions & 3,779 deletions indypool-client/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions indypool-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "indyscan-daemon",
"version": "4.5.2",
"version": "4.6.0",
"author": "Patrik Staš",
"license": "ISC",
"description": "Application scanning Hyperledger Indy blockchain for fetching and processing transactions.",
Expand All @@ -15,7 +15,7 @@
"dependencies": {
"cross-env": "^5.2.0",
"dotenv": "^7.0.0",
"indy-sdk": "1.15.0",
"vdr-tools": "0.8.5",
"sleep-promise": "^8.0.1",
"util": "^0.11.1",
"uuid": "^3.3.2",
Expand Down
20 changes: 10 additions & 10 deletions indypool-client/src/indyclient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const indy = require('indy-sdk')
const vdrtools = require('vdr-tools')
const logger = require('./logging/logger-main')
const fs = require('fs')
const os = require('os')
Expand All @@ -10,11 +10,11 @@ const LEDGER_NAME_TO_CODE = {
}

async function registerLedger (poolName, genesisFilePath) {
await indy.createPoolLedgerConfig(poolName, { genesis_txn: genesisFilePath })
await vdrtools.createPoolLedgerConfig(poolName, { genesis_txn: genesisFilePath })
}

async function getListOfRegisteredLedgers () {
let pools = await indy.listPools()
let pools = await vdrtools.listPools()
return pools.map(ledger => ledger.pool)
}

Expand All @@ -29,7 +29,7 @@ async function isKnownLedger (ledgerName) {

async function createIndyClient (ledgerName, genesisPath = undefined) {
const whoami = `IndyClient[${ledgerName}]`
await indy.setProtocolVersion(2)
await vdrtools.setProtocolVersion(2)

if (await isUnknownLedger(ledgerName)) {
if (!genesisPath) {
Expand All @@ -43,24 +43,24 @@ async function createIndyClient (ledgerName, genesisPath = undefined) {
let genesisData = fs.readFileSync(`${os.homedir()}/.indy_client/pool/${ledgerName}/${ledgerName}.txn`)
logger.info(`${whoami} Using genesis: ${genesisData}`)
logger.info(`${whoami} Connecting to ledger ${ledgerName}.`)
const poolHandle = await indy.openPoolLedger(ledgerName)
const poolHandle = await vdrtools.openPoolLedger(ledgerName)
logger.info(`${whoami} Connected to ledger ${ledgerName}.`)

const walletName = `indyscan-${ledgerName}`
logger.info(`${whoami} Assuring local wallet.`)
const config = JSON.stringify({ id: walletName, storage_type: 'default' })
const credentials = JSON.stringify({ key: 'ke®y' })
try {
await indy.createWallet(config, credentials)
await vdrtools.createWallet(config, credentials)
logger.debug(`New wallet '${walletName}' created.`)
} catch (err) {
if (err.message !== 'WalletAlreadyExistsError') {
logger.error(`Unexpected error trying to create a wallet: ${err.message} ${JSON.stringify(err.stack)}`)
}
}
const wh = await indy.openWallet(config, credentials)
const wh = await vdrtools.openWallet(config, credentials)
logger.debug(`${whoami} Opened wallet '${walletName}'.`)
const res = await indy.createAndStoreMyDid(wh, {})
const res = await vdrtools.createAndStoreMyDid(wh, {})
const did = res[0]
logger.debug(`${whoami} Created did/verkey ${JSON.stringify(res)}`)

Expand All @@ -71,9 +71,9 @@ async function createIndyClient (ledgerName, genesisPath = undefined) {
*/
async function getTx (subledgerName, seqNo) {
const subledgerCode = LEDGER_NAME_TO_CODE[subledgerName.toLowerCase()]
const getTx = await indy.buildGetTxnRequest(did, subledgerCode, seqNo)
const getTx = await vdrtools.buildGetTxnRequest(did, subledgerCode, seqNo)
logger.debug(`${whoami} Built GET_TX request: ${JSON.stringify(getTx)}`)
const tx = await indy.submitRequest(poolHandle, getTx)
const tx = await vdrtools.submitRequest(poolHandle, getTx)
if (tx.op === 'REPLY') {
if (tx.result.data) {
return tx.result.data
Expand Down
4 changes: 2 additions & 2 deletions indyscan-api-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion indyscan-api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "indyscan-api-client",
"version": "4.5.2",
"version": "4.6.0",
"author": "Patrik Staš",
"license": "ISC",
"description": "IndyScan HTTP API client.",
Expand Down
Loading