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(demo): add AVMProvider #20

Merged
merged 6 commits into from
Aug 29, 2024
Merged

feat(demo): add AVMProvider #20

merged 6 commits into from
Aug 29, 2024

Conversation

PhearZero
Copy link
Member

@PhearZero PhearZero commented Aug 19, 2024

ℹ Overview

  • adds AVMProvider to Liqud Auth Demo
  • removes crypto library in favor of Algo Models

Blocked By

📝 Related Issues

✅ Acceptance:

  • Conventional Commits

@PhearZero PhearZero self-assigned this Aug 19, 2024
@PhearZero PhearZero marked this pull request as ready for review August 28, 2024 21:33

// Must be unique to this provider
val providerId = uuidGenerator.generate().toString()
private val provider = AVMProvider(providerId)
Copy link
Contributor

Choose a reason for hiding this comment

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

The AVMProvider is being imported from demo and we are creating the class in the demo package.

Can't we just import the actual package and use that?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could offer a base interface with empty stubs or go with a more advanced strategy. The wallets would need to handle the signing operations and anything extra like Bio-metrics. We only are dependent on the message shapes/encoding at this point

}
}
// TODO: Refactor to ByteArray and allow streaming of the Buffer
val resultMessage = provider.handleRequestMessage(Message(Base64.UrlSafe.decode(msgStr), EncoderType.CBOR), keyPair)
Copy link
Contributor

Choose a reason for hiding this comment

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

handleRequestMessage should probably be from an agnostic interface that any AVM / Identity / other context can implement so that. Can we do that? Should be straight forward; maybe the interface can live in liquid code package

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be that way now, it does accepts a generic Message which is only the bytes and the encoding (not specifying ARC27 schema).

I named the method handleRequestMessage since it only handles RequestMessages from ARC27 (the most common use case for the Wallet and the AVMProvider). I could refactor it to handleMessage and have it support both?

* A provider for the Algorand Virtual Machine (AVM).
* Used to test the provider.avm.models package.
*/
class AVMProvider(val providerId: String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class should be part of the provider package?

Copy link
Member Author

@PhearZero PhearZero Aug 28, 2024

Choose a reason for hiding this comment

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

In continuing with #20 (comment), there are a few ways we could make this generic with a BaseProvider. It was included before we simplified, possibly it was over simplified?

I couldn't find a good shape that was useful outside of Observables, since we don't depend on the providers shape or interacting with multiple providers in a single application. It made sense to just make a concrete example of using the Models directly.

Example Base:

enum class EncoderType {
    MSGPACK,
    BASE64,
    CBOR,
    NONE
}
interface IMessage {
  payload: ByteArray
  encoding: EncoderType
}

interface IBaseProvider {
    fun handleMessage(message: IMessage): Any
}

Copy link
Contributor

@ehanoc ehanoc Aug 29, 2024

Choose a reason for hiding this comment

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

Lets to this! And the base interfaces can live in the liquid core package. Thanks !

@ehanoc ehanoc merged commit 4026bfb into develop Aug 29, 2024
1 check passed
@PhearZero PhearZero deleted the feat/avm-provider branch November 20, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants