Skip to content

Commit

Permalink
Merge pull request #104 from onflow/sainati/update-validator
Browse files Browse the repository at this point in the history
Update section about validator entitlement computation
  • Loading branch information
dsainati1 committed May 21, 2024
2 parents 549d7f9 + 3aab079 commit 4c27ce0
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ E.g., for a resource type `R` defined as:
```cadence
access(all) resource R {
access(E) fun foo() { ... }
access(G | H) fun bar() { ... }
access(G, H) fun bar() { ... }
}
```

Expand Down Expand Up @@ -78,6 +78,29 @@ access(all) resource R: I {
A type `&R{I}` should be updated to `auth(E) &R`, since the entitlements it is given is only those in `I`. It does not receive an entitlement to `F`, since
the old `&R{I}` was not able to call `bar`.

An additional caveat is that entitlement disjunctions behave slightly differently than normal during the migration.
While in general (after the release of Cadence 1.0) it will be possible to define a resource `R` like so:

```cadence
access(all) resource R {
access(E) fun foo() { ... }
access(G | H) fun bar() { ... }
}
```

The validator will reject this particular definition during the migration, as the inferred entitlements granted to a resource reference of this type (`&R`)
would be `E & (G | H)`, which Cadence cannot represent. The migration will attempt to result simple disjunctions, e.g. if you define a resource `X` like so:

```cadence
access(all) resource X {
access(E) fun foo() { ... }
access(E | G) fun bar() { ... }
}
```

The migration and validator will correctly realize that you can just grant `E` to `&X` references, but in the general case contract updates that use
entitlement disjunctions will fail in the validator.

## Account Types

The replacement for `AuthAccount` is the fully-entitled type `auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account`.
Expand Down

0 comments on commit 4c27ce0

Please sign in to comment.