Open asghaier76 opened 5 years ago
Have you upgrade to kulap-libra@1.0.14? prior to this version, there's an issue when run on browser.
Yes I am using kulap-libra@1.0.14. Not sure if the issue is related to grpc.
@asghaier76 I don't have a skill on angular, could you please share me your project that I can run and reproduce the error, or perhaps the steps on setting the project to reproduce this error, thanks.
@totiz I have sent you an invite to the repo
@totiz have you had the chance to clone the repo and test
Ok I got it, I'll let you know if I try and have any update, thanks.
@asghaier76 Ok I run your project and got the error, This's a known error that doesn't cause Vue project to crash but on Angular I've never try (and React as well).
grpc can not be load on browser, so I try to separate the require('grpc') by checking that the project run with grpc-web or not, then load.
// Init Admission Controller Proxy
if (this.config.dataProtocol === 'grpc') {
// this.admissionControlProxy = require('./Node');
}
PS: you should upgrade to kulap-libra@1.0.15 for new minting protocol https://github.com/kulapio/libra-core/releases/tag/v1.0.15
Please let me know if you're still have problems.
And just leave this issue open, because we still need a patch for completely fix.
@totiz while this fixes the error at compilation time still it brings issues in in run time
so after using the workaround and comment only this line
// this.admissionControlProxy = require('./Node');
I can compile and generate wallets but once try to connect to the Blockchain for example to retrieve balance I get this error
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'initAdmissionControlClient' of undefined TypeError: Cannot read property 'initAdmissionControlClient' of undefined
and it fails to create an instance of LibraClient which I am initiating and querying balance using these lines
const client = new LibraClient({ network: LibraNetwork.Testnet }) console.log(client); const accountState = await client.getAccountState(this.address); console.log(accountState); // log account balance this.balance = accountState.balance.toString(); console.log(accountState.balance.toString());
It seems by commenting that line the admissionControlProxy is not defined, so I went on and commented the this section
// Init Admission Controller Proxy //if (this.config.dataProtocol === 'grpc') { //this.admissionControlProxy = require('./Node'); //} //else { this.admissionControlProxy = require('./Browser'); //}
so that admissionControlProxy is defined but I got another type of error
POST ac.testnet.libra.org:80/admission_control.AdmissionControl/UpdateToLatestLedger net::ERR_UNKNOWN_URL_SCHEME
The LibraClient object instance looks like
LibraClient {config: {…}, admissionControlProxy: {…}, acClient: p…h../…b.js.p…o.admissio…, decoder: ClientDecoder, encoder: ClientEncoder} acClient: push../node_modules/kulap-libra/build/__generated__/admission_control_grpc_web_pb.js.proto.admission_control.AdmissionControlPromiseClient client_: Y {a: "text", c: false, b: false} credentials_: null hostname_: "ac.testnet.libra.org:80" options_: {format: "text"} __proto__: Object admissionControlProxy: initAdmissionControlClient: ƒ initAdmissionControlClient(connectionAddress) submitTransaction: async ƒ submitTransaction(acClient, request) updateToLatestLedger: async ƒ updateToLatestLedger(acClient, request) __esModule: true __proto__: Object config: {network: "testnet", host: "ac.testnet.libra.org", port: "80", transferProtocol: "http", dataProtocol: "grpc"} decoder: ClientDecoder {} encoder: ClientEncoder {client: LibraClient} __proto__: Object
I am not sure if the ServersHost config file need to be modified
On the browser you need to init client with this code.
// On Browser
const client = new LibraClient({
transferProtocol: 'https',
host: 'ac-libra-testnet.kulap.io',
port: '443',
dataProtocol: 'grpc-web-text'
})
Please let me know if still has any problems.
Thanks @totiz It works with this endpoint.
Great work Kulap team.
I am trying to use this library in an Angular project and I am getting this error
ERROR in ./node_modules/grpc/node_modules/detect-libc/lib/detect-libc.js Module not found: Error: Can't resolve 'child_process' in '../node_modules/grpc/node_modules/detect-libc/lib'
I am using
Node: 12.4.0 OS: darwin x64 Angular: 8.1.3
Any help on this issue?
Ahmad