@indexing/jiti 0.0.36 → 0.0.38

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
@@ -960,23 +960,25 @@ const $f9f6601c9222cc8e$export$722698bc663d0ac0 = {
960
960
  };
961
961
 
962
962
 
963
- const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
963
+ const $64e1e522540ffc4e$export$a51565c56ceacb0a = {
964
964
  match: (block)=>[
965
- "SOLANA"
965
+ "SOLANA",
966
+ "SOLANA_DEVNET",
967
+ "ECLIPSE"
966
968
  ].includes(block._network),
967
969
  transform (block) {
968
970
  let transfers = [];
969
971
  for (const tx of block.transactions){
970
- const solanaTx = tx;
971
- const txHash = solanaTx.transaction.signatures[0];
972
+ const svmTx = tx;
973
+ const txHash = svmTx.transaction.signatures[0];
972
974
  const timestamp = block.blockTime ? new Date(block.blockTime * 1000).toISOString() : null;
973
- const allAccounts = solanaTx.transaction.message.accountKeys.concat(solanaTx.meta.loadedAddresses.writable).concat(solanaTx.meta.loadedAddresses.readonly);
974
- let txFee = BigInt(solanaTx.meta.fee);
975
+ const allAccounts = svmTx.transaction.message.accountKeys.concat(svmTx.meta.loadedAddresses.writable).concat(svmTx.meta.loadedAddresses.readonly);
976
+ let txFee = BigInt(svmTx.meta.fee);
975
977
  if (txFee < BigInt(10)) txFee = txFee * BigInt(Math.pow(10, 9));
976
978
  const transfersByKey = {};
977
- for (const post of solanaTx.meta.postTokenBalances){
979
+ for (const post of svmTx.meta.postTokenBalances){
978
980
  let matched = false;
979
- for (const pre of solanaTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
981
+ for (const pre of svmTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
980
982
  let diff = BigInt(post.uiTokenAmount.amount) - BigInt(pre.uiTokenAmount.amount);
981
983
  if (diff === BigInt(0)) {
982
984
  matched = true;
@@ -998,7 +1000,18 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
998
1000
  };
999
1001
  if (isNegDiff) delete txfer.to;
1000
1002
  else delete txfer.from;
1001
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1003
+ if (!transfersByKey[key]) transfersByKey[key] = [
1004
+ txfer
1005
+ ];
1006
+ else {
1007
+ let didMerge = false;
1008
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1009
+ didMerge = true;
1010
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1011
+ break;
1012
+ }
1013
+ if (!didMerge) transfersByKey[key].push(txfer);
1014
+ }
1002
1015
  matched = true;
1003
1016
  }
1004
1017
  if (!matched) {
@@ -1019,12 +1032,23 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
1019
1032
  };
1020
1033
  if (isNegDiff) delete txfer.to;
1021
1034
  else delete txfer.from;
1022
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1035
+ if (!transfersByKey[key]) transfersByKey[key] = [
1036
+ txfer
1037
+ ];
1038
+ else {
1039
+ let didMerge = false;
1040
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1041
+ didMerge = true;
1042
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1043
+ break;
1044
+ }
1045
+ if (!didMerge) transfersByKey[key].push(txfer);
1046
+ }
1023
1047
  }
1024
1048
  }
1025
- for(let i = 0; i < solanaTx.meta.postBalances.length; i += 1){
1026
- const post = solanaTx.meta.postBalances[i];
1027
- const pre = solanaTx.meta.preBalances[i];
1049
+ for(let i = 0; i < svmTx.meta.postBalances.length; i += 1){
1050
+ const post = svmTx.meta.postBalances[i];
1051
+ const pre = svmTx.meta.preBalances[i];
1028
1052
  if (post !== undefined && pre !== undefined && post !== pre) {
1029
1053
  let diff = BigInt(post) - BigInt(pre);
1030
1054
  if (diff < 0) diff = -diff;
@@ -1042,13 +1066,23 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
1042
1066
  };
1043
1067
  if (post > pre) delete txfer.from;
1044
1068
  else delete txfer.to;
1045
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1069
+ if (!transfersByKey[key]) transfersByKey[key] = [
1070
+ txfer
1071
+ ];
1072
+ else {
1073
+ let didMerge = false;
1074
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1075
+ didMerge = true;
1076
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1077
+ break;
1078
+ }
1079
+ if (!didMerge) transfersByKey[key].push(txfer);
1080
+ }
1046
1081
  }
1047
1082
  }
1048
1083
  const unmatchedFrom = {};
1049
1084
  const unmatchedTo = {};
1050
- for(const key in transfersByKey){
1051
- const txfer = transfersByKey[key];
1085
+ for(const key in transfersByKey)for (const txfer of transfersByKey[key]){
1052
1086
  if (!txfer.from) {
1053
1087
  if (!unmatchedFrom[txfer.token]) unmatchedFrom[txfer.token] = [];
1054
1088
  unmatchedFrom[txfer.token].push(txfer);
@@ -1057,7 +1091,7 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
1057
1091
  if (!unmatchedTo[txfer.token]) unmatchedTo[txfer.token] = [];
1058
1092
  unmatchedTo[txfer.token].push(txfer);
1059
1093
  delete transfersByKey[key];
1060
- }
1094
+ } else transfers.push(txfer);
1061
1095
  }
1062
1096
  for(const token in unmatchedFrom)if (unmatchedTo[token]?.length && unmatchedFrom[token]?.length) {
1063
1097
  const unmatchedDiff = unmatchedTo[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0)) - unmatchedFrom[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0));
@@ -1065,15 +1099,68 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
1065
1099
  unmatchedTo[token].sort((a, b)=>a.amount > b.amount ? 1 : -1);
1066
1100
  unmatchedFrom[token].forEach((um)=>{
1067
1101
  um.from = unmatchedTo[token][0].from;
1068
- transfersByKey[`${token}-${um.amount.toString()}`] = um;
1102
+ transfers.push(um);
1069
1103
  });
1070
1104
  }
1071
1105
  }
1072
- transfers.push(...Object.values(transfersByKey));
1073
1106
  }
1074
1107
  return transfers;
1075
1108
  },
1076
1109
  tests: [
1110
+ {
1111
+ params: {
1112
+ network: "SOLANA",
1113
+ walletAddress: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1114
+ contractAddress: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump"
1115
+ },
1116
+ payload: "https://jiti.indexing.co/networks/solana/345871978",
1117
+ output: [
1118
+ {
1119
+ amount: 10492578617n,
1120
+ blockNumber: 324081557,
1121
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1122
+ timestamp: "2025-06-10T12:06:56.000Z",
1123
+ to: "ChkRerg6X89xHYqV4iBqcboBdU1WA8Uvs9fp2yZrqbg",
1124
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1125
+ tokenType: "TOKEN",
1126
+ transactionGasFee: 2506024n,
1127
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1128
+ },
1129
+ {
1130
+ amount: 10492578617n,
1131
+ blockNumber: 324081557,
1132
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1133
+ timestamp: "2025-06-10T12:06:56.000Z",
1134
+ to: "3shatpFgdVVwy8Pr723iE9L1fozzaXNdGYKtgrSwHYeJ",
1135
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1136
+ tokenType: "TOKEN",
1137
+ transactionGasFee: 2506024n,
1138
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1139
+ },
1140
+ {
1141
+ amount: 16788125787n,
1142
+ blockNumber: 324081557,
1143
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1144
+ timestamp: "2025-06-10T12:06:56.000Z",
1145
+ to: "GWPLjamb5ZxrGbTsYNWW7V3p1pAMryZSfaPFTdaEsWgC",
1146
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1147
+ tokenType: "TOKEN",
1148
+ transactionGasFee: 2506024n,
1149
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1150
+ },
1151
+ {
1152
+ amount: 4197031447n,
1153
+ blockNumber: 324081557,
1154
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1155
+ timestamp: "2025-06-10T12:06:56.000Z",
1156
+ to: "ANcfLC9JcbYbEWu71fE8973V8S6vD5hS98RNrz56hrT7",
1157
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1158
+ tokenType: "TOKEN",
1159
+ transactionGasFee: 2506024n,
1160
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1161
+ }
1162
+ ]
1163
+ },
1077
1164
  {
1078
1165
  params: {
1079
1166
  network: "SOLANA",
@@ -1284,7 +1371,7 @@ const $f0bdc73ab4ea9846$export$1f0fe79deb1b813b = {
1284
1371
  }
1285
1372
  ]
1286
1373
  }
1287
- ].slice(0)
1374
+ ]
1288
1375
  };
1289
1376
 
1290
1377
 
@@ -1585,7 +1672,7 @@ const $0ab1acc1eff391f6$var$SUB_TEMPLATES = [
1585
1672
  (0, $8860a67278817de8$export$893111d8d332e195),
1586
1673
  (0, $548ae36ea3681b01$export$d7ac970e8e789607),
1587
1674
  (0, $07b3982e2fc4c8b2$export$400f08bfae9ee97f),
1588
- (0, $f0bdc73ab4ea9846$export$1f0fe79deb1b813b),
1675
+ (0, $64e1e522540ffc4e$export$a51565c56ceacb0a),
1589
1676
  (0, $f7da547a9d6b4fc0$export$36783fc9701281c6),
1590
1677
  (0, $725699ccb951d76d$export$681f497010b17679),
1591
1678
  (0, $13c3ff41f568666f$export$bc6c7ab7e0727dd7),