teleton 0.2.3 → 0.2.4

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.
@@ -14,6 +14,7 @@ import {
14
14
  MessageStore,
15
15
  USED_TRANSACTIONS_SCHEMA,
16
16
  UserStore,
17
+ closeDatabase,
17
18
  createDbWrapper,
18
19
  getDatabase,
19
20
  initializeMemory,
@@ -10006,18 +10007,20 @@ function getDeal(db3, dealId) {
10006
10007
  }
10007
10008
  function acceptDeal(db3, dealId) {
10008
10009
  const newExpiry = Math.floor(Date.now() / 1e3) + DEAL_VERIFICATION_WINDOW_SECONDS;
10009
- db3.prepare(`UPDATE deals SET status = 'accepted', expires_at = ? WHERE id = ?`).run(
10010
- newExpiry,
10011
- dealId
10012
- );
10010
+ const r3 = db3.prepare(
10011
+ `UPDATE deals SET status = 'accepted', expires_at = ? WHERE id = ? AND status = 'proposed'`
10012
+ ).run(newExpiry, dealId);
10013
+ return r3.changes === 1;
10013
10014
  }
10014
10015
  function declineDeal(db3, dealId) {
10015
- db3.prepare(`UPDATE deals SET status = 'declined' WHERE id = ?`).run(dealId);
10016
+ const r3 = db3.prepare(`UPDATE deals SET status = 'declined' WHERE id = ? AND status = 'proposed'`).run(dealId);
10017
+ return r3.changes === 1;
10016
10018
  }
10017
10019
  function claimPayment(db3, dealId) {
10018
- db3.prepare(
10019
- `UPDATE deals SET status = 'payment_claimed', payment_claimed_at = unixepoch() WHERE id = ?`
10020
+ const r3 = db3.prepare(
10021
+ `UPDATE deals SET status = 'payment_claimed', payment_claimed_at = unixepoch() WHERE id = ? AND status = 'accepted'`
10020
10022
  ).run(dealId);
10023
+ return r3.changes === 1;
10021
10024
  }
10022
10025
  function setInlineMessageId(db3, dealId, inlineMessageId) {
10023
10026
  db3.prepare(`UPDATE deals SET inline_message_id = ? WHERE id = ?`).run(inlineMessageId, dealId);
@@ -10027,7 +10030,10 @@ function isDealExpired(deal) {
10027
10030
  return now > deal.expiresAt;
10028
10031
  }
10029
10032
  function expireDeal(db3, dealId) {
10030
- db3.prepare(`UPDATE deals SET status = 'expired' WHERE id = ?`).run(dealId);
10033
+ const r3 = db3.prepare(
10034
+ `UPDATE deals SET status = 'expired' WHERE id = ? AND status IN ('proposed', 'accepted')`
10035
+ ).run(dealId);
10036
+ return r3.changes === 1;
10031
10037
  }
10032
10038
  function getDealsAwaitingVerification(db3) {
10033
10039
  const rows = db3.prepare(
@@ -11477,12 +11483,16 @@ var VerificationPoller = class {
11477
11483
  * Handle verification timeout
11478
11484
  */
11479
11485
  async handleTimeout(deal) {
11480
- this.db.prepare(
11486
+ const r3 = this.db.prepare(
11481
11487
  `UPDATE deals SET
11482
11488
  status = 'failed',
11483
11489
  notes = 'Payment verification timeout'
11484
- WHERE id = ?`
11490
+ WHERE id = ? AND status = 'payment_claimed'`
11485
11491
  ).run(deal.dealId);
11492
+ if (r3.changes !== 1) {
11493
+ this.retryMap.delete(deal.dealId);
11494
+ return;
11495
+ }
11486
11496
  if (deal.inlineMessageId) {
11487
11497
  const { text, buttons } = buildFailedMessage(
11488
11498
  deal,
@@ -24281,6 +24291,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
24281
24291
  await mod.stop?.();
24282
24292
  }
24283
24293
  await this.bridge.disconnect();
24294
+ closeDatabase();
24284
24295
  }
24285
24296
  };
24286
24297
  async function main(configPath) {
package/dist/cli/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  saveWallet,
18
18
  validateApiKeyFormat,
19
19
  walletExists
20
- } from "../chunk-KU4Z3TYC.js";
20
+ } from "../chunk-74MTM3AB.js";
21
21
  import "../chunk-DUW5VBAZ.js";
22
22
  import "../chunk-OQGNS2FV.js";
23
23
  import "../chunk-TBIMVWQZ.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TonnetApp,
3
3
  main
4
- } from "./chunk-KU4Z3TYC.js";
4
+ } from "./chunk-74MTM3AB.js";
5
5
  import "./chunk-DUW5VBAZ.js";
6
6
  import "./chunk-OQGNS2FV.js";
7
7
  import "./chunk-TBIMVWQZ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleton",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Personal AI Agent for Telegram",
5
5
  "author": "ZKProof (https://t.me/zkproof)",
6
6
  "license": "MIT",