Add support for importing Attachment and AttachmentType #4301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #3114
Description
This PR adds support for importing
Attachmentvalues andAttachmentTypetypes in the Cadence runtime, addressing issue #3114 which identified that while attachments could be exported, they could not be imported.The implementation follows the existing pattern used for other composite types (Struct, Resource, Event, etc.) by leveraging the fact that
AttachmentTypealready implements theCompositeTypeinterface.Changes
runtime/convertTypes.go
*cadence.AttachmentTypeto the type switch inImportType()so attachment types are routed through the existingimportCompositeType()functionruntime/convertValues.go
cadence.Attachmentcase to the value switch inimportValue()to handle attachment value imports viaimportCompositeValue()runtime/convertValues_test.go
TestRuntimeImportAttachmentValue: Tests importing attachment values with fieldsTestRuntimeImportAttachmentType: Tests importing attachment types directlyTestRuntimeImportTypeValueOfAttachmentType: Tests importing TypeValues containing attachment typesReview Focus
Correctness of delegation: The implementation relies on existing composite type import infrastructure. Verify that
importCompositeValue()correctly handles attachment-specific concerns.Test coverage: Tests cover basic scenarios but use
TestLocationfor simplicity. Consider whether additional integration tests with real contract locations are needed.Edge cases: Verify there are no attachment-specific edge cases (e.g., attachment base type handling, attachment inheritance) that need special consideration beyond what the existing composite type logic provides.
Link to Devin run: https://app.devin.ai/sessions/1b6b7a027cc6487fbe1d7c3b87cc60e1
Requested by: [email protected]
masterbranchFiles changedin the Github PR explorer