-
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 deploy-contracts command #45
Conversation
1a2c2ff
to
bd6228a
Compare
bd6228a
to
5eb0f41
Compare
Documentation Sync Configuration Security Remote Imports Configuration Flow |
Feedback on the flow.json schema, I agree flow.private.json is a good idea to maybe avoid pushing secrets to github, it would also be helpful to have a warning in CLI when ran to warn you to be careful with the secret when running on mainnet? Or should CLI even discourage using that for mainnet? In any case, I strongly think there should be JSON schema validation. If devs will change and insert JSON conf by hand CLI should detect errors and even better suggest fixes. I think schema can be further simplified by not specifying default values. Such an example is:
These keys are default and I think should be avoided in config but if a developer wants to change them they can. Another thing that might be confusing a bit is that under the contracts key the first key are not contracts themselves but accounts. I'm not even sure what that first key represents and how can it be used (but that still might be because of my lack of understanding the code):
Is Are |
I created my take on a config schema that is compared to the current config for an example project. Test project: Deployed to emulator on two accounts, Deployed to testnet on two accounts I managed to lower the complexity of config (line count) by 58% for same configuration - 49 lines vs 114 lines schema current: {
"emulator": {
"default": {
"port": 3569,
"serviceKey": {
"privateKey": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47",
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
}
}
},
"networks": {
"emulator": {
"host": "127.0.0.1:3569",
"chain": "flow-emulator"
},
"testnet": {
"host": "access.testnet.nodes.onflow.org:9000",
"chain": "testnet"
}
},
"aliases": null,
"contracts": {
"test": {
"target": {
"emulator": "emulator-service-account-2",
"testnet": "testnet-account-2"
},
"source": {
"KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc",
"KittyItemsMarket": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc"
}
},
"hungry-kitties": {
"target": {
"emulator": "emulator-service-account",
"testnet": "testnet-account"
},
"source": {
"NonFungibleToken": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc",
"FungibleToken": "../hungry-kitties/cadence/contracts/FungibleToken.cdc",
"Kibble": "./cadence/kibble/contracts/Kibble.cdc",
"KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc",
"KittyItemsMarket": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc"
}
}
},
"accounts": {
"testnet-account-2": {
"address": "0x123123",
"chain": "testnet",
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "1232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
}
]
},
"testnet-account": {
"address": "0x222222",
"chain": "testnet",
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "222967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
}
]
},
"emulator-service-account": {
"address": "service",
"chain": "flow-emulator",
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
}
}
]
},
"emulator-service-account-2": {
"address": "0x2412848124",
"chain": "flow-emulator",
"keys": [
{
"type": "hex",
"index": 0,
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256",
"context": {
"privateKey": "30dd224db9c7a70f035f8092f6c5a44c920bb6cc4c86c4d7b1b34cb32d2f936f"
}
}
]
}
}
} shorter version:
{
"contracts": {
"NonFungibleToken": "../hungry-kitties/cadence/contracts/NonFungibleToken.cdc",
"FungibleToken": "../hungry-kitties/cadence/contracts/FungibleToken.cdc",
"Kibble": "./cadence/kibble/contracts/Kibble.cdc",
"KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc",
"KittyItemsMarket": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc"
},
"deploy": {
"account-1": ["KittyItems", "KittyItemsMarket"],
"account-2": ["NonFungibleToken", "FungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"],
"account-3": ["KittyItems", "KittyItemsMarket"],
"account-4": ["NonFungibleToken", "FungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"]
},
"accounts": {
"account-1": {
"address": "0xabd6e0586b0af502",
"keys": "1232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47",
"network": "testnet"
},
"account-2": {
"address": "0x2c1162386b0a245f",
"keys": "22232967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47",
"network": "testnet"
},
"account-3": {
"address": "service",
"keys": "service",
"network": "emulator"
},
"account-4": {
"address": "0xf8d6e0586b0a20c7",
"keys": "4442967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47",
"network": "emulator"
}
},
"networks": {
"emulator": {
"host": "127.0.0.1:3569",
"keys": "dd72967fd2bd75234ae9037dd4694c1f00baad63a10c35172bf65fbb8ad74b47"
},
"testnet": "access.testnet.nodes.onflow.org:9000"
},
"aliases": null
} |
Some sketches from our call:
"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"
},
"aliases: {
"emulator": {
"FungibleToken": "0xabc",
},
"testnet": {
"FungibleToken": "0xabc",
"NonFungibleToken": "0x1234",
}
}
"deploy": {
"testnet": {
"account-1": ["KittyItems", "KittyItemsMarket"],
"account-2": ["Kibble", "KittyItems", "KittyItemsMarket"],
},
"emulator": {
"account-3": ["KittyItems", "KittyItemsMarket"],
"account-4": ["NonFungibleToken", "Kibble", "KittyItems", "KittyItemsMarket"]
}
}, "contracts": {
"nft": {
"target": {
"emulator": "emulator-service-account",
"testnet": "0xabc"
},
"source": {
"NonFungibleToken": "./cadence/kittyItems/contracts/NonFungibleToken.cdc"
}
},
"kitty-items": {
"target": {
"emulator": "emulator-service-account",
"testnet": "testnet-admin-account"
},
"source": {
"Kibble": "./cadence/kibble/contracts/Kibble.cdc",
"KittyItems": "./cadence/kittyItems/contracts/KittyItems.cdc",
"KittyItemsMarket": "./cadence/kittyItemsMarket/contracts/KittyItemsMarket.cdc",
}
}
} |
it would be nice to have some cli features to help generate/modify that flow.json file.
|
|
This looks great! 👏 🎉 |
This is amazing. This config #45 (comment) looks really promising. Quick thought relevent to this thread: What would be the command for doing a 'reset' of a deployment?
Followed by a confirmation step?
|
Also, some contracts could be deployed to multiple accounts no?
|
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.
Great refactor! @sideninja
My comments are minor and mostly cosmetic. Apart from my suggested changes, I'd say this is pretty much ready to go 💯
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
Co-authored-by: Peter Siemens <peterjsiemens@gmail.com>
The way you can deploy a contract to multiple accounts with the new configuration is simply:
But this feature is currently disabled as it introduces some problems - one of most important is how to know which deployment of contract gets then imported in all the |
Closing this since most of the commits are from @sideninja now. Can you open another PR from the same branch? |
Closes #30
Description
This PR introduces the
flow beta deploy-contracts
command, which automates the contract deployment process for Flow developers.This command reads contract source files defined in
flow.json
and maps them to their declared target accounts. The following features are supported:flow.json
) before deployment"aliases"
map inflow.json
.Below is the
flow.json
config used in the above screen recording:For contributor use:
master
branchFiles changed
in the Github PR explorer