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

build-clients: check if contracts are already created and using correct wasm hash #73

Closed
chadoh opened this issue Jun 17, 2024 · 0 comments
Assignees

Comments

@chadoh
Copy link
Contributor

chadoh commented Jun 17, 2024

Follow-up to #42

Our handle_contracts logic currently assumes that it is being run for the first time. Right now, it will:

  1. run contract install --wasm path/to/some.wasm to get the current wasm binary on-chain
  2. run contract deploy --wasm-hash [return value of step 1] to create a new contract using this hash
  3. run contract bindings typescript for this newly-created contract
  4. overwrite the src/contracts/[contract name].ts file with the new contract ID from step 2

Instead, it should:

  1. run contract install --wasm path/to/some.wasm to get the current wasm binary on-chain. Yes, this is the same first step. This operation is idempotent, meaning it will always return the same hash for the same wasm blob.

  2. check if we have an alias saved for this contract (this depends on the recenly-added alias logic)

  3. if no alias, proceed as we currently do, but save the alias on the contract deploy step so we can use it next time

  4. if we have an alias, check if the contract with that ID is using the wasm hash generated in step 1. if so, then we're done.

  5. if we need to update the contract with the new code, we have a decision to make. Do we deploy a new contract, for simplicity? Maybe for now, assuming that we'll be using this in local & other test networks, that's the most straightforward option. And maybe for production environments and/or live networks, we throw an error for now. Because what really should happen is that we update the contract with the new code and make sure we run any relevant migrations and, and, and...

    We should probably integrate with smartdeploy to help us handle this more complicated update strategy?

@chadoh chadoh added this to Aha Jun 18, 2024
@chadoh chadoh moved this to To do in Aha Jun 18, 2024
@chadoh chadoh removed the status in Aha Jun 20, 2024
@chadoh chadoh moved this to To do in Aha Jun 20, 2024
@BlaineHeffron BlaineHeffron moved this from To do to In Progress in Aha Jun 24, 2024
@BlaineHeffron BlaineHeffron moved this from In Progress to Done in Aha Jul 13, 2024
@BlaineHeffron BlaineHeffron closed this as completed by moving to Done in Aha Jul 13, 2024
@BlaineHeffron BlaineHeffron self-assigned this Jul 13, 2024
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