bcgov / BC-Wallet-Demo

Demo of Verifiable Credentials Using the BC Wallet
https://digital.gov.bc.ca/digital-trust/showcase
Apache License 2.0
7 stars 13 forks source link

IndyError: LedgerNotFound #123

Closed trieulethe closed 1 year ago

trieulethe commented 1 year ago

I try to run a server but got the error, how i can fix that? Error: 2022-12-27 09:49:54.935 TRACE [IndyPoolService.getDidFromPool] Error retrieving did '4QxzWk3ajdnEA37NdNU5Kt' from ledger 'CandyDev' { error: IndyError: LedgerNotFound at Object.callback (/home/suntu/partime/nec/BC-Wallet-Demo/node_modules/indy-sdk/src/wrapIndyCallback.js:15:10) { indyCode: 309, indyName: 'LedgerNotFound', indyCurrentErrorJson: null }, did: '4QxzWk3ajdnEA37NdNU5Kt' } log stack:

• IndyPoolService.ts:152 getDidFromPool node_modules/@aries-framework/core/src/modules/ledger/services/IndyPoolService.ts:152:19

• IndyPoolService.ts:122 getSettledDidResponsesFromPools node_modules/@aries-framework/core/src/modules/ledger/services/IndyPoolService.ts:122:26

• IndyPoolService.ts:75 getPoolForDid node_modules/@aries-framework/core/src/modules/ledger/services/IndyPoolService.ts:75:38

2022-12-27 09:49:54.939 TRACE [IndyPoolService.getSettledDidResponsesFromPools] Retrieved 0 responses from ledgers for did '4QxzWk3ajdnEA37NdNU5Kt' log stack:

• IndyPoolService.ts:125 getSettledDidResponsesFromPools node_modules/@aries-framework/core/src/modules/ledger/services/IndyPoolService.ts:125:17

• IndyPoolService.ts:75 getPoolForDid node_modules/@aries-framework/core/src/modules/ledger/services/IndyPoolService.ts:75:38

• IndyLedgerService.ts:121 getSchema node_modules/@aries-framework/core/src/modules/ledger/services/IndyLedgerService.ts:121:22

wadeking98 commented 1 year ago

Hi @trieulethe, This error is because the agent can't find your DID on any of the ledgers CandyDev, SovrinMainNet, or SovrinStagingNet. To register your agent on a ledger, you need to need to sign up using your DID and Verkey which can be found here once you start your demo: http://localhost:5000/agent. I think CandyDev is restricted to BC Government uses and Sovrin Staging and MainNet both cost money. If you're using this for development purposes I recommend using Sovrin BuilderNet since it's free for development purposes. You can register your agent here: https://selfserve.sovrin.org/ (keep in mind this will only last for 6 months). You will also need to add BuilderNet's genesis transaction to this file: https://github.com/bcgov/BC-Wallet-Demo/blob/main/server/src/utils/utils.ts and then import and use it here (Note you will have to remove all other ledgers from the list or move BuilderNet to the top of the list for it to work): https://github.com/bcgov/BC-Wallet-Demo/blob/b1f44156076ac22f4db683f9249da4af83bf32ea/server/src/index.ts#L44 You can find BuilderNet's genesis transaction here: https://raw.githubusercontent.com/sovrin-foundation/sovrin/stable/sovrin/pool_transactions_builder_genesis.

Here are some example screenshots for of the needed code changes for clarity:

index.ts:

image

utils.ts:

image

After you've done all that, you'll also need to add the student card, member card, and person credential schemas to the ledger. To do this you'll need to interact with the agent api at http://localhost:5000. Make sure you have curl installed. Run the following curl commands from your terminal:

Student Card:

curl -X 'POST' -H 'Content-Type: application/json' -d '{"name":"student_card","version":"1.0","attributes":["student_first_name","student_last_name","expiry_date"]}' http://localhost:5000/schemas

Member Card:

curl -X 'POST' -H 'Content-Type: application/json' -d '{"name":"Member Card","version":"1.5.1","attributes":["PPID","Member Status Code","Surname","Given Name","Member Status"]}' http://localhost:5000/schemas

Person Credential:

curl -X 'POST' -H 'Content-Type: application/json' -d '{"name":"Person","version":"1.0","attributes":["given_names","region","street_address","postal_code","country","picture","birthdate_dateint","family_name","expiry_date_dateint","locality"]}' http://localhost:5000/schemas

I apologize that this process is so complicated, but I hope this helps you get started. Let me know if you have any more questions

trieulethe commented 1 year ago

Hi @wadeking98, Thank you very much for your help. I fixed the above error. I am using Von-network for development. My step: 1, Run Von-network 2, Create a pool and connect 3, Add schema 4, Run the backend image But I am stuck here when I scan QRcode on mobile, the error is: image Seem I need to add verify of student_card. Do you know how I can fix this?

wadeking98 commented 1 year ago

There's a couple issues with using VON-network from your local machine:

  1. If you're running VON-network from your computer then you need to make sure you're on the same network (ie: behind the same router, firewall, etc)
  2. You need some way of telling your wallet to connect to your VON-network ledger. Right now what's happening is that you're issuing a credential using a credential definition stored on your instance of VON-network, but your wallet doesn't know your instance on VON-network exists so it looks for the credential dentition on the main sovrin networks (Builder, Staging, and MainNet). Since it can't find the credential definition on these networks, it can't validate the credential and it shows up as an error message.

If you're going to use a local instance of von-network, you will need to add the genesis transaction to the wallet on your phone. (I don't think lissi supports adding custom ledgers like this, but trinsic does). you will need to download the genesis file from von-network as genesis.json and then upload it on your phone. In trinsic you can do this by going to settings / Network and then clicking the add icon

trieulethe commented 1 year ago

Hi @wadeking98, I am trying to run BC-Wallet on mobile(https://github.com/hyperledger/aries-mobile-agent-react-native) but it cannot connect to my ACA-PY mediator network: I start ACA with the command:

  aca-py start --label "Demo Agent" --trace-target log --trace-tag acapy.events --trace-label issuer.Agent.trace --log-level DEBUG \
  --auto-accept-invites --auto-accept-requests --auto-respond-messages --auto-ping-connection --public-invites \
  --enable-undelivered-queue \
  --auto-accept-intro-invitation-requests \
  --genesis-url http://192.168.1.78:9000/genesis --wallet-type indy --wallet-name "trieult" --wallet-key "123456" --auto-provision \
  -e http://192.168.1.78:8020 -it http 0.0.0.0 8020 -ot http --admin 0.0.0.0 8021 --admin-insecure-mode --auto-store-credential \
  --open-mediation

then I run mobile get the error:

image image

What is my problem and how to fix that? Thank you for your help and support!

wadeking98 commented 1 year ago

The people at this repo will be able to help you out better with mediator issues: https://github.com/hyperledger/aries-cloudagent-python. This repository is just for the BC wallet showcase demo.