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