OpenZeppelin / openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
MIT License
431 stars 200 forks source link

A method to read Contract JSON from DB and deploy #1562

Open code-ishwar opened 4 years ago

code-ishwar commented 4 years ago

Hi,

We are using OZ for deploying contracts in workflows. Can you add a feature to read raw text and create deployment? Here is the sample code: static createFromText(rawText: string): Contract; //Add this to Contracts.d.ts

//Add this to Contracts Class in Contracts.js


static createFromText(rawText){
      const schema = JSON.parse(rawText);

      if(schema == undefined)
          throw new Error(`Valid schema needed for contract ${schema.contractName}.`);
      if (schema.bytecode === '')
          throw new Error(`A bytecode must be provided for contract ${schema.contractName}.`);
      if (!Bytecode_1.hasUnlinkedVariables(schema.bytecode)) {
          schema.linkedBytecode = schema.bytecode;
          schema.linkedDeployedBytecode = schema.deployedBytecode;
      }
      return Contract_1.createContract(schema);
    }
abcoathup commented 4 years ago

Hi @thesolyd ! Thanks for the suggestion, it is really appreciated.

Can you provide more information on your use case?

Once we have more information, the project owner will then review your suggestion as soon as they can.

Please wait until we have discussed this idea before writing any code or submitting a Pull Request, so we can go through the design beforehand. We don’t want you to waste your time!

cyberiums commented 4 years ago

Hi @abcoathup

The code is already developed and deployed by us in our production servers. We just wanted to make this as a contribution to the community. Here is the use case: We process 1000s of smart contracts which are read for DB. There are no suitable methods available in OZ contract loaders for reading ABI from DB. Therefore we built the rawtext overloading. It seems that OZ is developed around precipse that all contracts will be read from disk. That's not enterprise thinking. BTW we LOVE OZ and are very very grateful to the community and core developers. Hope we meet and guzzle champagnes soon enough to celebrate this awesome platform.

abcoathup commented 4 years ago

Hi @cyberiums,

If you can hold off submitting a Pull Request, so the project owner can review your suggestion. We don’t want you to waste your time!

Thanks for the OpenZeppelin love!! I look forward to when we can all travel again and enjoy restaurants and bars.