@indexing/jiti 0.1.6 → 0.1.8

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
@@ -290,6 +290,7 @@ const $68871103c7bc00cf$var$CHAIN_ID = {
290
290
  APECHAIN: 33139,
291
291
  ARBITRUM: 42161,
292
292
  ARBITRUM_NOVA: 42170,
293
+ ARBITRUM_SEPOLIA: 421614,
293
294
  AURORA: 1313161554,
294
295
  AVALANCHE: 43114,
295
296
  AVALANCHE_FUJI: 43113,
@@ -3292,14 +3293,99 @@ const $f7da547a9d6b4fc0$export$36783fc9701281c6 = {
3292
3293
 
3293
3294
 
3294
3295
 
3296
+ // Stellar amounts are stringified decimals with 7 fractional digits ("12.3456789"),
3297
+ // but jiti expresses everything in stroops (smallest unit). Stripping the dot is
3298
+ // equivalent to multiplying by 10^7.
3299
+ const $725699ccb951d76d$var$toStroops = (s)=>BigInt(s.replace(".", ""));
3300
+ const $725699ccb951d76d$var$effectAsset = (e)=>{
3301
+ if (e.asset_type === "native") return {
3302
+ token: null,
3303
+ tokenType: "NATIVE"
3304
+ };
3305
+ if (e.asset_issuer) return {
3306
+ token: e.asset_issuer,
3307
+ tokenType: "TOKEN"
3308
+ };
3309
+ // contract_* effects expose `asset` as a single string ("CODE:ISSUER" or "native").
3310
+ if (e.asset && e.asset !== "native") {
3311
+ const [, issuer] = e.asset.split(":");
3312
+ return {
3313
+ token: issuer ?? e.asset,
3314
+ tokenType: "TOKEN"
3315
+ };
3316
+ }
3317
+ return {
3318
+ token: null,
3319
+ tokenType: "NATIVE"
3320
+ };
3321
+ };
3322
+ const $725699ccb951d76d$var$sameAsset = (a, b)=>a.asset_type === b.asset_type && a.asset_code === b.asset_code && a.asset_issuer === b.asset_issuer && a.asset === b.asset;
3323
+ // Pair account_debited/account_credited effects within a single op into transfers.
3324
+ // Used for ops where amount/asset isn't reliably on the op body (offer fills,
3325
+ // account_merge, claim_claimable_balance, liquidity_pool_*, invoke_host_function).
3326
+ // Unpaired sides become one-sided transfers (e.g. claim_claimable_balance has no
3327
+ // debit because the source is a protocol-managed escrow).
3328
+ function $725699ccb951d76d$var$effectsToTransfers(typedTx, op, typedBlock) {
3329
+ const transfers = [];
3330
+ const effects = (op.effects || []).filter((e)=>typeof e.amount === "string");
3331
+ const debits = effects.filter((e)=>e.type === "account_debited" || e.type === "contract_debited");
3332
+ const credits = effects.filter((e)=>e.type === "account_credited" || e.type === "contract_credited");
3333
+ const baseFields = {
3334
+ blockNumber: typedBlock.sequence,
3335
+ memo: typedTx.memo,
3336
+ timestamp: typedTx.created_at,
3337
+ transactionGasFee: BigInt(typedTx.fee_charged),
3338
+ transactionHash: typedTx.hash
3339
+ };
3340
+ const usedCredit = new Set();
3341
+ for (const d of debits){
3342
+ if (!d.amount) continue;
3343
+ const idx = credits.findIndex((c, i)=>!usedCredit.has(i) && $725699ccb951d76d$var$sameAsset(d, c) && c.amount === d.amount);
3344
+ const { token: token, tokenType: tokenType } = $725699ccb951d76d$var$effectAsset(d);
3345
+ if (idx !== -1) {
3346
+ const c = credits[idx];
3347
+ usedCredit.add(idx);
3348
+ transfers.push({
3349
+ ...baseFields,
3350
+ amount: $725699ccb951d76d$var$toStroops(d.amount),
3351
+ from: d.account || d.contract || null,
3352
+ to: c.account || c.contract || null,
3353
+ token: token,
3354
+ tokenType: tokenType
3355
+ });
3356
+ } else transfers.push({
3357
+ ...baseFields,
3358
+ amount: $725699ccb951d76d$var$toStroops(d.amount),
3359
+ from: d.account || d.contract || null,
3360
+ to: null,
3361
+ token: token,
3362
+ tokenType: tokenType
3363
+ });
3364
+ }
3365
+ for(let i = 0; i < credits.length; i++){
3366
+ if (usedCredit.has(i)) continue;
3367
+ const c = credits[i];
3368
+ if (!c.amount) continue;
3369
+ const { token: token, tokenType: tokenType } = $725699ccb951d76d$var$effectAsset(c);
3370
+ transfers.push({
3371
+ ...baseFields,
3372
+ amount: $725699ccb951d76d$var$toStroops(c.amount),
3373
+ from: null,
3374
+ to: c.account || c.contract || null,
3375
+ token: token,
3376
+ tokenType: tokenType
3377
+ });
3378
+ }
3379
+ return transfers;
3380
+ }
3295
3381
  const $725699ccb951d76d$export$681f497010b17679 = {
3296
3382
  match: (block)=>(0, $09654dffcb68affa$export$ae001c77434c5340)(block) === "STELLAR",
3297
3383
  transform (block) {
3298
- let transfers = [];
3384
+ const transfers = [];
3299
3385
  const typedBlock = block;
3300
3386
  for (const typedTx of typedBlock.transactions || []){
3301
3387
  // Failed txs still burn fee_charged — emit a fee transfer (to: null) so callers
3302
- // can account for the gas, but skip the payment ops that never actually moved funds.
3388
+ // can account for the gas, but skip the ops that never actually moved funds.
3303
3389
  if (!typedTx.successful) {
3304
3390
  transfers.push({
3305
3391
  amount: BigInt(typedTx.fee_charged),
@@ -3315,52 +3401,141 @@ const $725699ccb951d76d$export$681f497010b17679 = {
3315
3401
  });
3316
3402
  continue;
3317
3403
  }
3318
- for (const op of typedTx.operations)if (op.type === "payment") transfers.push({
3319
- amount: BigInt(op.amount.replace(".", "")),
3320
- blockNumber: typedBlock.sequence,
3321
- from: op.from,
3322
- memo: typedTx.memo,
3323
- timestamp: typedTx.created_at,
3324
- to: op.to,
3325
- token: op.asset_type === "native" ? null : op.asset_issuer,
3326
- tokenType: op.asset_type === "native" ? "NATIVE" : "TOKEN",
3327
- transactionGasFee: BigInt(typedTx.fee_charged),
3328
- transactionHash: typedTx.hash
3329
- });
3404
+ for (const op of typedTx.operations){
3405
+ const baseFields = {
3406
+ blockNumber: typedBlock.sequence,
3407
+ memo: typedTx.memo,
3408
+ timestamp: typedTx.created_at,
3409
+ transactionGasFee: BigInt(typedTx.fee_charged),
3410
+ transactionHash: typedTx.hash
3411
+ };
3412
+ if (op.type === "payment") transfers.push({
3413
+ ...baseFields,
3414
+ amount: $725699ccb951d76d$var$toStroops(op.amount),
3415
+ from: op.from,
3416
+ to: op.to,
3417
+ token: op.asset_type === "native" ? null : op.asset_issuer,
3418
+ tokenType: op.asset_type === "native" ? "NATIVE" : "TOKEN"
3419
+ });
3420
+ else if (op.type === "create_account") // create_account funds a new account with native XLM via starting_balance —
3421
+ // economically a native payment from funder → account, but a different op
3422
+ // type because it also creates the destination ledger entry.
3423
+ transfers.push({
3424
+ ...baseFields,
3425
+ amount: $725699ccb951d76d$var$toStroops(op.starting_balance),
3426
+ from: op.funder,
3427
+ to: op.account,
3428
+ token: null,
3429
+ tokenType: "NATIVE"
3430
+ });
3431
+ else if (op.type === "path_payment_strict_send" || op.type === "path_payment_strict_receive") {
3432
+ // Path payments swap source_asset → asset along a DEX path. Both legs are
3433
+ // emitted as separate transfers (different assets, different amounts) so the
3434
+ // sender debit and receiver credit are both visible from op fields alone.
3435
+ transfers.push({
3436
+ ...baseFields,
3437
+ amount: $725699ccb951d76d$var$toStroops(op.source_amount),
3438
+ from: op.from,
3439
+ to: op.to,
3440
+ token: op.source_asset_type === "native" ? null : op.source_asset_issuer,
3441
+ tokenType: op.source_asset_type === "native" ? "NATIVE" : "TOKEN"
3442
+ });
3443
+ transfers.push({
3444
+ ...baseFields,
3445
+ amount: $725699ccb951d76d$var$toStroops(op.amount),
3446
+ from: op.from,
3447
+ to: op.to,
3448
+ token: op.asset_type === "native" ? null : op.asset_issuer,
3449
+ tokenType: op.asset_type === "native" ? "NATIVE" : "TOKEN"
3450
+ });
3451
+ } else // Everything else — manage_*_offer fills, account_merge, claim_claimable_balance,
3452
+ // liquidity_pool_*, invoke_host_function (Soroban) — surfaces fund movements
3453
+ // only via Horizon effects. Requires oscar to attach `op.effects` (#38).
3454
+ transfers.push(...$725699ccb951d76d$var$effectsToTransfers(typedTx, op, typedBlock));
3455
+ }
3330
3456
  }
3331
3457
  return transfers;
3332
3458
  },
3333
3459
  tests: [
3460
+ // Single-op token payment: source wallet → dest wallet, USDC asset.
3334
3461
  {
3335
3462
  params: {
3336
3463
  network: "STELLAR",
3337
- walletAddress: "GC5HUFIKZBK5XRNOBPXR4PBR3PWR26GP5UFRKSCOOOIENYVSF3NMA23U"
3464
+ transactionHash: "e08e8dd92bde178c554146475cafdf00cef8a8874541b1bb568760b5bd33c6e6"
3338
3465
  },
3339
- payload: "https://jiti.indexing.co/networks/stellar/59592273",
3466
+ payload: "https://jiti.indexing.co/networks/stellar/62312535",
3340
3467
  output: [
3341
3468
  {
3342
- amount: 651200000n,
3343
- blockNumber: 59592273,
3344
- from: "GC5HUFIKZBK5XRNOBPXR4PBR3PWR26GP5UFRKSCOOOIENYVSF3NMA23U",
3345
- memo: "315004227",
3346
- timestamp: "2025-10-28T17:24:17Z",
3347
- to: "GABFQIK63R2NETJM7T673EAMZN4RJLLGP3OFUEJU5SZVTGWUKULZJNL6",
3469
+ amount: 100000000n,
3470
+ blockNumber: 62312535,
3471
+ from: "GAUA7XL5K54CC2DDGP77FJ2YBHRJLT36CPZDXWPM6MP7MANOGG77PNJU",
3472
+ memo: undefined,
3473
+ timestamp: "2026-04-27T16:14:30Z",
3474
+ to: "GBTPFDSY7NFLFXAXXU725NUB2CXYM57RXG4ATYWBTK7RB57DFFNIU7RH",
3348
3475
  token: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
3349
3476
  tokenType: "TOKEN",
3350
3477
  transactionGasFee: 200n,
3351
- transactionHash: "a0e5f0cbc64a13816db1d8428c4e2f849ed9ec475b80d4cbd23a8119b1b1c010"
3352
- },
3478
+ transactionHash: "e08e8dd92bde178c554146475cafdf00cef8a8874541b1bb568760b5bd33c6e6"
3479
+ }
3480
+ ]
3481
+ },
3482
+ // path_payment_strict_send swaps source_asset → asset along a DEX path. Both legs
3483
+ // are emitted as separate transfers so the sender debit and receiver credit are
3484
+ // visible. Self-swap here (source==dest) but logic handles distinct accounts the
3485
+ // same way.
3486
+ {
3487
+ params: {
3488
+ network: "STELLAR",
3489
+ transactionHash: "f036756ae1cbf61d8e43af39b24b991b59c3684fc030de42f5d8fc2c96a672eb"
3490
+ },
3491
+ payload: "https://jiti.indexing.co/networks/stellar/62312422",
3492
+ output: [
3353
3493
  {
3354
- amount: 4445100000n,
3355
- blockNumber: 59592273,
3356
- from: "GAUA7XL5K54CC2DDGP77FJ2YBHRJLT36CPZDXWPM6MP7MANOGG77PNJU",
3494
+ amount: 1000000n,
3495
+ blockNumber: 62312422,
3496
+ from: "GCY7AY7OOO2XKZUCKLOZL3MJ62DW5UNL3ISFWDEDEEJM7JFGYZEUS55Z",
3357
3497
  memo: undefined,
3358
- timestamp: "2025-10-28T17:24:17Z",
3359
- to: "GC5HUFIKZBK5XRNOBPXR4PBR3PWR26GP5UFRKSCOOOIENYVSF3NMA23U",
3360
- token: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
3498
+ timestamp: "2026-04-27T16:03:47Z",
3499
+ to: "GCY7AY7OOO2XKZUCKLOZL3MJ62DW5UNL3ISFWDEDEEJM7JFGYZEUS55Z",
3500
+ token: "GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55",
3361
3501
  tokenType: "TOKEN",
3362
- transactionGasFee: 300n,
3363
- transactionHash: "c554aed41145304e03c0877c9de526cdcb8a8255c9bf156ff0dec202ab12e20d"
3502
+ transactionGasFee: 200n,
3503
+ transactionHash: "f036756ae1cbf61d8e43af39b24b991b59c3684fc030de42f5d8fc2c96a672eb"
3504
+ },
3505
+ {
3506
+ amount: 1000179n,
3507
+ blockNumber: 62312422,
3508
+ from: "GCY7AY7OOO2XKZUCKLOZL3MJ62DW5UNL3ISFWDEDEEJM7JFGYZEUS55Z",
3509
+ memo: undefined,
3510
+ timestamp: "2026-04-27T16:03:47Z",
3511
+ to: "GCY7AY7OOO2XKZUCKLOZL3MJ62DW5UNL3ISFWDEDEEJM7JFGYZEUS55Z",
3512
+ token: null,
3513
+ tokenType: "NATIVE",
3514
+ transactionGasFee: 200n,
3515
+ transactionHash: "f036756ae1cbf61d8e43af39b24b991b59c3684fc030de42f5d8fc2c96a672eb"
3516
+ }
3517
+ ]
3518
+ },
3519
+ // create_account funds a new account with native XLM — emit it as a NATIVE
3520
+ // transfer (funder → account) using starting_balance.
3521
+ {
3522
+ params: {
3523
+ network: "STELLAR",
3524
+ transactionHash: "a11add92603c4cab2396804f26acfe6fb9b0f938dc7dfa9f2ed017eb75ca039a"
3525
+ },
3526
+ payload: "https://jiti.indexing.co/networks/stellar/62080113",
3527
+ output: [
3528
+ {
3529
+ amount: 344880700n,
3530
+ blockNumber: 62080113,
3531
+ from: "GDF4UGQSY6VHWN7T4XJEZ6WYJEREMZYLNYZ5CCKYVS3V3MNYIBMTB354",
3532
+ memo: undefined,
3533
+ timestamp: "2026-04-12T04:27:18Z",
3534
+ to: "GBJO6JIIPD4JEKDTKY4CKOSQZU3ETIKVWAWU56A46W72G377BGG4PS44",
3535
+ token: null,
3536
+ tokenType: "NATIVE",
3537
+ transactionGasFee: 100n,
3538
+ transactionHash: "a11add92603c4cab2396804f26acfe6fb9b0f938dc7dfa9f2ed017eb75ca039a"
3364
3539
  }
3365
3540
  ]
3366
3541
  },