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

Make it run on browser by using gRPC-web-text #28

Open
totiz opened this issue Jul 26, 2019 · 7 comments
Open

Make it run on browser by using gRPC-web-text #28

totiz opened this issue Jul 26, 2019 · 7 comments

Comments

@totiz
Copy link
Contributor

totiz commented Jul 26, 2019

I see that there's a lot of use case if we make this libra-core works directly on browser, and developer can use the same syntax as libra-core provided right now, so I make https://github.com/kulapio/libra-core that forked from this project and make it works on gRPC-web that some codes derived from https://github.com/bandprotocol/libra-web/ as well.

We make some changes for example.

  1. use grp-web, js-sha3 package.
  2. generate grpc-web protob for JS/TS with this script.
# Generate JavaScript/TypeScript for gRPC-web
protoc \
  --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:$GEN_OUT_DIR \
  -I=${PROTO_IMPORT_DIR} \
  ${FILE_PATHS} \
  1. the libra client init with this.
const client = new LibraClient({
    transferProtocol: 'https',
    host: 'ac-libra-testnet.kulap.io',
    port: '443',
    dataProtocol: 'grpc-web-text'
  })
  1. perhaps if we init client directly to ac.testnet.libra.org we can use this config (WIP).
const client = new LibraClient({
    transferProtocol: 'socket',
    host: 'ac.testnet.libra.org',
    port: '80',
    dataProtocol: 'grpc'
  })
// or just default
const client = new LibraClient({ network: LibraNetwork.Testnet });

What do you think for kind of this changes? that I can do a PR for this.

@perfectmak
Copy link
Owner

Thank you. I've been considering using grpc-web too, but I have not had enough bandwidth to update work on that. I would very much appreciate your contribution to this.

Please go ahead and make a PR for this. Also a heads up that I'm currently in the middle of some refactoring to the codebase, Ideally, it shouldn't touch the client module that you will be working on, but so you are aware of the changes when I open a PR/merge it in.

@totiz
Copy link
Contributor Author

totiz commented Jul 26, 2019

Great, I'll PR soon. Now I'm working on Client config to support both Browser and Node, and perhaps some e2n testing on browser as well (may be come later).

@totiz
Copy link
Contributor Author

totiz commented Aug 3, 2019

Sorry for the delay, I'm facing problem when integrate gRPC-web with gPRC and it can not import('grpc') on the browser so we need to separate the codes and load only necessary libs on browser, I'll pr when it done.

@perfectmak
Copy link
Owner

Hi @totiz are you still working on this, let me know if there is anyway I can help?

@totiz
Copy link
Contributor Author

totiz commented Aug 17, 2019

@perfectmak Hi, I've finished on https://github.com/kulapio/libra-core/tree/master/lib/client with separate files for Node.js and Browser.js to prevent import grpc on broser (that will cause error). If you have time please check this https://github.com/kulapio/libra-core/tree/master/lib/client and let me know if any suggestion that I should do before PR. I've very busy this week and hope can finish the PR soon.

@zoeyTM
Copy link

zoeyTM commented Sep 1, 2019

Any updates on this @perfectmak @totiz ? Could really use the separate client-side bundle, so if there's anything I can contribute to help either of you please let me know :)

@totiz
Copy link
Contributor Author

totiz commented Sep 4, 2019

@morgansliman I still have problem with Angular, It need to hook into node_modules to comment some codes to make it works, I believe there'll be some solution to fix this in https://github.com/kulapio/libra-core and testing to make sure everyone work perfectly, that PR to upstream here.

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

3 participants