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

[feature request] upload on instance of *Factory. #106

Open
deuszx opened this issue Jun 21, 2023 · 3 comments
Open

[feature request] upload on instance of *Factory. #106

deuszx opened this issue Jun 21, 2023 · 3 comments
Assignees

Comments

@deuszx
Copy link

deuszx commented Jun 21, 2023

It would be nice to have a DSL to upload code to chain like we have for new.

Consider the code that uploads and initialises (called new in this lib parle):

await my_contract.new(arg1, arg2, ..., { options });

The code above will do both: upload the my_contract contract and call new constructor on it.

But sometimes we want to just upload and that's not available directly on any of the types. We have to

const contractRaw = JSON.parse(
    fs.readFileSync(`my_contract.contract`, 'utf8')
  );
  const abi = new Abi(contractRaw);
  await new Promise(async (resolve, reject) => {
    const unsub = await abi.tx.contracts
      .uploadCode(abi.info.source.wasm, null, 0)
      .signAndSend(deployer, (result) => {
        if (result.isFinalized) {
          unsub();
          resolve(result.txHash);
        }
        if (result.isError) {
          unsub();
          reject(result);
        }
      });
  });

I think it's clear why I'd prefer to write:

await mycontractFactory.upload(...);
@varex83
Copy link

varex83 commented Jun 22, 2023

Hi @deuszx , thank you for the suggestion! Yes, I think we can consider adding that. I also thought about some auto-deploy functionality where you can just make some simple JSON file, with all the necessary data, init value etc. And by running some typechain deploy it will go through all contracts and deploy them with init, and then you just need to connect to the contract by the address provided. Would it be useful?

@deuszx
Copy link
Author

deuszx commented Jun 22, 2023

@varex83 For some use-cases, most probably yes, but I want to control the moment it's uploaded myself. Currently I'm writing deployment pipelines in TS and upload manually precisely when I need it so the auto-deploy feature would not be useful to me at least.

@varex83
Copy link

varex83 commented Jun 22, 2023

Okay, thank you for your feedback, I will talk with our team if we have the capacity for fixing all bugs and implementing this feature.

Will get back to you soon!

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