XRPL-Labs / xrpl-client

Connect to the XRP Ledger using WebSockets
https://www.npmjs.com/package/xrpl-client
MIT License
12 stars 8 forks source link

Missing fields from `getState()` after connection has been made #10

Closed ckniffen closed 1 year ago

ckniffen commented 1 year ago

Properties on getState() are never populated such as server.publicKey even though server_info responses contain it.

It seems to be related to these lines https://github.com/XRPL-Labs/xrpl-client/blob/main/src/index.ts#L366-L370.

I tried with and without tryAllNodes.

WietseWind commented 1 year ago

I just tested it, but it seems to work fine on my end 😇

test.mjs


import { XrplClient } from 'xrpl-client'

const client = new XrplClient() console.log('Connecting') await client.ready() console.log('Ready') console.log(client.getState())


Result:
```javascript
[nodemon] starting `node index.mjs`
Connecting
Ready
{
  online: true,
  latencyMs: { last: 107, avg: 839201422125.5, secAgo: 2.382999897003174 },
  server: {
    version: '1.9.4',
    uptime: 2015382,
    publicKey: 'n9K5o8AWr5QKPZKbGQcpxu11rfQ6kqS9GkP4aCqXkyh7pncSYwnZ',
    networkId: 0,
    uri: 'wss://xrplcluster.com'
  },
  ledger: { last: 78309695, validated: '32570-78309695', count: 78277125 },
  fee: { last: 12, avg: 12, secAgo: 2.382999897003174 },
  reserve: { base: 10, owner: 2 },
  secLastContact: 0
}

Can you provide more info? Endpoint? Sample code?

ckniffen commented 1 year ago

I found out the issue is with version 2.0.4. Using the same code with 2.0.3 works.

https://stackblitz.com/edit/node-jo1qra?file=package.json,index.js,package-lock.json

ckniffen commented 1 year ago

2.0.5 fixes this 🎉 . Can you release to npm?

WietseWind commented 1 year ago

Ah yeah, of course. Released ✅ - Thanks