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

ALL-1885 - second pass on fixing Tron RPCs #861

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading