@indexing/jiti 0.0.26 → 0.0.28

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/module.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {Buffer as $hgUW1$Buffer} from "buffer";
2
2
  import {decodeTxRaw as $hgUW1$decodeTxRaw, Registry as $hgUW1$Registry} from "@cosmjs/proto-signing";
3
3
  import {defaultRegistryTypes as $hgUW1$defaultRegistryTypes} from "@cosmjs/stargate";
4
- import {keccak256 as $hgUW1$keccak256, decodeEventLog as $hgUW1$decodeEventLog, parseAbi as $hgUW1$parseAbi} from "viem";
4
+ import {sha256 as $hgUW1$sha256, keccak256 as $hgUW1$keccak256, decodeEventLog as $hgUW1$decodeEventLog, parseAbi as $hgUW1$parseAbi} from "viem";
5
5
 
6
6
 
7
7
  function $parcel$exportWildcard(dest, source) {
@@ -272,6 +272,7 @@ $parcel$exportWildcard($fde9406d76ec24a9$exports, $8f1e0ae1ead9a2a9$exports);
272
272
 
273
273
 
274
274
 
275
+
275
276
  var $c18434deda90759d$require$Buffer = $hgUW1$Buffer;
276
277
  const $c18434deda90759d$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
277
278
  const $c18434deda90759d$var$tokenTransfersTemplate = {
@@ -326,32 +327,43 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
326
327
  case "APTOS_TESTNET":
327
328
  for (const tx of block.transactions){
328
329
  if (!tx?.events || !Array.isArray(tx.events)) continue;
329
- const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp) / 1000).toISOString() : null;
330
- const txfersByKey = {};
331
- for (const evt of tx.events)if ([
332
- "0x1::coin::WithdrawEvent",
333
- "0x1::coin::DepositEvent"
334
- ].includes(evt.type)) {
335
- const amount = evt.data?.amount;
336
- const key = `0x1-${amount}`;
337
- txfersByKey[key] ||= {
338
- amount: amount,
339
- tokenAddress: null
340
- };
341
- if (evt.type.endsWith("WithdrawEvent")) txfersByKey[key].from = evt.guid?.account_address;
342
- else txfersByKey[key].to = evt.guid?.account_address;
330
+ const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp, 10) / 1000).toISOString() : null;
331
+ const transfersByKey = {};
332
+ for (const evt of tx.events){
333
+ const evtType = evt.type;
334
+ if (/::(Withdraw|Deposit)[^:]*/.test(evtType)) {
335
+ const data = evt.data;
336
+ const amount = data.amount;
337
+ const accountAddr = data.store_owner || evt.guid?.account_address || "";
338
+ let tokenAddr = "0x1::aptos_coin::AptosCoin";
339
+ if (data.store) tokenAddr = tx.changes.find((c)=>c.address === data.store && c.data.type === "0x1::fungible_asset::FungibleStore")?.data?.data?.metadata?.inner || data.store;
340
+ const compositeKey = `${tx.hash}-${tokenAddr}-${amount}`;
341
+ if (!transfersByKey[compositeKey]) transfersByKey[compositeKey] = {
342
+ amount: amount,
343
+ tokenAddress: tokenAddr
344
+ };
345
+ if (/::Withdraw[^:]*/.test(evtType)) transfersByKey[compositeKey].from = accountAddr;
346
+ else transfersByKey[compositeKey].to = accountAddr;
347
+ }
343
348
  }
344
- for (const partial of Object.values(txfersByKey)){
349
+ for (const partial of Object.values(transfersByKey)){
345
350
  if (!partial.from || !partial.to) continue;
351
+ const fromAddr = partial.from.length < 66 ? `0x0${partial.from.slice(2)}` : partial.from;
352
+ const toAddr = partial.to.length < 66 ? `0x0${partial.to.slice(2)}` : partial.to;
353
+ let finalToken = null;
354
+ let finalTokenType = "TOKEN";
355
+ if (partial.tokenAddress?.toLowerCase().includes("aptos_coin")) finalToken = null;
356
+ else finalToken = partial.tokenAddress?.toLowerCase();
357
+ const gasUsed = BigInt(tx.gas_used || "0");
346
358
  transfers.push({
347
359
  amount: BigInt(partial.amount),
348
- blockNumber: parseInt(block.block_height),
349
- from: partial.from?.length < 66 ? `0x0${partial.from?.slice(2)}` : partial.from,
360
+ blockNumber: parseInt(block.block_height, 10),
361
+ from: fromAddr,
362
+ to: toAddr,
350
363
  timestamp: timestamp,
351
- to: partial.to?.length < 66 ? `0x0${partial.to?.slice(2)}` : partial.to,
352
- token: partial.tokenAddress,
353
- tokenType: "NATIVE",
354
- transactionGasFee: BigInt(tx.gas_used),
364
+ token: finalToken,
365
+ tokenType: finalTokenType,
366
+ transactionGasFee: gasUsed,
355
367
  transactionHash: tx.hash
356
368
  });
357
369
  }
@@ -644,10 +656,12 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
644
656
  {
645
657
  const typedBlock = block;
646
658
  const blockNumber = typedBlock.blockNumber;
647
- const blockHash = typedBlock.blockHash;
648
659
  const timestampExtrinsic = typedBlock.extrinsics.find((ex)=>ex.method === "timestamp.set");
649
660
  const blockTimestamp = timestampExtrinsic ? new Date(Number(timestampExtrinsic.args[0].toString().replace(/,/g, ""))).toISOString() : new Date().toISOString();
650
- for (const extrinsic of typedBlock.extrinsics)if (extrinsic.method === "balances.transferKeepAlive") {
661
+ for (const extrinsic of typedBlock.extrinsics)if ([
662
+ "balances.transfer",
663
+ "balances.transferKeepAlive"
664
+ ].includes(extrinsic.method)) {
651
665
  const from = extrinsic.signer;
652
666
  const to = extrinsic.args[0]?.Id || "";
653
667
  const amount = BigInt(extrinsic.args[1].replace(/,/g, ""));
@@ -660,7 +674,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
660
674
  tokenType: "NATIVE",
661
675
  timestamp: blockTimestamp,
662
676
  transactionGasFee: 0n,
663
- transactionHash: blockHash
677
+ transactionHash: extrinsic.hash
664
678
  });
665
679
  }
666
680
  break;
@@ -697,6 +711,38 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
697
711
  }
698
712
  break;
699
713
  }
714
+ case "FILECOIN":
715
+ {
716
+ const typedBlock = block;
717
+ const blockNumber = typedBlock.Height;
718
+ const blockTimestamp = new Date(typedBlock.Blocks[0].Timestamp * 1000).toISOString();
719
+ const parentBaseFee = BigInt(typedBlock.Blocks[0].ParentBaseFee);
720
+ let receiptIndex = 0;
721
+ for (const msgGroup of typedBlock.messages){
722
+ const secpkMessages = msgGroup.blockMessages.SecpkMessages || [];
723
+ for (const msg of secpkMessages){
724
+ const receipt = typedBlock.receipts[receiptIndex++];
725
+ const gasUsed = BigInt(receipt.GasUsed);
726
+ const gasFeeCap = BigInt(msg.Message.GasFeeCap);
727
+ const gasPremium = BigInt(msg.Message.GasPremium);
728
+ const baseFeeBurn = gasUsed * parentBaseFee;
729
+ const minerTip = gasUsed * (gasPremium < gasFeeCap - parentBaseFee ? gasPremium : gasFeeCap - parentBaseFee);
730
+ const transactionGasFee = baseFeeBurn + minerTip;
731
+ transfers.push({
732
+ amount: BigInt(msg.Message.Value),
733
+ blockNumber: blockNumber,
734
+ from: msg.Message.From,
735
+ to: msg.Message.To,
736
+ token: null,
737
+ tokenType: "NATIVE",
738
+ timestamp: blockTimestamp,
739
+ transactionGasFee: transactionGasFee,
740
+ transactionHash: msg.CID["/"]
741
+ });
742
+ }
743
+ }
744
+ break;
745
+ }
700
746
  // attempt to introspect data types
701
747
  default:
702
748
  // try Cosmos
@@ -704,9 +750,9 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
704
750
  const typedBlock = block;
705
751
  const blockNumber = Number(typedBlock.block.header.height);
706
752
  const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
707
- const blockHash = typedBlock.block_id.hash;
708
753
  for (const txRaw of typedBlock.block.data.txs || []){
709
754
  const decoded = (0, $hgUW1$decodeTxRaw)(new Uint8Array($c18434deda90759d$require$Buffer.from(txRaw, "base64")));
755
+ const txHash = (0, $hgUW1$sha256)(new Uint8Array($c18434deda90759d$require$Buffer.from(txRaw, "base64")));
710
756
  const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
711
757
  const registry = new (0, $hgUW1$Registry)((0, $hgUW1$defaultRegistryTypes));
712
758
  for (const message of decoded.body.messages)if ([
@@ -722,7 +768,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
722
768
  token: decodedMsg.token.denom,
723
769
  tokenType: "NATIVE",
724
770
  timestamp: blockTimestamp,
725
- transactionHash: blockHash,
771
+ transactionHash: txHash.slice(2).toUpperCase(),
726
772
  transactionGasFee: transactionGasFee
727
773
  });
728
774
  }
@@ -857,25 +903,36 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
857
903
  return transfers;
858
904
  },
859
905
  tests: [
860
- //FILECOIN
906
+ // APTOS
861
907
  {
862
908
  params: {
863
- network: "FILECOIN",
864
- walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
865
- contractAddress: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y"
909
+ network: "APTOS",
910
+ walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
911
+ contractAddress: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0"
866
912
  },
867
- payload: "https://jiti.indexing.co/networks/filecoin/4818438",
913
+ payload: "https://jiti.indexing.co/networks/aptos/297956660",
868
914
  output: [
869
915
  {
870
- amount: 7896300000000000000n,
871
- blockNumber: 4818438,
872
- from: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
873
- timestamp: "2025-03-24T23:39:00.000Z",
874
- to: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y",
916
+ amount: 1611839920n,
917
+ blockNumber: 297956660,
918
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
919
+ to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
920
+ timestamp: "2025-03-02T21:07:06.002Z",
875
921
  token: null,
876
- tokenType: "NATIVE",
877
- transactionGasFee: 1592498365133760n,
878
- transactionHash: "bafy2bzacecxud3tayyq3caagjej5srufcx5fufjuqkz3ltgfty27wdsrmqeew"
922
+ tokenType: "TOKEN",
923
+ transactionGasFee: 13n,
924
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
925
+ },
926
+ {
927
+ amount: 1502138836n,
928
+ blockNumber: 297956660,
929
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
930
+ to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
931
+ timestamp: "2025-03-02T21:07:06.002Z",
932
+ token: null,
933
+ tokenType: "TOKEN",
934
+ transactionGasFee: 13n,
935
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
879
936
  }
880
937
  ]
881
938
  },
@@ -883,21 +940,20 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
883
940
  {
884
941
  params: {
885
942
  network: "APTOS",
886
- walletAddress: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
887
- contractAddress: "0x1"
943
+ contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
888
944
  },
889
- payload: "https://jiti.indexing.co/networks/aptos/297956660",
945
+ payload: "https://jiti.indexing.co/networks/aptos/303623631",
890
946
  output: [
891
947
  {
892
- amount: 1502138836n,
893
- blockNumber: 297956660,
894
- from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
895
- timestamp: "2025-03-02T21:07:06.002Z",
896
- to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
897
- token: null,
898
- tokenType: "NATIVE",
899
- transactionGasFee: 13n,
900
- transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
948
+ amount: 1000060n,
949
+ blockNumber: 303623631,
950
+ from: "0xa4e7455d27731ab857e9701b1e6ed72591132b909fe6e4fd99b66c1d6318d9e8",
951
+ timestamp: "2025-03-14T15:39:49.845Z",
952
+ to: "0x9317336bfc9ba6987d40492ddea8d41e11b7c2e473f3556a9c82309d326e79ce",
953
+ token: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
954
+ tokenType: "TOKEN",
955
+ transactionGasFee: 16n,
956
+ transactionHash: "0x24b8854bad1f6543b35069eacd6ec40a583ca7fa452b422b04d747d24b65279c"
901
957
  }
902
958
  ]
903
959
  },
@@ -924,25 +980,69 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
924
980
  }
925
981
  ]
926
982
  },
927
- //BITTENSOR
983
+ // BITTENSOR
928
984
  {
929
985
  params: {
930
986
  network: "BITTENSOR",
931
- walletAddress: "5G4TazaYLvMd8g7sYCd7Z6GpnFM5Kw4nt5tsydkw7gu3BnLC",
987
+ walletAddress: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
932
988
  contractAddress: ""
933
989
  },
934
- payload: "https://jiti.indexing.co/networks/bittensor/5149839",
990
+ payload: "https://jiti.indexing.co/networks/bittensor/2652896",
935
991
  output: [
936
992
  {
937
- amount: 3210000000n,
938
- blockNumber: 5149839,
939
- from: "5G4TazaYLvMd8g7sYCd7Z6GpnFM5Kw4nt5tsydkw7gu3BnLC",
940
- timestamp: "2025-03-17T18:41:24.000Z",
941
- to: "5CWgT5vMteM2fUabZ7oPYHPmXi6xPHKUxd6wEWnUvFuxsdJX",
993
+ amount: 2154999850n,
994
+ blockNumber: 2652896,
995
+ from: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
996
+ to: "5CFwmfLfL1Z6vXU6hgGksh6irDFpcVXaTTNRoqDGMyHrDKK1",
942
997
  token: null,
943
998
  tokenType: "NATIVE",
999
+ timestamp: "2024-03-28T12:53:36.001Z",
944
1000
  transactionGasFee: 0n,
945
- transactionHash: "0x26eb4c29a49a67033cdd6eb1ef0887faeb764836b0cf0322716e7f783248236e"
1001
+ transactionHash: "0x9ea55a8f40b8d7704f27964155476ab9c744ec2ef2b1f431ad0e05a3a6f3c1ab"
1002
+ }
1003
+ ]
1004
+ },
1005
+ // CARDANO
1006
+ {
1007
+ params: {
1008
+ network: "CARDANO",
1009
+ walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1010
+ contractAddress: ""
1011
+ },
1012
+ payload: "https://jiti.indexing.co/networks/cardano/11443286",
1013
+ output: [
1014
+ {
1015
+ amount: 1110000n,
1016
+ blockNumber: 11443286,
1017
+ from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
1018
+ timestamp: "+057068-01-19T05:23:20.000Z",
1019
+ to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1020
+ token: null,
1021
+ tokenType: "NATIVE",
1022
+ transactionGasFee: 174257n,
1023
+ transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
1024
+ }
1025
+ ]
1026
+ },
1027
+ // COSMOS
1028
+ {
1029
+ params: {
1030
+ network: "COSMOS",
1031
+ walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1032
+ contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1033
+ },
1034
+ payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1035
+ output: [
1036
+ {
1037
+ blockNumber: 24419691,
1038
+ from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1039
+ to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1040
+ amount: 500000n,
1041
+ token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1042
+ tokenType: "NATIVE",
1043
+ timestamp: "2025-02-14T21:48:22.809Z",
1044
+ transactionHash: "963D4D7BB59C1280F58A7ECA2F1934E2AA005109A989193C815C7B98EDCD7445",
1045
+ transactionGasFee: 4860n
946
1046
  }
947
1047
  ]
948
1048
  },
@@ -968,25 +1068,25 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
968
1068
  }
969
1069
  ]
970
1070
  },
971
- // CARDANO
1071
+ // FILECOIN
972
1072
  {
973
1073
  params: {
974
- network: "CARDANO",
975
- walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
976
- contractAddress: ""
1074
+ network: "FILECOIN",
1075
+ walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
1076
+ contractAddress: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y"
977
1077
  },
978
- payload: "https://jiti.indexing.co/networks/cardano/11443286",
1078
+ payload: "https://jiti.indexing.co/networks/filecoin/4818438",
979
1079
  output: [
980
1080
  {
981
- amount: 1110000n,
982
- blockNumber: 11443286,
983
- from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
984
- timestamp: "+057068-01-19T05:23:20.000Z",
985
- to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1081
+ amount: 7896300000000000000n,
1082
+ blockNumber: 4818438,
1083
+ from: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
1084
+ timestamp: "2025-03-24T23:39:00.000Z",
1085
+ to: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y",
986
1086
  token: null,
987
1087
  tokenType: "NATIVE",
988
- transactionGasFee: 174257n,
989
- transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
1088
+ transactionGasFee: 1592498365133760n,
1089
+ transactionHash: "bafy2bzacecxud3tayyq3caagjej5srufcx5fufjuqkz3ltgfty27wdsrmqeew"
990
1090
  }
991
1091
  ]
992
1092
  },
@@ -1056,7 +1156,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1056
1156
  }
1057
1157
  ]
1058
1158
  },
1059
- //SUI
1159
+ // SUI
1060
1160
  {
1061
1161
  params: {
1062
1162
  network: "SUI",
@@ -1100,28 +1200,6 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1100
1200
  }
1101
1201
  ]
1102
1202
  },
1103
- // COSMOS
1104
- {
1105
- params: {
1106
- network: "COSMOS",
1107
- walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1108
- contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1109
- },
1110
- payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1111
- output: [
1112
- {
1113
- blockNumber: 24419691,
1114
- from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1115
- to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1116
- amount: 500000n,
1117
- token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1118
- tokenType: "NATIVE",
1119
- timestamp: "2025-02-14T21:48:22.809Z",
1120
- transactionHash: "DF5FB086E60EE2ADA3A842751337E06A40696D7983CC1C038ADE236B36ED8AEB",
1121
- transactionGasFee: 4860n
1122
- }
1123
- ]
1124
- },
1125
1203
  // SOLANA
1126
1204
  {
1127
1205
  params: {