@injectivelabs/sdk-ts 1.15.42 → 1.15.43
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/indexer/transformers/IndexerGrpcExplorerTransformer.d.ts +1 -1
- package/dist/cjs/client/indexer/transformers/IndexerGrpcExplorerTransformer.js +29 -32
- package/dist/esm/client/indexer/transformers/IndexerGrpcExplorerTransformer.d.ts +1 -1
- package/dist/esm/client/indexer/transformers/IndexerGrpcExplorerTransformer.js +29 -32
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block, GasFee, GrpcGasFee, Transaction, BlockWithTxs, IBCTransferTx, ExplorerStats, PeggyDepositTx, ValidatorUptime, ExplorerValidator, PeggyWithdrawalTx, GrpcIBCTransferTx, GrpcPeggyDepositTx, GrpcValidatorUptime, GrpcPeggyWithdrawalTx, BankMsgSendTransaction, ValidatorSlashingEvent, IndexerStreamTransaction, GrpcValidatorSlashingEvent, ExplorerValidatorDescription, GrpcIndexerValidatorDescription
|
|
1
|
+
import { Block, GasFee, GrpcGasFee, Transaction, BlockWithTxs, IBCTransferTx, ExplorerStats, PeggyDepositTx, ValidatorUptime, ExplorerValidator, PeggyWithdrawalTx, GrpcIBCTransferTx, GrpcPeggyDepositTx, GrpcValidatorUptime, GrpcPeggyWithdrawalTx, BankMsgSendTransaction, ValidatorSlashingEvent, ExplorerTransaction, ContractTransaction, IndexerStreamTransaction, GrpcValidatorSlashingEvent, ExplorerValidatorDescription, GrpcIndexerValidatorDescription } from '../types/explorer.js';
|
|
2
2
|
import { InjectiveExplorerRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
/**
|
|
4
4
|
* @category Indexer Grpc Transformer
|
|
@@ -21,18 +21,32 @@ const getContractTransactionV2Amount = (ApiTransaction) => {
|
|
|
21
21
|
}
|
|
22
22
|
return new utils_1.BigNumberInWei(msgObj.transfer.amount).toBase();
|
|
23
23
|
};
|
|
24
|
-
const
|
|
24
|
+
const parseStringToObjectLikeNoThrow = (object, defaultValue = []) => {
|
|
25
|
+
if (!object) {
|
|
26
|
+
return defaultValue;
|
|
27
|
+
}
|
|
28
|
+
if (typeof object === 'string') {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(object);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
return defaultValue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
25
36
|
try {
|
|
26
|
-
return JSON.parse(Buffer.from(
|
|
27
|
-
type: msg.type,
|
|
28
|
-
message: msg.value,
|
|
29
|
-
}));
|
|
37
|
+
return JSON.parse(Buffer.from(object).toString('utf8'));
|
|
30
38
|
}
|
|
31
|
-
catch (
|
|
32
|
-
|
|
33
|
-
return []; // Return an empty array in case of error
|
|
39
|
+
catch (e) {
|
|
40
|
+
return defaultValue;
|
|
34
41
|
}
|
|
35
42
|
};
|
|
43
|
+
const transactionV2MessagesToMessagesNoThrow = (messages) => {
|
|
44
|
+
const messagesArray = parseStringToObjectLikeNoThrow(messages);
|
|
45
|
+
return messagesArray.map((msg) => ({
|
|
46
|
+
type: msg.type,
|
|
47
|
+
message: msg.value,
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
36
50
|
/**
|
|
37
51
|
* @category Indexer Grpc Transformer
|
|
38
52
|
*/
|
|
@@ -321,16 +335,9 @@ class IndexerGrpcExplorerTransformer {
|
|
|
321
335
|
};
|
|
322
336
|
}
|
|
323
337
|
static grpcTxV2ToTransaction(tx) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
logs = JSON.parse(rawLogs || '[]');
|
|
328
|
-
}
|
|
329
|
-
catch (e) {
|
|
330
|
-
console.error('Failed to parse logs');
|
|
331
|
-
logs = [];
|
|
332
|
-
}
|
|
333
|
-
const txType = JSON.parse(Buffer.from(tx.txMsgTypes).toString('utf8'));
|
|
338
|
+
const logs = parseStringToObjectLikeNoThrow(tx.logs);
|
|
339
|
+
const txType = parseStringToObjectLikeNoThrow(tx.txMsgTypes);
|
|
340
|
+
const messages = transactionV2MessagesToMessagesNoThrow(tx.messages);
|
|
334
341
|
const signatures = tx.signatures.map((signature) => ({
|
|
335
342
|
address: signature.address,
|
|
336
343
|
pubkey: signature.pubkey,
|
|
@@ -340,7 +347,6 @@ class IndexerGrpcExplorerTransformer {
|
|
|
340
347
|
return parseInt(signature.sequence, 10);
|
|
341
348
|
}
|
|
342
349
|
catch (e) {
|
|
343
|
-
console.error('Failed to parse signature sequence:', e);
|
|
344
350
|
return 0;
|
|
345
351
|
}
|
|
346
352
|
})(),
|
|
@@ -350,24 +356,14 @@ class IndexerGrpcExplorerTransformer {
|
|
|
350
356
|
return parseInt(claimId, 10);
|
|
351
357
|
}
|
|
352
358
|
catch (e) {
|
|
353
|
-
console.error('Failed to parse claimId:', e);
|
|
354
359
|
return 0;
|
|
355
360
|
}
|
|
356
361
|
});
|
|
357
|
-
let messages = [];
|
|
358
|
-
try {
|
|
359
|
-
messages = transactionV2MessagesToMessages(tx.messages);
|
|
360
|
-
}
|
|
361
|
-
catch (e) {
|
|
362
|
-
console.error('Failed to parse messages:', e);
|
|
363
|
-
messages = [];
|
|
364
|
-
}
|
|
365
362
|
const blockNumber = parseInt(tx.blockNumber);
|
|
366
363
|
return {
|
|
367
364
|
logs,
|
|
368
365
|
info: '',
|
|
369
366
|
memo: '',
|
|
370
|
-
txType,
|
|
371
367
|
claimIds,
|
|
372
368
|
messages,
|
|
373
369
|
id: tx.id,
|
|
@@ -380,6 +376,7 @@ class IndexerGrpcExplorerTransformer {
|
|
|
380
376
|
errorLog: tx.errorLog,
|
|
381
377
|
codespace: tx.codespace,
|
|
382
378
|
blockTimestamp: tx.blockTimestamp,
|
|
379
|
+
txType: Array.isArray(txType) ? txType.join(',') : txType,
|
|
383
380
|
gasFee: { amounts: [], gasLimit: 0, granter: '', payer: '' },
|
|
384
381
|
};
|
|
385
382
|
}
|
|
@@ -419,8 +416,8 @@ class IndexerGrpcExplorerTransformer {
|
|
|
419
416
|
signature: signature.signature,
|
|
420
417
|
sequence: parseInt(signature.sequence, 10),
|
|
421
418
|
})),
|
|
422
|
-
messages:
|
|
423
|
-
logs:
|
|
419
|
+
messages: transactionV2MessagesToMessagesNoThrow(tx.messages),
|
|
420
|
+
logs: parseStringToObjectLikeNoThrow(tx.logs),
|
|
424
421
|
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
|
|
425
422
|
claimIds: tx.claimIds.map((claimId) => parseInt(claimId, 10)),
|
|
426
423
|
};
|
|
@@ -450,7 +447,7 @@ class IndexerGrpcExplorerTransformer {
|
|
|
450
447
|
};
|
|
451
448
|
}
|
|
452
449
|
static grpcContractTxV2ToTransaction(tx) {
|
|
453
|
-
const messages =
|
|
450
|
+
const messages = transactionV2MessagesToMessagesNoThrow(tx.messages);
|
|
454
451
|
return {
|
|
455
452
|
messages,
|
|
456
453
|
code: tx.code,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block, GasFee, GrpcGasFee, Transaction, BlockWithTxs, IBCTransferTx, ExplorerStats, PeggyDepositTx, ValidatorUptime, ExplorerValidator, PeggyWithdrawalTx, GrpcIBCTransferTx, GrpcPeggyDepositTx, GrpcValidatorUptime, GrpcPeggyWithdrawalTx, BankMsgSendTransaction, ValidatorSlashingEvent, IndexerStreamTransaction, GrpcValidatorSlashingEvent, ExplorerValidatorDescription, GrpcIndexerValidatorDescription
|
|
1
|
+
import { Block, GasFee, GrpcGasFee, Transaction, BlockWithTxs, IBCTransferTx, ExplorerStats, PeggyDepositTx, ValidatorUptime, ExplorerValidator, PeggyWithdrawalTx, GrpcIBCTransferTx, GrpcPeggyDepositTx, GrpcValidatorUptime, GrpcPeggyWithdrawalTx, BankMsgSendTransaction, ValidatorSlashingEvent, ExplorerTransaction, ContractTransaction, IndexerStreamTransaction, GrpcValidatorSlashingEvent, ExplorerValidatorDescription, GrpcIndexerValidatorDescription } from '../types/explorer.js';
|
|
2
2
|
import { InjectiveExplorerRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
/**
|
|
4
4
|
* @category Indexer Grpc Transformer
|
|
@@ -18,18 +18,32 @@ const getContractTransactionV2Amount = (ApiTransaction) => {
|
|
|
18
18
|
}
|
|
19
19
|
return new BigNumberInWei(msgObj.transfer.amount).toBase();
|
|
20
20
|
};
|
|
21
|
-
const
|
|
21
|
+
const parseStringToObjectLikeNoThrow = (object, defaultValue = []) => {
|
|
22
|
+
if (!object) {
|
|
23
|
+
return defaultValue;
|
|
24
|
+
}
|
|
25
|
+
if (typeof object === 'string') {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(object);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
return defaultValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
try {
|
|
23
|
-
return JSON.parse(Buffer.from(
|
|
24
|
-
type: msg.type,
|
|
25
|
-
message: msg.value,
|
|
26
|
-
}));
|
|
34
|
+
return JSON.parse(Buffer.from(object).toString('utf8'));
|
|
27
35
|
}
|
|
28
|
-
catch (
|
|
29
|
-
|
|
30
|
-
return []; // Return an empty array in case of error
|
|
36
|
+
catch (e) {
|
|
37
|
+
return defaultValue;
|
|
31
38
|
}
|
|
32
39
|
};
|
|
40
|
+
const transactionV2MessagesToMessagesNoThrow = (messages) => {
|
|
41
|
+
const messagesArray = parseStringToObjectLikeNoThrow(messages);
|
|
42
|
+
return messagesArray.map((msg) => ({
|
|
43
|
+
type: msg.type,
|
|
44
|
+
message: msg.value,
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
33
47
|
/**
|
|
34
48
|
* @category Indexer Grpc Transformer
|
|
35
49
|
*/
|
|
@@ -318,16 +332,9 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
318
332
|
};
|
|
319
333
|
}
|
|
320
334
|
static grpcTxV2ToTransaction(tx) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
logs = JSON.parse(rawLogs || '[]');
|
|
325
|
-
}
|
|
326
|
-
catch (e) {
|
|
327
|
-
console.error('Failed to parse logs');
|
|
328
|
-
logs = [];
|
|
329
|
-
}
|
|
330
|
-
const txType = JSON.parse(Buffer.from(tx.txMsgTypes).toString('utf8'));
|
|
335
|
+
const logs = parseStringToObjectLikeNoThrow(tx.logs);
|
|
336
|
+
const txType = parseStringToObjectLikeNoThrow(tx.txMsgTypes);
|
|
337
|
+
const messages = transactionV2MessagesToMessagesNoThrow(tx.messages);
|
|
331
338
|
const signatures = tx.signatures.map((signature) => ({
|
|
332
339
|
address: signature.address,
|
|
333
340
|
pubkey: signature.pubkey,
|
|
@@ -337,7 +344,6 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
337
344
|
return parseInt(signature.sequence, 10);
|
|
338
345
|
}
|
|
339
346
|
catch (e) {
|
|
340
|
-
console.error('Failed to parse signature sequence:', e);
|
|
341
347
|
return 0;
|
|
342
348
|
}
|
|
343
349
|
})(),
|
|
@@ -347,24 +353,14 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
347
353
|
return parseInt(claimId, 10);
|
|
348
354
|
}
|
|
349
355
|
catch (e) {
|
|
350
|
-
console.error('Failed to parse claimId:', e);
|
|
351
356
|
return 0;
|
|
352
357
|
}
|
|
353
358
|
});
|
|
354
|
-
let messages = [];
|
|
355
|
-
try {
|
|
356
|
-
messages = transactionV2MessagesToMessages(tx.messages);
|
|
357
|
-
}
|
|
358
|
-
catch (e) {
|
|
359
|
-
console.error('Failed to parse messages:', e);
|
|
360
|
-
messages = [];
|
|
361
|
-
}
|
|
362
359
|
const blockNumber = parseInt(tx.blockNumber);
|
|
363
360
|
return {
|
|
364
361
|
logs,
|
|
365
362
|
info: '',
|
|
366
363
|
memo: '',
|
|
367
|
-
txType,
|
|
368
364
|
claimIds,
|
|
369
365
|
messages,
|
|
370
366
|
id: tx.id,
|
|
@@ -377,6 +373,7 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
377
373
|
errorLog: tx.errorLog,
|
|
378
374
|
codespace: tx.codespace,
|
|
379
375
|
blockTimestamp: tx.blockTimestamp,
|
|
376
|
+
txType: Array.isArray(txType) ? txType.join(',') : txType,
|
|
380
377
|
gasFee: { amounts: [], gasLimit: 0, granter: '', payer: '' },
|
|
381
378
|
};
|
|
382
379
|
}
|
|
@@ -416,8 +413,8 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
416
413
|
signature: signature.signature,
|
|
417
414
|
sequence: parseInt(signature.sequence, 10),
|
|
418
415
|
})),
|
|
419
|
-
messages:
|
|
420
|
-
logs:
|
|
416
|
+
messages: transactionV2MessagesToMessagesNoThrow(tx.messages),
|
|
417
|
+
logs: parseStringToObjectLikeNoThrow(tx.logs),
|
|
421
418
|
data: '/' + Buffer.from(tx.data).toString('utf8').split('/').pop(),
|
|
422
419
|
claimIds: tx.claimIds.map((claimId) => parseInt(claimId, 10)),
|
|
423
420
|
};
|
|
@@ -447,7 +444,7 @@ export class IndexerGrpcExplorerTransformer {
|
|
|
447
444
|
};
|
|
448
445
|
}
|
|
449
446
|
static grpcContractTxV2ToTransaction(tx) {
|
|
450
|
-
const messages =
|
|
447
|
+
const messages = transactionV2MessagesToMessagesNoThrow(tx.messages);
|
|
451
448
|
return {
|
|
452
449
|
messages,
|
|
453
450
|
code: tx.code,
|
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.43",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": {
|
|
@@ -123,16 +123,16 @@
|
|
|
123
123
|
"@cosmjs/stargate": "^0.33.0",
|
|
124
124
|
"@injectivelabs/abacus-proto-ts": "1.14.0",
|
|
125
125
|
"@injectivelabs/core-proto-ts": "1.15.0",
|
|
126
|
-
"@injectivelabs/exceptions": "^1.15.
|
|
126
|
+
"@injectivelabs/exceptions": "^1.15.40",
|
|
127
127
|
"@injectivelabs/grpc-web": "^0.0.1",
|
|
128
128
|
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
|
|
129
129
|
"@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
|
|
130
130
|
"@injectivelabs/indexer-proto-ts": "1.13.14",
|
|
131
131
|
"@injectivelabs/mito-proto-ts": "1.13.2",
|
|
132
|
-
"@injectivelabs/networks": "^1.15.
|
|
132
|
+
"@injectivelabs/networks": "^1.15.41",
|
|
133
133
|
"@injectivelabs/olp-proto-ts": "1.13.4",
|
|
134
|
-
"@injectivelabs/ts-types": "^1.15.
|
|
135
|
-
"@injectivelabs/utils": "^1.15.
|
|
134
|
+
"@injectivelabs/ts-types": "^1.15.41",
|
|
135
|
+
"@injectivelabs/utils": "^1.15.41",
|
|
136
136
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
137
137
|
"@noble/curves": "^1.8.1",
|
|
138
138
|
"@noble/hashes": "^1.7.1",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"shx": "^0.3.4",
|
|
152
152
|
"snakecase-keys": "^5.4.1"
|
|
153
153
|
},
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "18294bf4c22a7a832c8466ec0a825ea6c3e0a2f3",
|
|
155
155
|
"typedoc": {
|
|
156
156
|
"entryPoint": "./src/index.ts",
|
|
157
157
|
"readmeFile": "./README.md",
|