@injectivelabs/sdk-ts 1.15.3 → 1.15.5
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/cjs/service/TokenStaticFactory.js +4 -13
- 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/dist/esm/service/TokenStaticFactory.js +4 -13
- package/package.json +6 -6
|
@@ -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: {
|
|
@@ -38,21 +38,12 @@ class TokenStaticFactory {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
mapRegistry(registry) {
|
|
41
|
-
this.denomVerifiedMap = {};
|
|
42
|
-
this.denomBlacklistedMap = {};
|
|
43
|
-
this.denomUnverifiedMap = {};
|
|
44
|
-
this.cw20AddressVerifiedMap = {};
|
|
45
|
-
this.cw20AddressUnverifiedMap = {};
|
|
46
|
-
this.factoryTokenDenomVerifiedMap = {};
|
|
47
|
-
this.factoryTokenDenomUnverifiedMap = {};
|
|
48
|
-
this.ibcDenomsVerifiedMap = {};
|
|
49
|
-
this.ibcDenomsUnverifiedMap = {};
|
|
50
|
-
this.ibcBaseDenomsVerifiedMap = {};
|
|
51
|
-
this.ibcBaseDenomsUnverifiedMap = {};
|
|
52
|
-
this.symbolTokensMap = {};
|
|
53
|
-
this.insuranceTokensMap = {};
|
|
54
41
|
for (const token of registry) {
|
|
55
42
|
const { denom, baseDenom, symbol, address, tokenType, tokenVerification, } = token;
|
|
43
|
+
const existingToken = this.toToken(denom);
|
|
44
|
+
if (existingToken) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
56
47
|
if (tokenVerification === index_js_2.TokenVerification.Verified) {
|
|
57
48
|
this.denomVerifiedMap[denom] = token;
|
|
58
49
|
this.symbolTokensMap[symbol.toLowerCase()] = token;
|
|
@@ -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: {
|
|
@@ -35,21 +35,12 @@ export class TokenStaticFactory {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
mapRegistry(registry) {
|
|
38
|
-
this.denomVerifiedMap = {};
|
|
39
|
-
this.denomBlacklistedMap = {};
|
|
40
|
-
this.denomUnverifiedMap = {};
|
|
41
|
-
this.cw20AddressVerifiedMap = {};
|
|
42
|
-
this.cw20AddressUnverifiedMap = {};
|
|
43
|
-
this.factoryTokenDenomVerifiedMap = {};
|
|
44
|
-
this.factoryTokenDenomUnverifiedMap = {};
|
|
45
|
-
this.ibcDenomsVerifiedMap = {};
|
|
46
|
-
this.ibcDenomsUnverifiedMap = {};
|
|
47
|
-
this.ibcBaseDenomsVerifiedMap = {};
|
|
48
|
-
this.ibcBaseDenomsUnverifiedMap = {};
|
|
49
|
-
this.symbolTokensMap = {};
|
|
50
|
-
this.insuranceTokensMap = {};
|
|
51
38
|
for (const token of registry) {
|
|
52
39
|
const { denom, baseDenom, symbol, address, tokenType, tokenVerification, } = token;
|
|
40
|
+
const existingToken = this.toToken(denom);
|
|
41
|
+
if (existingToken) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
53
44
|
if (tokenVerification === TokenVerification.Verified) {
|
|
54
45
|
this.denomVerifiedMap[denom] = token;
|
|
55
46
|
this.symbolTokensMap[symbol.toLowerCase()] = token;
|
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.5",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": {
|
|
@@ -124,16 +124,16 @@
|
|
|
124
124
|
"@ethersproject/bytes": "^5.8.0",
|
|
125
125
|
"@injectivelabs/abacus-proto-ts": "1.14.0",
|
|
126
126
|
"@injectivelabs/core-proto-ts": "1.14.3",
|
|
127
|
-
"@injectivelabs/exceptions": "^1.15.
|
|
127
|
+
"@injectivelabs/exceptions": "^1.15.2",
|
|
128
128
|
"@injectivelabs/grpc-web": "^0.0.1",
|
|
129
129
|
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
|
|
130
130
|
"@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
|
|
131
131
|
"@injectivelabs/indexer-proto-ts": "1.13.9",
|
|
132
132
|
"@injectivelabs/mito-proto-ts": "1.13.2",
|
|
133
|
-
"@injectivelabs/networks": "^1.15.
|
|
133
|
+
"@injectivelabs/networks": "^1.15.3",
|
|
134
134
|
"@injectivelabs/olp-proto-ts": "1.13.4",
|
|
135
|
-
"@injectivelabs/ts-types": "^1.15.
|
|
136
|
-
"@injectivelabs/utils": "^1.15.
|
|
135
|
+
"@injectivelabs/ts-types": "^1.15.3",
|
|
136
|
+
"@injectivelabs/utils": "^1.15.3",
|
|
137
137
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
138
138
|
"@noble/curves": "^1.8.1",
|
|
139
139
|
"@noble/hashes": "^1.7.1",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"shx": "^0.3.4",
|
|
153
153
|
"snakecase-keys": "^5.4.1"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "adf15fdda3172783b16fddba631c8054160fe772",
|
|
156
156
|
"typedoc": {
|
|
157
157
|
"entryPoint": "./src/index.ts",
|
|
158
158
|
"readmeFile": "./README.md",
|