Skip to content

Commit

Permalink
Merge branch 'master' into release-0.24.3-promote
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity authored Dec 3, 2024
2 parents 8511b56 + 3405dc6 commit 386ae8e
Show file tree
Hide file tree
Showing 54 changed files with 908 additions and 266 deletions.
50 changes: 48 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@

# UNRELEASED

### feat: `dfx start --pocketic` supports `--force` and shared networks.

`dfx start --pocketic` is now compatible with `--force` and shared networks.

### feat: error when using insecure identity on mainnet

This used to be a warning. A hard error can abort the command so that no insecure state will be on the mainnet.

Users can surpress this error by setting `export DFX_WARNING=-mainnet_plaintext_identity`.

The warning won't display when executing commands like `dfx deploy --playground`.

### feat: support `--replica` in `dfx start`

Added a flag `--replica` to `dfx start`. This flag currently has no effect.
Once PocketIC becomes the default for `dfx start` this flag will start the replica instead.
You can use the `--replica` flag already to write scripts that anticipate that change.

### feat: extensions can define project templates

An extension can define one or more project templates for `dfx new` to use.
These can be new templates or replace the built-in project templates.

### fix: all commands with --all parameter skip remote canisters

This affects the following commands:
- `dfx canister delete`
- `dfx canister deposit-cycles`
- `dfx canister start`
- `dfx canister status`
- `dfx canister stop`
- `dfx canister uninstall-code`
- `dfx canister update-settings`
- `dfx ledger fabricate-cycles`

### chore: improve `dfx deploy` messages.

If users run `dfx deploy` without enough cycles, show additional messages to indicate what to do next.
```
Error explanation:
Insufficient cycles balance to create the canister.
How to resolve the error:
Please top up your cycles balance by converting ICP to cycles like below:
'dfx cycles convert --amount=0.123'.
```

# 0.24.3

### feat: Bitcoin support in PocketIC
Expand Down Expand Up @@ -33,9 +79,9 @@ Allow setting permissions lists in init arguments just like in upgrade arguments
- Module hash: f45db224b40fac516c877e3108dc809d4b22fa42d05ee8dfa5002536a3a3daed
- Bump agent-js to fix error code

### chore!: improve the messages for the subcommands of `dfx cycles`.
### chore!: improve the messages for the subcommands of `dfx cycles` and `dfx ledger`.

If users run subcommands of `dfx cycles` without the `--ic` flag, show below messages to indicate what to do next.
If users run subcommands of `dfx cycles` or `dfx ledger` without the `--ic` flag, show below messages to indicate what to do next.
```
Error explanation:
Cycles ledger with canister ID 'um5iw-rqaaa-aaaaq-qaaba-cai' is not installed.
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/cli-reference/dfx-cycles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ The following subcommands are available:

| Command | Description |
|---------------------------------------|--------------------------------------------------------------------------------------|
| [`approve`](#dfx-cycles-approve) | Approves a principal to spend cycles on your behalf. |
| [`balance`](#dfx-cycles-balance) | Prints the account balance of the user. |
| [`convert`](#dfx-cycles-convert) | Convert some of the user's ICP balance into cycles. |
| [`top-up`](#dfx-cycles-top-up) | Deposit cycles into a canister. |
| [`transfer`](#dfx-cycles-transfer) | Send cycles to another account. |
| `help` | Displays usage information message for a specified subcommand. |

Expand Down Expand Up @@ -135,7 +137,7 @@ You can specify the following arguments for the `dfx cycles convert` command.
| `--e8s <e8s>` | Specify ICP token fractional units—called e8s—as a whole number, where one e8 is the smallest fraction of an ICP token. For example, 1.05000000 is 1 ICP and 5000000 e8s. You can use this option on its own or in conjunction with the `--icp` option. |
| `--fee <fee>` | Specify a transaction fee. The default is 10000 e8s. |
| `--icp <icp>` | Specify ICP tokens as a whole number. You can use this option on its own or in conjunction with `--e8s`. |
| `--memo <memo>` | Memo used when depositing the minted cycles. |
| `--deposit-memo <memo>` | Memo used when depositing the minted cycles. |
| `--to-subaccount <subaccount>` | Subaccount where the cycles are deposited. |

### Examples
Expand Down
1 change: 1 addition & 0 deletions docs/cli-reference/dfx-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can use the following optional flags with the `dfx start` command.
| `--enable-bitcoin` | Enables bitcoin integration. |
| `--enable-canister-http` | Enables canister HTTP requests. (deprecated: now enabled by default) |
| `--pocketic` | Runs [PocketIC](https://github.com/dfinity/pocketic) instead of the replica. |
| `--replica` | Runs the replica instead of [PocketIC](https://github.com/dfinity/pocketic). |

## Options

Expand Down
66 changes: 66 additions & 0 deletions docs/concepts/extension-defined-project-templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Extension-Defined Project Templates

## Overview

An extension can define one or more project templates for `dfx new` to use.

A project template is a set of files that `dfx new` copies or patches into a new project.

For examples of project template files, see the [project_templates] directory in the SDK repository.

# Specification

The `project_templates` field in an extension's `extension.json` defines the project templates
included in the extension. It is an object field mapping `project template name -> project template properties`.
These are the properties of a project template:

| Field | Type | Description |
|------------------------------|---------------------------|------------------------------------------------------------------------------------------------------|
| `display` | String | Display name of the project template |
| `category` | String | Category for inclusion in `--backend` and `--frontend` CLI options, as well as interactive selection |
| `requirements` | Array of String | Required project templates |
| `post_create` | String or Array of String | Command(s) to run after adding the canister to the project |
| `post_create_spinner_message` | String | Message to display while running the post_create command |
| `post_create_failure_warning` | String | Warning to display if the post_create command fails |

Within the files distributed with the extension, the project template files are
located in the `project_templates/{project template name}` directory.

## The `display` field

The `display` field is a string that describes the project template.
`dfx new` will use this value for interactive selection of project templates.

## The `category` field

The `category` field is an array of strings that categorize the project template.
`dfx new` uses this field to determine whether to include this project template
as an option for the `--backend` and `-frontend` flags, as well as in interactive setup.

Valid values for the field:
- `frontend`
- `backend`
- `extra`
- `frontend-test`
- `support`

## The `requirements` field

The `requirements` field lists any project templates that `dfx new` must apply before this project template.
For example, many of the frontend templates depend on the `dfx_js_base` template, which adds
package.json and tsconfig.json to the project.

## The `post_create` field

The `post_create` field specifies a command or commands to run after adding the project template files to the project.
For example, the rust project template runs `cargo update` after adding the files.

## The `post_create_spinner_message` field

If this field is set, `dfx new` will display a spinner with this message while running the `post_create` command.

## The `post_create_failure_warning` field

If this field is present and the `post_create` command fails, `dfx new` will display this warning but won't stop creating the project.

[project_templates]: https://github.com/dfinity/sdk/tree/master/src/dfx/assets/project_templates
2 changes: 2 additions & 0 deletions docs/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- [Asset Canister Interface](../design/asset-canister-interface.md)
- [Canister metadata](./canister-metadata.md)
- [Extension-Defined Canister Types](./extension-defined-canister-types.md)
- [Extension-Defined Project Templates](./extension-defined-project-templates.md)
84 changes: 84 additions & 0 deletions docs/extension-manifest-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
"name": {
"type": "string"
},
"project_templates": {
"type": [
"object",
"null"
],
"additionalProperties": {
"$ref": "#/definitions/ExtensionProjectTemplate"
}
},
"subcommands": {
"anyOf": [
{
Expand Down Expand Up @@ -155,6 +164,58 @@
}
]
},
"ExtensionProjectTemplate": {
"type": "object",
"required": [
"category",
"display",
"post_create",
"requirements"
],
"properties": {
"category": {
"description": "Used to determine which CLI group (`--type`, `--backend`, `--frontend`) as well as for interactive selection",
"allOf": [
{
"$ref": "#/definitions/ProjectTemplateCategory"
}
]
},
"display": {
"description": "The name used for display and sorting",
"type": "string"
},
"post_create": {
"description": "Run a command after adding the canister to dfx.json",
"allOf": [
{
"$ref": "#/definitions/SerdeVec_for_String"
}
]
},
"post_create_failure_warning": {
"description": "If the post-create command fails, display this warning but don't fail",
"type": [
"string",
"null"
]
},
"post_create_spinner_message": {
"description": "If set, display a spinner while this command runs",
"type": [
"string",
"null"
]
},
"requirements": {
"description": "Other project templates to patch in alongside this one",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"ExtensionSubcommandArgOpts": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -231,6 +292,16 @@
"$ref": "#/definitions/ExtensionSubcommandOpts"
}
},
"ProjectTemplateCategory": {
"type": "string",
"enum": [
"backend",
"frontend",
"frontend-test",
"extra",
"support"
]
},
"Range_of_uint": {
"type": "object",
"required": [
Expand All @@ -249,6 +320,19 @@
"minimum": 0.0
}
}
},
"SerdeVec_for_String": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
}
}
6 changes: 4 additions & 2 deletions e2e/tests-dfx/canister_url.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ load ../utils/_

setup() {
standard_setup

# some of the tests run on mainnet with default plaintext identity
# so we need to set this to avoid the error
export DFX_WARNING=-mainnet_plaintext_identity
dfx_new_assets hello
}

Expand Down Expand Up @@ -58,7 +60,7 @@ teardown() {
echo "{}" > canister_ids.json
jq '.hello_frontend.ic = "qsgof-4qaaa-aaaan-qekqq-cai"' canister_ids.json | sponge canister_ids.json
frontend_id=$(dfx canister id hello_frontend --ic)

assert_command dfx canister url hello_frontend --ic
assert_match "https://${frontend_id}.icp0.io"

Expand Down
22 changes: 21 additions & 1 deletion e2e/tests-dfx/cycles-ledger.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ teardown() {
start_and_install_nns() {
dfx_start_for_nns_install

dfx extension install nns --version 0.4.3
dfx extension install nns --version 0.4.7
dfx nns install --ledger-accounts "$(dfx ledger account-id --identity cycle-giver)"
}

Expand Down Expand Up @@ -458,6 +458,13 @@ current_time_nanoseconds() {
assert_eq "2399699700000 cycles."
assert_command dfx canister status e2e_project_backend
assert_contains "Balance: 3_100_002_100_000 Cycles"

# deposit-cycles --all skips remote canisters
jq '.canisters.remote.remote.id.local="rdmx6-jaaaa-aaaaa-aaadq-cai"' dfx.json | sponge dfx.json
assert_command dfx canister deposit-cycles 10000 --all --identity bob
assert_contains "Skipping canister 'remote' because it is remote for network 'local'"
assert_contains "Depositing 10000 cycles onto e2e_project_backend"
assert_not_contains "Depositing 10000 cycles onto remote"
}

@test "top-up deduplication" {
Expand Down Expand Up @@ -584,9 +591,22 @@ current_time_nanoseconds() {

assert_command dfx deploy

# Test canister creation failure before topping up cycles.
cd ..
dfx_new canister_creation_failed

# shellcheck disable=SC2030,SC2031
export DFX_DISABLE_AUTO_WALLET=1
assert_command_fail dfx canister create canister_creation_failed_backend --with-cycles 1T --identity alice
assert_contains "Insufficient cycles balance to create the canister."

## Back to top up cycles.
cd ../temporary

assert_command dfx canister call depositor deposit "(record {to = record{owner = principal \"$ALICE\";};cycles = 13_400_000_000_000;})" --identity cycle-giver
assert_command dfx canister call depositor deposit "(record {to = record{owner = principal \"$ALICE\"; subaccount = opt blob \"$ALICE_SUBACCT1_CANDID\"};cycles = 2_600_000_000_000;})" --identity cycle-giver

# shellcheck disable=SC2103
cd ..
dfx_new
# setup done
Expand Down
Loading

0 comments on commit 386ae8e

Please sign in to comment.