1
- const indy = require ( 'indy-sdk ' )
1
+ const vdrtools = require ( 'vdr-tools ' )
2
2
const logger = require ( './logging/logger-main' )
3
3
const fs = require ( 'fs' )
4
4
const os = require ( 'os' )
@@ -10,11 +10,11 @@ const LEDGER_NAME_TO_CODE = {
10
10
}
11
11
12
12
async function registerLedger ( poolName , genesisFilePath ) {
13
- await indy . createPoolLedgerConfig ( poolName , { genesis_txn : genesisFilePath } )
13
+ await vdrtools . createPoolLedgerConfig ( poolName , { genesis_txn : genesisFilePath } )
14
14
}
15
15
16
16
async function getListOfRegisteredLedgers ( ) {
17
- let pools = await indy . listPools ( )
17
+ let pools = await vdrtools . listPools ( )
18
18
return pools . map ( ledger => ledger . pool )
19
19
}
20
20
@@ -29,7 +29,7 @@ async function isKnownLedger (ledgerName) {
29
29
30
30
async function createIndyClient ( ledgerName , genesisPath = undefined ) {
31
31
const whoami = `IndyClient[${ ledgerName } ]`
32
- await indy . setProtocolVersion ( 2 )
32
+ await vdrtools . setProtocolVersion ( 2 )
33
33
34
34
if ( await isUnknownLedger ( ledgerName ) ) {
35
35
if ( ! genesisPath ) {
@@ -43,24 +43,24 @@ async function createIndyClient (ledgerName, genesisPath = undefined) {
43
43
let genesisData = fs . readFileSync ( `${ os . homedir ( ) } /.indy_client/pool/${ ledgerName } /${ ledgerName } .txn` )
44
44
logger . info ( `${ whoami } Using genesis: ${ genesisData } ` )
45
45
logger . info ( `${ whoami } Connecting to ledger ${ ledgerName } .` )
46
- const poolHandle = await indy . openPoolLedger ( ledgerName )
46
+ const poolHandle = await vdrtools . openPoolLedger ( ledgerName )
47
47
logger . info ( `${ whoami } Connected to ledger ${ ledgerName } .` )
48
48
49
49
const walletName = `indyscan-${ ledgerName } `
50
50
logger . info ( `${ whoami } Assuring local wallet.` )
51
51
const config = JSON . stringify ( { id : walletName , storage_type : 'default' } )
52
52
const credentials = JSON . stringify ( { key : 'ke®y' } )
53
53
try {
54
- await indy . createWallet ( config , credentials )
54
+ await vdrtools . createWallet ( config , credentials )
55
55
logger . debug ( `New wallet '${ walletName } ' created.` )
56
56
} catch ( err ) {
57
57
if ( err . message !== 'WalletAlreadyExistsError' ) {
58
58
logger . error ( `Unexpected error trying to create a wallet: ${ err . message } ${ JSON . stringify ( err . stack ) } ` )
59
59
}
60
60
}
61
- const wh = await indy . openWallet ( config , credentials )
61
+ const wh = await vdrtools . openWallet ( config , credentials )
62
62
logger . debug ( `${ whoami } Opened wallet '${ walletName } '.` )
63
- const res = await indy . createAndStoreMyDid ( wh , { } )
63
+ const res = await vdrtools . createAndStoreMyDid ( wh , { } )
64
64
const did = res [ 0 ]
65
65
logger . debug ( `${ whoami } Created did/verkey ${ JSON . stringify ( res ) } ` )
66
66
@@ -71,9 +71,9 @@ async function createIndyClient (ledgerName, genesisPath = undefined) {
71
71
*/
72
72
async function getTx ( subledgerName , seqNo ) {
73
73
const subledgerCode = LEDGER_NAME_TO_CODE [ subledgerName . toLowerCase ( ) ]
74
- const getTx = await indy . buildGetTxnRequest ( did , subledgerCode , seqNo )
74
+ const getTx = await vdrtools . buildGetTxnRequest ( did , subledgerCode , seqNo )
75
75
logger . debug ( `${ whoami } Built GET_TX request: ${ JSON . stringify ( getTx ) } ` )
76
- const tx = await indy . submitRequest ( poolHandle , getTx )
76
+ const tx = await vdrtools . submitRequest ( poolHandle , getTx )
77
77
if ( tx . op === 'REPLY' ) {
78
78
if ( tx . result . data ) {
79
79
return tx . result . data
0 commit comments