@injectivelabs/sdk-ts 1.15.3 → 1.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/chain/grpc/ChainGrpcTendermintApi.d.ts +2 -1
- package/dist/cjs/client/chain/grpc/ChainGrpcTendermintApi.js +23 -1
- package/dist/cjs/client/chain/rest/ChainRestTendermintApi.d.ts +1 -0
- package/dist/cjs/client/chain/rest/ChainRestTendermintApi.js +18 -1
- package/dist/cjs/client/chain/types/tendermint-rest.d.ts +27 -0
- package/dist/esm/client/chain/grpc/ChainGrpcTendermintApi.d.ts +2 -1
- package/dist/esm/client/chain/grpc/ChainGrpcTendermintApi.js +23 -1
- package/dist/esm/client/chain/rest/ChainRestTendermintApi.d.ts +1 -0
- package/dist/esm/client/chain/rest/ChainRestTendermintApi.js +18 -1
- package/dist/esm/client/chain/types/tendermint-rest.d.ts +27 -0
- package/package.json +2 -2
|
@@ -7,5 +7,6 @@ export declare class ChainGrpcTendermintApi extends BaseGrpcConsumer {
|
|
|
7
7
|
protected module: string;
|
|
8
8
|
protected client: CosmosBaseTendermintV1Beta1Query.ServiceClientImpl;
|
|
9
9
|
constructor(endpoint: string);
|
|
10
|
-
fetchLatestBlock(): Promise<import("@injectivelabs/core-proto-ts/cjs/tendermint/types
|
|
10
|
+
fetchLatestBlock(): Promise<import("@injectivelabs/core-proto-ts/cjs/cosmos/base/tendermint/v1beta1/types.js").Block | import("@injectivelabs/core-proto-ts/cjs/tendermint/types/block.js").Block | undefined>;
|
|
11
|
+
fetchBlock(height: number | string): Promise<import("@injectivelabs/core-proto-ts/cjs/cosmos/base/tendermint/v1beta1/types.js").Block | import("@injectivelabs/core-proto-ts/cjs/tendermint/types/block.js").Block | undefined>;
|
|
11
12
|
}
|
|
@@ -22,7 +22,7 @@ class ChainGrpcTendermintApi extends BaseGrpcConsumer_js_1.default {
|
|
|
22
22
|
const request = core_proto_ts_1.CosmosBaseTendermintV1Beta1Query.GetLatestBlockRequest.create();
|
|
23
23
|
try {
|
|
24
24
|
const response = await this.retry(() => this.client.GetLatestBlock(request, this.metadata));
|
|
25
|
-
return response.
|
|
25
|
+
return response.sdkBlock || response.block;
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
28
|
if (e instanceof core_proto_ts_1.CosmosBaseTendermintV1Beta1Query.GrpcWebError) {
|
|
@@ -39,5 +39,27 @@ class ChainGrpcTendermintApi extends BaseGrpcConsumer_js_1.default {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
async fetchBlock(height) {
|
|
43
|
+
const request = core_proto_ts_1.CosmosBaseTendermintV1Beta1Query.GetBlockByHeightRequest.create();
|
|
44
|
+
request.height = height.toString();
|
|
45
|
+
try {
|
|
46
|
+
const response = await this.retry(() => this.client.GetBlockByHeight(request, this.metadata));
|
|
47
|
+
return response.sdkBlock || response.block;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
if (e instanceof core_proto_ts_1.CosmosBaseTendermintV1Beta1Query.GrpcWebError) {
|
|
51
|
+
throw new exceptions_1.GrpcUnaryRequestException(new Error(e.toString()), {
|
|
52
|
+
code: (0, exceptions_1.grpcErrorCodeToErrorCode)(e.code),
|
|
53
|
+
context: 'TendermintApi.fetchBlock',
|
|
54
|
+
contextModule: this.module,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
throw new exceptions_1.GrpcUnaryRequestException(e, {
|
|
58
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
59
|
+
context: 'TendermintApi.fetchBlock',
|
|
60
|
+
contextModule: this.module,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
42
64
|
}
|
|
43
65
|
exports.ChainGrpcTendermintApi = ChainGrpcTendermintApi;
|
|
@@ -5,6 +5,7 @@ import { BlockLatestRestResponse, NodeInfoRestResponse } from './../types/tender
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class ChainRestTendermintApi extends BaseRestConsumer {
|
|
7
7
|
fetchLatestBlock(params?: Record<string, any>): Promise<BlockLatestRestResponse['block']>;
|
|
8
|
+
fetchBlock(height: number | string, params?: Record<string, any>): Promise<BlockLatestRestResponse['block']>;
|
|
8
9
|
fetchNodeInfo(params?: Record<string, any>): Promise<{
|
|
9
10
|
nodeInfo: NodeInfoRestResponse['default_node_info'];
|
|
10
11
|
applicationVersion: NodeInfoRestResponse['application_version'];
|
|
@@ -15,7 +15,24 @@ class ChainRestTendermintApi extends BaseRestConsumer_js_1.default {
|
|
|
15
15
|
const endpoint = `cosmos/base/tendermint/v1beta1/blocks/latest`;
|
|
16
16
|
try {
|
|
17
17
|
const response = await this.retry(() => this.get(endpoint, params));
|
|
18
|
-
return response.data.block;
|
|
18
|
+
return response.data.sdk_block || response.data.block;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if (e instanceof exceptions_1.HttpRequestException) {
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
throw new exceptions_1.HttpRequestException(new Error(e), {
|
|
25
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
26
|
+
context: `${this.endpoint}/${endpoint}`,
|
|
27
|
+
contextModule: index_js_1.ChainModule.Tendermint,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async fetchBlock(height, params = {}) {
|
|
32
|
+
const endpoint = `cosmos/base/tendermint/v1beta1/blocks/${height}`;
|
|
33
|
+
try {
|
|
34
|
+
const response = await this.retry(() => this.get(endpoint, params));
|
|
35
|
+
return response.data.sdk_block || response.data.block;
|
|
19
36
|
}
|
|
20
37
|
catch (e) {
|
|
21
38
|
if (e instanceof exceptions_1.HttpRequestException) {
|
|
@@ -33,6 +33,33 @@ export interface BlockLatestRestResponse {
|
|
|
33
33
|
proposer_address: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
sdk_block: {
|
|
37
|
+
header: {
|
|
38
|
+
version: {
|
|
39
|
+
block: string;
|
|
40
|
+
app: string;
|
|
41
|
+
};
|
|
42
|
+
chain_id: string;
|
|
43
|
+
height: string;
|
|
44
|
+
time: Date;
|
|
45
|
+
last_block_id: {
|
|
46
|
+
hash: string;
|
|
47
|
+
part_set_header: {
|
|
48
|
+
total: 0;
|
|
49
|
+
hash: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
last_commit_hash: string;
|
|
53
|
+
data_hash: string;
|
|
54
|
+
validators_hash: string;
|
|
55
|
+
next_validators_hash: string;
|
|
56
|
+
consensus_hash: string;
|
|
57
|
+
app_hash: string;
|
|
58
|
+
last_results_hash: string;
|
|
59
|
+
evidence_hash: string;
|
|
60
|
+
proposer_address: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
36
63
|
}
|
|
37
64
|
export interface NodeInfoRestResponse {
|
|
38
65
|
default_node_info: {
|
|
@@ -7,5 +7,6 @@ export declare class ChainGrpcTendermintApi extends BaseGrpcConsumer {
|
|
|
7
7
|
protected module: string;
|
|
8
8
|
protected client: CosmosBaseTendermintV1Beta1Query.ServiceClientImpl;
|
|
9
9
|
constructor(endpoint: string);
|
|
10
|
-
fetchLatestBlock(): Promise<import("@injectivelabs/core-proto-ts/cjs/tendermint/types
|
|
10
|
+
fetchLatestBlock(): Promise<import("@injectivelabs/core-proto-ts/cjs/cosmos/base/tendermint/v1beta1/types.js").Block | import("@injectivelabs/core-proto-ts/cjs/tendermint/types/block.js").Block | undefined>;
|
|
11
|
+
fetchBlock(height: number | string): Promise<import("@injectivelabs/core-proto-ts/cjs/cosmos/base/tendermint/v1beta1/types.js").Block | import("@injectivelabs/core-proto-ts/cjs/tendermint/types/block.js").Block | undefined>;
|
|
11
12
|
}
|
|
@@ -16,7 +16,7 @@ export class ChainGrpcTendermintApi extends BaseGrpcConsumer {
|
|
|
16
16
|
const request = CosmosBaseTendermintV1Beta1Query.GetLatestBlockRequest.create();
|
|
17
17
|
try {
|
|
18
18
|
const response = await this.retry(() => this.client.GetLatestBlock(request, this.metadata));
|
|
19
|
-
return response.
|
|
19
|
+
return response.sdkBlock || response.block;
|
|
20
20
|
}
|
|
21
21
|
catch (e) {
|
|
22
22
|
if (e instanceof CosmosBaseTendermintV1Beta1Query.GrpcWebError) {
|
|
@@ -33,4 +33,26 @@ export class ChainGrpcTendermintApi extends BaseGrpcConsumer {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
async fetchBlock(height) {
|
|
37
|
+
const request = CosmosBaseTendermintV1Beta1Query.GetBlockByHeightRequest.create();
|
|
38
|
+
request.height = height.toString();
|
|
39
|
+
try {
|
|
40
|
+
const response = await this.retry(() => this.client.GetBlockByHeight(request, this.metadata));
|
|
41
|
+
return response.sdkBlock || response.block;
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e instanceof CosmosBaseTendermintV1Beta1Query.GrpcWebError) {
|
|
45
|
+
throw new GrpcUnaryRequestException(new Error(e.toString()), {
|
|
46
|
+
code: grpcErrorCodeToErrorCode(e.code),
|
|
47
|
+
context: 'TendermintApi.fetchBlock',
|
|
48
|
+
contextModule: this.module,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
throw new GrpcUnaryRequestException(e, {
|
|
52
|
+
code: UnspecifiedErrorCode,
|
|
53
|
+
context: 'TendermintApi.fetchBlock',
|
|
54
|
+
contextModule: this.module,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
36
58
|
}
|
|
@@ -5,6 +5,7 @@ import { BlockLatestRestResponse, NodeInfoRestResponse } from './../types/tender
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class ChainRestTendermintApi extends BaseRestConsumer {
|
|
7
7
|
fetchLatestBlock(params?: Record<string, any>): Promise<BlockLatestRestResponse['block']>;
|
|
8
|
+
fetchBlock(height: number | string, params?: Record<string, any>): Promise<BlockLatestRestResponse['block']>;
|
|
8
9
|
fetchNodeInfo(params?: Record<string, any>): Promise<{
|
|
9
10
|
nodeInfo: NodeInfoRestResponse['default_node_info'];
|
|
10
11
|
applicationVersion: NodeInfoRestResponse['application_version'];
|
|
@@ -9,7 +9,24 @@ export class ChainRestTendermintApi extends BaseRestConsumer {
|
|
|
9
9
|
const endpoint = `cosmos/base/tendermint/v1beta1/blocks/latest`;
|
|
10
10
|
try {
|
|
11
11
|
const response = await this.retry(() => this.get(endpoint, params));
|
|
12
|
-
return response.data.block;
|
|
12
|
+
return response.data.sdk_block || response.data.block;
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
if (e instanceof HttpRequestException) {
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
throw new HttpRequestException(new Error(e), {
|
|
19
|
+
code: UnspecifiedErrorCode,
|
|
20
|
+
context: `${this.endpoint}/${endpoint}`,
|
|
21
|
+
contextModule: ChainModule.Tendermint,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async fetchBlock(height, params = {}) {
|
|
26
|
+
const endpoint = `cosmos/base/tendermint/v1beta1/blocks/${height}`;
|
|
27
|
+
try {
|
|
28
|
+
const response = await this.retry(() => this.get(endpoint, params));
|
|
29
|
+
return response.data.sdk_block || response.data.block;
|
|
13
30
|
}
|
|
14
31
|
catch (e) {
|
|
15
32
|
if (e instanceof HttpRequestException) {
|
|
@@ -33,6 +33,33 @@ export interface BlockLatestRestResponse {
|
|
|
33
33
|
proposer_address: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
sdk_block: {
|
|
37
|
+
header: {
|
|
38
|
+
version: {
|
|
39
|
+
block: string;
|
|
40
|
+
app: string;
|
|
41
|
+
};
|
|
42
|
+
chain_id: string;
|
|
43
|
+
height: string;
|
|
44
|
+
time: Date;
|
|
45
|
+
last_block_id: {
|
|
46
|
+
hash: string;
|
|
47
|
+
part_set_header: {
|
|
48
|
+
total: 0;
|
|
49
|
+
hash: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
last_commit_hash: string;
|
|
53
|
+
data_hash: string;
|
|
54
|
+
validators_hash: string;
|
|
55
|
+
next_validators_hash: string;
|
|
56
|
+
consensus_hash: string;
|
|
57
|
+
app_hash: string;
|
|
58
|
+
last_results_hash: string;
|
|
59
|
+
evidence_hash: string;
|
|
60
|
+
proposer_address: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
36
63
|
}
|
|
37
64
|
export interface NodeInfoRestResponse {
|
|
38
65
|
default_node_info: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/sdk-ts",
|
|
3
3
|
"description": "SDK in TypeScript for building Injective applications in a browser, node, and react native environment.",
|
|
4
|
-
"version": "1.15.
|
|
4
|
+
"version": "1.15.4",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": {
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"shx": "^0.3.4",
|
|
153
153
|
"snakecase-keys": "^5.4.1"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "b3c1eea83eec540cbd39b923a430c132014b59b6",
|
|
156
156
|
"typedoc": {
|
|
157
157
|
"entryPoint": "./src/index.ts",
|
|
158
158
|
"readmeFile": "./README.md",
|