Closed mrosendin closed 3 years ago
For anyone using Deno, here's an example of a workaround:
import ripple from 'https://dev.jspm.io/npm:ripple-lib';
(async () => {
const api = new (ripple as any).RippleAPI({ server: 'wss://s.altnet.rippletest.net:51233' });
const address = 'rH8NxV12EuV9er1eS34ZhcvVkhfJ5uw9kT';
api.connect().then(() => {
api.getBalances(address).then((balances: any) => {
console.log(JSON.stringify(balances, null, 2));
});
});
})();
I'm newish to TypeScript and Deno so there might be a better way to do this. I simply tried constructing RippleAPI
like new ripple.RippleAPI()
but I got this error:
Property 'RippleAPI' does not exist on type '{}'
My best guess as to what's going on is that the compiler seems to expect a type for ripple
because it's imported as a variable. I tried importing RippleAPI like so, but ran into this error:
import { RippleAPI } from 'https://dev.jspm.io/npm:ripple-lib';
Module '"../../../../Library/Caches/deno/deps/https/dev.jspm.io/a78c92b0c97f76c4ed6e61e378467ae3fd740a2a3af6378ba8475ebab06b8161"' has no exported member 'RippleAPI'. Did you mean to use 'import RippleAPI from "../../../../Library/Caches/deno/deps/https/dev.jspm.io/a78c92b0c97f76c4ed6e61e378467ae3fd740a2a3af6378ba8475ebab06b8161"' instead?
@mrosendin I tried to execute your code and worked as expected:
[
{
"currency": "XRP",
"value": "4673.999388"
}
]
is this still an issue?
Hi @elmurci,
I am using Deno and this issue was a request to add ripple-lib support. The code snippet I posted above is a workaround.
Since ripple-lib uses node APIs it can't easily be ported to Deno (there is a similar problem with using ripple-lib in a React Native project). For example, Denoify can help achieve what rn-nodeify does.
I'll close out this issue, but thought it would be helpful to anyone who was also working with Deno and may be helpful if you want to support an official Deno port in the future.
Makes sense Matt, I am not very familiar with Deno but will reopen and do some research on how to add Deno support.
The workaround is in the README and it's the way forward for now. If you have a specific change that would make this library work better with Deno, please open a PR -- we'd love to merge it!
Requesting support for Deno. There are workarounds, but it would be nice to have this supported.