Convert `upgrade` to Cadence.

See #375.