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: allow union return types #71

Merged
merged 3 commits into from
Nov 17, 2021
Merged

feat: allow union return types #71

merged 3 commits into from
Nov 17, 2021

Conversation

TimoGlastra
Copy link
Collaborator

Fixes #54

It's a bit hacky because uplink doesn't support union types but pydantic does. So basically what I've done is that if the return type is union it will put it as a variable in a wrapper model and use pydantic to choose which of the types of the union to transform.

Tested with the transaction endorser for schema and it will return the correct schema based on whether you're using endorsement:

with endorsement:

sent=None txn=TransactionRecord(type=None, connection_id='089ff39d-dc54-4caa-8485-3d3bb5092afd', created_at='2021-11-16 20:31:27.671716Z', endorser_write_txn=None, formats=[{'attach_id': '4d7d457f-26b3-41b4-9af3-8c41a5910f9d', 'format': 'dif/endorse-transaction/request@v1.0'}], messages_attach=[{'@id': '4d7d457f-26b3-41b4-9af3-8c41a5910f9d', 'mime-type': 'application/json', 'data': {'json': '{"endorser":"F3WNyQVcSqPHu8hxLTh52s","identifier":"F3WNyQVcSqPHu8hxLTh52s","operation":{"data":{"attr_names":["test"],"name":"schema_namerrr0.6131096105546552","version":"1.0.0"},"type":"101"},"protocolVersion":2,"reqId":1637094687666071000,"signatures":{"F3WNyQVcSqPHu8hxLTh52s":"3NxQN1tB7CLHWYcNxFLWke2XxrhWA19F4QWvPBfdy4FTEKFyHJ8FoEDDo8ZhDjEVXNMTersgKESGsKTbkjtF4WWb"},"taaAcceptance":{"mechanism":"on_file","taaDigest":"251e2c7f2fbd23cb2c70d9ef8e66d7bbc6a84ebafcb85f3d39b8f197b5041ee7","time":1636934400}}'}}], signature_request=[], signature_response=[], state='transaction_created', thread_id=None, timing={}, trace=False, transaction_id='a135caf0-efa2-4ee6-b954-f46e780b3ace', updated_at='2021-11-16 20:31:27.671716Z')

No endorsement

schema_=ModelSchema(attr_names=['test'], id='F3WNyQVcSqPHu8hxLTh52s:2:schema_namerrr0.2997454197312166:1.0.0', name='schema_namerrr0.2997454197312166', seq_no=23701, ver='1.0', version='1.0.0') schema_id='F3WNyQVcSqPHu8hxLTh52s:2:schema_namerrr0.2997454197312166:1.0.0'

Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@morrieinmaas morrieinmaas merged commit 1362312 into main Nov 17, 2021
@TimoGlastra TimoGlastra deleted the feat/allow-union branch February 24, 2022 09:34
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.

Enable transaction endorser role
2 participants