CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
115 stars 80 forks source link

[feat] - browser support #52

Closed cyborgmarina closed 4 years ago

cyborgmarina commented 4 years ago

So, got it done without using webpack, but needs more testing. I'm not entirely sure this approach is working on every example available and would love to have some feedback on this.

@rkalis let me know your thoughts on this.

codecov-io commented 4 years ago

Codecov Report

Merging #52 into master will decrease coverage by <.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #52      +/-   ##
=========================================
- Coverage    94.7%   94.7%   -0.01%     
=========================================
  Files          32      33       +1     
  Lines        1756    1755       -1     
  Branches      237     238       +1     
=========================================
- Hits         1663    1662       -1     
  Misses         87      87              
  Partials        6       6
Impacted Files Coverage Δ
packages/cashc/src/generation/preimage.ts 100% <ø> (ø) :arrow_up:
packages/cashc/src/optimisations/Optimisations.ts 100% <100%> (ø)
.../cashc/src/optimisations/TargetCodeOptimisation.ts 100% <100%> (ø) :arrow_up:
packages/cashscript/src/Contract.ts 92.5% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6cf1b8d...03df3ff. Read the comment docs.

rkalis commented 4 years ago

Awesome! I got it to run on my machine as well. Added examples/Browser as a separate workspace in the root package.json so that Lerna automatically links the local version of cashscript into the project without doing npm link.

I also figured out how to do the cashproof stuff. I added a pre and post hook for running the optimisations proof:

"preproof:opt": "cp packages/cashc/src/optimisations/Optimisations.ts opt.equiv && sed -i '' '/`/d' opt.equiv",
"proof:opt": "yarn cashproof opt.equiv",
"postproof:opt": "rm opt.equiv",

So now when running yarn proof:opt or yarn proof it copies over the ts file into a temp file, and cuts out the lines containing `. Then it executes cashproof on that file and deletes it again.

rkalis commented 4 years ago

Did you enable commits from maintainer in your PR? The I'll push my changes so you can pick it up from there

cyborgmarina commented 4 years ago

Did you enable commits from maintainer in your PR? The I'll push my changes so you can pick it up from there

Yes, it's enabled. Let me know if there's any issue with that :)

rkalis commented 4 years ago

Welp looks like I messed up pushing my changes 😅

rkalis commented 4 years ago

Can you push your changes to your remote again?

cyborgmarina commented 4 years ago

done

rkalis commented 4 years ago

I'm glad that in the end it was possible to do it without any complex build processes. So we'll have to add a note to the docs stating that CashScript can only be compiled as a string in the web, so they will have to load the file in a different way (like a GET request to some file), and then pass in the file contents.

Perhaps we can change the example app so that it has a pre-filled input field for the constructor argument and the function arguments, and it shows the balance/address in the UI. I think that we're all done after that.

cyborgmarina commented 4 years ago

Added option to select a network and an input for seed words, what do you think?

rkalis commented 4 years ago

I just created the branch v0.3.2 from master. Can you change the PR to target that branch, then I'll merge it in.

cyborgmarina commented 4 years ago

Done!

rkalis commented 4 years ago

Perfect. Thanks again for the help.