diff --git a/CHANGELOG.md b/CHANGELOG.md index ad61d28..a7e7124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,17 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 2.0.2 - 2024-01-25 + +### Fixed +- Fixed a bug in `create_and_install_canister_with_candid()` on application subnets by adding 2T cycles to the +canister before installing a Wasm + + ## 2.0.1 - 2023-11-23 ### Added - Support for PocketIC server version 2.0.1 - ### Changed - When the PocketIC binary is not found, the error now points to the PocketIC repo instead of the download link - ## 2.0.0 - 2023-11-21 ### Added diff --git a/README.md b/README.md index 621babf..a77a551 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,18 @@ from pocket_ic import PocketIC pic = PocketIC() canister_id = pic.create_canister() -pic.add_cycles(canister_id, 2_000_000_000_000) +pic.add_cycles(canister_id, 2_000_000_000_000) # 2T cycles +pic.install_code(...) # make canister calls -response = pic.update_call(canister_id, method="greeting", ...) +response = pic.update_call(canister_id, method="greet", ...) assert(response == 'Hello, PocketIC!') ``` ... or even directly with a canister object: ```python my_canister = pic.create_and_install_canister_with_candid(...) # call your canister methods with native Python syntax -respone = my_canister.greeting() +response = my_canister.greet() assert(response == 'Hello, PocketIC!') ``` diff --git a/pocket_ic/pocket_ic.py b/pocket_ic/pocket_ic.py index 4f2dc00..c5f1f81 100644 --- a/pocket_ic/pocket_ic.py +++ b/pocket_ic/pocket_ic.py @@ -407,16 +407,17 @@ def create_and_install_canister_with_candid( self, candid: str, wasm_module: bytes, - init_args: dict, + init_args: Optional[dict] = None, subnet: Optional[ic.Principal] = None, ) -> ic.Canister: - """Creates a canister, installs the provided WASM with the given init arguments. Returns a canister object. - For an example on how to use the canister object, see `/examples/ledger_canister_test.py`. + """Creates a canister, charges it with 2T cycles and installs the provided WASM with the given init arguments. + Returns a canister object. For an example on how to use the canister object, + see `/examples/ledger_canister/ledger_canister_test.py`. Args: candid (str): a valid candid file describing the canister interface wasm_module (bytes): the canister wasm as bytes - init_args (dict): the init args as required by the candid file + init_args (Optional[dict], optional): the init args as required by the candid file, defaults to `None` subnet (Optional[ic.Principal], optional): optional subnet ID where to install the canister, defaults to `None` @@ -436,7 +437,8 @@ def create_and_install_canister_with_candid( arg = [{"type": canister_arguments[0], "value": init_args}] else: raise ValueError("The candid file appears to be malformed") - + + self.add_cycles(canister_id, 2_000_000_000_000) self.install_code(canister_id, wasm_module, arg) return canister diff --git a/pyproject.toml b/pyproject.toml index dce00ce..650f0d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pocket_ic" -version = "2.0.1" +version = "2.0.2" description = "PocketIC: A Canister Smart Contract Testing Platform" authors = [ "The Internet Computer Project Developers ",