-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add documentation for project commands #57
Conversation
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.
Wow projects! Cant wait to use this!
Was there any thought in adding project support to the vscode flow plugin?
docs/initialize-project.md
Outdated
|
||
## Example Project Configuration | ||
|
||
TODO: add sample project config here |
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.
Is this todo meant for later?
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.
@sideninja I saw that you had a pretty good example version of flow.json
. Can you add it here?
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.
This is a draft from my docs
title: Deploy contracts with the Flow CLI
sidebar_title: Deploy Contracts
description: How to deploy Cadence contracts using Flow CLI
The Flow CLI provides a command to deploy Cadence contracts on predefined accounts on any network.
flow project deploy-contracts
Example Usage
> flow project deploy-contracts
NonFungibleToken -> 0xf8d6e0586b0a20c7
FungibleToken -> 0xf8d6e0586b0a20c7
Kibble -> 0xf8d6e0586b0a20c7
✅ All contracts deployed successfully
Options
Network
- Flag:
--network
- Valid inputs:
"emulator", "testnet", "any"
- Default:
"emulator"
Network configuration to use for deploy. You can use any network specified in configuration.
Update
- Flag:
--update
- Valid inputs:
false, true
- Default:
false
Use update flag to update existing contracts on the account.
Configuration
Project uses configuration file you can generate by using flow project init
command or by hand. After you generate configuration file you must add contracts and accounts you wish to use for deployment.
Bellow is an example configuration file and we will document each configuration option.
{
"contracts": {
"NonFungibleToken": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc",
"Kibble": "./cadence/kibble/contracts/Kibble.cdc",
"KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc",
"KittyItemsMarket": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc",
"FungibleToken": {
"testnet": "0x123",
"emulator": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc"
}
},
"deploy": {
"testnet": {
"admin-account": ["NonFungibleToken"],
"user-account": ["Kibble", "KittyItems", "KittyItemsMarket"]
},
"emulator": {
"emulator-account": ["NonFungibleToken", "FungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"]
}
},
"accounts": {
"admin-account": {
"address": "0x2244224422",
"keys": "22232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
},
"user-account": {
"address": "0x123123123",
"keys": "22232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
},
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"keys": "2eae2f31cb5b756151fa11d82949c634b8f28796a711d7eb1e52cc301edfb3e0",
"chain": "flow-emulator"
}
},
"networks": {
"emulator": {
"host": "127.0.0.1:3569",
"serviceAccount": "emulator-service"
},
"testnet": "access.testnet.nodes.onflow.org:9000"
}
}
Contracts
Contract section defines contract names and their code location or address. We can also use advance format where we can define code location for each network.
Simple format
...
"contracts": {
"NonFungibleToken": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc"
}
...
Advanced format
...
"FungibleToken": {
"testnet": "0x123",
"emulator": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc"
}
...
Accounts
Account section is used to define account properties such as keys and addresses. Each account must include a name which then gets referenced throught the config file.
Simple format
All we need to define in simple format is address
for the account and its private key under keys
.
...
"accounts": {
"admin-account": {
"address": "0x2244224422",
"keys": "22232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
}
...
Advanced format
Advanced format allows us to define any paramter possible. You can check all the values for paramters (here). Please note we can use service
for address in case the account is used on emulator
network
as this is a special value that is defined on the run time to the default service address on the emulator network.
...
"accounts": {
"admin-account": {
"address": "service",
"chain": "flow-emulator",
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "1272967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
},
{
"type": "hex",
"index": 1,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "2372967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
}
]
}
}
...
Deploys
Deploys section defines where the deploy-contracts
command will deploy specified contracts. This configuration property is like glue that ties together accounts,
contracts and networks all referenced by their name.
Simple format
"deploy": {
"emulator": {
"emulator-account": ["NonFungibleToken", "FungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"]
},
"testnet": {
"admin-account": ["NonFungibleToken"],
"user-account": ["Kibble", "KittyItems", "KittyItemsMarket"]
},
}
...
Networks
Use this section to define networks and their attributes.
Simple format
...
"networks": {
"emulator": {
"host": "127.0.0.1:3569",
"serviceAccount": "emulator-service"
},
"testnet": "access.testnet.nodes.onflow.org:9000"
}
...
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.
We need to update this for the aliases-sources
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.
Nice!
|
||
In the example above, your `flow.json` file might look something like this: | ||
|
||
```json |
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.
add ...
before and after json config example so we show that is not complete flow.json.
|
||
⚠️ _Warning: CLI projects are an experimental feature._ | ||
|
||
## Add a Contract |
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.
Should we add also advanced format
d6c36ee
to
cf6b63d
Compare
}, | ||
"deploy": { | ||
"testnet": { | ||
"my-testnet-account": ["Foo", "Bar"] |
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.
Should we reference emulator-account
in our examples since it is already generated by project init
? If a user wants to add more accounts on different networks that should maybe be described in a separate section.
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.
Yes, this is a good idea. Let's follow up with this change
57b7754
to
31d7406
Compare
Closes #50
Description
Add documentation for the new
flow project
commands, including the much-anticipatedflow project deploy
.For contributor use:
master
branchFiles changed
in the Github PR explorer