@indexing/jiti 0.0.27 → 0.0.29

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
  }
@@ -586,22 +598,44 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
586
598
  break;
587
599
  case "SUI":
588
600
  {
589
- const blockNumber = block.sequence;
590
- const blockTimestamp = new Date(block.timestamp).toISOString();
591
- for (const tx of block.transactions || []){
601
+ const blockNumber = parseInt(block.sequence, 10);
602
+ const blockTimestamp = new Date(parseInt(block.timestamp, 10)).toISOString();
603
+ const transactions = block.transactions || [];
604
+ for (const tx of transactions){
592
605
  const transactionHash = tx.digest;
593
- const transactionGasFee = BigInt(tx.gasFee || "0");
594
- for (const bc of tx.balanceChanges || [])transfers.push({
595
- blockNumber: blockNumber,
596
- from: tx.sender ? tx.sender : undefined,
597
- to: tx.receiver ? tx.receiver : undefined,
598
- amount: BigInt(bc.amount),
599
- token: bc.coinRepr,
600
- tokenType: "NATIVE",
601
- timestamp: blockTimestamp,
602
- transactionHash: transactionHash,
603
- transactionGasFee: transactionGasFee
604
- });
606
+ let transactionGasFee = BigInt(0);
607
+ if (tx.effects?.gasUsed) {
608
+ const gu = tx.effects.gasUsed;
609
+ transactionGasFee = BigInt(gu.computationCost) + BigInt(gu.storageCost) - BigInt(gu.storageRebate) + BigInt(gu.nonRefundableStorageFee);
610
+ if (transactionGasFee < 0n) transactionGasFee = 0n;
611
+ }
612
+ const balanceChanges = tx.balanceChanges || [];
613
+ for (const bc of balanceChanges){
614
+ let rawAmt = BigInt(bc.amount);
615
+ if (rawAmt === 0n) continue;
616
+ let fromAddr;
617
+ let toAddr;
618
+ const rawOwner = bc.owner?.AddressOwner || bc.owner?.ObjectOwner || bc.owner?.Shared?.initial_shared_version || "UNKNOWN_OWNER";
619
+ if (rawAmt < 0n) {
620
+ fromAddr = String(rawOwner);
621
+ toAddr = undefined;
622
+ rawAmt = -rawAmt;
623
+ } else {
624
+ fromAddr = undefined;
625
+ toAddr = String(rawOwner);
626
+ }
627
+ transfers.push({
628
+ blockNumber: blockNumber,
629
+ from: fromAddr,
630
+ to: toAddr,
631
+ amount: rawAmt,
632
+ token: bc.coinType,
633
+ tokenType: "NATIVE",
634
+ timestamp: blockTimestamp,
635
+ transactionHash: transactionHash,
636
+ transactionGasFee: transactionGasFee
637
+ });
638
+ }
605
639
  }
606
640
  break;
607
641
  }
@@ -712,9 +746,9 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
712
746
  const typedBlock = block;
713
747
  const blockNumber = Number(typedBlock.block.header.height);
714
748
  const blockTimestamp = new Date(typedBlock.block.header.time).toISOString();
715
- const blockHash = typedBlock.block_id.hash;
716
749
  for (const txRaw of typedBlock.block.data.txs || []){
717
750
  const decoded = (0, $8zHUo$cosmjsprotosigning.decodeTxRaw)(new Uint8Array($6144a02851f23907$require$Buffer.from(txRaw, "base64")));
751
+ const txHash = (0, $8zHUo$viem.sha256)(new Uint8Array($6144a02851f23907$require$Buffer.from(txRaw, "base64")));
718
752
  const transactionGasFee = BigInt(decoded.authInfo.fee?.amount?.[0]?.amount || "0");
719
753
  const registry = new (0, $8zHUo$cosmjsprotosigning.Registry)((0, $8zHUo$cosmjsstargate.defaultRegistryTypes));
720
754
  for (const message of decoded.body.messages)if ([
@@ -730,7 +764,7 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
730
764
  token: decodedMsg.token.denom,
731
765
  tokenType: "NATIVE",
732
766
  timestamp: blockTimestamp,
733
- transactionHash: blockHash,
767
+ transactionHash: txHash.slice(2).toUpperCase(),
734
768
  transactionGasFee: transactionGasFee
735
769
  });
736
770
  }
@@ -869,24 +903,56 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
869
903
  {
870
904
  params: {
871
905
  network: "APTOS",
872
- walletAddress: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
873
- contractAddress: "0x1"
906
+ walletAddress: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
907
+ contractAddress: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0"
874
908
  },
875
909
  payload: "https://jiti.indexing.co/networks/aptos/297956660",
876
910
  output: [
877
911
  {
878
- amount: 1502138836n,
912
+ amount: 1611839920n,
879
913
  blockNumber: 297956660,
880
914
  from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
915
+ to: "0x3b5d2e7e8da86903beb19d5a7135764aac812e18af193895d75f3a8f6a066cb0",
881
916
  timestamp: "2025-03-02T21:07:06.002Z",
917
+ token: null,
918
+ tokenType: "TOKEN",
919
+ transactionGasFee: 13n,
920
+ transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
921
+ },
922
+ {
923
+ amount: 1502138836n,
924
+ blockNumber: 297956660,
925
+ from: "0x5bd7de5c56d5691f32ea86c973c73fec7b1445e59736c97158020018c080bb00",
882
926
  to: "0x04b2b6bc8c2c5794c51607c962f482593f9b5ea09373a8ce249a1f799cca7a1e",
927
+ timestamp: "2025-03-02T21:07:06.002Z",
883
928
  token: null,
884
- tokenType: "NATIVE",
929
+ tokenType: "TOKEN",
885
930
  transactionGasFee: 13n,
886
931
  transactionHash: "0xfbdef795d11df124cca264f3370b09fb04fb1c1d24a2d2e1df0693c096a76d13"
887
932
  }
888
933
  ]
889
934
  },
935
+ // APTOS
936
+ {
937
+ params: {
938
+ network: "APTOS",
939
+ contractAddress: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
940
+ },
941
+ payload: "https://jiti.indexing.co/networks/aptos/303623631",
942
+ output: [
943
+ {
944
+ amount: 1000060n,
945
+ blockNumber: 303623631,
946
+ from: "0xa4e7455d27731ab857e9701b1e6ed72591132b909fe6e4fd99b66c1d6318d9e8",
947
+ timestamp: "2025-03-14T15:39:49.845Z",
948
+ to: "0x9317336bfc9ba6987d40492ddea8d41e11b7c2e473f3556a9c82309d326e79ce",
949
+ token: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
950
+ tokenType: "TOKEN",
951
+ transactionGasFee: 16n,
952
+ transactionHash: "0x24b8854bad1f6543b35069eacd6ec40a583ca7fa452b422b04d747d24b65279c"
953
+ }
954
+ ]
955
+ },
890
956
  // BASE
891
957
  {
892
958
  params: {
@@ -954,6 +1020,28 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
954
1020
  }
955
1021
  ]
956
1022
  },
1023
+ // COSMOS
1024
+ {
1025
+ params: {
1026
+ network: "COSMOS",
1027
+ walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1028
+ contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1029
+ },
1030
+ payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1031
+ output: [
1032
+ {
1033
+ blockNumber: 24419691,
1034
+ from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1035
+ to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1036
+ amount: 500000n,
1037
+ token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1038
+ tokenType: "NATIVE",
1039
+ timestamp: "2025-02-14T21:48:22.809Z",
1040
+ transactionHash: "963D4D7BB59C1280F58A7ECA2F1934E2AA005109A989193C815C7B98EDCD7445",
1041
+ transactionGasFee: 4860n
1042
+ }
1043
+ ]
1044
+ },
957
1045
  // DOGECOIN
958
1046
  {
959
1047
  params: {
@@ -976,7 +1064,7 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
976
1064
  }
977
1065
  ]
978
1066
  },
979
- //FILECOIN
1067
+ // FILECOIN
980
1068
  {
981
1069
  params: {
982
1070
  network: "FILECOIN",
@@ -1064,25 +1152,58 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
1064
1152
  }
1065
1153
  ]
1066
1154
  },
1067
- //SUI
1155
+ // SUI
1068
1156
  {
1069
1157
  params: {
1070
1158
  network: "SUI",
1071
- walletAddress: "0xfd0fb434d076e4cca300cf6534a5235b19ad184eedf49066726664ded42c6b5e",
1159
+ walletAddress: "0x39b9e5942df9a4686ebe727534077281d6adcee15a9bb74d3e052e56d78b2744",
1072
1160
  contractAddress: ""
1073
1161
  },
1074
- payload: "https://jiti.indexing.co/networks/sui/112336044",
1162
+ payload: "https://jiti.indexing.co/networks/sui/132734364",
1075
1163
  output: [
1076
1164
  {
1077
- blockNumber: 112336044,
1078
- from: "0xfd0fb434d076e4cca300cf6534a5235b19ad184eedf49066726664ded42c6b5e",
1165
+ blockNumber: 132734364,
1166
+ from: "0x39b9e5942df9a4686ebe727534077281d6adcee15a9bb74d3e052e56d78b2744",
1167
+ to: undefined,
1168
+ amount: 5321172n,
1169
+ token: "0x2::sui::SUI",
1170
+ tokenType: "NATIVE",
1171
+ timestamp: "2025-04-11T14:57:40.091Z",
1172
+ transactionHash: "4JWC8DX8eKYhwvRgzesGNWsb5t5RUyQVSNibKxLRaN22",
1173
+ transactionGasFee: 5408344n
1174
+ },
1175
+ {
1176
+ blockNumber: 132734364,
1177
+ from: "0x39b9e5942df9a4686ebe727534077281d6adcee15a9bb74d3e052e56d78b2744",
1178
+ to: undefined,
1179
+ amount: 825772n,
1180
+ token: "0x2::sui::SUI",
1181
+ tokenType: "NATIVE",
1182
+ timestamp: "2025-04-11T14:57:40.091Z",
1183
+ transactionHash: "5bXBDeoYqXTawkf2bCDriAE2M6Vu2EgYKEgJ1hW4qagZ",
1184
+ transactionGasFee: 901544n
1185
+ },
1186
+ {
1187
+ blockNumber: 132734364,
1188
+ from: "0x39b9e5942df9a4686ebe727534077281d6adcee15a9bb74d3e052e56d78b2744",
1079
1189
  to: undefined,
1080
- amount: 180772n,
1081
- token: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
1190
+ amount: 5321248n,
1191
+ token: "0x2::sui::SUI",
1082
1192
  tokenType: "NATIVE",
1083
- timestamp: "2025-02-13T23:10:54.529Z",
1084
- transactionHash: "336V3wP8cHDAnB1Aku3j6n9948i8FG5N1eVP6Ac68BaE",
1085
- transactionGasFee: -4165572n
1193
+ timestamp: "2025-04-11T14:57:40.091Z",
1194
+ transactionHash: "6KZYwvaAk76AL9p5kjkA27Tj5Jy47ipCxLKiCXtBbngo",
1195
+ transactionGasFee: 5408496n
1196
+ },
1197
+ {
1198
+ blockNumber: 132734364,
1199
+ from: "0x39b9e5942df9a4686ebe727534077281d6adcee15a9bb74d3e052e56d78b2744",
1200
+ to: undefined,
1201
+ amount: 5321096n,
1202
+ token: "0x2::sui::SUI",
1203
+ tokenType: "NATIVE",
1204
+ timestamp: "2025-04-11T14:57:40.091Z",
1205
+ transactionHash: "HcJAHtSUypt8z2us2HqDm7PzB5HKS3ASY86pDKNAsgnE",
1206
+ transactionGasFee: 5408192n
1086
1207
  }
1087
1208
  ]
1088
1209
  },
@@ -1108,28 +1229,6 @@ const $6144a02851f23907$var$tokenTransfersTemplate = {
1108
1229
  }
1109
1230
  ]
1110
1231
  },
1111
- // COSMOS
1112
- {
1113
- params: {
1114
- network: "COSMOS",
1115
- walletAddress: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1116
- contractAddress: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013"
1117
- },
1118
- payload: "https://jiti.indexing.co/networks/cosmos/24419691",
1119
- output: [
1120
- {
1121
- blockNumber: 24419691,
1122
- from: "cosmos1x4qvmtcfc02pklttfgxzdccxcsyzklrxavteyz",
1123
- to: "noble1x4qvmtcfc02pklttfgxzdccxcsyzklrx4073uv",
1124
- amount: 500000n,
1125
- token: "ibc/F663521BF1836B00F5F177680F74BFB9A8B5654A694D0D2BC249E03CF2509013",
1126
- tokenType: "NATIVE",
1127
- timestamp: "2025-02-14T21:48:22.809Z",
1128
- transactionHash: "DF5FB086E60EE2ADA3A842751337E06A40696D7983CC1C038ADE236B36ED8AEB",
1129
- transactionGasFee: 4860n
1130
- }
1131
- ]
1132
- },
1133
1232
  // SOLANA
1134
1233
  {
1135
1234
  params: {