Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
fxgst committed Nov 3, 2023
1 parent 96c97ea commit d1c9b66
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pocket_ic/pocket_ic.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,28 @@ def add_cycles(self, canister_id: ic.Principal, amount: int) -> int:
return self._instance_post("update/add_cycles", body)["cycles"]

def get_stable_memory(self, canister_id: ic.Principal) -> bytes:
"""Gets the stable memory of a canister.
Args:
canister_id (ic.Principal): the ID of the canister
Returns:
bytes: the stable memory of the canister
"""
body = {
"canister_id": base64.b64encode(canister_id.bytes).decode(),
}
response = self._instance_post("read/get_stable_memory", body)
return base64.b64decode(response["blob"])


def set_stable_memory(self, canister_id: ic.Principal, data: bytes, compression = None) -> None:
"""Sets the stable memory of a canister.
Args:
canister_id (ic.Principal): the ID of the canister
data (bytes): the data to set
compression (str, optional): optional gzip compression, efaults to None
"""
blob_id = self.server.set_blob_store_entry(data, compression)
body = {
"canister_id": base64.b64encode(canister_id.bytes).decode(),
Expand Down

0 comments on commit d1c9b66

Please sign in to comment.