near / near-cli

General purpose command line tools for interacting with NEAR Protocol
https://docs.near.org
MIT License
193 stars 93 forks source link

feat: js command #975

Closed ChaoticTempest closed 2 years ago

ChaoticTempest commented 2 years ago

Initial work on the JS cli command which includes:

Getting this one out for now to see if we want to move in this kind of direction before going on to adding more subcommands

volovyks commented 2 years ago

@ChaoticTempest Looks cool. Let's fix the bug and merge.

ailisp commented 2 years ago

@ChaoticTempest Looks like the deploy_js_contract ignore the initFunction. As we don't have the support to batch deploy and call init function in the same transaction, there're two choices here:

  1. Drop initFunction option, let user call a near js call contract init ... right after the deploy
  2. Keep initFunction, in deploy cmd, do deploy and call as two transactions
ChaoticTempest commented 2 years ago

@ailisp I don't think either of those options would guarantee us the safety of a batch transaction though unless point 2 is talking about that. JSVM should be able to schedule a promise that would allow us to do this deploy with the initFunction. But I get that it could take a while to implement and since our aim is June to release, we likely won't make it in time. I'll remove the init* related args and we can add it back in later

ailisp commented 2 years ago

@ChaoticTempest Sounds good! It would be perfect if JSVM does that as a promise but you're right on timeline. Currently, if contract is building with sdk-js's @NearBindgen then the contract would throw error, if it's not initialized and any contract method is called, that gives some level of security.

ChaoticTempest commented 2 years ago

@ailisp @volovyk-s pushed view and dev-deploy here as well. Not sure how to implement view-state since that requires more know-how about the enclave and doesn't seem like there's a specific call I can make that's exposed. But besides that, this PR should be ready to pull in

ailisp commented 2 years ago

It looks very solid and all good on my side! But I'm not often in maintaining near-cli, so let @volovyk-s double check it fits near-cli well.

volovyks commented 2 years ago

@ChaoticTempest we have working tests in master now. I will add them here.

volovyks commented 2 years ago

Nice work @ChaoticTempest ! Merging now. Let's add some docs and examples from your doc to the README in the next PR.