@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/main.js CHANGED
@@ -966,23 +966,25 @@ const $3b9b8f5747dcca8e$export$722698bc663d0ac0 = {
966
966
  };
967
967
 
968
968
 
969
- const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
969
+ const $fc7ca671efecc378$export$a51565c56ceacb0a = {
970
970
  match: (block)=>[
971
- "SOLANA"
971
+ "SOLANA",
972
+ "SOLANA_DEVNET",
973
+ "ECLIPSE"
972
974
  ].includes(block._network),
973
975
  transform (block) {
974
976
  let transfers = [];
975
977
  for (const tx of block.transactions){
976
- const solanaTx = tx;
977
- const txHash = solanaTx.transaction.signatures[0];
978
+ const svmTx = tx;
979
+ const txHash = svmTx.transaction.signatures[0];
978
980
  const timestamp = block.blockTime ? new Date(block.blockTime * 1000).toISOString() : null;
979
- const allAccounts = solanaTx.transaction.message.accountKeys.concat(solanaTx.meta.loadedAddresses.writable).concat(solanaTx.meta.loadedAddresses.readonly);
980
- let txFee = BigInt(solanaTx.meta.fee);
981
+ const allAccounts = svmTx.transaction.message.accountKeys.concat(svmTx.meta.loadedAddresses.writable).concat(svmTx.meta.loadedAddresses.readonly);
982
+ let txFee = BigInt(svmTx.meta.fee);
981
983
  if (txFee < BigInt(10)) txFee = txFee * BigInt(Math.pow(10, 9));
982
984
  const transfersByKey = {};
983
- for (const post of solanaTx.meta.postTokenBalances){
985
+ for (const post of svmTx.meta.postTokenBalances){
984
986
  let matched = false;
985
- for (const pre of solanaTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
987
+ for (const pre of svmTx.meta.preTokenBalances)if (post.mint === pre.mint && post.owner === pre.owner) {
986
988
  let diff = BigInt(post.uiTokenAmount.amount) - BigInt(pre.uiTokenAmount.amount);
987
989
  if (diff === BigInt(0)) {
988
990
  matched = true;
@@ -1004,7 +1006,18 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1004
1006
  };
1005
1007
  if (isNegDiff) delete txfer.to;
1006
1008
  else delete txfer.from;
1007
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1009
+ if (!transfersByKey[key]) transfersByKey[key] = [
1010
+ txfer
1011
+ ];
1012
+ else {
1013
+ let didMerge = false;
1014
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1015
+ didMerge = true;
1016
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1017
+ break;
1018
+ }
1019
+ if (!didMerge) transfersByKey[key].push(txfer);
1020
+ }
1008
1021
  matched = true;
1009
1022
  }
1010
1023
  if (!matched) {
@@ -1025,12 +1038,23 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1025
1038
  };
1026
1039
  if (isNegDiff) delete txfer.to;
1027
1040
  else delete txfer.from;
1028
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1041
+ if (!transfersByKey[key]) transfersByKey[key] = [
1042
+ txfer
1043
+ ];
1044
+ else {
1045
+ let didMerge = false;
1046
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1047
+ didMerge = true;
1048
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1049
+ break;
1050
+ }
1051
+ if (!didMerge) transfersByKey[key].push(txfer);
1052
+ }
1029
1053
  }
1030
1054
  }
1031
- for(let i = 0; i < solanaTx.meta.postBalances.length; i += 1){
1032
- const post = solanaTx.meta.postBalances[i];
1033
- const pre = solanaTx.meta.preBalances[i];
1055
+ for(let i = 0; i < svmTx.meta.postBalances.length; i += 1){
1056
+ const post = svmTx.meta.postBalances[i];
1057
+ const pre = svmTx.meta.preBalances[i];
1034
1058
  if (post !== undefined && pre !== undefined && post !== pre) {
1035
1059
  let diff = BigInt(post) - BigInt(pre);
1036
1060
  if (diff < 0) diff = -diff;
@@ -1048,13 +1072,23 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1048
1072
  };
1049
1073
  if (post > pre) delete txfer.from;
1050
1074
  else delete txfer.to;
1051
- transfersByKey[key] = Object.assign(transfersByKey[key] || {}, txfer);
1075
+ if (!transfersByKey[key]) transfersByKey[key] = [
1076
+ txfer
1077
+ ];
1078
+ else {
1079
+ let didMerge = false;
1080
+ for(let tbi = 0; tbi < transfersByKey[key].length; tbi += 1)if (txfer.to && !transfersByKey[key][tbi].to || txfer.from && !transfersByKey[key][tbi].from) {
1081
+ didMerge = true;
1082
+ transfersByKey[key][tbi] = Object.assign(transfersByKey[key][tbi] || {}, txfer);
1083
+ break;
1084
+ }
1085
+ if (!didMerge) transfersByKey[key].push(txfer);
1086
+ }
1052
1087
  }
1053
1088
  }
1054
1089
  const unmatchedFrom = {};
1055
1090
  const unmatchedTo = {};
1056
- for(const key in transfersByKey){
1057
- const txfer = transfersByKey[key];
1091
+ for(const key in transfersByKey)for (const txfer of transfersByKey[key]){
1058
1092
  if (!txfer.from) {
1059
1093
  if (!unmatchedFrom[txfer.token]) unmatchedFrom[txfer.token] = [];
1060
1094
  unmatchedFrom[txfer.token].push(txfer);
@@ -1063,7 +1097,7 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1063
1097
  if (!unmatchedTo[txfer.token]) unmatchedTo[txfer.token] = [];
1064
1098
  unmatchedTo[txfer.token].push(txfer);
1065
1099
  delete transfersByKey[key];
1066
- }
1100
+ } else transfers.push(txfer);
1067
1101
  }
1068
1102
  for(const token in unmatchedFrom)if (unmatchedTo[token]?.length && unmatchedFrom[token]?.length) {
1069
1103
  const unmatchedDiff = unmatchedTo[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0)) - unmatchedFrom[token].reduce((a, b)=>a + BigInt(b.amount), BigInt(0));
@@ -1071,15 +1105,68 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1071
1105
  unmatchedTo[token].sort((a, b)=>a.amount > b.amount ? 1 : -1);
1072
1106
  unmatchedFrom[token].forEach((um)=>{
1073
1107
  um.from = unmatchedTo[token][0].from;
1074
- transfersByKey[`${token}-${um.amount.toString()}`] = um;
1108
+ transfers.push(um);
1075
1109
  });
1076
1110
  }
1077
1111
  }
1078
- transfers.push(...Object.values(transfersByKey));
1079
1112
  }
1080
1113
  return transfers;
1081
1114
  },
1082
1115
  tests: [
1116
+ {
1117
+ params: {
1118
+ network: "SOLANA",
1119
+ walletAddress: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1120
+ contractAddress: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump"
1121
+ },
1122
+ payload: "https://jiti.indexing.co/networks/solana/345871978",
1123
+ output: [
1124
+ {
1125
+ amount: 10492578617n,
1126
+ blockNumber: 324081557,
1127
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1128
+ timestamp: "2025-06-10T12:06:56.000Z",
1129
+ to: "ChkRerg6X89xHYqV4iBqcboBdU1WA8Uvs9fp2yZrqbg",
1130
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1131
+ tokenType: "TOKEN",
1132
+ transactionGasFee: 2506024n,
1133
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1134
+ },
1135
+ {
1136
+ amount: 10492578617n,
1137
+ blockNumber: 324081557,
1138
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1139
+ timestamp: "2025-06-10T12:06:56.000Z",
1140
+ to: "3shatpFgdVVwy8Pr723iE9L1fozzaXNdGYKtgrSwHYeJ",
1141
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1142
+ tokenType: "TOKEN",
1143
+ transactionGasFee: 2506024n,
1144
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1145
+ },
1146
+ {
1147
+ amount: 16788125787n,
1148
+ blockNumber: 324081557,
1149
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1150
+ timestamp: "2025-06-10T12:06:56.000Z",
1151
+ to: "GWPLjamb5ZxrGbTsYNWW7V3p1pAMryZSfaPFTdaEsWgC",
1152
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1153
+ tokenType: "TOKEN",
1154
+ transactionGasFee: 2506024n,
1155
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1156
+ },
1157
+ {
1158
+ amount: 4197031447n,
1159
+ blockNumber: 324081557,
1160
+ from: "DgC9bBDvJYeVyTqcp8nW5F5USNvxBiZ9NMoTUVy5UVPz",
1161
+ timestamp: "2025-06-10T12:06:56.000Z",
1162
+ to: "ANcfLC9JcbYbEWu71fE8973V8S6vD5hS98RNrz56hrT7",
1163
+ token: "6MQpbiTC2YcogidTmKqMLK82qvE9z5QEm7EP3AEDpump",
1164
+ tokenType: "TOKEN",
1165
+ transactionGasFee: 2506024n,
1166
+ transactionHash: "65sABMeYatoyzsp1mL6UjAXoBqUdw47HR33ouvR9BFNipTNydqvWTt8PMbVqZZfvnX3TzwB3XSdk55cy3N6u8okR"
1167
+ }
1168
+ ]
1169
+ },
1083
1170
  {
1084
1171
  params: {
1085
1172
  network: "SOLANA",
@@ -1290,7 +1377,7 @@ const $290fd8bc430da9f0$export$1f0fe79deb1b813b = {
1290
1377
  }
1291
1378
  ]
1292
1379
  }
1293
- ].slice(0)
1380
+ ]
1294
1381
  };
1295
1382
 
1296
1383
 
@@ -1591,7 +1678,7 @@ const $7dd402f6ad0dab6a$var$SUB_TEMPLATES = [
1591
1678
  (0, $60d24c82dc5feb2e$export$893111d8d332e195),
1592
1679
  (0, $5a4d345db3c04a51$export$d7ac970e8e789607),
1593
1680
  (0, $2e46ec862e47c14f$export$400f08bfae9ee97f),
1594
- (0, $290fd8bc430da9f0$export$1f0fe79deb1b813b),
1681
+ (0, $fc7ca671efecc378$export$a51565c56ceacb0a),
1595
1682
  (0, $fc745f3cb8eb3f52$export$36783fc9701281c6),
1596
1683
  (0, $3478cd776d185339$export$681f497010b17679),
1597
1684
  (0, $11a2c5b0fd56c033$export$bc6c7ab7e0727dd7),