@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/main.js CHANGED
@@ -278,6 +278,7 @@ $parcel$exportWildcard($d7167569386d0d4c$exports, $414c83047563e72e$exports);
278
278
 
279
279
 
280
280
 
281
+
281
282
  var $6144a02851f23907$require$Buffer = $8zHUo$buffer.Buffer;
282
283
  const $6144a02851f23907$var$NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
283
284
  const $6144a02851f23907$var$tokenTransfersTemplate = {
@@ -332,32 +333,43 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
332
333
  case "APTOS_TESTNET":
333
334
  for (const tx of block.transactions){
334
335
  if (!tx?.events || !Array.isArray(tx.events)) continue;
335
- const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp) / 1000).toISOString() : null;
336
- const txfersByKey = {};
337
- for (const evt of tx.events)if ([
338
- "0x1::coin::WithdrawEvent",
339
- "0x1::coin::DepositEvent"
340
- ].includes(evt.type)) {
341
- const amount = evt.data?.amount;
342
- const key = `0x1-${amount}`;
343
- txfersByKey[key] ||= {
344
- amount: amount,
345
- tokenAddress: null
346
- };
347
- if (evt.type.endsWith("WithdrawEvent")) txfersByKey[key].from = evt.guid?.account_address;
348
- else txfersByKey[key].to = evt.guid?.account_address;
336
+ const timestamp = tx.timestamp ? new Date(parseInt(tx.timestamp, 10) / 1000).toISOString() : null;
337
+ const transfersByKey = {};
338
+ for (const evt of tx.events){
339
+ const evtType = evt.type;
340
+ if (/::(Withdraw|Deposit)[^:]*/.test(evtType)) {
341
+ const data = evt.data;
342
+ const amount = data.amount;
343
+ const accountAddr = data.store_owner || evt.guid?.account_address || "";
344
+ let tokenAddr = "0x1::aptos_coin::AptosCoin";
345
+ 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;
346
+ const compositeKey = `${tx.hash}-${tokenAddr}-${amount}`;
347
+ if (!transfersByKey[compositeKey]) transfersByKey[compositeKey] = {
348
+ amount: amount,
349
+ tokenAddress: tokenAddr
350
+ };
351
+ if (/::Withdraw[^:]*/.test(evtType)) transfersByKey[compositeKey].from = accountAddr;
352
+ else transfersByKey[compositeKey].to = accountAddr;
353
+ }
349
354
  }
350
- for (const partial of Object.values(txfersByKey)){
355
+ for (const partial of Object.values(transfersByKey)){
351
356
  if (!partial.from || !partial.to) continue;
357
+ const fromAddr = partial.from.length < 66 ? `0x0${partial.from.slice(2)}` : partial.from;
358
+ const toAddr = partial.to.length < 66 ? `0x0${partial.to.slice(2)}` : partial.to;
359
+ let finalToken = null;
360
+ let finalTokenType = "TOKEN";
361
+ if (partial.tokenAddress?.toLowerCase().includes("aptos_coin")) finalToken = null;
362
+ else finalToken = partial.tokenAddress?.toLowerCase();
363
+ const gasUsed = BigInt(tx.gas_used || "0");
352
364
  transfers.push({
353
365
  amount: BigInt(partial.amount),
354
- blockNumber: parseInt(block.block_height),
355
- from: partial.from?.length < 66 ? `0x0${partial.from?.slice(2)}` : partial.from,
366
+ blockNumber: parseInt(block.block_height, 10),
367
+ from: fromAddr,
368
+ to: toAddr,
356
369
  timestamp: timestamp,
357
- to: partial.to?.length < 66 ? `0x0${partial.to?.slice(2)}` : partial.to,
358
- token: partial.tokenAddress,
359
- tokenType: "NATIVE",
360
- transactionGasFee: BigInt(tx.gas_used),
370
+ token: finalToken,
371
+ tokenType: finalTokenType,
372
+ transactionGasFee: gasUsed,
361
373
  transactionHash: tx.hash
362
374
  });
363
375
  }
@@ -650,10 +662,12 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
650
662
  {
651
663
  const typedBlock = block;
652
664
  const blockNumber = typedBlock.blockNumber;
653
- const blockHash = typedBlock.blockHash;
654
665
  const timestampExtrinsic = typedBlock.extrinsics.find((ex)=>ex.method === "timestamp.set");
655
666
  const blockTimestamp = timestampExtrinsic ? new Date(Number(timestampExtrinsic.args[0].toString().replace(/,/g, ""))).toISOString() : new Date().toISOString();
656
- for (const extrinsic of typedBlock.extrinsics)if (extrinsic.method === "balances.transferKeepAlive") {
667
+ for (const extrinsic of typedBlock.extrinsics)if ([
668
+ "balances.transfer",
669
+ "balances.transferKeepAlive"
670
+ ].includes(extrinsic.method)) {
657
671
  const from = extrinsic.signer;
658
672
  const to = extrinsic.args[0]?.Id || "";
659
673
  const amount = BigInt(extrinsic.args[1].replace(/,/g, ""));
@@ -666,7 +680,7 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
666
680
  tokenType: "NATIVE",
667
681
  timestamp: blockTimestamp,
668
682
  transactionGasFee: 0n,
669
- transactionHash: blockHash
683
+ transactionHash: extrinsic.hash
670
684
  });
671
685
  }
672
686
  break;
@@ -703,6 +717,38 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
703
717
  }
704
718
  break;
705
719
  }
720
+ case "FILECOIN":
721
+ {
722
+ const typedBlock = block;
723
+ const blockNumber = typedBlock.Height;
724
+ const blockTimestamp = new Date(typedBlock.Blocks[0].Timestamp * 1000).toISOString();
725
+ const parentBaseFee = BigInt(typedBlock.Blocks[0].ParentBaseFee);
726
+ let receiptIndex = 0;
727
+ for (const msgGroup of typedBlock.messages){
728
+ const secpkMessages = msgGroup.blockMessages.SecpkMessages || [];
729
+ for (const msg of secpkMessages){
730
+ const receipt = typedBlock.receipts[receiptIndex++];
731
+ const gasUsed = BigInt(receipt.GasUsed);
732
+ const gasFeeCap = BigInt(msg.Message.GasFeeCap);
733
+ const gasPremium = BigInt(msg.Message.GasPremium);
734
+ const baseFeeBurn = gasUsed * parentBaseFee;
735
+ const minerTip = gasUsed * (gasPremium < gasFeeCap - parentBaseFee ? gasPremium : gasFeeCap - parentBaseFee);
736
+ const transactionGasFee = baseFeeBurn + minerTip;
737
+ transfers.push({
738
+ amount: BigInt(msg.Message.Value),
739
+ blockNumber: blockNumber,
740
+ from: msg.Message.From,
741
+ to: msg.Message.To,
742
+ token: null,
743
+ tokenType: "NATIVE",
744
+ timestamp: blockTimestamp,
745
+ transactionGasFee: transactionGasFee,
746
+ transactionHash: msg.CID["/"]
747
+ });
748
+ }
749
+ }
750
+ break;
751
+ }
706
752
  // attempt to introspect data types
707
753
  default:
708
754
  // try Cosmos
@@ -710,9 +756,9 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
710
756
  const typedBlock = block;
711
757
  const blockNumber = Number(typedBlock.block.header.height);
712
758
  const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
713
- const blockHash = typedBlock.block_id.hash;
714
759
  for (const txRaw of typedBlock.block.data.txs || []){
715
760
  const decoded = (0, $8zHUo$cosmjsprotosigning.decodeTxRaw)(new Uint8Array($6144a02851f23907$require$Buffer.from(txRaw, "base64")));
761
+ const txHash = (0, $8zHUo$viem.sha256)(new Uint8Array($6144a02851f23907$require$Buffer.from(txRaw, "base64")));
716
762
  const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
717
763
  const registry = new (0, $8zHUo$cosmjsprotosigning.Registry)((0, $8zHUo$cosmjsstargate.defaultRegistryTypes));
718
764
  for (const message of decoded.body.messages)if ([
@@ -728,7 +774,7 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
728
774
  token: decodedMsg.token.denom,
729
775
  tokenType: "NATIVE",
730
776
  timestamp: blockTimestamp,
731
- transactionHash: blockHash,
777
+ transactionHash: txHash.slice(2).toUpperCase(),
732
778
  transactionGasFee: transactionGasFee
733
779
  });
734
780
  }
@@ -863,25 +909,36 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
863
909
  return transfers;
864
910
  },
865
911
  tests: [
866
- //FILECOIN
912
+ // APTOS
867
913
  {
868
914
  params: {
869
- network: "FILECOIN",
870
- walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
871
- contractAddress: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y"
915
+ network: "APTOS",
916
+ walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
917
+ contractAddress: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0"
872
918
  },
873
- payload: "https://jiti.indexing.co/networks/filecoin/4818438",
919
+ payload: "https://jiti.indexing.co/networks/aptos/297956660",
874
920
  output: [
875
921
  {
876
- amount: 7896300000000000000n,
877
- blockNumber: 4818438,
878
- from: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
879
- timestamp: "2025-03-24T23:39:00.000Z",
880
- to: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y",
922
+ amount: 1611839920n,
923
+ blockNumber: 297956660,
924
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
925
+ to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
926
+ timestamp: "2025-03-02T21:07:06.002Z",
881
927
  token: null,
882
- tokenType: "NATIVE",
883
- transactionGasFee: 1592498365133760n,
884
- transactionHash: "bafy2bzacecxud3tayyq3caagjej5srufcx5fufjuqkz3ltgfty27wdsrmqeew"
928
+ tokenType: "TOKEN",
929
+ transactionGasFee: 13n,
930
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
931
+ },
932
+ {
933
+ amount: 1502138836n,
934
+ blockNumber: 297956660,
935
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
936
+ to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
937
+ timestamp: "2025-03-02T21:07:06.002Z",
938
+ token: null,
939
+ tokenType: "TOKEN",
940
+ transactionGasFee: 13n,
941
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
885
942
  }
886
943
  ]
887
944
  },
@@ -889,21 +946,20 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
889
946
  {
890
947
  params: {
891
948
  network: "APTOS",
892
- walletAddress: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
893
- contractAddress: "0x1"
949
+ contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
894
950
  },
895
- payload: "https://jiti.indexing.co/networks/aptos/297956660",
951
+ payload: "https://jiti.indexing.co/networks/aptos/303623631",
896
952
  output: [
897
953
  {
898
- amount: 1502138836n,
899
- blockNumber: 297956660,
900
- from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
901
- timestamp: "2025-03-02T21:07:06.002Z",
902
- to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
903
- token: null,
904
- tokenType: "NATIVE",
905
- transactionGasFee: 13n,
906
- transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
954
+ amount: 1000060n,
955
+ blockNumber: 303623631,
956
+ from: "0xa4e7455d27731ab857e9701b1e6ed72591132b909fe6e4fd99b66c1d6318d9e8",
957
+ timestamp: "2025-03-14T15:39:49.845Z",
958
+ to: "0x9317336bfc9ba6987d40492ddea8d41e11b7c2e473f3556a9c82309d326e79ce",
959
+ token: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
960
+ tokenType: "TOKEN",
961
+ transactionGasFee: 16n,
962
+ transactionHash: "0x24b8854bad1f6543b35069eacd6ec40a583ca7fa452b422b04d747d24b65279c"
907
963
  }
908
964
  ]
909
965
  },
@@ -930,25 +986,69 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
930
986
  }
931
987
  ]
932
988
  },
933
- //BITTENSOR
989
+ // BITTENSOR
934
990
  {
935
991
  params: {
936
992
  network: "BITTENSOR",
937
- walletAddress: "5G4TazaYLvMd8g7sYCd7Z6GpnFM5Kw4nt5tsydkw7gu3BnLC",
993
+ walletAddress: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
938
994
  contractAddress: ""
939
995
  },
940
- payload: "https://jiti.indexing.co/networks/bittensor/5149839",
996
+ payload: "https://jiti.indexing.co/networks/bittensor/2652896",
941
997
  output: [
942
998
  {
943
- amount: 3210000000n,
944
- blockNumber: 5149839,
945
- from: "5G4TazaYLvMd8g7sYCd7Z6GpnFM5Kw4nt5tsydkw7gu3BnLC",
946
- timestamp: "2025-03-17T18:41:24.000Z",
947
- to: "5CWgT5vMteM2fUabZ7oPYHPmXi6xPHKUxd6wEWnUvFuxsdJX",
999
+ amount: 2154999850n,
1000
+ blockNumber: 2652896,
1001
+ from: "5G6WmJ4mym9oSQzUF5tr7LvsNMvH5vWtutZM8vMvRv1Wwy6J",
1002
+ to: "5CFwmfLfL1Z6vXU6hgGksh6irDFpcVXaTTNRoqDGMyHrDKK1",
948
1003
  token: null,
949
1004
  tokenType: "NATIVE",
1005
+ timestamp: "2024-03-28T12:53:36.001Z",
950
1006
  transactionGasFee: 0n,
951
- transactionHash: "0x26eb4c29a49a67033cdd6eb1ef0887faeb764836b0cf0322716e7f783248236e"
1007
+ transactionHash: "0x9ea55a8f40b8d7704f27964155476ab9c744ec2ef2b1f431ad0e05a3a6f3c1ab"
1008
+ }
1009
+ ]
1010
+ },
1011
+ // CARDANO
1012
+ {
1013
+ params: {
1014
+ network: "CARDANO",
1015
+ walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1016
+ contractAddress: ""
1017
+ },
1018
+ payload: "https://jiti.indexing.co/networks/cardano/11443286",
1019
+ output: [
1020
+ {
1021
+ amount: 1110000n,
1022
+ blockNumber: 11443286,
1023
+ from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
1024
+ timestamp: "+057068-01-19T05:23:20.000Z",
1025
+ to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1026
+ token: null,
1027
+ tokenType: "NATIVE",
1028
+ transactionGasFee: 174257n,
1029
+ transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
1030
+ }
1031
+ ]
1032
+ },
1033
+ // COSMOS
1034
+ {
1035
+ params: {
1036
+ network: "COSMOS",
1037
+ walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1038
+ contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1039
+ },
1040
+ payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1041
+ output: [
1042
+ {
1043
+ blockNumber: 24419691,
1044
+ from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1045
+ to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1046
+ amount: 500000n,
1047
+ token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1048
+ tokenType: "NATIVE",
1049
+ timestamp: "2025-02-14T21:48:22.809Z",
1050
+ transactionHash: "963D4D7BB59C1280F58A7ECA2F1934E2AA005109A989193C815C7B98EDCD7445",
1051
+ transactionGasFee: 4860n
952
1052
  }
953
1053
  ]
954
1054
  },
@@ -974,25 +1074,25 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
974
1074
  }
975
1075
  ]
976
1076
  },
977
- // CARDANO
1077
+ // FILECOIN
978
1078
  {
979
1079
  params: {
980
- network: "CARDANO",
981
- walletAddress: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
982
- contractAddress: ""
1080
+ network: "FILECOIN",
1081
+ walletAddress: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
1082
+ contractAddress: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y"
983
1083
  },
984
- payload: "https://jiti.indexing.co/networks/cardano/11443286",
1084
+ payload: "https://jiti.indexing.co/networks/filecoin/4818438",
985
1085
  output: [
986
1086
  {
987
- amount: 1110000n,
988
- blockNumber: 11443286,
989
- from: "addr1qymdv285few5tyqvya86rl97r9e608njs37shfew6l2nn473aw2pcnrcvfwfgg2dnew99m4tjj0apsu7232w2euzwpysndh0h3",
990
- timestamp: "+057068-01-19T05:23:20.000Z",
991
- to: "addr1q9syxu908lef7r6rsvk0h7gsx3rxj22cuykgx2a2l4hcfd8e9y2e9vtv4w9dyej96w99wwj8hwgc273862lk6a3vt30qjjrund",
1087
+ amount: 7896300000000000000n,
1088
+ blockNumber: 4818438,
1089
+ from: "f1e3aa3z6gkaqxxwmbbna5gf2frggswwjaeavx7bq",
1090
+ timestamp: "2025-03-24T23:39:00.000Z",
1091
+ to: "f1bqdligg7ipuiizvmdn7ijobhbkwaieh6z6lah5y",
992
1092
  token: null,
993
1093
  tokenType: "NATIVE",
994
- transactionGasFee: 174257n,
995
- transactionHash: "261c42ba9124f55d8e169ebb692cd3759d796a54369acb316ee449b546e79309"
1094
+ transactionGasFee: 1592498365133760n,
1095
+ transactionHash: "bafy2bzacecxud3tayyq3caagjej5srufcx5fufjuqkz3ltgfty27wdsrmqeew"
996
1096
  }
997
1097
  ]
998
1098
  },
@@ -1062,7 +1162,7 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
1062
1162
  }
1063
1163
  ]
1064
1164
  },
1065
- //SUI
1165
+ // SUI
1066
1166
  {
1067
1167
  params: {
1068
1168
  network: "SUI",
@@ -1106,28 +1206,6 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
1106
1206
  }
1107
1207
  ]
1108
1208
  },
1109
- // COSMOS
1110
- {
1111
- params: {
1112
- network: "COSMOS",
1113
- walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1114
- contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1115
- },
1116
- payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1117
- output: [
1118
- {
1119
- blockNumber: 24419691,
1120
- from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1121
- to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1122
- amount: 500000n,
1123
- token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1124
- tokenType: "NATIVE",
1125
- timestamp: "2025-02-14T21:48:22.809Z",
1126
- transactionHash: "DF5FB086E60EE2ADA3A842751337E06A40696D7983CC1C038ADE236B36ED8AEB",
1127
- transactionGasFee: 4860n
1128
- }
1129
- ]
1130
- },
1131
1209
  // SOLANA
1132
1210
  {
1133
1211
  params: {