@pioneer-platform/ton-network 8.11.0 → 8.11.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.
@@ -1,2 +1 @@
1
-
2
- $ tsc -p .
1
+ $ tsc -p .
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @pioneer-platform/ton-network
2
+
3
+ ## 8.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: move @types/pdfkit to dependencies for Docker --production build
8
+
9
+ ## 8.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - chore: chore: fix: 📦 Add tsoa.json to Docker build
package/lib/index.js CHANGED
@@ -168,6 +168,14 @@ module.exports = {
168
168
  getWalletSeqno: function (address) {
169
169
  return get_wallet_seqno(address);
170
170
  },
171
+ /**
172
+ * Get account info for transaction building
173
+ * Returns data needed to build transactions: seqno, balance, wallet_version
174
+ * @param address - TON address
175
+ */
176
+ getAccountInfo: function (address) {
177
+ return get_account_info_for_tx(address);
178
+ },
171
179
  /**
172
180
  * Broadcast a signed transaction (BOC)
173
181
  * @param boc - Base64 encoded BOC (Bag of Cells)
@@ -486,3 +494,82 @@ function get_masterchain_info() {
486
494
  });
487
495
  });
488
496
  }
497
+ function get_account_info_for_tx(address) {
498
+ return __awaiter(this, void 0, void 0, function () {
499
+ var tag, seqno, addressInfo, walletVersion, pubKeyResponse, addressInfoDetailed, code, e_9, e_10;
500
+ var _a;
501
+ return __generator(this, function (_b) {
502
+ switch (_b.label) {
503
+ case 0:
504
+ tag = TAG + " | get_account_info_for_tx | ";
505
+ _b.label = 1;
506
+ case 1:
507
+ _b.trys.push([1, 10, , 11]);
508
+ log.debug(tag, "Getting account info for transaction building:", address);
509
+ return [4 /*yield*/, get_wallet_seqno(address)
510
+ // Get address info for balance and state
511
+ ];
512
+ case 2:
513
+ seqno = _b.sent();
514
+ return [4 /*yield*/, get_address_info(address)
515
+ // Determine wallet version by querying the contract
516
+ ];
517
+ case 3:
518
+ addressInfo = _b.sent();
519
+ walletVersion = 'v4' // Default to v4 as it's most common
520
+ ;
521
+ _b.label = 4;
522
+ case 4:
523
+ _b.trys.push([4, 8, , 9]);
524
+ return [4 /*yield*/, axios({
525
+ url: "".concat(apiUrl, "/runGetMethod"),
526
+ method: 'POST',
527
+ headers: getHeaders(),
528
+ data: {
529
+ address: address,
530
+ method: "get_public_key",
531
+ stack: []
532
+ }
533
+ })
534
+ // If get_public_key exists, it's likely a standard wallet
535
+ ];
536
+ case 5:
537
+ pubKeyResponse = _b.sent();
538
+ if (!(pubKeyResponse.data && pubKeyResponse.data.ok)) return [3 /*break*/, 7];
539
+ return [4 /*yield*/, axios({
540
+ url: "".concat(apiUrl, "/getAddressInformation"),
541
+ method: 'GET',
542
+ headers: getHeaders(),
543
+ params: { address: address }
544
+ })];
545
+ case 6:
546
+ addressInfoDetailed = _b.sent();
547
+ if (addressInfoDetailed.data && addressInfoDetailed.data.ok) {
548
+ code = addressInfoDetailed.data.result.code;
549
+ // Different wallet versions have different code hashes
550
+ // This is a simplified check - you'd want to compare actual code hashes
551
+ if (code) {
552
+ walletVersion = 'v4'; // Default assumption
553
+ }
554
+ }
555
+ _b.label = 7;
556
+ case 7: return [3 /*break*/, 9];
557
+ case 8:
558
+ e_9 = _b.sent();
559
+ // If detection fails, stick with default v4
560
+ log.debug(tag, "Could not detect wallet version, using default v4");
561
+ return [3 /*break*/, 9];
562
+ case 9: return [2 /*return*/, {
563
+ seqno: seqno !== null ? seqno : 0,
564
+ balance: ((_a = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.balance) === null || _a === void 0 ? void 0 : _a.toString()) || '0',
565
+ wallet_version: walletVersion
566
+ }];
567
+ case 10:
568
+ e_10 = _b.sent();
569
+ log.error(tag, "Error getting account info for tx:", e_10.message);
570
+ throw e_10;
571
+ case 11: return [2 /*return*/];
572
+ }
573
+ });
574
+ });
575
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/ton-network",
3
- "version": "8.11.0",
3
+ "version": "8.11.2",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "Pioneer Platform TON Network module",