Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

feat: js command #975

Merged
merged 16 commits into from
May 19, 2022
Merged

feat: js command #975

merged 16 commits into from
May 19, 2022

Conversation

ChaoticTempest
Copy link
Member

Initial work on the JS cli command which includes:

  • deploy
  • call
  • remove

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
Copy link
Collaborator

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

commands/js.js Outdated Show resolved Hide resolved
Copy link
Member

@ailisp ailisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! It works, we may want some small enhancement after this PR.

@ailisp
Copy link
Member

ailisp commented May 18, 2022

@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
Copy link
Member Author

@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
Copy link
Member

ailisp commented May 19, 2022

@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
Copy link
Member Author

@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
Copy link
Member

ailisp commented May 19, 2022

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
Copy link
Collaborator

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

@volovyks
Copy link
Collaborator

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

@volovyks volovyks merged commit 8fe4a1f into master May 19, 2022
function base64_encode_args(contractId, functionName, args) {
let buf = Buffer.concat([
Buffer.from(contractId),
Buffer.from([0]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curiosity: why are 0 bytes included in-between these?

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

Successfully merging this pull request may close these issues.

4 participants