teleton 0.7.1 → 0.7.2

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.
@@ -48,7 +48,6 @@ import {
48
48
  createLogger
49
49
  } from "./chunk-RCMD3U65.js";
50
50
  import {
51
- __require,
52
51
  __toESM
53
52
  } from "./chunk-QGM4M3NI.js";
54
53
 
@@ -660,54 +659,71 @@ var SDK_VERSION = "1.0.0";
660
659
  // src/ton/transfer.ts
661
660
  import { WalletContractV5R1, TonClient, toNano, internal } from "@ton/ton";
662
661
  import { Address, SendMode } from "@ton/core";
662
+
663
+ // src/ton/tx-lock.ts
664
+ var pending = Promise.resolve();
665
+ function withTxLock(fn) {
666
+ const execute = pending.then(fn, fn);
667
+ pending = execute.then(
668
+ () => {
669
+ },
670
+ () => {
671
+ }
672
+ );
673
+ return execute;
674
+ }
675
+
676
+ // src/ton/transfer.ts
663
677
  var log4 = createLogger("TON");
664
678
  async function sendTon(params) {
665
- try {
666
- const { toAddress, amount, comment = "", bounce = false } = params;
667
- if (!Number.isFinite(amount) || amount <= 0) {
668
- log4.error({ amount }, "Invalid transfer amount");
669
- return null;
670
- }
671
- let recipientAddress;
679
+ return withTxLock(async () => {
672
680
  try {
673
- recipientAddress = Address.parse(toAddress);
674
- } catch (e) {
675
- log4.error({ err: e }, `Invalid recipient address: ${toAddress}`);
676
- return null;
677
- }
678
- const keyPair = await getKeyPair();
679
- if (!keyPair) {
680
- log4.error("Wallet not initialized");
681
+ const { toAddress, amount, comment = "", bounce = false } = params;
682
+ if (!Number.isFinite(amount) || amount <= 0) {
683
+ log4.error({ amount }, "Invalid transfer amount");
684
+ return null;
685
+ }
686
+ let recipientAddress;
687
+ try {
688
+ recipientAddress = Address.parse(toAddress);
689
+ } catch (e) {
690
+ log4.error({ err: e }, `Invalid recipient address: ${toAddress}`);
691
+ return null;
692
+ }
693
+ const keyPair = await getKeyPair();
694
+ if (!keyPair) {
695
+ log4.error("Wallet not initialized");
696
+ return null;
697
+ }
698
+ const wallet = WalletContractV5R1.create({
699
+ workchain: 0,
700
+ publicKey: keyPair.publicKey
701
+ });
702
+ const endpoint = await getCachedHttpEndpoint();
703
+ const client = new TonClient({ endpoint });
704
+ const contract = client.open(wallet);
705
+ const seqno = await contract.getSeqno();
706
+ await contract.sendTransfer({
707
+ seqno,
708
+ secretKey: keyPair.secretKey,
709
+ sendMode: SendMode.PAY_GAS_SEPARATELY,
710
+ messages: [
711
+ internal({
712
+ to: recipientAddress,
713
+ value: toNano(amount),
714
+ body: comment,
715
+ bounce
716
+ })
717
+ ]
718
+ });
719
+ const pseudoHash = `${seqno}_${Date.now()}_${amount.toFixed(2)}`;
720
+ log4.info(`Sent ${amount} TON to ${toAddress.slice(0, 8)}... - seqno: ${seqno}`);
721
+ return pseudoHash;
722
+ } catch (error) {
723
+ log4.error({ err: error }, "Error sending TON");
681
724
  return null;
682
725
  }
683
- const wallet = WalletContractV5R1.create({
684
- workchain: 0,
685
- publicKey: keyPair.publicKey
686
- });
687
- const endpoint = await getCachedHttpEndpoint();
688
- const client = new TonClient({ endpoint });
689
- const contract = client.open(wallet);
690
- const seqno = await contract.getSeqno();
691
- await contract.sendTransfer({
692
- seqno,
693
- secretKey: keyPair.secretKey,
694
- sendMode: SendMode.PAY_GAS_SEPARATELY,
695
- messages: [
696
- internal({
697
- to: recipientAddress,
698
- value: toNano(amount),
699
- body: comment,
700
- bounce
701
- })
702
- ]
703
- });
704
- const pseudoHash = `${seqno}_${Date.now()}_${amount.toFixed(2)}`;
705
- log4.info(`Sent ${amount} TON to ${toAddress.slice(0, 8)}... - seqno: ${seqno}`);
706
- return pseudoHash;
707
- } catch (error) {
708
- log4.error({ err: error }, "Error sending TON");
709
- return null;
710
- }
726
+ });
711
727
  }
712
728
 
713
729
  // src/utils/retry.ts
@@ -759,6 +775,8 @@ async function withBlockchainRetry(fn, operation = "blockchain operation") {
759
775
  }
760
776
 
761
777
  // src/sdk/ton.ts
778
+ import { toNano as tonToNano, fromNano as tonFromNano } from "@ton/ton";
779
+ import { Address as TonAddress } from "@ton/core";
762
780
  var DEFAULT_MAX_AGE_MINUTES = 10;
763
781
  var DEFAULT_TX_RETENTION_DAYS = 30;
764
782
  var CLEANUP_PROBABILITY = 0.1;
@@ -1035,26 +1053,29 @@ function createTonSDK(log7, db) {
1035
1053
  if (!keyPair) {
1036
1054
  throw new PluginSDKError("Wallet key derivation failed", "OPERATION_FAILED");
1037
1055
  }
1038
- const wallet = WalletContractV5R12.create({
1039
- workchain: 0,
1040
- publicKey: keyPair.publicKey
1041
- });
1042
- const endpoint = await getCachedHttpEndpoint2();
1043
- const client = new TonClient2({ endpoint });
1044
- const walletContract = client.open(wallet);
1045
- const seqno = await walletContract.getSeqno();
1046
- await walletContract.sendTransfer({
1047
- seqno,
1048
- secretKey: keyPair.secretKey,
1049
- sendMode: SendMode2.PAY_GAS_SEPARATELY,
1050
- messages: [
1051
- internal2({
1052
- to: Address2.parse(senderJettonWallet),
1053
- value: toNano2("0.05"),
1054
- body: messageBody,
1055
- bounce: true
1056
- })
1057
- ]
1056
+ const seqno = await withTxLock(async () => {
1057
+ const wallet = WalletContractV5R12.create({
1058
+ workchain: 0,
1059
+ publicKey: keyPair.publicKey
1060
+ });
1061
+ const endpoint = await getCachedHttpEndpoint2();
1062
+ const client = new TonClient2({ endpoint });
1063
+ const walletContract = client.open(wallet);
1064
+ const seq = await walletContract.getSeqno();
1065
+ await walletContract.sendTransfer({
1066
+ seqno: seq,
1067
+ secretKey: keyPair.secretKey,
1068
+ sendMode: SendMode2.PAY_GAS_SEPARATELY,
1069
+ messages: [
1070
+ internal2({
1071
+ to: Address2.parse(senderJettonWallet),
1072
+ value: toNano2("0.05"),
1073
+ body: messageBody,
1074
+ bounce: true
1075
+ })
1076
+ ]
1077
+ });
1078
+ return seq;
1058
1079
  });
1059
1080
  return { success: true, seqno };
1060
1081
  } catch (err) {
@@ -1121,8 +1142,7 @@ function createTonSDK(log7, db) {
1121
1142
  // ─── Utilities ───────────────────────────────────────────────
1122
1143
  toNano(amount) {
1123
1144
  try {
1124
- const { toNano: convert } = __require("@ton/ton");
1125
- return convert(String(amount));
1145
+ return tonToNano(String(amount));
1126
1146
  } catch (err) {
1127
1147
  throw new PluginSDKError(
1128
1148
  `toNano conversion failed: ${err instanceof Error ? err.message : String(err)}`,
@@ -1131,13 +1151,11 @@ function createTonSDK(log7, db) {
1131
1151
  }
1132
1152
  },
1133
1153
  fromNano(nano) {
1134
- const { fromNano: convert } = __require("@ton/ton");
1135
- return convert(nano);
1154
+ return tonFromNano(nano);
1136
1155
  },
1137
1156
  validateAddress(address) {
1138
1157
  try {
1139
- const { Address: Address2 } = __require("@ton/core");
1140
- Address2.parse(address);
1158
+ TonAddress.parse(address);
1141
1159
  return true;
1142
1160
  } catch {
1143
1161
  return false;
@@ -42,7 +42,7 @@ import {
42
42
  writePluginSecret,
43
43
  writeRawConfig,
44
44
  writeSummaryToDailyLog
45
- } from "./chunk-HZNZT4TG.js";
45
+ } from "./chunk-JHKWHGBM.js";
46
46
  import {
47
47
  getKeyPair,
48
48
  getTonPrice,
@@ -21398,7 +21398,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
21398
21398
  );
21399
21399
  if (this.config.webui.enabled) {
21400
21400
  try {
21401
- const { WebUIServer } = await import("./server-DS5OARW6.js");
21401
+ const { WebUIServer } = await import("./server-NPSODUMA.js");
21402
21402
  const mcpServers = () => Object.entries(this.config.mcp.servers).map(([name, serverConfig]) => {
21403
21403
  const type = serverConfig.command ? "stdio" : serverConfig.url ? "streamable-http" : "sse";
21404
21404
  const target = serverConfig.command ?? serverConfig.url ?? "";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TelegramUserClient,
3
3
  main
4
- } from "../chunk-3YM57ZAV.js";
4
+ } from "../chunk-VSMUAU5X.js";
5
5
  import "../chunk-UDD7FYOU.js";
6
6
  import "../chunk-EHEV7FJ7.js";
7
7
  import "../chunk-U7FQYCBQ.js";
@@ -14,7 +14,7 @@ import {
14
14
  readRawConfig,
15
15
  setNestedValue,
16
16
  writeRawConfig
17
- } from "../chunk-HZNZT4TG.js";
17
+ } from "../chunk-JHKWHGBM.js";
18
18
  import {
19
19
  ConfigSchema,
20
20
  DealsConfigSchema,
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  TeletonApp,
3
3
  main
4
- } from "./chunk-3YM57ZAV.js";
4
+ } from "./chunk-VSMUAU5X.js";
5
5
  import "./chunk-UDD7FYOU.js";
6
6
  import "./chunk-EHEV7FJ7.js";
7
7
  import "./chunk-U7FQYCBQ.js";
8
- import "./chunk-HZNZT4TG.js";
8
+ import "./chunk-JHKWHGBM.js";
9
9
  import "./chunk-NERLQY2H.js";
10
10
  import "./chunk-QUAPFI2N.js";
11
11
  import "./chunk-TSKJCWQQ.js";
@@ -16,7 +16,7 @@ import {
16
16
  validateWritePath,
17
17
  writePluginSecret,
18
18
  writeRawConfig
19
- } from "./chunk-HZNZT4TG.js";
19
+ } from "./chunk-JHKWHGBM.js";
20
20
  import "./chunk-NERLQY2H.js";
21
21
  import "./chunk-QUAPFI2N.js";
22
22
  import "./chunk-TSKJCWQQ.js";
@@ -609,11 +609,8 @@ import { Hono as Hono6 } from "hono";
609
609
  function createPluginsRoutes(deps) {
610
610
  const app = new Hono6();
611
611
  app.get("/", (c) => {
612
- const response = {
613
- success: true,
614
- data: deps.plugins
615
- };
616
- return c.json(response);
612
+ const data = deps.marketplace ? deps.marketplace.modules.filter((m) => deps.toolRegistry.isPluginModule(m.name)).map((m) => ({ name: m.name, version: m.version ?? "0.0.0" })) : deps.plugins;
613
+ return c.json({ success: true, data });
617
614
  });
618
615
  return app;
619
616
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleton",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "workspaces": [
5
5
  "packages/*"
6
6
  ],