@indexing/jiti 0.0.27 → 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
  }
@@ -699,6 +711,38 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
699
711
  }
700
712
  break;
701
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
+ }
702
746
  // attempt to introspect data types
703
747
  default:
704
748
  // try Cosmos
@@ -706,9 +750,9 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
706
750
  const typedBlock = block;
707
751
  const blockNumber = Number(typedBlock.block.header.height);
708
752
  const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
709
- const blockHash = typedBlock.block_id.hash;
710
753
  for (const txRaw of typedBlock.block.data.txs || []){
711
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")));
712
756
  const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
713
757
  const registry = new (0, $hgUW1$Registry)((0, $hgUW1$defaultRegistryTypes));
714
758
  for (const message of decoded.body.messages)if ([
@@ -724,7 +768,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
724
768
  token: decodedMsg.token.denom,
725
769
  tokenType: "NATIVE",
726
770
  timestamp: blockTimestamp,
727
- transactionHash: blockHash,
771
+ transactionHash: txHash.slice(2).toUpperCase(),
728
772
  transactionGasFee: transactionGasFee
729
773
  });
730
774
  }
@@ -863,24 +907,56 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
863
907
  {
864
908
  params: {
865
909
  network: "APTOS",
866
- walletAddress: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
867
- contractAddress: "0x1"
910
+ walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
911
+ contractAddress: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0"
868
912
  },
869
913
  payload: "https://jiti.indexing.co/networks/aptos/297956660",
870
914
  output: [
871
915
  {
872
- amount: 1502138836n,
916
+ amount: 1611839920n,
873
917
  blockNumber: 297956660,
874
918
  from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
919
+ to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
875
920
  timestamp: "2025-03-02T21:07:06.002Z",
921
+ token: null,
922
+ tokenType: "TOKEN",
923
+ transactionGasFee: 13n,
924
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
925
+ },
926
+ {
927
+ amount: 1502138836n,
928
+ blockNumber: 297956660,
929
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
876
930
  to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
931
+ timestamp: "2025-03-02T21:07:06.002Z",
877
932
  token: null,
878
- tokenType: "NATIVE",
933
+ tokenType: "TOKEN",
879
934
  transactionGasFee: 13n,
880
935
  transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
881
936
  }
882
937
  ]
883
938
  },
939
+ // APTOS
940
+ {
941
+ params: {
942
+ network: "APTOS",
943
+ contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
944
+ },
945
+ payload: "https://jiti.indexing.co/networks/aptos/303623631",
946
+ output: [
947
+ {
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"
957
+ }
958
+ ]
959
+ },
884
960
  // BASE
885
961
  {
886
962
  params: {
@@ -948,6 +1024,28 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
948
1024
  }
949
1025
  ]
950
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
1046
+ }
1047
+ ]
1048
+ },
951
1049
  // DOGECOIN
952
1050
  {
953
1051
  params: {
@@ -970,7 +1068,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
970
1068
  }
971
1069
  ]
972
1070
  },
973
- //FILECOIN
1071
+ // FILECOIN
974
1072
  {
975
1073
  params: {
976
1074
  network: "FILECOIN",
@@ -1058,7 +1156,7 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1058
1156
  }
1059
1157
  ]
1060
1158
  },
1061
- //SUI
1159
+ // SUI
1062
1160
  {
1063
1161
  params: {
1064
1162
  network: "SUI",
@@ -1102,28 +1200,6 @@ const $c18434deda90759d$var$tokenTransfersTemplate = {
1102
1200
  }
1103
1201
  ]
1104
1202
  },
1105
- // COSMOS
1106
- {
1107
- params: {
1108
- network: "COSMOS",
1109
- walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1110
- contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1111
- },
1112
- payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1113
- output: [
1114
- {
1115
- blockNumber: 24419691,
1116
- from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1117
- to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1118
- amount: 500000n,
1119
- token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1120
- tokenType: "NATIVE",
1121
- timestamp: "2025-02-14T21:48:22.809Z",
1122
- transactionHash: "DF5FB086E60EE2ADA3A842751337E06A40696D7983CC1C038ADE236B36ED8AEB",
1123
- transactionGasFee: 4860n
1124
- }
1125
- ]
1126
- },
1127
1203
  // SOLANA
1128
1204
  {
1129
1205
  params: {