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

feat: agent flow for proof presentation #98

Merged
merged 6 commits into from
Oct 3, 2024
Merged

Conversation

berendsliedrecht
Copy link
Member

Signed-off-by: Berend Sliedrecht [email protected]

@berendsliedrecht berendsliedrecht force-pushed the add-credo-flow branch 3 times, most recently from d398720 to a50320e Compare October 1, 2024 11:59
@@ -0,0 +1,164 @@
import {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main request proof functionality

@@ -0,0 +1,200 @@
import {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main share proof functionality.

Comment on lines +19 to +24
const onFailure = () => console.error('[CENTRAL]: failure')
const onConnected = () => console.log('[CENTRAL]: connected')
const onDisconnected = () => console.log('[CENTRAL]: disconnected')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make the example a bit more in-depth? Would you usually do some reconnection stuff here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really depends on the flow. I see them more as like UI update items. they are not too relevant.

Comment on lines 19 to 21
useEffect(() => {
setupAgent().then(setAgent)
}, [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had issues with this in past, where setupAgent was called multiple times. I think we should handle it with state, or we can make it a useSetupAgent hook, which handles it with state internally ( and returns the agent afterwards ).

I know it's an example, but good to make the example follow best practices

})
})

const disconnctedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const disconnctedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => {
const disconnectedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => {

Comment on lines 148 to 155
if (proofRecord.id === id) {
if (proofRecord.state === ProofState.PresentationReceived) {
const pp = agent.proofs.config.proofProtocols.find((x) => x.version === 'v2')
const { message } = await pp.acceptPresentation(agent.context, { proofRecord })
const serializedMessage = JsonTransformer.serialize(message)
await peripheral.sendMessage(serializedMessage)
off()
resolve(proofRecord)
} else if ([ProofState.Abandoned, ProofState.Declined].includes(proofRecord.state)) {
off()
reject(new Error(`Proof could not be shared because it has been ${proofRecord.state}`))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but usually if (proofRecord.id !==) return looks cleaner

@@ -0,0 +1,109 @@
// import {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anymore?

Comment on lines 27 to 32
const formatData = await agent.proofs.getFormatData(proofRecord.id)
const proofRepository = agent.dependencyManager.resolve(ProofRepository)
proofRecord.metadata.set(METADATA_KEY_FORMAT_DATA, formatData)
await proofRepository.update(agent.context, proofRecord)
agent.events.off(ProofEventTypes.ProofStateChanged, listener)
resolve(proofRecord)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this for the example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not really.

patches/@hyperledger__indy-vdr-react-native.patch Outdated Show resolved Hide resolved
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Berend Sliedrecht <[email protected]>
@berendsliedrecht berendsliedrecht merged commit a282608 into main Oct 3, 2024
2 checks passed
@berendsliedrecht berendsliedrecht deleted the add-credo-flow branch October 3, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants