-
Notifications
You must be signed in to change notification settings - Fork 138
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
Account type #2648
Account type #2648
Conversation
…g include identity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far! I checked most of the implementation code. What's remaining is the tests. Will check them in the next iteration.
With #2751 and #2755 merged into Stable Cadence, I now reverted the removal of the composite static type ID caching changes in this PR. Conflict resolution for the merge:$ git log -1 -p -w --remerge-diff 28ee8ade85c6b3280efd0ce7c5e611d0fa14c95d commit 28ee8ade85c6b3280efd0ce7c5e611d0fa14c95d
Merge: ff83742c9 3773020ec
Author: Bastian Müller <[email protected]>
Date: Tue Aug 29 15:59:17 2023 -0700
Merge branch 'bastian/sync-stable-cadence-6' into bastian/account-type
diff --git a/encoding/json/encoding_test.go b/encoding/json/encoding_test.go
index 3fcfcb6a7..5aa668f6d 100644
--- a/encoding/json/encoding_test.go
+++ b/encoding/json/encoding_test.go
@@ -202,7 +202,7 @@ func TestDecodeInvalidAddress(t *testing.T) {
msg := `{"type":"Address","value":"000000000102030405"}`
- _, err := json.Decode(nil, []byte(msg))
+ _, err := Decode(nil, []byte(msg))
require.ErrorContains(t, err, "invalid address prefix: (shown as hex) expected 3078, got 3030")
}
diff --git a/runtime/capabilitycontrollers_test.go b/runtime/capabilitycontrollers_test.go
index 403e05168..bf7234a1c 100644
--- a/runtime/capabilitycontrollers_test.go
+++ b/runtime/capabilitycontrollers_test.go
@@ -1910,7 +1910,7 @@ func TestRuntimeCapabilityControllers(t *testing.T) {
import Test from 0x1
transaction {
- prepare(signer: AuthAccount) {
+ prepare(signer: auth(Storage, Capabilities) &Account) {
let storagePath = /storage/r
let resourceID = 42
@@ -2428,11 +2428,11 @@ func TestRuntimeCapabilityControllers(t *testing.T) {
import Test from 0x1
transaction {
- prepare(signer: AuthAccount) {
+ prepare(signer: auth(Capabilities) &Account) {
// Arrange
- let issuedCap: Capability<&AuthAccount> =
- signer.capabilities.account.issue<&AuthAccount>()
+ let issuedCap: Capability<&Account> =
+ signer.capabilities.account.issue<&Account>()
let controller1: &AccountCapabilityController =
signer.capabilities.account.getController(byCapabilityID: issuedCap.id)!
let controller2: &AccountCapabilityController =
@@ -2443,8 +2443,8 @@ func TestRuntimeCapabilityControllers(t *testing.T) {
let controller2Cap = controller2.capability
// Assert
- assert(controller1Cap.borrow<&AuthAccount>() != nil)
- assert(controller2Cap.borrow<&AuthAccount>() != nil)
+ assert(controller1Cap.borrow<&Account>() != nil)
+ assert(controller2Cap.borrow<&Account>() != nil)
}
}
`,
diff --git a/runtime/convertValues.go b/runtime/convertValues.go
index dba5c70d9..522ff25b1 100644
--- a/runtime/convertValues.go
+++ b/runtime/convertValues.go
@@ -1310,7 +1310,8 @@ func (i valueImporter) importCompositeValue(
inter := i.inter
locationRange := i.locationRange
- compositeType, typeErr := inter.GetCompositeType(location, qualifiedIdentifier)
+ typeID := common.NewTypeIDFromQualifiedName(inter, location, qualifiedIdentifier)
+ compositeType, typeErr := inter.GetCompositeType(location, qualifiedIdentifier, typeID)
if typeErr != nil {
return nil, typeErr
}
diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go
index a30daa203..b2bdbc851 100644
--- a/runtime/convertValues_test.go
+++ b/runtime/convertValues_test.go
@@ -1160,36 +1160,28 @@ func TestRuntimeImportRuntimeType(t *testing.T) {
actual: &cadence.StructType{
QualifiedIdentifier: "AccountKey",
},
- expected: interpreter.CompositeStaticType{
- QualifiedIdentifier: "AccountKey",
- },
+ expected: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "AccountKey"),
},
{
label: "PublicKey",
actual: &cadence.StructType{
QualifiedIdentifier: "PublicKey",
},
- expected: interpreter.CompositeStaticType{
- QualifiedIdentifier: "PublicKey",
- },
+ expected: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "PublicKey"),
},
{
label: "HashAlgorithm",
actual: &cadence.StructType{
QualifiedIdentifier: "HashAlgorithm",
},
- expected: interpreter.CompositeStaticType{
- QualifiedIdentifier: "HashAlgorithm",
- },
+ expected: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "HashAlgorithm"),
},
{
label: "SignatureAlgorithm",
actual: &cadence.StructType{
QualifiedIdentifier: "SignatureAlgorithm",
},
- expected: interpreter.CompositeStaticType{
- QualifiedIdentifier: "SignatureAlgorithm",
- },
+ expected: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "SignatureAlgorithm"),
},
{
label: "Optional",
@@ -2240,7 +2232,7 @@ func TestRuntimeExportCapabilityValue(t *testing.T) {
capability := interpreter.NewUnmeteredCapabilityValue(
3,
interpreter.AddressValue{0x1},
- interpreter.NewCompositeStaticType(inter, TestLocation, "S"),
+ interpreter.NewCompositeStaticTypeComputeTypeID(inter, TestLocation, "S"),
)
actual, err := exportValueWithInterpreter(
diff --git a/runtime/entitlements_test.go b/runtime/entitlements_test.go
remerge CONFLICT (content): Merge conflict in runtime/entitlements_test.go
index ba4bd3732..de0b5878a 100644
--- a/runtime/entitlements_test.go
+++ b/runtime/entitlements_test.go
@@ -951,13 +951,8 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
resource R {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
->>>>>>> 3773020ec (remove TODO)
let r <- create R()
account.storage.save(<-r, to: /storage/foo)
@@ -985,19 +980,11 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
struct S {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
let s = S()
account.storage.save(s, to: /storage/foo)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
-
- let s = S()
- account.save(s, to: /storage/foo)
->>>>>>> 3773020ec (remove TODO)
let issuedCap = account.capabilities.storage.issue<auth(X) &S>(/storage/foo)
account.capabilities.publish(issuedCap, at: /public/foo)
@@ -1022,19 +1009,11 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
struct S {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
let s = S()
account.storage.save(s, to: /storage/foo)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
-
- let s = S()
- account.save(s, to: /storage/foo)
->>>>>>> 3773020ec (remove TODO)
let issuedCap = account.capabilities.storage.issue<&S>(/storage/foo)
account.capabilities.publish(issuedCap, at: /public/foo)
@@ -1063,19 +1042,11 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
resource R {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
let r <- create R()
account.storage.save(<-r, to: /storage/foo)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
-
- let r <- create R()
- account.save(<-r, to: /storage/foo)
->>>>>>> 3773020ec (remove TODO)
let issuedCap = account.capabilities.storage.issue<auth(X, Y) &R>(/storage/foo)
account.capabilities.publish(issuedCap, at: /public/foo)
@@ -1100,19 +1071,11 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
resource R {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
let r <- create R()
account.storage.save(<-r, to: /storage/foo)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
-
- let r <- create R()
- account.save(<-r, to: /storage/foo)
->>>>>>> 3773020ec (remove TODO)
let issuedCap = account.capabilities.storage.issue<auth(X) &R>(/storage/foo)
account.capabilities.publish(issuedCap, at: /public/foo)
@@ -1137,19 +1100,11 @@ func TestRuntimeCapabilityEntitlements(t *testing.T) {
resource R {}
access(all)
-<<<<<<< ff83742c9 (improve naming)
fun main() {
let account = getAuthAccount<auth(Storage, Capabilities) &Account>(0x1)
let r <- create R()
account.storage.save(<-r, to: /storage/foo)
-=======
- fun main() {
- let account = getAuthAccount(0x1)
-
- let r <- create R()
- account.save(<-r, to: /storage/foo)
->>>>>>> 3773020ec (remove TODO)
let issuedCap = account.capabilities.storage.issue<auth(X) &R>(/storage/foo)
account.capabilities.publish(issuedCap, at: /public/foo)
diff --git a/runtime/imported_values_memory_metering_test.go b/runtime/imported_values_memory_metering_test.go
index 69c7472dc..3418fe15f 100644
--- a/runtime/imported_values_memory_metering_test.go
+++ b/runtime/imported_values_memory_metering_test.go
@@ -396,7 +396,7 @@ func TestRuntimeImportedValueMemoryMetering(t *testing.T) {
executeScript(t, script, meter, structValue)
assert.Equal(t, uint64(1), meter[common.MemoryKindCompositeValueBase])
- assert.Equal(t, uint64(284), meter[common.MemoryKindRawString])
+ assert.Equal(t, uint64(71), meter[common.MemoryKindRawString])
})
}
diff --git a/runtime/interpreter/decode.go b/runtime/interpreter/decode.go
index cb54854c6..2fd7c66c8 100644
--- a/runtime/interpreter/decode.go
+++ b/runtime/interpreter/decode.go
@@ -1351,7 +1351,7 @@ func (d TypeDecoder) decodeCompositeStaticType() (StaticType, error) {
return nil, err
}
- return NewCompositeStaticType(d.memoryGauge, location, qualifiedIdentifier), nil
+ return NewCompositeStaticTypeComputeTypeID(d.memoryGauge, location, qualifiedIdentifier), nil
}
func (d TypeDecoder) decodeInterfaceStaticType() (InterfaceStaticType, error) {
diff --git a/runtime/interpreter/encoding_test.go b/runtime/interpreter/encoding_test.go
index c6117e4bd..56650ac62 100644
--- a/runtime/interpreter/encoding_test.go
+++ b/runtime/interpreter/encoding_test.go
@@ -3458,7 +3458,7 @@ func TestEncodeDecodeTypeValue(t *testing.T) {
identifier := strings.Repeat("x", int(maxInlineElementSize+1))
expected := TypeValue{
- Type: NewCompositeStaticType(
+ Type: NewCompositeStaticTypeComputeTypeID(
nil,
common.AddressLocation{},
identifier,
@@ -3494,7 +3494,7 @@ func TestEncodeDecodeStaticType(t *testing.T) {
t.Parallel()
- ty := NewCompositeStaticType(nil, nil, "PublicKey")
+ ty := NewCompositeStaticTypeComputeTypeID(nil, nil, "PublicKey")
encoded := cbor.RawMessage{
// tag
@@ -3661,7 +3661,7 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) {
value := &StorageCapabilityControllerValue{
TargetPath: publicPathValue,
BorrowType: ReferenceStaticType{
- ReferencedType: NewCompositeStaticType(
+ ReferencedType: NewCompositeStaticTypeComputeTypeID(
nil,
utils.TestLocation,
"SimpleStruct",
diff --git a/runtime/interpreter/interpreter.go b/runtime/interpreter/interpreter.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/interpreter.go
index f542909b0..df602b038 100644
--- a/runtime/interpreter/interpreter.go
+++ b/runtime/interpreter/interpreter.go
@@ -3242,7 +3242,7 @@ func lookupInterface(interpreter *Interpreter, typeID string) (*sema.InterfaceTy
return nil, err
}
- typ, err := interpreter.getInterfaceType(location, qualifiedIdentifier)
+ typ, err := interpreter.GetInterfaceType(location, qualifiedIdentifier, TypeID(typeID))
if err != nil {
return nil, err
}
@@ -3257,11 +3257,7 @@ func lookupComposite(interpreter *Interpreter, typeID string) (*sema.CompositeTy
return nil, err
}
-<<<<<<< ff83742c9 (improve naming)
- typ, err := interpreter.GetCompositeType(location, qualifiedIdentifier)
-=======
typ, err := interpreter.GetCompositeType(location, qualifiedIdentifier, TypeID(typeID))
->>>>>>> 3773020ec (remove TODO)
if err != nil {
return nil, err
}
@@ -4481,16 +4477,11 @@ func (interpreter *Interpreter) ConvertStaticToSemaType(staticType StaticType) (
return ConvertStaticToSemaType(
config.MemoryGauge,
staticType,
- func(location common.Location, qualifiedIdentifier string) (*sema.InterfaceType, error) {
- return interpreter.getInterfaceType(location, qualifiedIdentifier)
+ func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.InterfaceType, error) {
+ return interpreter.GetInterfaceType(location, qualifiedIdentifier, typeID)
},
-<<<<<<< ff83742c9 (improve naming)
- func(location common.Location, qualifiedIdentifier string) (*sema.CompositeType, error) {
- return interpreter.GetCompositeType(location, qualifiedIdentifier)
-=======
func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.CompositeType, error) {
return interpreter.GetCompositeType(location, qualifiedIdentifier, typeID)
->>>>>>> 3773020ec (remove TODO)
},
interpreter.getEntitlement,
interpreter.getEntitlementMapType,
@@ -4562,27 +4553,15 @@ func (interpreter *Interpreter) GetContractComposite(contractLocation common.Add
func (interpreter *Interpreter) GetCompositeType(
location common.Location,
qualifiedIdentifier string,
-<<<<<<< ff83742c9 (improve naming)
-=======
typeID TypeID,
->>>>>>> 3773020ec (remove TODO)
) (*sema.CompositeType, error) {
var compositeType *sema.CompositeType
- var typeID common.TypeID
if location == nil {
compositeType = sema.NativeCompositeTypes[qualifiedIdentifier]
if compositeType != nil {
return compositeType, nil
}
- typeID = common.TypeID(qualifiedIdentifier)
} else {
-<<<<<<< ff83742c9 (improve naming)
- typeID = location.TypeID(interpreter, qualifiedIdentifier)
-
- compositeType = interpreter.getUserCompositeType(location, typeID)
- if compositeType != nil {
- return compositeType, nil
-=======
config := interpreter.SharedState.Config
compositeTypeHandler := config.CompositeTypeHandler
if compositeTypeHandler != nil {
@@ -4590,7 +4569,6 @@ func (interpreter *Interpreter) GetCompositeType(
if compositeType != nil {
return compositeType, nil
}
->>>>>>> 3773020ec (remove TODO)
}
compositeType = interpreter.getUserCompositeType(location, typeID)
@@ -4613,13 +4591,15 @@ func (interpreter *Interpreter) getUserCompositeType(location common.Location, t
return elaboration.CompositeType(typeID)
}
-func (interpreter *Interpreter) getInterfaceType(location common.Location, qualifiedIdentifier string) (*sema.InterfaceType, error) {
+func (interpreter *Interpreter) GetInterfaceType(
+ location common.Location,
+ qualifiedIdentifier string,
+ typeID TypeID,
+) (*sema.InterfaceType, error) {
if location == nil {
return nil, InterfaceMissingLocationError{QualifiedIdentifier: qualifiedIdentifier}
}
- typeID := location.TypeID(interpreter, qualifiedIdentifier)
-
elaboration := interpreter.getElaboration(location)
if elaboration == nil {
return nil, TypeLoadingError{
diff --git a/runtime/interpreter/interpreter_transaction.go b/runtime/interpreter/interpreter_transaction.go
index 7c9d472b6..ece979924 100644
--- a/runtime/interpreter/interpreter_transaction.go
+++ b/runtime/interpreter/interpreter_transaction.go
@@ -52,7 +52,7 @@ func (interpreter *Interpreter) declareTransactionEntryPoint(declaration *ast.Tr
interpreter.Program.Elaboration.PostConditionsRewrite(declaration.PostConditions)
const qualifiedIdentifier = ""
- staticType := NewCompositeStaticType(interpreter, interpreter.Location, qualifiedIdentifier)
+ staticType := NewCompositeStaticTypeComputeTypeID(interpreter, interpreter.Location, qualifiedIdentifier)
self := NewSimpleCompositeValue(
interpreter,
diff --git a/runtime/interpreter/primitivestatictype.go b/runtime/interpreter/primitivestatictype.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/primitivestatictype.go
index 37e0310e5..7063c7d03 100644
--- a/runtime/interpreter/primitivestatictype.go
+++ b/runtime/interpreter/primitivestatictype.go
@@ -395,8 +395,6 @@ func (t PrimitiveStaticType) elementSize() uint {
panic(errors.NewUnexpectedError("missing case for %s", t))
}
-<<<<<<< ff83742c9 (improve naming)
-=======
func (t PrimitiveStaticType) Equal(other StaticType) bool {
otherPrimitiveType, ok := other.(PrimitiveStaticType)
if !ok {
@@ -423,7 +421,6 @@ func (t PrimitiveStaticType) ID() TypeID {
return t.SemaType().ID()
}
->>>>>>> 3773020ec (remove TODO)
func (t PrimitiveStaticType) SemaType() sema.Type {
switch t {
case PrimitiveStaticTypeVoid:
@@ -559,7 +556,6 @@ func (t PrimitiveStaticType) SemaType() sema.Type {
return sema.StorageCapabilityControllerType
case PrimitiveStaticTypeAccountCapabilityController:
return sema.AccountCapabilityControllerType
-<<<<<<< ff83742c9 (improve naming)
case PrimitiveStaticTypeAuthAccount,
PrimitiveStaticTypePublicAccount,
@@ -655,18 +651,6 @@ func (t PrimitiveStaticType) SemaType() sema.Type {
return sema.CapabilitiesMappingType
case PrimitiveStaticTypeAccountMapping:
return sema.AccountMappingType
-=======
- case PrimitiveStaticTypeAuthAccountStorageCapabilities:
- return sema.AuthAccountStorageCapabilitiesType
- case PrimitiveStaticTypeAuthAccountAccountCapabilities:
- return sema.AuthAccountAccountCapabilitiesType
- case PrimitiveStaticTypeAuthAccountCapabilities:
- return sema.AuthAccountCapabilitiesType
- case PrimitiveStaticTypePublicAccountCapabilities:
- return sema.PublicAccountCapabilitiesType
- default:
- panic(errors.NewUnexpectedError("missing case for %s", t))
->>>>>>> 3773020ec (remove TODO)
}
panic(errors.NewUnexpectedError("missing case for %s", t))
diff --git a/runtime/interpreter/statictype.go b/runtime/interpreter/statictype.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/statictype.go
index 77bf175eb..49e5f012b 100644
--- a/runtime/interpreter/statictype.go
+++ b/runtime/interpreter/statictype.go
@@ -58,10 +58,7 @@ type TypeID = common.TypeID
type CompositeStaticType struct {
Location common.Location
QualifiedIdentifier string
-<<<<<<< ff83742c9 (improve naming)
-=======
TypeID TypeID
->>>>>>> 3773020ec (remove TODO)
}
var _ StaticType = CompositeStaticType{}
@@ -70,10 +67,7 @@ func NewCompositeStaticType(
memoryGauge common.MemoryGauge,
location common.Location,
qualifiedIdentifier string,
-<<<<<<< ff83742c9 (improve naming)
-=======
typeID TypeID,
->>>>>>> 3773020ec (remove TODO)
) CompositeStaticType {
common.UseMemory(memoryGauge, common.CompositeStaticTypeMemoryUsage)
@@ -84,11 +78,10 @@ func NewCompositeStaticType(
return CompositeStaticType{
Location: location,
QualifiedIdentifier: qualifiedIdentifier,
+ TypeID: typeID,
}
}
-<<<<<<< ff83742c9 (improve naming)
-=======
func NewCompositeStaticTypeComputeTypeID(
memoryGauge common.MemoryGauge,
location common.Location,
@@ -108,7 +101,6 @@ func NewCompositeStaticTypeComputeTypeID(
)
}
->>>>>>> 3773020ec (remove TODO)
func (CompositeStaticType) isStaticType() {}
func (CompositeStaticType) elementSize() uint {
@@ -119,14 +111,19 @@ func (t CompositeStaticType) String() string {
if t.Location == nil {
return t.QualifiedIdentifier
}
- return string(t.Location.TypeID(nil, t.QualifiedIdentifier))
+ return string(t.TypeID)
}
func (t CompositeStaticType) MeteredString(memoryGauge common.MemoryGauge) string {
+ var amount int
if t.Location == nil {
- return t.QualifiedIdentifier
+ amount = len(t.QualifiedIdentifier)
+ } else {
+ amount = len(t.TypeID)
}
- return string(t.Location.TypeID(memoryGauge, t.QualifiedIdentifier))
+
+ common.UseMemory(memoryGauge, common.NewRawStringMemoryUsage(amount))
+ return t.String()
}
func (t CompositeStaticType) Equal(other StaticType) bool {
@@ -135,8 +132,7 @@ func (t CompositeStaticType) Equal(other StaticType) bool {
return false
}
- return otherCompositeType.Location == t.Location &&
- otherCompositeType.QualifiedIdentifier == t.QualifiedIdentifier
+ return otherCompositeType.TypeID == t.TypeID
}
func (t CompositeStaticType) ID() TypeID {
@@ -1020,13 +1016,6 @@ func ConvertSemaInterfaceTypeToStaticInterfaceType(
)
}
-func ConvertSemaCompositeTypeToStaticCompositeType(
- memoryGauge common.MemoryGauge,
- t *sema.CompositeType,
-) CompositeStaticType {
- return NewCompositeStaticType(memoryGauge, t.Location, t.QualifiedIdentifier())
-}
-
func ConvertStaticAuthorizationToSemaAccess(
memoryGauge common.MemoryGauge,
auth Authorization,
@@ -1065,23 +1054,17 @@ func ConvertStaticAuthorizationToSemaAccess(
func ConvertStaticToSemaType(
memoryGauge common.MemoryGauge,
typ StaticType,
- getInterface func(location common.Location, qualifiedIdentifier string) (*sema.InterfaceType, error),
-<<<<<<< ff83742c9 (improve naming)
- getComposite func(location common.Location, qualifiedIdentifier string) (*sema.CompositeType, error),
- getEntitlement func(typeID common.TypeID) (*sema.EntitlementType, error),
- getEntitlementMapType func(typeID common.TypeID) (*sema.EntitlementMapType, error),
-=======
+ getInterface func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.InterfaceType, error),
getComposite func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.CompositeType, error),
getEntitlement func(typeID TypeID) (*sema.EntitlementType, error),
getEntitlementMapType func(typeID TypeID) (*sema.EntitlementMapType, error),
->>>>>>> 3773020ec (remove TODO)
) (_ sema.Type, err error) {
switch t := typ.(type) {
case CompositeStaticType:
- return getComposite(t.Location, t.QualifiedIdentifier)
+ return getComposite(t.Location, t.QualifiedIdentifier, t.TypeID)
case InterfaceStaticType:
- return getInterface(t.Location, t.QualifiedIdentifier)
+ return getInterface(t.Location, t.QualifiedIdentifier, t.TypeID)
case VariableSizedStaticType:
ty, err := ConvertStaticToSemaType(
@@ -1169,7 +1152,7 @@ func ConvertStaticToSemaType(
intersectedTypes = make([]*sema.InterfaceType, typeCount)
for i, typ := range t.Types {
- intersectedTypes[i], err = getInterface(typ.Location, typ.QualifiedIdentifier)
+ intersectedTypes[i], err = getInterface(typ.Location, typ.QualifiedIdentifier, typ.TypeID)
if err != nil {
return nil, err
}
diff --git a/runtime/interpreter/statictype_test.go b/runtime/interpreter/statictype_test.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/statictype_test.go
index 92c2f17df..2bbbc41e7 100644
--- a/runtime/interpreter/statictype_test.go
+++ b/runtime/interpreter/statictype_test.go
@@ -179,12 +179,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.True(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
utils.TestLocation,
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
utils.TestLocation,
"X",
@@ -198,12 +198,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
utils.TestLocation,
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
utils.TestLocation,
"Y",
@@ -217,12 +217,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
common.IdentifierLocation("A"),
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
common.IdentifierLocation("B"),
"X",
@@ -236,12 +236,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
common.IdentifierLocation("A"),
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
common.StringLocation("A"),
"X",
@@ -255,12 +255,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.True(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"X",
@@ -274,12 +274,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"Y",
@@ -293,12 +293,12 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"X",
).Equal(
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
common.StringLocation("B"),
"X",
@@ -312,7 +312,7 @@ func TestCompositeStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
- NewCompositeStaticType(
+ NewCompositeStaticTypeComputeTypeID(
nil,
nil,
"X",
@@ -402,21 +402,8 @@ func TestInterfaceStaticType_Equal(t *testing.T) {
t.Parallel()
require.False(t,
-<<<<<<< ff83742c9 (improve naming)
- InterfaceStaticType{
- Location: nil,
- QualifiedIdentifier: "X",
- }.Equal(
- NewCompositeStaticType(
- nil,
- nil,
- "X",
- ),
- ),
-=======
NewInterfaceStaticTypeComputeTypeID(nil, nil, "X").
Equal(NewCompositeStaticTypeComputeTypeID(nil, nil, "X")),
->>>>>>> 3773020ec (remove TODO)
)
})
}
@@ -922,18 +909,11 @@ func TestStaticTypeConversion(t *testing.T) {
Identifier: testCompositeQualifiedIdentifier,
}
-<<<<<<< ff83742c9 (improve naming)
- testCompositeStaticType := CompositeStaticType{
- Location: testLocation,
- QualifiedIdentifier: testCompositeQualifiedIdentifier,
- }
-=======
testCompositeStaticType := NewCompositeStaticTypeComputeTypeID(
nil,
testLocation,
testCompositeQualifiedIdentifier,
)
->>>>>>> 3773020ec (remove TODO)
testFunctionType := &sema.FunctionType{}
@@ -945,6 +925,7 @@ func TestStaticTypeConversion(t *testing.T) {
t *testing.T,
location common.Location,
qualifiedIdentifier string,
+ typeID TypeID,
) (
*sema.InterfaceType,
error,
@@ -953,10 +934,7 @@ func TestStaticTypeConversion(t *testing.T) {
t *testing.T,
location common.Location,
qualifiedIdentifier string,
-<<<<<<< ff83742c9 (improve naming)
-=======
typeID TypeID,
->>>>>>> 3773020ec (remove TODO)
) (
*sema.CompositeType,
error,
@@ -1273,6 +1251,7 @@ func TestStaticTypeConversion(t *testing.T) {
t *testing.T,
location common.Location,
qualifiedIdentifier string,
+ _ TypeID,
) (*sema.CompositeType, error) {
require.Nil(t, location)
require.Equal(t, "AccountKey", qualifiedIdentifier)
@@ -1512,6 +1491,7 @@ func TestStaticTypeConversion(t *testing.T) {
t *testing.T,
location common.Location,
qualifiedIdentifier string,
+ typeID TypeID,
) (*sema.InterfaceType, error) {
require.Equal(t, testLocation, location)
require.Equal(t, testInterfaceQualifiedIdentifier, qualifiedIdentifier)
@@ -1526,6 +1506,7 @@ func TestStaticTypeConversion(t *testing.T) {
t *testing.T,
location common.Location,
qualifiedIdentifier string,
+ typeID TypeID,
) (*sema.InterfaceType, error) {
require.Equal(t, testLocation, location)
require.Equal(t, testInterfaceQualifiedIdentifier, qualifiedIdentifier)
@@ -1536,15 +1517,12 @@ func TestStaticTypeConversion(t *testing.T) {
name: "Composite",
semaType: testCompositeSemaType,
staticType: testCompositeStaticType,
-<<<<<<< ff83742c9 (improve naming)
getComposite: func(
t *testing.T,
location common.Location,
qualifiedIdentifier string,
+ typeID TypeID,
) (*sema.CompositeType, error) {
-=======
- getComposite: func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.CompositeType, error) {
->>>>>>> 3773020ec (remove TODO)
require.Equal(t, testLocation, location)
require.Equal(t, testCompositeQualifiedIdentifier, qualifiedIdentifier)
return testCompositeSemaType, nil
@@ -1644,6 +1622,7 @@ func TestStaticTypeConversion(t *testing.T) {
_ *testing.T,
_ common.Location,
_ string,
+ _ TypeID,
) (*sema.InterfaceType, error) {
require.FailNow(t, "getInterface should not be called")
return nil, nil
@@ -1652,15 +1631,12 @@ func TestStaticTypeConversion(t *testing.T) {
getComposite := test.getComposite
if getComposite == nil {
-<<<<<<< ff83742c9 (improve naming)
getComposite = func(
_ *testing.T,
_ common.Location,
_ string,
+ _ TypeID,
) (*sema.CompositeType, error) {
-=======
- getComposite = func(_ common.Location, _ string, _ TypeID) (*sema.CompositeType, error) {
->>>>>>> 3773020ec (remove TODO)
require.FailNow(t, "getComposite should not be called")
return nil, nil
}
@@ -1679,11 +1655,11 @@ func TestStaticTypeConversion(t *testing.T) {
convertedSemaType, err := ConvertStaticToSemaType(
nil,
test.staticType,
- func(location common.Location, qualifiedIdentifier string) (*sema.InterfaceType, error) {
- return getInterface(t, location, qualifiedIdentifier)
+ func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.InterfaceType, error) {
+ return getInterface(t, location, qualifiedIdentifier, typeID)
},
- func(location common.Location, qualifiedIdentifier string) (*sema.CompositeType, error) {
- return getComposite(t, location, qualifiedIdentifier)
+ func(location common.Location, qualifiedIdentifier string, typeID TypeID) (*sema.CompositeType, error) {
+ return getComposite(t, location, qualifiedIdentifier, typeID)
},
getEntitlement,
getEntitlementMap,
diff --git a/runtime/interpreter/value.go b/runtime/interpreter/value.go
index 917f3614e..1ec1c1e54 100644
--- a/runtime/interpreter/value.go
+++ b/runtime/interpreter/value.go
@@ -16394,6 +16394,7 @@ func (v *CompositeValue) StaticType(interpreter *Interpreter) StaticType {
interpreter,
v.Location,
v.QualifiedIdentifier,
+ v.TypeID(),
)
}
return v.staticType
diff --git a/runtime/interpreter/value_accountcapabilitycontroller.go b/runtime/interpreter/value_accountcapabilitycontroller.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/value_accountcapabilitycontroller.go
index 07304c218..d43a78e23 100644
--- a/runtime/interpreter/value_accountcapabilitycontroller.go
+++ b/runtime/interpreter/value_accountcapabilitycontroller.go
@@ -246,10 +246,6 @@ func (*AccountCapabilityControllerValue) RemoveMember(_ *Interpreter, _ Location
panic(errors.NewUnreachableError())
}
-<<<<<<< ff83742c9 (improve naming)
-func (v *AccountCapabilityControllerValue) SetMember(_ *Interpreter, _ LocationRange, _ string, _ Value) bool {
- // Account capability controllers have no settable members (fields / functions)
-=======
func (v *AccountCapabilityControllerValue) SetMember(
_ *Interpreter,
_ LocationRange,
@@ -267,7 +263,6 @@ func (v *AccountCapabilityControllerValue) SetMember(
return true
}
->>>>>>> 3773020ec (remove TODO)
panic(errors.NewUnreachableError())
}
diff --git a/runtime/interpreter/value_accountkey.go b/runtime/interpreter/value_accountkey.go
index 46ca5dfd9..05013dbbf 100644
--- a/runtime/interpreter/value_accountkey.go
+++ b/runtime/interpreter/value_accountkey.go
@@ -23,7 +23,7 @@ import (
)
var accountKeyTypeID = sema.AccountKeyType.ID()
-var AccountKeyStaticType StaticType = NewCompositeStaticType(nil, nil, "AccountKey") // unmetered
+var AccountKeyStaticType StaticType = ConvertSemaCompositeTypeToStaticCompositeType(nil, sema.AccountKeyType)
var accountKeyFieldNames = []string{
sema.AccountKeyKeyIndexFieldName,
sema.AccountKeyPublicKeyFieldName,
diff --git a/runtime/interpreter/value_deployedcontract.go b/runtime/interpreter/value_deployedcontract.go
index fd9d364c1..745c9fc3b 100644
--- a/runtime/interpreter/value_deployedcontract.go
+++ b/runtime/interpreter/value_deployedcontract.go
@@ -71,7 +71,8 @@ func newPublicTypesFunctionValue(inter *Interpreter, addressValue AddressValue,
contractLocation := common.NewAddressLocation(innerInter, address, name.Str)
// we're only looking at the contract as a whole, so no need to construct a nested path
qualifiedIdent := name.Str
- compositeType, err := innerInter.GetCompositeType(contractLocation, qualifiedIdent)
+ typeID := common.NewTypeIDFromQualifiedName(innerInter, contractLocation, qualifiedIdent)
+ compositeType, err := innerInter.GetCompositeType(contractLocation, qualifiedIdent, typeID)
if err != nil {
panic(err)
}
diff --git a/runtime/runtime_memory_metering_test.go b/runtime/runtime_memory_metering_test.go
index 9dcd1c93f..9ec4886c7 100644
--- a/runtime/runtime_memory_metering_test.go
+++ b/runtime/runtime_memory_metering_test.go
@@ -97,7 +97,7 @@ func TestRuntimeInterpreterAddressLocationMetering(t *testing.T) {
assert.Equal(t, uint64(1), meter.getMemory(common.MemoryKindAddressLocation))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindElaboration))
- assert.Equal(t, uint64(21), meter.getMemory(common.MemoryKindRawString))
+ assert.Equal(t, uint64(0), meter.getMemory(common.MemoryKindRawString))
assert.Equal(t, uint64(1), meter.getMemory(common.MemoryKindCadenceVoidValue))
})
}
diff --git a/runtime/sema/access.go b/runtime/sema/access.go
remerge CONFLICT (content): Merge conflict in runtime/sema/access.go
index 75b760a23..6f0e60c85 100644
--- a/runtime/sema/access.go
+++ b/runtime/sema/access.go
@@ -334,7 +334,7 @@ func (e *EntitlementMapAccess) entitlementImage(entitlement *EntitlementType) *E
}
}
if e.Type.IncludesIdentity {
- output.Set(entitlement, struct{}{})
+ imageMap.Set(entitlement, struct{}{})
}
e.images.Store(entitlement, imageMap)
@@ -346,13 +346,6 @@ func (e *EntitlementMapAccess) entitlementImage(entitlement *EntitlementType) *E
// arguments.
func (e *EntitlementMapAccess) Image(inputs Access, astRange func() ast.Range) (Access, error) {
-<<<<<<< ff83742c9 (improve naming)
- if e.Type == IdentityType {
- return inputs, nil
- }
-
-=======
->>>>>>> 3773020ec (remove TODO)
switch inputs := inputs.(type) {
// primitive access always passes trivially through the map
case PrimitiveAccess:
diff --git a/runtime/sema/account_capability_controller.gen.go b/runtime/sema/account_capability_controller.gen.go
remerge CONFLICT (content): Merge conflict in runtime/sema/account_capability_controller.gen.go
index 0cc149225..c91e435e1 100644
--- a/runtime/sema/account_capability_controller.gen.go
+++ b/runtime/sema/account_capability_controller.gen.go
@@ -117,10 +117,7 @@ func init() {
return MembersAsResolvers([]*Member{
NewUnmeteredFieldMember(
t,
-<<<<<<< ff83742c9 (improve naming)
PrimitiveAccess(ast.AccessAll),
-=======
- ast.AccessAll,
ast.VariableKindConstant,
AccountCapabilityControllerTypeCapabilityFieldName,
AccountCapabilityControllerTypeCapabilityFieldType,
@@ -128,8 +125,7 @@ func init() {
),
NewUnmeteredFieldMember(
t,
- ast.AccessAll,
->>>>>>> 3773020ec (remove TODO)
+ PrimitiveAccess(ast.AccessAll),
ast.VariableKindVariable,
AccountCapabilityControllerTypeTagFieldName,
AccountCapabilityControllerTypeTagFieldType,
diff --git a/runtime/sema/gen/main.go b/runtime/sema/gen/main.go
index bb88ea987..e2c223ce4 100644
--- a/runtime/sema/gen/main.go
+++ b/runtime/sema/gen/main.go
@@ -593,7 +593,7 @@ func (g *generator) VisitEntitlementMappingDeclaration(decl *ast.EntitlementMapp
entitlementMappingName := decl.Identifier.Identifier
typeVarName := typeVarName(entitlementMappingName)
- typeVarDecl := entitlementMapTypeLiteral(entitlementMappingName, decl.Associations)
+ typeVarDecl := entitlementMapTypeLiteral(entitlementMappingName, decl.Elements)
g.addDecls(
goVarDecl(
@@ -1721,7 +1721,7 @@ func entitlementTypeLiteral(name string) dst.Expr {
}
}
-func entitlementMapTypeLiteral(name string, associations []*ast.EntitlementMapElement) dst.Expr {
+func entitlementMapTypeLiteral(name string, elements []ast.EntitlementMapElement) dst.Expr {
// &sema.EntitlementMapType{
// Identifier: "Foo",
// Relations: []EntitlementRelation{
@@ -1732,14 +1732,20 @@ func entitlementMapTypeLiteral(name string, associations []*ast.EntitlementMapEl
// }
// }
- relationExprs := make([]dst.Expr, 0, len(associations))
+ relationExprs := make([]dst.Expr, 0, len(elements))
+
+ for _, element := range elements {
+
+ relation, ok := element.(*ast.EntitlementMapRelation)
+ if !ok {
+ panic(fmt.Errorf("non-relation map element is not supported: %s", element))
+ }
- for _, association := range associations {
relationExpr := &dst.CompositeLit{
Type: dst.NewIdent("EntitlementRelation"),
Elts: []dst.Expr{
- goKeyValue("Input", typeExpr(association.Input, nil)),
- goKeyValue("Output", typeExpr(association.Output, nil)),
+ goKeyValue("Input", typeExpr(relation.Input, nil)),
+ goKeyValue("Output", typeExpr(relation.Output, nil)),
},
}
diff --git a/runtime/sema/storage_capability_controller.gen.go b/runtime/sema/storage_capability_controller.gen.go
remerge CONFLICT (content): Merge conflict in runtime/sema/storage_capability_controller.gen.go
index 558dfece6..c74ed0974 100644
--- a/runtime/sema/storage_capability_controller.gen.go
+++ b/runtime/sema/storage_capability_controller.gen.go
@@ -149,10 +149,7 @@ func init() {
return MembersAsResolvers([]*Member{
NewUnmeteredFieldMember(
t,
-<<<<<<< ff83742c9 (improve naming)
PrimitiveAccess(ast.AccessAll),
-=======
- ast.AccessAll,
ast.VariableKindConstant,
StorageCapabilityControllerTypeCapabilityFieldName,
StorageCapabilityControllerTypeCapabilityFieldType,
@@ -160,8 +157,7 @@ func init() {
),
NewUnmeteredFieldMember(
t,
- ast.AccessAll,
->>>>>>> 3773020ec (remove TODO)
+ PrimitiveAccess(ast.AccessAll),
ast.VariableKindVariable,
StorageCapabilityControllerTypeTagFieldName,
StorageCapabilityControllerTypeTagFieldType,
diff --git a/runtime/sema/type.go b/runtime/sema/type.go
remerge CONFLICT (content): Merge conflict in runtime/sema/type.go
index 6bdf4ac71..a507a9d26 100644
--- a/runtime/sema/type.go
+++ b/runtime/sema/type.go
@@ -3752,21 +3752,18 @@ func addToBaseActivation(ty Type) {
)
}
-<<<<<<< ff83742c9 (improve naming)
-var IdentityType = NewEntitlementMapType(nil, nil, "Identity")
-=======
const IdentityMappingIdentifier string = "Identity"
-// The `Identity` mapping is an empty map that includes the Identity map,
+// IdentityType represents the `Identity` entitlement mapping type.
+// It is an empty map that includes the Identity map,
// and is considered already "resolved" with regards to its (vacuously empty) inclusions.
// defining it this way eliminates the need to do any special casing for its behavior
-var IdentityMappingType = func() *EntitlementMapType {
+var IdentityType = func() *EntitlementMapType {
m := NewEntitlementMapType(nil, nil, IdentityMappingIdentifier)
m.IncludesIdentity = true
m.resolveInclusions.Do(func() {})
return m
}()
->>>>>>> 3773020ec (remove TODO)
func baseTypeVariable(name string, ty Type) *Variable {
return &Variable{
diff --git a/runtime/stdlib/bls.go b/runtime/stdlib/bls.go
remerge CONFLICT (content): Merge conflict in runtime/stdlib/bls.go
index 91cfd7f52..f99591db2 100644
--- a/runtime/stdlib/bls.go
+++ b/runtime/stdlib/bls.go
@@ -48,14 +48,10 @@ var blsContractType = func() *sema.CompositeType {
return ty
}()
-<<<<<<< ff83742c9 (improve naming)
-var blsContractStaticType interpreter.StaticType = interpreter.NewCompositeStaticType(nil, nil, blsContractType.Identifier)
-=======
var blsContractStaticType interpreter.StaticType = interpreter.ConvertSemaCompositeTypeToStaticCompositeType(
nil,
blsContractType,
)
->>>>>>> 3773020ec (remove TODO)
const blsAggregateSignaturesFunctionDocString = `
Aggregates multiple BLS signatures into one,
diff --git a/runtime/stdlib/contracts/test.cdc b/runtime/stdlib/contracts/test.cdc
remerge CONFLICT (content): Merge conflict in runtime/stdlib/contracts/test.cdc
index 7a0548702..f9a022518 100644
--- a/runtime/stdlib/contracts/test.cdc
+++ b/runtime/stdlib/contracts/test.cdc
@@ -27,12 +27,8 @@ contract Test {
/// The transaction is paid by the service account.
/// The returned account can be used to sign and authorize transactions.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) fun createAccount(): TestAccount {
-=======
access(all)
- fun createAccount(): Account {
->>>>>>> 3773020ec (remove TODO)
+ fun createAccount(): TestAccount {
return self.backend.createAccount()
}
@@ -122,12 +118,8 @@ contract Test {
/// Returns the service account of the blockchain. Can be used to sign
/// transactions with this account.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) fun serviceAccount(): TestAccount {
-=======
access(all)
- fun serviceAccount(): Account {
->>>>>>> 3773020ec (remove TODO)
+ fun serviceAccount(): TestAccount {
return self.backend.serviceAccount()
}
@@ -205,7 +197,7 @@ contract Test {
/// Result is the interface to be implemented by the various execution
/// operations, such as transactions and scripts.
- ///\
+ ///
access(all)
struct interface Result {
/// The result status of an executed operation.
@@ -270,20 +262,14 @@ contract Test {
/// TestAccount represents info about the account created on the blockchain.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) struct TestAccount {
- access(all) let address: Address
- access(all) let publicKey: PublicKey
-=======
access(all)
- struct Account {
+ struct TestAccount {
access(all)
let address: Address
access(all)
let publicKey: PublicKey
->>>>>>> 3773020ec (remove TODO)
init(address: Address, publicKey: PublicKey) {
self.address = address
@@ -307,13 +293,6 @@ contract Test {
/// Transaction that can be submitted and executed on the blockchain.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) struct Transaction {
- access(all) let code: String
- access(all) let authorizers: [Address]
- access(all) let signers: [TestAccount]
- access(all) let arguments: [AnyStruct]
-=======
access(all)
struct Transaction {
@@ -324,13 +303,11 @@ contract Test {
let authorizers: [Address]
access(all)
- let signers: [Account]
+ let signers: [TestAccount]
access(all)
let arguments: [AnyStruct]
->>>>>>> 3773020ec (remove TODO)
-
init(code: String, authorizers: [Address], signers: [TestAccount], arguments: [AnyStruct]) {
self.code = code
self.authorizers = authorizers
@@ -354,12 +331,8 @@ contract Test {
/// The transaction is paid by the service account.
/// The returned account can be used to sign and authorize transactions.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) fun createAccount(): TestAccount
-=======
access(all)
- fun createAccount(): Account
->>>>>>> 3773020ec (remove TODO)
+ fun createAccount(): TestAccount
/// Add a transaction to the current block.
///
@@ -402,12 +375,8 @@ contract Test {
/// Returns the service account of the blockchain. Can be used to sign
/// transactions with this account.
///
-<<<<<<< ff83742c9 (improve naming)
- access(all) fun serviceAccount(): TestAccount
-=======
access(all)
- fun serviceAccount(): Account
->>>>>>> 3773020ec (remove TODO)
+ fun serviceAccount(): TestAccount
/// Returns all events emitted from the blockchain, optionally filtered
/// by type.
diff --git a/runtime/stdlib/hashalgorithm.go b/runtime/stdlib/hashalgorithm.go
remerge CONFLICT (content): Merge conflict in runtime/stdlib/hashalgorithm.go
index 1fdf79834..65019f84e 100644
--- a/runtime/stdlib/hashalgorithm.go
+++ b/runtime/stdlib/hashalgorithm.go
@@ -25,14 +25,10 @@ import (
"github.com/onflow/cadence/runtime/sema"
)
-<<<<<<< ff83742c9 (improve naming)
-var hashAlgorithmStaticType interpreter.StaticType = interpreter.NewCompositeStaticType(nil, nil, sema.HashAlgorithmTypeName)
-=======
var hashAlgorithmStaticType interpreter.StaticType = interpreter.ConvertSemaCompositeTypeToStaticCompositeType(
nil,
sema.HashAlgorithmType,
)
->>>>>>> 3773020ec (remove TODO)
type Hasher interface {
// Hash returns the digest of hashing the given data with using the given hash algorithm
diff --git a/runtime/stdlib/rlp.go b/runtime/stdlib/rlp.go
remerge CONFLICT (content): Merge conflict in runtime/stdlib/rlp.go
index 9f6f15581..4743450d2 100644
--- a/runtime/stdlib/rlp.go
+++ b/runtime/stdlib/rlp.go
@@ -51,14 +51,10 @@ var rlpContractType = func() *sema.CompositeType {
return ty
}()
-<<<<<<< ff83742c9 (improve naming)
-var rlpContractStaticType interpreter.StaticType = interpreter.NewCompositeStaticType(nil, nil, rlpContractType.Identifier)
-=======
var rlpContractStaticType interpreter.StaticType = interpreter.ConvertSemaCompositeTypeToStaticCompositeType(
nil,
rlpContractType,
)
->>>>>>> 3773020ec (remove TODO)
const rlpErrMsgInputContainsExtraBytes = "input data is expected to be RLP-encoded of a single string or a single list but it seems it contains extra trailing bytes."
diff --git a/runtime/stdlib/signaturealgorithm.go b/runtime/stdlib/signaturealgorithm.go
remerge CONFLICT (content): Merge conflict in runtime/stdlib/signaturealgorithm.go
index 85aa8eb1d..fa475433c 100644
--- a/runtime/stdlib/signaturealgorithm.go
+++ b/runtime/stdlib/signaturealgorithm.go
@@ -24,14 +24,10 @@ import (
"github.com/onflow/cadence/runtime/sema"
)
-<<<<<<< ff83742c9 (improve naming)
-var signatureAlgorithmStaticType interpreter.StaticType = interpreter.NewCompositeStaticType(nil, nil, sema.SignatureAlgorithmTypeName)
-=======
var signatureAlgorithmStaticType interpreter.StaticType = interpreter.ConvertSemaCompositeTypeToStaticCompositeType(
nil,
sema.SignatureAlgorithmType,
)
->>>>>>> 3773020ec (remove TODO)
func NewSignatureAlgorithmCase(rawValue interpreter.UInt8Value) interpreter.MemberAccessibleValue {
diff --git a/runtime/tests/interpreter/account_test.go b/runtime/tests/interpreter/account_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/account_test.go
index c3ea2775a..e0f83103b 100644
--- a/runtime/tests/interpreter/account_test.go
+++ b/runtime/tests/interpreter/account_test.go
@@ -613,14 +613,7 @@ func TestInterpretAccountStorageType(t *testing.T) {
require.Equal(t,
interpreter.NewUnmeteredSomeValueNonCopying(
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: TestLocation,
- QualifiedIdentifier: "R",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
},
),
value,
@@ -639,14 +632,7 @@ func TestInterpretAccountStorageType(t *testing.T) {
require.Equal(t,
interpreter.NewUnmeteredSomeValueNonCopying(
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: TestLocation,
- QualifiedIdentifier: "S",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "S"),
->>>>>>> 3773020ec (remove TODO)
},
),
value,
diff --git a/runtime/tests/interpreter/composite_value_test.go b/runtime/tests/interpreter/composite_value_test.go
index 470fc0958..97c824fd4 100644
--- a/runtime/tests/interpreter/composite_value_test.go
+++ b/runtime/tests/interpreter/composite_value_test.go
@@ -96,7 +96,7 @@ func testCompositeValue(t *testing.T, code string) *interpreter.Interpreter {
"This is the color",
))
- fruitStaticType := interpreter.NewCompositeStaticType(
+ fruitStaticType := interpreter.NewCompositeStaticTypeComputeTypeID(
nil,
TestLocation,
fruitType.Identifier,
diff --git a/runtime/tests/interpreter/memory_metering_test.go b/runtime/tests/interpreter/memory_metering_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/memory_metering_test.go
index bf878862c..3bb817901 100644
--- a/runtime/tests/interpreter/memory_metering_test.go
+++ b/runtime/tests/interpreter/memory_metering_test.go
@@ -644,7 +644,7 @@ func TestInterpretCompositeMetering(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, uint64(6), meter.getMemory(common.MemoryKindStringValue))
- assert.Equal(t, uint64(102), meter.getMemory(common.MemoryKindRawString))
+ assert.Equal(t, uint64(66), meter.getMemory(common.MemoryKindRawString))
assert.Equal(t, uint64(4), meter.getMemory(common.MemoryKindCompositeValueBase))
assert.Equal(t, uint64(5), meter.getMemory(common.MemoryKindAtreeMapDataSlab))
assert.Equal(t, uint64(1), meter.getMemory(common.MemoryKindAtreeMapMetaDataSlab))
@@ -739,7 +739,7 @@ func TestInterpretCompositeFieldMetering(t *testing.T) {
_, err := inter.Invoke("main")
require.NoError(t, err)
- assert.Equal(t, uint64(9), meter.getMemory(common.MemoryKindRawString))
+ assert.Equal(t, uint64(0), meter.getMemory(common.MemoryKindRawString))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindCompositeValueBase))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindAtreeMapDataSlab))
assert.Equal(t, uint64(0), meter.getMemory(common.MemoryKindAtreeMapMetaDataSlab))
@@ -767,7 +767,7 @@ func TestInterpretCompositeFieldMetering(t *testing.T) {
_, err := inter.Invoke("main")
require.NoError(t, err)
- assert.Equal(t, uint64(34), meter.getMemory(common.MemoryKindRawString))
+ assert.Equal(t, uint64(16), meter.getMemory(common.MemoryKindRawString))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindCompositeValueBase))
assert.Equal(t, uint64(1), meter.getMemory(common.MemoryKindAtreeMapElementOverhead))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindAtreeMapDataSlab))
@@ -798,7 +798,7 @@ func TestInterpretCompositeFieldMetering(t *testing.T) {
_, err := inter.Invoke("main")
require.NoError(t, err)
- assert.Equal(t, uint64(61), meter.getMemory(common.MemoryKindRawString))
+ assert.Equal(t, uint64(34), meter.getMemory(common.MemoryKindRawString))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindAtreeMapDataSlab))
assert.Equal(t, uint64(2), meter.getMemory(common.MemoryKindAtreeMapElementOverhead))
assert.Equal(t, uint64(0), meter.getMemory(common.MemoryKindAtreeMapMetaDataSlab))
@@ -7826,7 +7826,7 @@ func TestInterpreterStringLocationMetering(t *testing.T) {
testLocationStringCount := meter.getMemory(common.MemoryKindRawString)
// raw string location is "test" + locationIDs
- assert.Equal(t, uint64(14), testLocationStringCount-emptyLocationStringCount)
+ assert.Equal(t, uint64(5), testLocationStringCount-emptyLocationStringCount)
assert.Equal(t, uint64(1), meter.getMemory(common.MemoryKindCompositeStaticType))
@@ -8952,14 +8952,7 @@ func TestInterpretValueStringConversion(t *testing.T) {
interpreter.NewUnmeteredCapabilityValue(
4,
interpreter.AddressValue{1},
-<<<<<<< ff83742c9 (improve naming)
- interpreter.CompositeStaticType{
- Location: utils.TestLocation,
- QualifiedIdentifier: "Bar",
- },
-=======
interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "Bar"),
->>>>>>> 3773020ec (remove TODO)
))
})
diff --git a/runtime/tests/interpreter/metatype_test.go b/runtime/tests/interpreter/metatype_test.go
index 19b86fac6..90994ccfd 100644
--- a/runtime/tests/interpreter/metatype_test.go
+++ b/runtime/tests/interpreter/metatype_test.go
@@ -640,7 +640,7 @@ func TestInterpretGetType(t *testing.T) {
}
`,
result: interpreter.TypeValue{
- Type: interpreter.NewCompositeStaticType(nil, TestLocation, "R"),
+ Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"),
},
},
{
diff --git a/runtime/tests/interpreter/runtimetype_test.go b/runtime/tests/interpreter/runtimetype_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/runtimetype_test.go
index 8d9e896ac..a1e140864 100644
--- a/runtime/tests/interpreter/runtimetype_test.go
+++ b/runtime/tests/interpreter/runtimetype_test.go
@@ -65,14 +65,7 @@ func TestInterpretOptionalType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.OptionalStaticType{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: utils.TestLocation,
- QualifiedIdentifier: "R",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
},
},
inter.Globals.Get("c").GetValue(),
@@ -131,14 +124,7 @@ func TestInterpretVariableSizedArrayType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.VariableSizedStaticType{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: utils.TestLocation,
- QualifiedIdentifier: "R",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
},
},
inter.Globals.Get("c").GetValue(),
@@ -198,14 +184,7 @@ func TestInterpretConstantSizedArrayType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.ConstantSizedStaticType{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: utils.TestLocation,
- QualifiedIdentifier: "R",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
Size: int64(400),
},
},
@@ -271,16 +250,8 @@ func TestInterpretDictionaryType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.DictionaryStaticType{
-<<<<<<< ff83742c9 (improve naming)
- ValueType: interpreter.CompositeStaticType{
- Location: utils.TestLocation,
- QualifiedIdentifier: "R",
- },
- KeyType: interpreter.PrimitiveStaticTypeInt,
-=======
ValueType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
KeyType: interpreter.PrimitiveStaticTypeInt,
->>>>>>> 3773020ec (remove TODO)
},
},
inter.Globals.Get("c").GetValue(),
@@ -334,28 +305,14 @@ func TestInterpretCompositeType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- QualifiedIdentifier: "R",
- Location: utils.TestLocation,
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
},
inter.Globals.Get("a").GetValue(),
)
assert.Equal(t,
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- QualifiedIdentifier: "S",
- Location: utils.TestLocation,
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"),
->>>>>>> 3773020ec (remove TODO)
},
inter.Globals.Get("b").GetValue(),
)
@@ -377,42 +334,21 @@ func TestInterpretCompositeType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- QualifiedIdentifier: "F",
- Location: utils.TestLocation,
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "F"),
->>>>>>> 3773020ec (remove TODO)
},
inter.Globals.Get("f").GetValue(),
)
assert.Equal(t,
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: nil,
- QualifiedIdentifier: "PublicKey",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "PublicKey"),
->>>>>>> 3773020ec (remove TODO)
},
inter.Globals.Get("g").GetValue(),
)
assert.Equal(t,
interpreter.TypeValue{
-<<<<<<< ff83742c9 (improve naming)
- Type: interpreter.CompositeStaticType{
- Location: nil,
- QualifiedIdentifier: "HashAlgorithm",
- },
-=======
Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, nil, "HashAlgorithm"),
->>>>>>> 3773020ec (remove TODO)
},
inter.Globals.Get("h").GetValue(),
)
@@ -537,14 +473,7 @@ func TestInterpretReferenceType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.ReferenceStaticType{
-<<<<<<< ff83742c9 (improve naming)
- ReferencedType: interpreter.CompositeStaticType{
- QualifiedIdentifier: "R",
- Location: utils.TestLocation,
- },
-=======
ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
->>>>>>> 3773020ec (remove TODO)
Authorization: interpreter.NewEntitlementSetAuthorization(
nil,
func() []common.TypeID { return []common.TypeID{"S.test.X"} },
@@ -569,14 +498,7 @@ func TestInterpretReferenceType(t *testing.T) {
assert.Equal(t,
interpreter.TypeValue{
Type: interpreter.ReferenceStaticType{
-<<<<<<< ff83742c9 (improve naming)
- ReferencedType: interpreter.CompositeStaticType{
- QualifiedIdentifier: "S",
- Location: utils.TestLocation,
- },
-=======
ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"),
->>>>>>> 3773020ec (remove TODO)
Authorization: interpreter.NewEntitlementSetAuthorization(
nil,
func() []common.TypeID { return []common.TypeID{"S.test.X"} },
@@ -730,16 +652,8 @@ func TestInterpretCapabilityType(t *testing.T) {
interpreter.TypeValue{
Type: interpreter.CapabilityStaticType{
BorrowType: interpreter.ReferenceStaticType{
-<<<<<<< ff83742c9 (improve naming)
- ReferencedType: interpreter.CompositeStaticType{
- QualifiedIdentifier: "R",
- Location: utils.TestLocation,
- },
- Authorization: interpreter.UnauthorizedAccess,
-=======
ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"),
Authorization: interpreter.UnauthorizedAccess,
->>>>>>> 3773020ec (remove TODO)
},
},
},
diff --git a/types.go b/types.go
remerge CONFLICT (content): Merge conflict in types.go
index 8a026653c..e0608208b 100644
--- a/types.go
+++ b/types.go
@@ -853,11 +853,7 @@ func NewMeteredAttachmentType(
fields []Field,
initializers [][]Parameter,
) *AttachmentType {
-<<<<<<< ff83742c9 (improve naming)
common.UseMemory(gauge, common.CadenceAttachmentTypeMemoryUsage)
-=======
- common.UseMemory(gauge, common.CadenceStructTypeMemoryUsage)
->>>>>>> 3773020ec (remove TODO)
return NewAttachmentType(
location,
baseType,
@@ -1802,167 +1798,6 @@ func (t *EnumType) Equal(other Type) bool {
t.QualifiedIdentifier == otherType.QualifiedIdentifier
}
-<<<<<<< ff83742c9 (improve naming)
-func generateTypeID(location common.Location, identifier string) string {
- if location == nil {
- return identifier
- }
-
- return string(location.TypeID(nil, identifier))
-=======
-// AuthAccountType
-type AuthAccountType struct{}
-
-var TheAuthAccountType = AuthAccountType{}
-
-func NewAuthAccountType() AuthAccountType {
- return TheAuthAccountType
-}
-
-func (AuthAccountType) isType() {}
-
-func (AuthAccountType) ID() string {
- return "AuthAccount"
-}
-
-func (t AuthAccountType) Equal(other Type) bool {
- return t == other
-}
-
-// PublicAccountType
-type PublicAccountType struct{}
-
-var ThePublicAccountType = PublicAccountType{}
-
-func NewPublicAccountType() PublicAccountType {
- return ThePublicAccountType
-}
-
-func (PublicAccountType) isType() {}
-
-func (PublicAccountType) ID() string {
- return "PublicAccount"
-}
-
-func (t PublicAccountType) Equal(other Type) bool {
- return t == other
-}
-
-// DeployedContractType
-type DeployedContractType struct{}
-
-var TheDeployedContractType = DeployedContractType{}
-
-func NewDeployedContractType() DeployedContractType {
- return TheDeployedContractType
-}
-
-func (DeployedContractType) isType() {}
-
-func (DeployedContractType) ID() string {
- return "DeployedContract"
-}
-
-func (t DeployedContractType) Equal(other Type) bool {
- return t == other
-}
-
-// AuthAccountContractsType
-type AuthAccountContractsType struct{}
-
-var TheAuthAccountContractsType = AuthAccountContractsType{}
-
-func NewAuthAccountContractsType() AuthAccountContractsType {
- return TheAuthAccountContractsType
-}
-
-func (AuthAccountContractsType) isType() {}
-
-func (AuthAccountContractsType) ID() string {
- return "AuthAccount.Contracts"
-}
-
-func (t AuthAccountContractsType) Equal(other Type) bool {
- return t == other
-}
-
-// PublicAccountContractsType
-type PublicAccountContractsType struct{}
-
-var ThePublicAccountContractsType = PublicAccountContractsType{}
-
-func NewPublicAccountContractsType() PublicAccountContractsType {
- return ThePublicAccountContractsType
-}
-
-func (PublicAccountContractsType) isType() {}
-
-func (PublicAccountContractsType) ID() string {
- return "PublicAccount.Contracts"
-}
-
-func (t PublicAccountContractsType) Equal(other Type) bool {
- return t == other
-}
-
-// AuthAccountKeysType
-type AuthAccountKeysType struct{}
-
-var TheAuthAccountKeysType = AuthAccountKeysType{}
-
-func NewAuthAccountKeysType() AuthAccountKeysType {
- return TheAuthAccountKeysType
-}
-
-func (AuthAccountKeysType) isType() {}
-
-func (AuthAccountKeysType) ID() string {
- return "AuthAccount.Keys"
-}
-
-func (t AuthAccountKeysType) Equal(other Type) bool {
- return t == other
-}
-
-// PublicAccountKeysType
-type PublicAccountKeysType struct{}
-
-var ThePublicAccountKeysType = PublicAccountKeysType{}
-
-func NewPublicAccountKeysType() PublicAccountKeysType {
- return ThePublicAccountKeysType
-}
-
-func (PublicAccountKeysType) isType() {}
-
-func (PublicAccountKeysType) ID() string {
- return "PublicAccount.Keys"
-}
-
-func (t PublicAccountKeysType) Equal(other Type) bool {
- return t == other
-}
-
-// AccountKeyType
-type AccountKeyType struct{}
-
-var TheAccountKeyType = AccountKeyType{}
-
-func NewAccountKeyType() AccountKeyType {
- return TheAccountKeyType
-}
-
-func (AccountKeyType) isType() {}
-
-func (AccountKeyType) ID() string {
- return "AccountKey"
-}
-
-func (t AccountKeyType) Equal(other Type) bool {
- return t == other
->>>>>>> 3773020ec (remove TODO)
-}
-
// TypeWithCachedTypeID recursively caches type ID of type t.
// This is needed because each type ID is lazily cached on
// its first use in ID() to avoid performance penalty.
|
@SupunS @dsainati1 Could you please have another look? (see comment above) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Closes #2641
Description
AuthAccount
andPublicAccount
intoAccount
typeAuthAccount
andPublicAccount
uses with variations of&Account
typeAuthAccount
storage functions toAccount.Storage
functionsAccount.Storage
AuthAccount
value and related nested value implementations (e.g.AuthAccount.Capabilities
) toAccount
PublicAccount
value and related nested value implementations (e.g.PublicAccount.Capabilities
)AuthAccount
constructor toAccount
constructorcadence
packageStorageCapabilityController
andAccountCapabilityController
Mutate
Insert
Remove
Identity
Storage
SaveValue
LoadValue
BorrowValue
Contracts
AddContract
UpdateContract
RemoveContract
Keys
AddKey
RevokeKey
Inbox
PublishInboxCapability
UnpublishInboxCapability
ClaimInboxCapability
Capabilities
StorageCapabilities
AccountCapabilities
PublishCapability
UnpublishCapability
GetStorageCapabilityController
IssueStorageCapabilityController
GetAccountCapabilityController
IssueAccountCapabilityController
owner
valuegetAuthAccount
with more entitlementsmaster
branchFiles changed
in the Github PR explorer