hashgraph / did-sdk-js

Javascript SDK for managing DID Documents & Verifiable Credentials
Apache License 2.0
21 stars 13 forks source link

CREATE did transaction throws timeout error #71

Open nicola-attico opened 2 years ago

nicola-attico commented 2 years ago

Description

This is the error:

Error subscribing to topic 0.0.34026405 during attempt 0. Waiting 250 ms before next attempt: Topic 0.0.34026405 does not exist
/home/nicola/hdid/node_modules/@hashgraph/did-sdk-js/dist/identity/hcs/message-transaction.js:49
            throw new Error(err.message);
                  ^

Error: timeout exceeded
    at HcsDidTransaction.handleError (/home/nicola/hdid/node_modules/@hashgraph/did-sdk-js/dist/identity/hcs/message-transaction.js:49:19)
    at HcsDidTransaction.<anonymous> (/home/nicola/hdid/node_modules/@hashgraph/did-sdk-js/dist/identity/hcs/message-transaction.js:161:22)
    at Generator.throw (<anonymous>)
    at rejected (/home/nicola/hdid/node_modules/@hashgraph/did-sdk-js/dist/identity/hcs/message-transaction.js:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

This is the code that allows to reproduce the issue:

const { Client, AccountId, PrivateKey, Hbar } = require('@hashgraph/sdk')
const { HcsIdentityNetworkBuilder, DidMethodOperation } = require('@hashgraph/did-sdk-js')

require('dotenv').config()

async function main () {
  console.log(process.env.HCLI_MIRROR_PROVIDER)

  const client = Client
    .forName(process.env.HCLI_NETWORK)
    .setOperator(AccountId.fromString(process.env.HCLI_PAYER), PrivateKey.fromString(process.env.HCLI_PAYERPRIVKEY))
    .setMirrorNetwork(process.env.HCLI_MIRROR_PROVIDER)

  const identityNetwork = await new HcsIdentityNetworkBuilder()
    .setNetwork(process.env.HCLI_NETWORK)
    .setAppnetName('MyIdentityAppnet')
    .addAppnetDidServer('https://appnet-did-server-url:port/path-to-did-api')
    .setPublicKey(PrivateKey.fromString(process.env.HCLI_PAYERPRIVKEY).publicKey)
    .setMaxTransactionFee(new Hbar(2))
    .setDidTopicMemo('MyIdentityAppnet DID topic')
    .setVCTopicMemo('MyIdentityAppnet VC topic')
    .execute(client)

  console.log(identityNetwork)

  const did = identityNetwork.generateDid(true)

  console.log(did)

  const didRootKey = did.getPrivateDidRootKey()

  console.log(didRootKey)

  const didDocument = did.generateDidDocument()

  console.log(didDocument)

  await identityNetwork.createDidTransaction(DidMethodOperation.CREATE)
    .setDidDocument(JSON.stringify(didDocument))
    .signMessage(doc => didRootKey.sign(doc))
    .buildAndSignTransaction(tx => tx.setMaxTransactionFee(new Hbar(2)))
    .onMessageConfirmed(msg => {
      console.log(msg)
    })
    .execute(client)
}

main()

The format of the .env file is:

HCLI_PAYER=0.0.xxx
HCLI_PAYERPRIVKEY=yyyyyyyyyyy
HCLI_NETWORK=testnet
HCLI_MIRROR_PROVIDER=hcs.testnet.mirrornode.hedera.com:5600

Steps to reproduce

  1. Run the script with the .env file set

Additional context

No response

Hedera network

testnet

Version

current testnet version

Operating system

Linux

roshanking000 commented 1 year ago

I have same issue. What is the solution?