Skip to content
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

Actor interface upgradeCanister #47

Open
peterpeterparker opened this issue Apr 30, 2024 · 2 comments
Open

Actor interface upgradeCanister #47

peterpeterparker opened this issue Apr 30, 2024 · 2 comments

Comments

@peterpeterparker
Copy link

Feature request

It would be nice to be able to provide an ActorInterface to the upgradeCanister function, similar to setupCanister, and receive an updated actor as a result.

This can notably be useful if the candid declaration changes between version and one want to test an upgrade.

Currently, this can be solved by creating a new actor once the upgrade has been processed. Such a feature would spare few lines of code.

From:

await pic.upgradeCanister({
  canisterId,
  wasm: SATELLITE_WASM_PATH,
  sender: controller.getPrincipal()
});
		
const newActor = pic.createActor<SatelliteActorNEW>(idlFactorSatellite, canisterId);
newActor.setIdentity(controller);

To:

const {actor: newActor} = await pic.upgradeCanister<SatelliteActorNEW>({
  canisterId,
  wasm: SATELLITE_WASM_PATH,
  sender: controller.getPrincipal()
});
@nathanosdev
Copy link
Contributor

This looks like it would be a nice ergonomic improvement.

With creating canisters this is separated into two methods:

  • createCanister() for simply creating the canister.
  • setupCanister() for creating the canister, installing code and creating the actor.

I think a similar separation here would be good. I'll need to think about how to name these methods better. In any case I won't have time to look at this until next week, but I'll report back once it's done.

Thanks for the suggestion!

@peterpeterparker
Copy link
Author

Definitely no rush from my side and only a suggestion, everything works already smoothly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants