Skip to content

Commit

Permalink
Merge pull request #217 from Patrik-Stas/release/4.6.0
Browse files Browse the repository at this point in the history
Release 4.6.0, use vdrtools indy indypool-client
  • Loading branch information
Patrik-Stas authored Aug 5, 2023
2 parents 27e2117 + fc57cdb commit 3f96f72
Show file tree
Hide file tree
Showing 18 changed files with 2,156 additions and 3,991 deletions.
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

0 comments on commit 3f96f72

Please sign in to comment.