Skip to content

Commit 6b14a49

Browse files
authored
Merge pull request #261 from onflow/more-migration-guides
Edit remaining Cadence Migration guides
2 parents 59ad9df + 16a061d commit 6b14a49

3 files changed

Lines changed: 134 additions & 213 deletions

File tree

docs/cadence-migration-guide/core-contracts-guide.mdx

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,25 @@ sidebar_position: 4
44
sidebar_label: Core Contracts Guide
55
---
66

7-
## Protocol Smart Contracts in Cadence 1.0
7+
# Protocol Smart Contracts in Cadence 1.0
88

9-
On September 4th, 2024 the Flow Mainnet upgraded to Cadence 1.0.
10-
In addition to many changes to the Cadence programming language and
11-
the Cadence token standards, the Flow Protocol smart contracts
12-
also updated to be compatible with the changes.
9+
:::important
1310

14-
All applications that interact with these contracts need to update their transactions and scripts
15-
in order to be compatible with the changes.
11+
On September 4th, 2024, the Flow Mainnet upgraded to Cadence 1.0. In addition to many changes to the Cadence programming language and the Cadence token standards, the Flow Protocol smart contracts were also updated to be compatible with the changes.
1612

17-
## Important Info
13+
All applications that interact with these contracts need to update their transactions and scripts in order to be compatible with these changes.
1814

19-
This document assumes you have a basic understanding of the
20-
[Cadence 1.0 improvements](./improvements.md) and modifications to the Fungible Token Standard.
21-
We encourage you to consult those guides for more details on these changes if you are interested.
15+
:::
2216

23-
The updated code for the Cadence 1.0 versions of the protocol smart contracts is located in the
24-
[`master` branch of the flow-core-contracts repo](https://github.com/onflow/flow-core-contracts).
25-
Please look at the [PR that made the changes](https://github.com/onflow/flow-core-contracts/pull/319)
26-
to understand how the contracts have changed. Every contract in the repo changed.
17+
## Important info
2718

28-
Additionally, here are the import addresses
29-
for all of the important contracts related to the protocol:
19+
This document assumes you have a basic understanding of the [Cadence 1.0 improvements] and modifications to the Fungible Token Standard. We encourage you to consult those guides for more details on these changes if you are interested.
3020

31-
| Contract | Emulator Import Address | Testing Framework |
21+
The updated code for the Cadence 1.0 versions of the protocol smart contracts is located in the [`master` branch of the flow-core-contracts repo]. Please look at the [PR that made the changes] to understand how the contracts have changed. Every contract in the repo changed.
22+
23+
Additionally, here are the import addresses for all of the important contracts related to the protocol:
24+
25+
| Contract | Emulator import address | Testing framework |
3226
| --------------------------- | ----------------------- | -------------------- |
3327
| `FungibleToken` | `0xee82856bf20e2aa6` | `0x0000000000000002` |
3428
| `ViewResolver` | `0xf8d6e0586b0a20c7` | `0x0000000000000001` |
@@ -49,16 +43,16 @@ for all of the important contracts related to the protocol:
4943
| `FlowEpoch` | `0xf8d6e0586b0a20c7` | `0x0000000000000001` |
5044
| `FlowStakingCollection` | `0xf8d6e0586b0a20c7` | `0x0000000000000001` |
5145

52-
See the other guides in this section of the docs for the import
53-
addresses of other important contracts in the emulator.
46+
See the other guides in this section of the docs for the import addresses of other important contracts in the emulator.
47+
48+
## Upgrade guide
49+
50+
The NFT guide covers a lot of common changes that are required for NFT contracts, but many of these changes will also apply to any contract on Flow, so it is still useful to read even if you don't have an NFT contract.
5451

55-
## Upgrade Guide
52+
The core contracts do not have any meaningful changes outside of what is required to be compatible with Cadence 1.0 and the token standard changes. If you have questions about the core contracts changes for Cadence 1.0, please reach out to the Flow team in Discord and we will be happy to help.
5653

57-
The NFT guide covers a lot of common changes that are required for NFT contracts,
58-
but many of these changes will also apply to any contract on Flow, so it is still
59-
useful to read even if you don't have an NFT contract.
54+
<!-- Relative links. Will not render on the page -->
6055

61-
The core contracts do not have any meaningful changes outside of what is required
62-
to be compatible with Cadence 1.0 and the token standard changes.
63-
If you have questions about the core contracts changes for Cadence 1.0,
64-
please reach out to the Flow team in Discord and we will be happy to help.
56+
[Cadence 1.0 improvements]: ./improvements.md
57+
[`master` branch of the flow-core-contracts repo]: https://github.com/onflow/flow-core-contracts
58+
[PR that made the changes]: https://github.com/onflow/flow-core-contracts/pull/319

docs/cadence-migration-guide/ft-guide.mdx

Lines changed: 45 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,25 @@ sidebar_label: FT Cadence 1.0 Guide
66

77
# Fungible Tokens in Cadence 1.0
88

9-
On September 4th, 2024 the Flow Mainnet upgraded to Cadence 1.0.
10-
In addition to many changes to the Cadence programming language,
11-
the Cadence token standards also got streamlined and improved.
12-
All applications need to migrate their existing Cadence scripts and transactions for the update.
13-
If you do not update your code, your application will not function.
14-
15-
This document describes the changes to the Cadence Fungible Token (FT) standard.
16-
We'll be using the
17-
[`ExampleToken` contract](https://github.com/onflow/flow-ft/blob/master/contracts/ExampleToken.cdc)
18-
as an example. Many projects have used `ExampleToken` as a starting point for their projects,
19-
so it is widely applicable to most NFT developers on Flow.
20-
The upgrades required for `ExampleToken` will cover 90%+ of what you'll
21-
need to do to update your contract. Each project most likely has
22-
additional logic or features that aren't included in `ExampleToken`,
23-
but hopefully after reading this guide, you'll understand Cadence 1.0
24-
well enough that you can easily make any other changes that are necessary.
25-
26-
As always, there are plenty of people on the Flow team and in the community
27-
who are happy to help answer any questions you may have, so please reach out
28-
in Discord if you need any help.
29-
30-
# Important Info
31-
32-
Please read [the FLIP](https://github.com/onflow/flips/pull/55)
33-
that describes the changes to the `FungibleToken` standard first.
34-
35-
The updated code for the V2 Fungible Token standard is located in the
36-
[`master` branch of the flow-ft repo](https://github.com/onflow/flow-ft).
37-
Please look at the [PR that made the changes](https://github.com/onflow/flow-ft/pull/131)
38-
to understand how the standard and examples have changed.
39-
Note the changes to the `FungibleTokenMetadataViews`,
40-
`Burner`, `FungibleTokenSwitchboard`, and `TokenForwarding` contracts.
41-
42-
Additionally, here are the import addresses
43-
for all of the important contracts related to fungible tokens.
44-
The second column is the import address if you are testing with a basic version of the emulator.
45-
The third column contains the import addresses if you are using the Cadence testing framework.
46-
47-
| Contract | Emulator Import Address | Testing Framework |
9+
:::important
10+
11+
On September 4th, 2024, the Flow Mainnet upgraded to Cadence 1.0. In addition to many changes to the Cadence programming language, the Cadence token standards also got streamlined and improved. All applications need to migrate their existing Cadence scripts and transactions for the update. If you do not update your code, your application will not function.
12+
13+
:::
14+
15+
This document describes the changes to the Cadence Fungible Token (FT) standard. We'll be using the [`ExampleToken` contract] as an example. Many projects have used `ExampleToken` as a starting point for their projects, so it is widely applicable to most NFT developers on Flow. The upgrades required for `ExampleToken` will cover 90%+ of what you'll need to do to update your contract. Each project most likely has additional logic or features that aren't included in `ExampleToken`, but hopefully, after reading this guide, you'll understand Cadence 1.0 well enough that you can easily make any other changes that are necessary.
16+
17+
As always, there are plenty of people on the Flow team and in the community who are happy to help answer any questions you may have, so please reach out in Discord if you need any help.
18+
19+
## Important info
20+
21+
Please read the [FLIP] that describes the changes to the `FungibleToken` standard first.
22+
23+
The updated code for the V2 Fungible Token standard is located in the [`master` branch of the flow-ft repo]. Please look at the [PR that made the changes] to understand how the standard and examples have changed. Note the changes to the `FungibleTokenMetadataViews`, `Burner`, `FungibleTokenSwitchboard`, and `TokenForwarding` contracts.
24+
25+
Additionally, here are the import addresses for all of the important contracts related to fungible tokens. The second column is the import address if you are testing with a basic version of the emulator. The third column contains the import addresses if you are using the Cadence testing framework:
26+
27+
| Contract | Emulator import address | Testing framework |
4828
| --------------------------- | ----------------------- | -------------------- |
4929
| `FungibleToken` | `0xee82856bf20e2aa6` | `0x0000000000000002` |
5030
| `ViewResolver` | `0xf8d6e0586b0a20c7` | `0x0000000000000001` |
@@ -53,47 +33,46 @@ The third column contains the import addresses if you are using the Cadence test
5333
| `FungibleTokenMetadataViews`| `0xee82856bf20e2aa6` | `0x0000000000000002` |
5434
| `FungibleTokenSwitchboard` | `0xee82856bf20e2aa6` | `0x0000000000000002` |
5535

56-
See the other guides in this section of the docs for the import
57-
addresses of other important contracts in the emulator.
58-
59-
As for contracts that are important for NFT developers but aren't "core contracts",
60-
here is information about where to find the Cadence 1.0 versions of each:
36+
See the other guides in this section of the docs for the import addresses of other important contracts in the emulator.
6137

62-
**USDC:** USDC was migrated to standard bridged USDC on Flow. See the [repo](https://github.com/onflow/bridged-usdc) for the latest version of the USDC contract.
38+
As for contracts that are important for NFT developers but aren't _core contracts_, here is information about where to find the Cadence 1.0 versions of each:
6339

64-
**Account Linking and Hybrid Custody:**
65-
See [this PR in the hybrid custody repo](https://github.com/onflow/hybrid-custody/pull/164)
66-
for updated hybrid custody contracts.
40+
- **USDC** — USDC was migrated to standard bridged USDC on Flow. See the [repo] for the latest version of the USDC contract.
41+
- **Account Linking and Hybrid Custody** — See [this PR in the hybrid custody repo] for updated hybrid custody contracts.
6742

68-
[This Discord announcement](https://discord.com/channels/613813861610684416/811693600403357706/1225909248429527140)
69-
also contains versions of a lot of important contracts.
43+
[This Discord announcement] also contains versions of a lot of important contracts.
7044

71-
Use the [Flow Contract Browser](https://contractbrowser.com/) to find the 1.0 code of other contracts.
45+
Use the [Flow Contract Browser] to find the 1.0 code of other contracts.
7246

73-
# Migration Guide
47+
## Migration guide
7448

75-
Please see the [NFT Cadence 1.0 migration guide](./nft-guide.mdx).
76-
While the contracts aren't exactly the same, they share a huge amount of functionality,
77-
and the changes described in that guide will cover 90% of the changes
78-
that are needed for fungible tokens, so if you just follow those instructions
79-
for your fungible token contract, you'll be most of the way there.
49+
Please see the [NFT Cadence 1.0 migration guide]. While the contracts aren't exactly the same, they share a large amount of functionality, and the changes described in that guide will cover 90% of the changes that are needed for fungible tokens, so if you just follow those instructions for your fungible token contract, you'll be most of the way there.
8050

8151
Here, we will only describe the changes that are specific to the fungible token standard.
8252

83-
## `Vault` implements `FungibleToken.Vault`
53+
### `Vault` implements `FungibleToken.Vault`
8454

85-
`FungibleToken.Vault` is no longer a resource type specification.
86-
It is now an interface that inherits from `Provider`, `Receiver`, `Balance`,
87-
`ViewResolver.Resolver`, and `Burner.Burnable`.
55+
`FungibleToken.Vault` is no longer a resource type specification. It is now an interface that inherits from `Provider`, `Receiver`, `Balance`, `ViewResolver.Resolver`, and `Burner Burnable`.
56+
57+
Since `Vault` is an interface, you will need to update every instance in your code that refers to `@FungibleToken.Vault` or `&FungibleToken.Vault` to `@{FungibleToken.Vault}` or `&{FungibleToken.Vault}` respectively to show that it is now an interface specification instead of a concrete type specification.
58+
59+
Here's an example in `deposit()`:
8860

89-
Since `Vault` is an interface, you will need to update every instance in your code
90-
that refers to `@FungibleToken.Vault` or `&FungibleToken.Vault` to
91-
`@{FungibleToken.Vault}` or `&{FungibleToken.Vault}` respectively to show
92-
that it is now an interface specification instead of a concrete type specification.
93-
Example in `deposit()`:
9461
```cadence
9562
/// deposit now accepts a resource that implements the `FungibleToken.Vault` interface type
9663
access(all) fun deposit(from: @{FungibleToken.Vault})
9764
```
9865

9966
If you have any more questions, please ask in discord and the Flow team will be happy to assist!
67+
68+
<!-- Relative links. Will not render on the page -->
69+
70+
[`ExampleToken` contract]: https://github.com/onflow/flow-ft/blob/master/contracts/ExampleToken.cdc
71+
[FLIP]: https://github.com/onflow/flips/pull/55
72+
[`master` branch of the flow-ft repo]: https://github.com/onflow/flow-ft
73+
[PR that made the changes]: https://github.com/onflow/flow-ft/pull/131
74+
[repo]: https://github.com/onflow/bridged-usdc
75+
[this PR in the hybrid custody repo]: https://github.com/onflow/hybrid-custody/pull/164
76+
[This Discord announcement]: https://discord.com/channels/613813861610684416/811693600403357706/1225909248429527140
77+
[Flow Contract Browser]: https://contractbrowser.com/
78+
[NFT Cadence 1.0 migration guide]: ./nft-guide.mdx

0 commit comments

Comments
 (0)