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

AgreementStoreManager fails when agreement not found #297

Open
H34D opened this issue Jun 24, 2022 · 0 comments
Open

AgreementStoreManager fails when agreement not found #297

H34D opened this issue Jun 24, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@H34D
Copy link
Contributor

H34D commented Jun 24, 2022

Describe the bug

public async getAgreement(agreementId: string): Promise<AgreementData> {
const templateId: string = await this.call('getAgreementTemplate', [
zeroX(agreementId)
])
const events = await this.templates[templateId].getAgreementCreatedEvent(
agreementId
)
const values = events.map(e => e.returnValues || e)
const { _did, _didOwner, _conditionIds, _conditionIdSeeds } = values[0]
return {
did: _did,
agreementId,
didOwner: _didOwner,
templateId,
conditionIdSeeds: _conditionIdSeeds,
conditionIds: _conditionIds
} as AgreementData
}

Will lead to:

TypeError: Cannot destructure property '_did' of 'values[0]' as it is undefined.

if the agreement id was not found.

To Reproduce

Steps to reproduce the behavior:

  1. Try to load agreement Id that does not exist
  2. fail

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

@H34D H34D added the bug Something isn't working label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant