Skip to content

Commit

Permalink
Merge pull request #2405 from onflow/sainati/entitled-references
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Jun 1, 2023
2 parents 7856e8a + f9b39e2 commit 5739c86
Show file tree
Hide file tree
Showing 79 changed files with 6,848 additions and 2,256 deletions.
215 changes: 0 additions & 215 deletions docs/subtyping.md

This file was deleted.

23 changes: 11 additions & 12 deletions encoding/ccf/ccf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6881,7 +6881,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.String("a"),
cadence.String("b"),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(false, cadence.NewStringType()),
cadence.NewReferenceType(cadence.UnauthorizedAccess, cadence.NewStringType()),
)),
expected: []byte{
// language=json, format=json-cdc
Expand Down Expand Up @@ -6929,7 +6929,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.NewOptional(cadence.String("a")),
cadence.NewOptional(nil),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(false, cadence.NewOptionalType(cadence.NewStringType())),
cadence.NewReferenceType(cadence.UnauthorizedAccess, cadence.NewOptionalType(cadence.NewStringType())),
)),
expected: []byte{
// language=json, format=json-cdc
Expand Down Expand Up @@ -6978,8 +6978,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
KeyType: cadence.TheStringType,
ElementType: &cadence.OptionalType{
Type: &cadence.ReferenceType{
Type: cadence.TheInt128Type,
Authorized: false,
Type: cadence.TheInt128Type,
},
},
}
Expand Down Expand Up @@ -7055,7 +7054,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.String("a"),
cadence.NewUInt8(1),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(false, cadence.NewAnyStructType()),
cadence.NewReferenceType(cadence.UnauthorizedAccess, cadence.NewAnyStructType()),
)),
expected: []byte{
// language=json, format=json-cdc
Expand Down Expand Up @@ -7123,7 +7122,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.String("b"),
}).WithType(simpleStructType),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(false, simpleStructType),
cadence.NewReferenceType(cadence.UnauthorizedAccess, simpleStructType),
))
}(),
expected: []byte{
Expand Down Expand Up @@ -7216,7 +7215,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.String("b"),
}).WithType(simpleStructType),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(false, cadence.NewAnyStructType()),
cadence.NewReferenceType(cadence.UnauthorizedAccess, cadence.NewAnyStructType()),
))
}(),
expected: []byte{
Expand Down Expand Up @@ -7321,7 +7320,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
cadence.NewOptional(nil),
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewReferenceType(
false,
cadence.UnauthorizedAccess,
cadence.NewOptionalType(cadence.NewAnyStructType()),
))),
expected: []byte{
Expand Down Expand Up @@ -7393,7 +7392,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewOptionalType(
cadence.NewReferenceType(
false,
cadence.UnauthorizedAccess,
cadence.NewAnyStructType(),
)))),
expected: []byte{
Expand Down Expand Up @@ -7465,7 +7464,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) {
}).WithType(cadence.NewVariableSizedArrayType(
cadence.NewOptionalType(
cadence.NewReferenceType(
false,
cadence.UnauthorizedAccess,
cadence.NewOptionalType(
cadence.NewAnyStructType(),
))))),
Expand Down Expand Up @@ -8828,8 +8827,8 @@ func TestEncodeType(t *testing.T) {
t,
cadence.TypeValue{
StaticType: &cadence.ReferenceType{
Authorized: false,
Type: cadence.IntType{},
Authorization: cadence.UnauthorizedAccess,
Type: cadence.IntType{},
},
},
[]byte{
Expand Down
8 changes: 5 additions & 3 deletions encoding/ccf/decode_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ func (d *Decoder) decodeReferenceType(
}

// element 0: authorized
authorized, err := d.dec.DecodeBool()
// TODO: implement in later PR
// authorized, err := d.dec.DecodeBool()
if err != nil {
return nil, err
}
Expand All @@ -508,8 +509,9 @@ func (d *Decoder) decodeReferenceType(
if elementType == nil {
return nil, errors.New("unexpected nil type as reference type")
}

return cadence.NewMeteredReferenceType(d.gauge, authorized, elementType), nil
// TODO: implement in later PR
// return cadence.NewMeteredReferenceType(d.gauge, authorized, elementType), nil
return nil, nil
}

// decodeRestrictedType decodes restricted-type or restricted-type-value as
Expand Down
3 changes: 2 additions & 1 deletion encoding/ccf/encode_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ func (e *Encoder) encodeReferenceTypeWithRawTag(
}

// element 0: authorized as bool
err = e.enc.EncodeBool(typ.Authorized)
// TODO: implement in later PR
// err = e.enc.EncodeBool(typ.Authorized)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 5739c86

Please sign in to comment.