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