Skip to content

Commit

Permalink
ALL-1885 - second pass on fixing Tron RPCs (#861)
Browse files Browse the repository at this point in the history
* ALL-1885 - second pass on fixing Tron RPCs

* ALL-1885 - version bump
  • Loading branch information
Smrecz authored Jul 12, 2023
1 parent a955c6a commit 73ff3cf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.5.9] - 2023.07.12
### Changed
- Several Tron RPC calls fixed

## [1.5.8] - 2023.07.10
### Changed
- Update all RPC calls to return unmodified data
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumcom/js",
"version": "1.5.8",
"version": "1.5.9",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
6 changes: 6 additions & 0 deletions src/e2e/rpc/tatum.rpc.tron.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ describe('RPCs', () => {

expect(result.txID).toBe('eb49c1c052fb23a9b909a0f487602459112d1fb41276361752e9bc491e649598')
})
it('getBlockByLimitNext', async () => {
const tatum = await getTronRpc(false)
const result = await tatum.rpc.getBlockByLimitNext(1, 5)
expect(result.block).toHaveLength(4)
expect(result.block[0].block_header.raw_data.number).toBeGreaterThan(0)
})
it('getAccountBalance', async () => {
const address = 'TQuDQGdYmzuicmjkWrdpFWXKxpb9P17777'
const blockHash = '0000000003153ce39bcd0a9832ab6783b629b43d656107bb26f18697095ec073'
Expand Down
4 changes: 2 additions & 2 deletions src/service/rpc/TronRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class TronRpc extends AbstractBatchRpc implements TronRpcSuite {
getBlockById(id: string): Promise<any> {
return this.connector.post({
path: this.getRpcNodeUrl('/wallet/getblockbyid'),
body: Utils.convertObjCamelToSnake({ id }),
body: Utils.convertObjCamelToSnake({ value: id }),
})
}

Expand All @@ -314,7 +314,7 @@ export class TronRpc extends AbstractBatchRpc implements TronRpcSuite {
getBlockByLimitNext(startNum: number, endNum: number): Promise<any> {
return this.connector.post({
path: this.getRpcNodeUrl('/wallet/getblockbylimitnext'),
body: Utils.convertObjCamelToSnake({ startNum, endNum }),
body: { startNum, endNum },
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/rpc/generic/AbstractBatchRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export abstract class AbstractBatchRpc implements AbstractRpcInterface {
`https://api.tatum.io/v3/blockchain/node/${network}/${apiKey.v1 ? apiKey.v1 : apiKey.v2}`
return url.concat(subPath || '')
}
return rpc?.nodes?.[0].url || `https://api.tatum.io/v3/blockchain/node/${network}/`.concat(subPath || '')
return rpc?.nodes?.[0].url || `https://api.tatum.io/v3/blockchain/node/${network}`.concat(subPath || '')
}

rawRpcCall(body: JsonRpcCall): Promise<JsonRpcResponse<any>> {
Expand Down

0 comments on commit 73ff3cf

Please sign in to comment.