@indexing/jiti 0.1.13 → 0.1.15
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 +387 -22
- package/dist/main.js.map +1 -1
- package/dist/module.js +379 -21
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -1
package/dist/main.js
CHANGED
|
@@ -3,10 +3,14 @@ var $8zHUo$viem = require("viem");
|
|
|
3
3
|
var $8zHUo$tronweb = require("tronweb");
|
|
4
4
|
var $8zHUo$cosmjsprotosigning = require("@cosmjs/proto-signing");
|
|
5
5
|
var $8zHUo$cosmjsstargate = require("@cosmjs/stargate");
|
|
6
|
-
var $8zHUo$bs58 = require("bs58");
|
|
7
6
|
var $8zHUo$toncore = require("@ton/core");
|
|
7
|
+
var $8zHUo$bs58 = require("bs58");
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
function $parcel$export(e, n, v, s) {
|
|
11
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
function $parcel$exportWildcard(dest, source) {
|
|
11
15
|
Object.keys(source).forEach(function(key) {
|
|
12
16
|
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
|
|
@@ -24,18 +28,123 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
24
28
|
return dest;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
function $parcel$export(e, n, v, s) {
|
|
28
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
31
|
function $parcel$interopDefault(a) {
|
|
32
32
|
return a && a.__esModule ? a.default : a;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
var $parcel$global = globalThis;
|
|
36
|
+
|
|
37
|
+
var $parcel$modules = {};
|
|
38
|
+
var $parcel$inits = {};
|
|
39
|
+
|
|
40
|
+
var parcelRequire = $parcel$global["parcelRequire3fdc"];
|
|
41
|
+
|
|
42
|
+
if (parcelRequire == null) {
|
|
43
|
+
parcelRequire = function(id) {
|
|
44
|
+
if (id in $parcel$modules) {
|
|
45
|
+
return $parcel$modules[id].exports;
|
|
46
|
+
}
|
|
47
|
+
if (id in $parcel$inits) {
|
|
48
|
+
var init = $parcel$inits[id];
|
|
49
|
+
delete $parcel$inits[id];
|
|
50
|
+
var module = {id: id, exports: {}};
|
|
51
|
+
$parcel$modules[id] = module;
|
|
52
|
+
init.call(module.exports, module, module.exports);
|
|
53
|
+
return module.exports;
|
|
54
|
+
}
|
|
55
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
56
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
57
|
+
throw err;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
parcelRequire.register = function register(id, init) {
|
|
61
|
+
$parcel$inits[id] = init;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
$parcel$global["parcelRequire3fdc"] = parcelRequire;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var parcelRegister = parcelRequire.register;
|
|
68
|
+
parcelRegister("lCdWD", function(module, exports) {
|
|
69
|
+
|
|
70
|
+
$parcel$export(module.exports, "createPostgresCacheStorage", () => createPostgresCacheStorage);
|
|
71
|
+
function createPostgresCacheStorage(opts) {
|
|
72
|
+
const table = (opts.table ?? "jiti_cache").replace(/[^a-zA-Z0-9_]/g, "");
|
|
73
|
+
let pool = opts.pool;
|
|
74
|
+
function getPool() {
|
|
75
|
+
if (!pool) {
|
|
76
|
+
// Obscure the require so jiti's bundler leaves `pg` external (loaded from the consumer).
|
|
77
|
+
const requirePg = eval("require");
|
|
78
|
+
const pg = requirePg("pg");
|
|
79
|
+
pool = new pg.Pool({
|
|
80
|
+
connectionString: opts.connectionUri
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return pool;
|
|
84
|
+
}
|
|
85
|
+
let ready;
|
|
86
|
+
function ensureTable() {
|
|
87
|
+
if (!ready) ready = (async ()=>{
|
|
88
|
+
const p = getPool();
|
|
89
|
+
await p.query(`CREATE TABLE IF NOT EXISTS ${table} (
|
|
90
|
+
namespace text NOT NULL,
|
|
91
|
+
key text NOT NULL,
|
|
92
|
+
value jsonb,
|
|
93
|
+
found boolean NOT NULL DEFAULT true,
|
|
94
|
+
resolved_at timestamptz NOT NULL DEFAULT now(),
|
|
95
|
+
expires_at timestamptz,
|
|
96
|
+
PRIMARY KEY (namespace, key)
|
|
97
|
+
);`);
|
|
98
|
+
await p.query(`CREATE INDEX IF NOT EXISTS ${table}_expires_idx ON ${table} (expires_at) WHERE expires_at IS NOT NULL;`);
|
|
99
|
+
})();
|
|
100
|
+
return ready;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
async get (namespace, key) {
|
|
104
|
+
await ensureTable();
|
|
105
|
+
const { rows } = await getPool().query(`SELECT value, found, expires_at FROM ${table} WHERE namespace = $1 AND key = $2`, [
|
|
106
|
+
namespace,
|
|
107
|
+
key
|
|
108
|
+
]);
|
|
109
|
+
if (!rows.length) return null;
|
|
110
|
+
const row = rows[0];
|
|
111
|
+
return {
|
|
112
|
+
value: row.value ?? null,
|
|
113
|
+
found: row.found,
|
|
114
|
+
expiresAt: row.expires_at ? new Date(row.expires_at).getTime() : null
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
async set (namespace, key, row) {
|
|
118
|
+
await ensureTable();
|
|
119
|
+
await getPool().query(`INSERT INTO ${table} (namespace, key, value, found, resolved_at, expires_at)
|
|
120
|
+
VALUES ($1, $2, $3::jsonb, $4, now(), $5)
|
|
121
|
+
ON CONFLICT (namespace, key) DO UPDATE
|
|
122
|
+
SET value = EXCLUDED.value, found = EXCLUDED.found, resolved_at = now(), expires_at = EXCLUDED.expires_at`, [
|
|
123
|
+
namespace,
|
|
124
|
+
key,
|
|
125
|
+
row.value === null || row.value === undefined ? null : JSON.stringify(row.value),
|
|
126
|
+
row.found,
|
|
127
|
+
row.expiresAt ? new Date(row.expiresAt).toISOString() : null
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
|
|
35
136
|
$parcel$export(module.exports, "utils", () => $882b6d93070905b3$export$eab97d15b1788b8d);
|
|
36
137
|
$parcel$export(module.exports, "templates", () => $882b6d93070905b3$export$a8fc3402335b0b04);
|
|
37
138
|
$parcel$export(module.exports, "getAllTemplates", () => $882b6d93070905b3$export$cceb5167b935aafb);
|
|
38
139
|
$parcel$export(module.exports, "getTemplateByKey", () => $882b6d93070905b3$export$a07bfd14bbc36e4b);
|
|
140
|
+
$parcel$export(module.exports, "cacheGet", () => $45fec2af5a17964d$export$2aca74ef9665e35d);
|
|
141
|
+
$parcel$export(module.exports, "cacheSet", () => $45fec2af5a17964d$export$59c69e19e33761f6);
|
|
142
|
+
$parcel$export(module.exports, "registerCacheNamespace", () => $226820b1648da9ad$export$2b845901f37b4099);
|
|
143
|
+
$parcel$export(module.exports, "createPostgresCacheStorage", () => (parcelRequire("lCdWD")).createPostgresCacheStorage);
|
|
144
|
+
$parcel$export(module.exports, "lookupJettonWallet", () => $b2a2726ff5c26695$export$77ffdf974cb300ec);
|
|
145
|
+
$parcel$export(module.exports, "resolveJettonWalletData", () => $b2a2726ff5c26695$export$cef9e9799d863462);
|
|
146
|
+
$parcel$export(module.exports, "setTonRpcHosts", () => $b2a2726ff5c26695$export$c9db54a59e1b6652);
|
|
147
|
+
$parcel$export(module.exports, "TON_JETTON_NAMESPACE", () => $b2a2726ff5c26695$export$a0a0f70252f1386f);
|
|
39
148
|
var $d7167569386d0d4c$exports = {};
|
|
40
149
|
var $56acd58307ebf8e6$exports = {};
|
|
41
150
|
|
|
@@ -1360,6 +1469,233 @@ const $5a4d345db3c04a51$export$d7ac970e8e789607 = {
|
|
|
1360
1469
|
|
|
1361
1470
|
|
|
1362
1471
|
|
|
1472
|
+
// Per-namespace policy registry. Namespaces differ only here: immutable vs TTL
|
|
1473
|
+
// (`ttlSeconds`), and resolve-on-miss vs externally-populated (presence of `resolve`).
|
|
1474
|
+
// jiti registers the namespaces it can resolve itself (e.g. ton-jetton-wallet); a consumer
|
|
1475
|
+
// may register its own (e.g. token-price with no resolver, populated via cacheSet).
|
|
1476
|
+
const $226820b1648da9ad$var$REGISTRY = new Map();
|
|
1477
|
+
function $226820b1648da9ad$export$2b845901f37b4099(namespace, policy) {
|
|
1478
|
+
$226820b1648da9ad$var$REGISTRY.set(namespace, policy);
|
|
1479
|
+
}
|
|
1480
|
+
function $226820b1648da9ad$export$d23e4dbc7b86eaca(namespace) {
|
|
1481
|
+
return $226820b1648da9ad$var$REGISTRY.get(namespace) ?? {};
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
// cache-or-lookup core. jiti owns the orchestration — in-process L1, single-flight, negative
|
|
1486
|
+
// caching, TTL/immutability, read-through/write-through — and the per-namespace resolvers.
|
|
1487
|
+
// The consumer injects only durable storage (see createPostgresCacheStorage for a ready-made
|
|
1488
|
+
// Postgres adapter). With no storage available, callers simply don't invoke cacheGet.
|
|
1489
|
+
const $45fec2af5a17964d$var$L1_MAX = 50000;
|
|
1490
|
+
const $45fec2af5a17964d$var$L1 = new Map();
|
|
1491
|
+
function $45fec2af5a17964d$var$l1Get(id) {
|
|
1492
|
+
const e = $45fec2af5a17964d$var$L1.get(id);
|
|
1493
|
+
if (!e) return undefined;
|
|
1494
|
+
if (e.expiresAt !== null && e.expiresAt <= Date.now()) {
|
|
1495
|
+
$45fec2af5a17964d$var$L1.delete(id);
|
|
1496
|
+
return undefined;
|
|
1497
|
+
}
|
|
1498
|
+
$45fec2af5a17964d$var$L1.delete(id);
|
|
1499
|
+
$45fec2af5a17964d$var$L1.set(id, e); // bump recency
|
|
1500
|
+
return e;
|
|
1501
|
+
}
|
|
1502
|
+
function $45fec2af5a17964d$var$l1Set(id, value, expiresAt) {
|
|
1503
|
+
if ($45fec2af5a17964d$var$L1.size >= $45fec2af5a17964d$var$L1_MAX) {
|
|
1504
|
+
const oldest = $45fec2af5a17964d$var$L1.keys().next().value;
|
|
1505
|
+
if (oldest !== undefined) $45fec2af5a17964d$var$L1.delete(oldest);
|
|
1506
|
+
}
|
|
1507
|
+
$45fec2af5a17964d$var$L1.set(id, {
|
|
1508
|
+
value: value,
|
|
1509
|
+
expiresAt: expiresAt
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
const $45fec2af5a17964d$var$inflight = new Map();
|
|
1513
|
+
function $45fec2af5a17964d$var$cacheId(namespace, key) {
|
|
1514
|
+
return `${namespace} ${key}`;
|
|
1515
|
+
}
|
|
1516
|
+
async function $45fec2af5a17964d$export$2aca74ef9665e35d(storage, namespace, key) {
|
|
1517
|
+
const id = $45fec2af5a17964d$var$cacheId(namespace, key);
|
|
1518
|
+
const l1 = $45fec2af5a17964d$var$l1Get(id);
|
|
1519
|
+
if (l1) return l1.value;
|
|
1520
|
+
const existing = $45fec2af5a17964d$var$inflight.get(id);
|
|
1521
|
+
if (existing !== undefined) return existing;
|
|
1522
|
+
const p = (async ()=>{
|
|
1523
|
+
const row = await storage.get(namespace, key);
|
|
1524
|
+
if (row && (row.expiresAt === null || row.expiresAt > Date.now())) {
|
|
1525
|
+
const value = row.found ? row.value : null;
|
|
1526
|
+
$45fec2af5a17964d$var$l1Set(id, value, row.expiresAt);
|
|
1527
|
+
return value;
|
|
1528
|
+
}
|
|
1529
|
+
const policy = (0, $226820b1648da9ad$export$d23e4dbc7b86eaca)(namespace);
|
|
1530
|
+
if (!policy.resolve) return null; // externally-populated namespace: miss ⇒ null (no write)
|
|
1531
|
+
let resolved = null;
|
|
1532
|
+
try {
|
|
1533
|
+
resolved = await policy.resolve(key);
|
|
1534
|
+
} catch {
|
|
1535
|
+
// Transient resolver failure (e.g. RPC) — do NOT cache so it retries next time.
|
|
1536
|
+
return null;
|
|
1537
|
+
}
|
|
1538
|
+
const found = resolved !== null && resolved !== undefined;
|
|
1539
|
+
const negativeTtl = policy.negativeTtlSeconds ?? 3600;
|
|
1540
|
+
if (!found && negativeTtl === 0) return null; // negative caching disabled for this namespace
|
|
1541
|
+
const ttlSeconds = found ? policy.ttlSeconds : negativeTtl;
|
|
1542
|
+
const expiresAt = ttlSeconds === null || ttlSeconds === undefined ? null : Date.now() + ttlSeconds * 1000;
|
|
1543
|
+
await storage.set(namespace, key, {
|
|
1544
|
+
value: found ? resolved : null,
|
|
1545
|
+
found: found,
|
|
1546
|
+
expiresAt: expiresAt
|
|
1547
|
+
});
|
|
1548
|
+
$45fec2af5a17964d$var$l1Set(id, found ? resolved : null, expiresAt);
|
|
1549
|
+
return found ? resolved : null;
|
|
1550
|
+
})().finally(()=>$45fec2af5a17964d$var$inflight.delete(id));
|
|
1551
|
+
$45fec2af5a17964d$var$inflight.set(id, p);
|
|
1552
|
+
return p;
|
|
1553
|
+
}
|
|
1554
|
+
async function $45fec2af5a17964d$export$59c69e19e33761f6(storage, namespace, key, value, ttlSecondsOverride) {
|
|
1555
|
+
const policy = (0, $226820b1648da9ad$export$d23e4dbc7b86eaca)(namespace);
|
|
1556
|
+
const ttlSeconds = ttlSecondsOverride !== undefined ? ttlSecondsOverride : policy.ttlSeconds;
|
|
1557
|
+
const expiresAt = ttlSeconds === null || ttlSeconds === undefined ? null : Date.now() + ttlSeconds * 1000;
|
|
1558
|
+
await storage.set(namespace, key, {
|
|
1559
|
+
value: value,
|
|
1560
|
+
found: true,
|
|
1561
|
+
expiresAt: expiresAt
|
|
1562
|
+
});
|
|
1563
|
+
$45fec2af5a17964d$var$l1Set($45fec2af5a17964d$var$cacheId(namespace, key), value, expiresAt);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
const $b2a2726ff5c26695$export$a0a0f70252f1386f = "ton-jetton-wallet";
|
|
1569
|
+
const $b2a2726ff5c26695$var$ORBS_MANAGER_URL = "https://ton.access.orbs.network/mngr/nodes";
|
|
1570
|
+
const $b2a2726ff5c26695$var$ORBS_REFRESH_MS = 300000;
|
|
1571
|
+
let $b2a2726ff5c26695$var$orbsHosts = [];
|
|
1572
|
+
let $b2a2726ff5c26695$var$orbsRefreshedAt = 0;
|
|
1573
|
+
// Consumer-injected TON RPC hosts (toncenter v2 jsonRPC-compatible base hosts). When set, the
|
|
1574
|
+
// resolver uses THESE instead of Orbs discovery — e.g. the indexer injects oscar's configured
|
|
1575
|
+
// TON hosts (BlockPi/QuickNode from network_connections) so jiti hits the same hosts oscar uses
|
|
1576
|
+
// and avoids Orbs's per-IP rate limit on the oscar box. Empty ⇒ fall back to Orbs discovery.
|
|
1577
|
+
let $b2a2726ff5c26695$var$configuredHosts = [];
|
|
1578
|
+
function $b2a2726ff5c26695$export$c9db54a59e1b6652(hosts) {
|
|
1579
|
+
$b2a2726ff5c26695$var$configuredHosts = (hosts || []).filter(Boolean);
|
|
1580
|
+
}
|
|
1581
|
+
function $b2a2726ff5c26695$var$shuffled(hosts) {
|
|
1582
|
+
const a = [
|
|
1583
|
+
...hosts
|
|
1584
|
+
];
|
|
1585
|
+
for(let i = a.length - 1; i > 0; i--){
|
|
1586
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
1587
|
+
[a[i], a[j]] = [
|
|
1588
|
+
a[j],
|
|
1589
|
+
a[i]
|
|
1590
|
+
];
|
|
1591
|
+
}
|
|
1592
|
+
return a;
|
|
1593
|
+
}
|
|
1594
|
+
// toncenter v2 speaks JSON-RPC at `<host>/jsonRPC`. Orbs hosts already end in it; BlockPi-style
|
|
1595
|
+
// base hosts (…/rpc/<key>) need it appended — mirrors oscar's TON buildUrl.
|
|
1596
|
+
function $b2a2726ff5c26695$var$buildUrl(host) {
|
|
1597
|
+
return host.endsWith("/jsonRPC") ? host : `${host.replace(/\/$/, "")}/jsonRPC`;
|
|
1598
|
+
}
|
|
1599
|
+
async function $b2a2726ff5c26695$var$getHosts() {
|
|
1600
|
+
if ($b2a2726ff5c26695$var$configuredHosts.length) return $b2a2726ff5c26695$var$shuffled($b2a2726ff5c26695$var$configuredHosts).map($b2a2726ff5c26695$var$buildUrl);
|
|
1601
|
+
if ($b2a2726ff5c26695$var$orbsHosts.length && Date.now() - $b2a2726ff5c26695$var$orbsRefreshedAt < $b2a2726ff5c26695$var$ORBS_REFRESH_MS) return $b2a2726ff5c26695$var$shuffled($b2a2726ff5c26695$var$orbsHosts);
|
|
1602
|
+
try {
|
|
1603
|
+
const resp = await fetch($b2a2726ff5c26695$var$ORBS_MANAGER_URL, {
|
|
1604
|
+
signal: AbortSignal.timeout(8000)
|
|
1605
|
+
});
|
|
1606
|
+
const nodes = await resp.json();
|
|
1607
|
+
const healthy = nodes.filter((n)=>n.Healthy === "1" && n.Mngr?.health?.["v2-mainnet"]).map((n)=>`https://ton.access.orbs.network/${n.NodeId}/1/mainnet/toncenter-api-v2/jsonRPC`);
|
|
1608
|
+
if (healthy.length) {
|
|
1609
|
+
$b2a2726ff5c26695$var$orbsHosts = healthy;
|
|
1610
|
+
$b2a2726ff5c26695$var$orbsRefreshedAt = Date.now();
|
|
1611
|
+
}
|
|
1612
|
+
} catch {
|
|
1613
|
+
// keep prior cached set
|
|
1614
|
+
}
|
|
1615
|
+
return $b2a2726ff5c26695$var$shuffled($b2a2726ff5c26695$var$orbsHosts);
|
|
1616
|
+
}
|
|
1617
|
+
function $b2a2726ff5c26695$export$938b62d04991c792(addr) {
|
|
1618
|
+
try {
|
|
1619
|
+
return (0, $8zHUo$toncore.Address).parse(addr).toString({
|
|
1620
|
+
urlSafe: true,
|
|
1621
|
+
bounceable: true,
|
|
1622
|
+
testOnly: false
|
|
1623
|
+
});
|
|
1624
|
+
} catch {
|
|
1625
|
+
return addr;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
function $b2a2726ff5c26695$var$parseAddressFromStackEntry(entry) {
|
|
1629
|
+
// toncenter v2 runGetMethod returns slice/cell results as ['cell', { bytes: <base64 BoC> }].
|
|
1630
|
+
const value = entry?.[1];
|
|
1631
|
+
const b64 = typeof value === "string" ? value : value?.bytes;
|
|
1632
|
+
if (!b64) return null;
|
|
1633
|
+
return $b2a2726ff5c26695$export$938b62d04991c792((0, $8zHUo$toncore.Cell).fromBase64(b64).beginParse().loadAddress().toString());
|
|
1634
|
+
}
|
|
1635
|
+
async function $b2a2726ff5c26695$var$runGetMethod(host, address, method, stack) {
|
|
1636
|
+
const resp = await fetch(host, {
|
|
1637
|
+
method: "POST",
|
|
1638
|
+
headers: {
|
|
1639
|
+
"content-type": "application/json"
|
|
1640
|
+
},
|
|
1641
|
+
body: JSON.stringify({
|
|
1642
|
+
jsonrpc: "2.0",
|
|
1643
|
+
id: 1,
|
|
1644
|
+
method: "runGetMethod",
|
|
1645
|
+
params: {
|
|
1646
|
+
address: address,
|
|
1647
|
+
method: method,
|
|
1648
|
+
stack: stack
|
|
1649
|
+
}
|
|
1650
|
+
}),
|
|
1651
|
+
signal: AbortSignal.timeout(15000)
|
|
1652
|
+
});
|
|
1653
|
+
const json = await resp.json();
|
|
1654
|
+
if (!json.ok || !json.result) throw new Error(`TON runGetMethod ${method} error: ${json.error || "unknown"}`);
|
|
1655
|
+
return {
|
|
1656
|
+
exitCode: json.result.exit_code,
|
|
1657
|
+
stack: json.result.stack
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
async function $b2a2726ff5c26695$export$cef9e9799d863462(wallet) {
|
|
1661
|
+
const hosts = await $b2a2726ff5c26695$var$getHosts();
|
|
1662
|
+
if (!hosts.length) throw new Error("TON: no Orbs hosts available for get_wallet_data");
|
|
1663
|
+
let sawDefiniteMiss = false;
|
|
1664
|
+
let lastErr;
|
|
1665
|
+
for(let attempt = 0; attempt < 2; attempt++){
|
|
1666
|
+
for (const host of hosts)try {
|
|
1667
|
+
const { exitCode: exitCode, stack: stack } = await $b2a2726ff5c26695$var$runGetMethod(host, wallet, "get_wallet_data", []);
|
|
1668
|
+
if (exitCode !== 0) {
|
|
1669
|
+
sawDefiniteMiss = true; // no get_wallet_data → not a jetton wallet
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
const owner = $b2a2726ff5c26695$var$parseAddressFromStackEntry(stack[1]);
|
|
1673
|
+
const master = $b2a2726ff5c26695$var$parseAddressFromStackEntry(stack[2]);
|
|
1674
|
+
if (owner && master) return {
|
|
1675
|
+
owner: owner,
|
|
1676
|
+
master: master
|
|
1677
|
+
};
|
|
1678
|
+
sawDefiniteMiss = true;
|
|
1679
|
+
} catch (e) {
|
|
1680
|
+
lastErr = e;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
if (sawDefiniteMiss) return null; // definitive: not a jetton wallet → negative-cache
|
|
1684
|
+
throw new Error(`TON: get_wallet_data failed for ${wallet}: ${lastErr?.message}`); // transient → don't cache
|
|
1685
|
+
}
|
|
1686
|
+
async function $b2a2726ff5c26695$export$77ffdf974cb300ec(storage, wallet) {
|
|
1687
|
+
return await (0, $45fec2af5a17964d$export$2aca74ef9665e35d)(storage, $b2a2726ff5c26695$export$a0a0f70252f1386f, $b2a2726ff5c26695$export$938b62d04991c792(wallet));
|
|
1688
|
+
}
|
|
1689
|
+
// Register on import: immutable mapping, resolve-on-miss via get_wallet_data; non-jetton
|
|
1690
|
+
// accounts negative-cached for a day.
|
|
1691
|
+
(0, $226820b1648da9ad$export$2b845901f37b4099)($b2a2726ff5c26695$export$a0a0f70252f1386f, {
|
|
1692
|
+
resolve: (key)=>$b2a2726ff5c26695$export$cef9e9799d863462(key),
|
|
1693
|
+
ttlSeconds: null,
|
|
1694
|
+
negativeTtlSeconds: 86400
|
|
1695
|
+
});
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
|
|
1363
1699
|
const $2e46ec862e47c14f$export$400f08bfae9ee97f = {
|
|
1364
1700
|
match: (block)=>(0, $6bd2ca253e883278$export$ae001c77434c5340)(block) === "RIPPLE",
|
|
1365
1701
|
transform (block) {
|
|
@@ -3775,6 +4111,27 @@ const $7dd402f6ad0dab6a$var$UNIVERSAL_SUB_TEMPLATES = [
|
|
|
3775
4111
|
(0, $f9ab50a3e879ac1c$export$b5fd4920e8b7d913),
|
|
3776
4112
|
(0, $8deaea1ef39b6485$export$5beebc5708fabf3c)
|
|
3777
4113
|
];
|
|
4114
|
+
// Drops zero-amount + duplicate transfers and applies the optional contractAddress /
|
|
4115
|
+
// walletAddress / transactionHash param filters. Runs AFTER any jetton enrichment so the
|
|
4116
|
+
// filters see the resolved owner/master.
|
|
4117
|
+
function $7dd402f6ad0dab6a$var$applyTransferFilters(transfers, _ctx) {
|
|
4118
|
+
const seenTransfers = new Set();
|
|
4119
|
+
return transfers.filter((txfer)=>{
|
|
4120
|
+
if (txfer.amount <= BigInt(0)) return false;
|
|
4121
|
+
if (_ctx?.params) {
|
|
4122
|
+
if (_ctx.params.contractAddress && _ctx.params.contractAddress !== txfer.token) return false;
|
|
4123
|
+
if (_ctx.params.walletAddress && ![
|
|
4124
|
+
txfer.from,
|
|
4125
|
+
txfer.to
|
|
4126
|
+
].includes(_ctx.params.walletAddress)) return false;
|
|
4127
|
+
if (_ctx.params.transactionHash && txfer.transactionHash !== _ctx.params.transactionHash) return false;
|
|
4128
|
+
}
|
|
4129
|
+
const key = `${txfer.transactionHash}-${txfer.from}-${txfer.to}-${txfer.amount}-${txfer.token}-${txfer.index}`;
|
|
4130
|
+
if (seenTransfers.has(key)) return false;
|
|
4131
|
+
seenTransfers.add(key);
|
|
4132
|
+
return true;
|
|
4133
|
+
});
|
|
4134
|
+
}
|
|
3778
4135
|
const $7dd402f6ad0dab6a$var$tokenTransfersTemplate = {
|
|
3779
4136
|
key: "token_transfers",
|
|
3780
4137
|
name: "Token Transfers",
|
|
@@ -3827,23 +4184,27 @@ const $7dd402f6ad0dab6a$var$tokenTransfersTemplate = {
|
|
|
3827
4184
|
transfers = sub.transform(block, _ctx);
|
|
3828
4185
|
break;
|
|
3829
4186
|
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
4187
|
+
// Optional enrichment for account-model token transfers (TON jettons) where the block
|
|
4188
|
+
// only carries the token-WALLET address and no master: they come out as
|
|
4189
|
+
// `tokenType: 'TOKEN'`, `to` = wallet, `token` = undefined. When the caller injects a
|
|
4190
|
+
// `_ctx.cacheStorage` (durable cache), jiti resolves the wallet → { owner, master } via
|
|
4191
|
+
// its own cache+RPC and rewrites `to`/`token` BEFORE filtering, so contractAddress /
|
|
4192
|
+
// walletAddress filters match the real owner + master. jiti owns the cache + resolver
|
|
4193
|
+
// (get_wallet_data over Orbs); the consumer injects only storage. Async only when storage
|
|
4194
|
+
// is provided; the sync path is unchanged for every existing caller.
|
|
4195
|
+
const cacheStorage = _ctx?.cacheStorage;
|
|
4196
|
+
if (cacheStorage) return (async ()=>{
|
|
4197
|
+
await Promise.all(transfers.map(async (txfer)=>{
|
|
4198
|
+
if (txfer.tokenType !== "TOKEN" || txfer.token || !txfer.to) return;
|
|
4199
|
+
const info = await (0, $b2a2726ff5c26695$export$77ffdf974cb300ec)(cacheStorage, txfer.to);
|
|
4200
|
+
if (info) {
|
|
4201
|
+
txfer.to = info.owner;
|
|
4202
|
+
txfer.token = info.master;
|
|
4203
|
+
}
|
|
4204
|
+
}));
|
|
4205
|
+
return $7dd402f6ad0dab6a$var$applyTransferFilters(transfers, _ctx);
|
|
4206
|
+
})();
|
|
4207
|
+
return $7dd402f6ad0dab6a$var$applyTransferFilters(transfers, _ctx);
|
|
3847
4208
|
},
|
|
3848
4209
|
tests: $7dd402f6ad0dab6a$var$SUB_TEMPLATES.concat($7dd402f6ad0dab6a$var$UNIVERSAL_SUB_TEMPLATES).map((v)=>v.tests).flat()
|
|
3849
4210
|
};
|
|
@@ -11600,6 +11961,10 @@ $parcel$exportWildcard($b4b970cc11bce2a5$exports, $4828ba704a8a504f$exports);
|
|
|
11600
11961
|
$parcel$exportWildcard($b4b970cc11bce2a5$exports, $4a8e5fd52443a474$exports);
|
|
11601
11962
|
|
|
11602
11963
|
|
|
11964
|
+
|
|
11965
|
+
|
|
11966
|
+
var $lCdWD = parcelRequire("lCdWD");
|
|
11967
|
+
|
|
11603
11968
|
const $882b6d93070905b3$export$eab97d15b1788b8d = {
|
|
11604
11969
|
...$d7167569386d0d4c$exports
|
|
11605
11970
|
};
|