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