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

Support 2 new attachment types in CCF codec #2516

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions encoding/ccf/ccf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7746,6 +7746,8 @@ func TestEncodeSimpleTypes(t *testing.T) {
for _, ty := range []simpleTypes{
{cadence.AnyType{}, ccf.TypeAny},
{cadence.AnyResourceType{}, ccf.TypeAnyResource},
{cadence.AnyStructAttachmentType{}, ccf.TypeAnyStructAttachmentType},
{cadence.AnyResourceAttachmentType{}, ccf.TypeAnyResourceAttachmentType},
{cadence.MetaType{}, ccf.TypeMetaType},
{cadence.VoidType{}, ccf.TypeVoid},
{cadence.NeverType{}, ccf.TypeNever},
Expand Down
6 changes: 6 additions & 0 deletions encoding/ccf/decode_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ func (d *Decoder) decodeSimpleTypeID() (cadence.Type, error) {
case TypeVoid:
return cadence.TheVoidType, nil

case TypeAnyStructAttachmentType:
return cadence.TheAnyStructAttachmentType, nil

case TypeAnyResourceAttachmentType:
return cadence.TheAnyResourceAttachmentType, nil

default:
return nil, fmt.Errorf("unsupported encoded simple type ID %d", simpleTypeID)
}
Expand Down
8 changes: 8 additions & 0 deletions encoding/ccf/simple_type_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const ( // Cadence simple type IDs
TypeFunction
TypeWord128
TypeWord256
TypeAnyStructAttachmentType
TypeAnyResourceAttachmentType
)

// NOTE: cadence.FunctionType isn't included in simpleTypeIDByType
Expand Down Expand Up @@ -249,6 +251,12 @@ func simpleTypeIDByType(typ cadence.Type) (uint64, bool) {

case cadence.DeployedContractType:
return TypeDeployedContract, true

case cadence.AnyStructAttachmentType:
return TypeAnyStructAttachmentType, true

case cadence.AnyResourceAttachmentType:
return TypeAnyResourceAttachmentType, true
}

return 0, false
Expand Down