Skip to content
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

FEATURE: Cadence 1.0 Core Contracts Changes #319

Merged
merged 136 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
d7330c3
update to view functions for stable cadence
joshuahannan Nov 2, 2022
bebb19d
Update to newest Stable Cadence Preview (#371)
dsainati1 Jul 5, 2023
a9e9e5d
remove casting and fix conflicts
joshuahannan Jul 10, 2023
253f985
integrate ft and nft stable cadence changes, use access, view, and en…
joshuahannan Jul 18, 2023
d5d3fc2
use v2 ft and nft
joshuahannan Jul 18, 2023
58bfcfb
use string for nft import
joshuahannan Jul 18, 2023
d9d2614
update token deps
joshuahannan Jul 18, 2023
9b8c764
update token deps
joshuahannan Jul 18, 2023
5044e1d
update nft dependecy
joshuahannan Jul 18, 2023
07c8c7b
update nft dep
joshuahannan Jul 18, 2023
99f47a0
update ft dep
joshuahannan Jul 18, 2023
aa0d30b
add more view
joshuahannan Jul 19, 2023
69e65bd
update FlowToken contract getter to explicitly use metadata views
joshuahannan Jul 19, 2023
a94c565
implement new standard methods
joshuahannan Jul 19, 2023
90cd889
update nft dependency
joshuahannan Jul 19, 2023
8217b15
update ft dep
joshuahannan Jul 19, 2023
7a4a112
fix FungibleToken.Vault types and imports
joshuahannan Jul 19, 2023
dc499b4
remove view from copy
joshuahannan Jul 19, 2023
3e0bd42
add correct vault type
joshuahannan Jul 19, 2023
e642b90
remove views and update balances
joshuahannan Jul 19, 2023
9f786d5
use vault interface type
joshuahannan Jul 19, 2023
a3ad792
remove restricted types
joshuahannan Jul 26, 2023
0bd0969
remove AnyStruct
joshuahannan Jul 26, 2023
40fdc45
remove type restrictions
joshuahannan Jul 26, 2023
bceaf1d
fix view modifiers in epoch contracts
joshuahannan Jul 27, 2023
d6f1c62
remove view for dkgCompleted
joshuahannan Jul 27, 2023
00f3f53
remove non-view methods from pre-conditions
joshuahannan Jul 27, 2023
d258883
use setter methods in QC
joshuahannan Jul 27, 2023
334b5ef
remove pub from QC
joshuahannan Jul 27, 2023
088c4f1
add fun keyword
joshuahannan Jul 27, 2023
186f352
use setters for fields and use getBalance
joshuahannan Jul 27, 2023
eaf04f6
use view keyword
joshuahannan Jul 27, 2023
4a593e6
remove restricted types from flow epoch
joshuahannan Jul 27, 2023
f82c0bd
use setters in FlowEpoch
joshuahannan Jul 27, 2023
1e42943
correct metadata types
joshuahannan Jul 27, 2023
b6eea49
use UInt64 in NodeVersionBeacon
joshuahannan Jul 27, 2023
234488b
dont use restricted types in locked tokens and staking collection
joshuahannan Jul 27, 2023
32ee36b
make LockedTokens compatible with FungibleToken
joshuahannan Jul 28, 2023
3e7e66c
use entitlement for manager
joshuahannan Jul 28, 2023
81673c1
correct entitlement syntax
joshuahannan Jul 28, 2023
3366647
fix entitlement issues with locked tokens
joshuahannan Jul 28, 2023
ae14189
fix entitlement issues with staking collection
joshuahannan Jul 28, 2023
98e669c
fix entitlement return types
joshuahannan Jul 28, 2023
d03de9a
add withdrawable to machine account functions
joshuahannan Jul 28, 2023
20bc88d
replace addresses and fix transactions and scripts
joshuahannan Aug 2, 2023
f00e74c
fixes to epoch tests
joshuahannan Aug 8, 2023
8a95802
update to latest token standards and update locked tokens transactions
joshuahannan Aug 22, 2023
90028cb
Update contracts
SupunS Sep 8, 2023
5624221
Update more contracts
SupunS Sep 11, 2023
a146eb7
Update contracts
SupunS Sep 11, 2023
47c7323
Update contarcts and transactions
SupunS Sep 12, 2023
7f6a9cf
go mod tidy
SupunS Sep 12, 2023
006692d
Update flow-sdk
SupunS Sep 12, 2023
20bf827
Update more contracts
SupunS Sep 12, 2023
f90b7db
Update ft/nft deps
SupunS Sep 13, 2023
3e4a8d7
Generate assets
SupunS Sep 13, 2023
148f186
Update more cadence codes
SupunS Sep 13, 2023
5287d71
Update staking collection
SupunS Sep 13, 2023
82e83fc
Update go mods
SupunS Sep 13, 2023
6e65aab
Fix typo
SupunS Sep 14, 2023
071589b
Replace get()+borrow() with borrow()
SupunS Sep 14, 2023
8bf41b7
Refactor code
SupunS Sep 14, 2023
36b3a40
Update go-sdk and flow-nft versions
SupunS Sep 15, 2023
a14bfc3
Fix publish_voter transaction
SupunS Sep 18, 2023
1a47522
Update to Cadence v1.0.0-preview.1
SupunS Sep 21, 2023
7f0ae3d
Apply suggestions from code review
SupunS Sep 21, 2023
222d143
Refactor code
SupunS Sep 22, 2023
889e103
fix and improve syntax
turbolent Sep 22, 2023
0e44d6d
use optional chaining and nil-coaelescing instead of force-unwrapping
turbolent Sep 22, 2023
2ba8ec1
Update get_total_balance.cdc
SupunS Sep 26, 2023
5d361b6
Merge remote-tracking branch 'origin/master' into stable-cadence
joshuahannan Nov 21, 2023
b41a334
make sure epoch contracts work with capability controllers and entitl…
joshuahannan Nov 22, 2023
f8dfacb
update dependencies and add public burn tokens method
joshuahannan Dec 4, 2023
69a42be
fix go.mod conflict from merge from master
joshuahannan Dec 11, 2023
e45ba2b
remove view from getRandomSourceHistoryPage and use account.storage
joshuahannan Dec 11, 2023
37cbe45
remove custom destructors and fix entitlement usage
joshuahannan Dec 12, 2023
965521c
merge from master and update dependencies
joshuahannan Jan 2, 2024
5f2af20
get all go tests passing for cadence 1.0
joshuahannan Jan 2, 2024
93317bc
make ci
joshuahannan Jan 2, 2024
6eb32e7
make ci
joshuahannan Jan 2, 2024
b29775f
update random source transactions
joshuahannan Jan 2, 2024
1c546c6
update cli version for CI
joshuahannan Jan 2, 2024
cb90b89
update go version
joshuahannan Jan 3, 2024
c0c5250
Update Cadence version (#406)
SupunS Jan 23, 2024
77b4a62
update Withdrawable and createEmptyVault
joshuahannan Jan 23, 2024
1036e08
merge from origin
joshuahannan Jan 23, 2024
8d58eb4
update createEmpty in staking
joshuahannan Jan 24, 2024
7204ba8
use Burner and update dependencies
joshuahannan Jan 25, 2024
9289bdc
update to SDK v1.0.0-M1
turbolent Jan 25, 2024
1a178d6
update NFT contracts, remove replace statements
turbolent Jan 25, 2024
edbd26e
update to Cadence v1.0.0-M3
turbolent Jan 25, 2024
df76aaf
update to Cadence v1.0.0-M3 and SDK v1.0.0-M1
turbolent Jan 25, 2024
b7a9513
remove getBalance, add isAvailableToWithdraw
joshuahannan Jan 25, 2024
e3aada3
update ft and nft deps
joshuahannan Feb 1, 2024
1984b08
merge from master
joshuahannan Feb 1, 2024
5f44be4
update emulator dependencies and get tests passing
joshuahannan Feb 1, 2024
80dacce
use FungibleToken.Balance instead of FlowToken.Vault
joshuahannan Feb 1, 2024
89c4b73
use correct public path types
joshuahannan Feb 5, 2024
e489275
update imports
joshuahannan Feb 6, 2024
7af9d5b
go mod tidy
joshuahannan Feb 6, 2024
b75941c
add fungible token switchboard
joshuahannan Feb 6, 2024
928bf99
fix switchboard
joshuahannan Feb 6, 2024
098fbb0
update error messages for ledger transactions
joshuahannan Feb 7, 2024
439755c
add updated manifests with new account, FT, and NFT transactions and …
joshuahannan Feb 9, 2024
b403661
update account transactions to use simple arguments
joshuahannan Feb 12, 2024
7d800d5
update manifest to include both styles of token transfer transactions:
joshuahannan Feb 13, 2024
46d7685
update emulator dependency
joshuahannan Feb 13, 2024
439c5aa
use string args for NFT contracts
joshuahannan Feb 14, 2024
f5053a4
update collection machine account transactions to not use keylist entry
joshuahannan Feb 15, 2024
a7b73af
Update contract getter methods to use env (#410)
joshuahannan Feb 27, 2024
fda9bc2
get address replacement working in tests and add event emission restr…
joshuahannan Feb 27, 2024
d81e0c3
update to latest emulator, cadence, and token standards versions
joshuahannan Mar 5, 2024
6f9e0a9
Update README
joshuahannan Mar 7, 2024
bcf77ee
Don't copy dictionary in getEpochMetadata (#413)
janezpodhostnik Mar 22, 2024
4352c32
update NFT contracts
joshuahannan Mar 26, 2024
10241ff
update ft dependency
joshuahannan Mar 27, 2024
f410947
update token standard dependencies
joshuahannan Apr 2, 2024
9004857
make ci
joshuahannan Apr 2, 2024
77f7eae
fix algorithm typo and test names
joshuahannan Apr 8, 2024
826099b
update nft transactions
joshuahannan Apr 9, 2024
d40b890
fix typos in transactions
joshuahannan Apr 15, 2024
486ea68
update nft dependencies
joshuahannan Apr 15, 2024
1b20b4d
update RandomBeaconHistory to Cadence 1.0
joshuahannan Apr 16, 2024
272832a
Add entitlement for locked account creator (#423)
joshuahannan Apr 24, 2024
50821c3
update ft dependencies
joshuahannan Apr 24, 2024
93d97ed
remove optional chaining in FlowStakingCollection
joshuahannan Apr 24, 2024
0fc367f
remove optional chaining
joshuahannan Apr 24, 2024
e696a8e
update nft imports and remove unnecessary Burner import from FlowToken
joshuahannan Apr 29, 2024
af808a6
update dependencies
joshuahannan May 7, 2024
7cecccd
Improve random distribution (#428)
tarakby May 9, 2024
fa79414
address PR comments and add entitlements to LockedTokens.TokenManager
joshuahannan May 9, 2024
4f23668
remove UseTokens entitlement
joshuahannan May 9, 2024
9490f1d
use view more and update nft deps
joshuahannan May 17, 2024
47a27af
make ci
joshuahannan May 17, 2024
228d291
add view modifiers
joshuahannan Jun 6, 2024
437cc82
update dependencies
joshuahannan Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 3 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: "1.21.5"
- uses: actions/setup-node@v3
with:
node-version: 16
cache: "npm"
cache-dependency-path: lib/js/test/package-lock.json
go-version: '1.21.5'
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.15.0
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)"
- name: Flow cli Version
run: flow version
run: flow-c1 version
- name: Update PATH
run: echo "/root/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: cd lib/js/test && npm ci
- name: Run tests
run: export GOPATH=$HOME/go && make ci
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
test:
$(MAKE) generate -C lib/go
$(MAKE) test -C lib/go
flow test --cover --covercode="contracts" tests/test_*.cdc
flow-c1 test --cover --covercode="contracts" tests/*.cdc

.PHONY: ci
ci:
$(MAKE) ci -C lib/go
flow test --cover --covercode="contracts" tests/test_*.cdc
flow-c1 test --cover --covercode="contracts" tests/*.cdc
135 changes: 61 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

These are the smart contracts that define the core functionality of the Flow protocol.

The version of the contracts in the `master` branch is the
Cadence 1.0 version of the contracts and is not the same
as the ones that are currently deployed to testnet and mainnet.
See the `cadence-0.42` branch for the currently deployed versions.

# What is Flow?

Flow is a new blockchain for open worlds. Read more about it [here](https://www.onflow.org/).
Expand All @@ -20,12 +25,13 @@ so they can build a basic understanding of the programming language.

`contracts/FlowToken.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0x0ae53cb6e3f42a79` |
| Testnet | `0x7e60df042a9c0868` |
| Sandboxnet | `0x0661ab7d6696a460` |
| Mainnet | `0x1654653399040a61` |
| Network | Contract Address |
| ---------------------------- | -------------------- |
| Emulator | `0x0ae53cb6e3f42a79` |
| Previewnet | `0x4445e7ad11568276` |
| Testnet/Crescendo | `0x7e60df042a9c0868` |
| Sandboxnet | `0x0661ab7d6696a460` |
| Mainnet | `0x1654653399040a61` |

This is the contract that defines the network token for Flow.
This token is used for account creation fees, transaction fees, staking, and more. It is
Expand All @@ -39,25 +45,27 @@ You can find transactions for using the Flow Token in the `transactions/flowToke

`contracts/FlowFees.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xe5a8b7f23e8b548f` |
| Testnet | `0x912d5440f7e3769e` |
| Sandboxnet | `0xe92c2039bbe9da96` |
| Mainnet | `0xf919ee77447b7497` |
| Network | Contract Address |
| ---------------------------- | -------------------- |
| Emulator | `0xe5a8b7f23e8b548f` |
| Previewnet | `0xab086ce9cc29fc80` |
| Testnet/Crescendo | `0x912d5440f7e3769e` |
| Sandboxnet | `0xe92c2039bbe9da96` |
| Mainnet | `0xf919ee77447b7497` |

This contract defines fees that are spent for executing transactions and creating accounts.

## Storage Fee Contract

`contracts/FlowStorageFees.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |
| Network | Contract Address |
| ---------------------------- | -------------------- |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet/Crescendo | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |

This contract defines fees that are spent to pay for the storage that an account uses.
There is a minimum balance that an account needs to maintain in its main `FlowToken` Vault
Expand All @@ -68,12 +76,13 @@ You can see [more docs about storage capacity and fees here.](https://docs.onflo

`contracts/FlowServiceAccount.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |
| Network | Contract Address |
| ---------------------------- | -------------------- |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet/Crescendo | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |

This contract manages account creation and flow token initialization. It enforces temporary
requirements for which accounts are allowed to create other accounts, and provides common
Expand All @@ -85,12 +94,13 @@ You can find transactions for interacting with the service account contract in t

`contracts/RandomBeaconHistory.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |
| Network | Contract Address |
| ---------------------------- | -------------------- |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet/Crescendo | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |

This contract stores the history of random sources generated by
the Flow network. The defined Heartbeat resource is
Expand All @@ -104,14 +114,15 @@ You can find transactions for interacting with the random beacon

`contracts/NodeVersionBeacon.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |
| Network | Contract Address |
| ----------------- | -------------------- |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet/Crescendo | `0x8c5303eaa26202d6` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0xe467b9dd11fa00df` |

The NodeVersionBeacon contract holds the past
The `NodeVersionBeacon` contract holds the past
and future protocol versions that should be used
to execute/handle blocks at a given block height.

Expand All @@ -123,12 +134,13 @@ history contract in the `transactions/nodeVersionBeacon` directory.
`contracts/FlowIDTableStaking.cdc`
`contracts/epochs/FlowEpoch.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x9eca2b38b18b5dfe` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0x8624b52f9ddcd04a` |
| Network | Contract Address |
| ------------------- | -------------------- |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet/Crescendo | `0x9eca2b38b18b5dfe` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0x8624b52f9ddcd04a` |

These contract manages the list of identities that correspond to node operators in the Flow network
as well as the process for adding and removing nodes from the network via Epochs.
Expand Down Expand Up @@ -156,7 +168,8 @@ These scripts are documented in the [staking scripts section of the docs](https:

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Emulator | `0xf8d6e0586b0a20c7` |
| Previewnet | `0xb6763b4399a888c8` |
| Testnet | `0x95e019a17d0e23d7` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0x8d0e87b65159ae63` |
Expand All @@ -168,12 +181,8 @@ token sale in October of 2020. See more documentation about `LockedTokens` [here

`contracts/FlowStakingCollection.cdc`

| Network | Contract Address |
| --------------- | -------------------- |
| Emulator/Canary | `0xf8d6e0586b0a20c7` |
| Testnet | `0x95e019a17d0e23d7` |
| Sandboxnet | `0xf4527793ee68aede` |
| Mainnet | `0x8d0e87b65159ae63` |
The `StakingCollection` contract has the same import addresses
as the `LockedTokens` contract on all the networks.

A Staking Collection is a resource that allows its owner to manage multiple staking
objects in a single account via a single storage path, and perform staking and delegation actions using both locked and unlocked Flow.
Expand Down Expand Up @@ -226,35 +235,13 @@ need to copy and paste them into your code. We plan on providing packages for di
languages to import in order to use the transactions instead of copying and pasting.

We currently include the `lib/go/templates` package for getting templates in the Go programming language.
To use this package, run `import github.com/onflow/flow-core-contracts/lib/go/templates@{latest version}`
To use this package, run `go get github.com/onflow/flow-core-contracts/lib/go/templates@{latest version}`
in your Go project direcory. To use it in your Go code, you can simply call one of the many
template getters in one of the `*_templates.go` files.

For example, to get the transaction text of the tranasction that is used to register a new node
for staking, and add arguments to it, you would use something like this Go code.

```Go
tx := flow.NewTransaction().
SetScript(templates.GenerateRegisterNodeScript(env)).
SetGasLimit(100).
SetProposalKey(b.ServiceKey().Address, b.ServiceKey().Index, b.ServiceKey().SequenceNumber).
SetPayer(b.ServiceKey().Address).
AddAuthorizer(userAddress)

// Invalid ID: Too short
_ = tx.AddArgument(cadence.NewString("3039"))
_ = tx.AddArgument(cadence.NewUInt8(1))
_ = tx.AddArgument(cadence.NewString("12234"))
_ = tx.AddArgument(cadence.NewString("netkey"))
_ = tx.AddArgument(cadence.NewString("stakekey"))
tokenAmount, err := cadence.NewUFix64("250000.0")
require.NoError(t, err)
_ = tx.AddArgument(tokenAmount)
```

### Packages in other languages

We are planning to add new packages for other popular languages to get transaction templates.
We would like to add new packages for other popular languages to get transaction templates.
If you would like to contribute to add one of these new packages, please reach out
to the team and we would be happy to help!

Expand Down
Loading
Loading