@typus/typus-sdk 0.3.7 → 0.3.9

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,3 @@
1
1
  export declare function getBidEventsCranker(type: string, renewSec: number): Promise<void>;
2
2
  export declare function getNewAuctionEventsCranker(type: string, renewSec: number): Promise<void>;
3
+ export declare function sendEventToTelegramChannel(text: any): Promise<void>;
@@ -39,27 +39,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
42
+ exports.sendEventToTelegramChannel = exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
43
43
  var constants_1 = require("../constants");
44
44
  var sui_js_1 = require("@mysten/sui.js");
45
45
  var node_cron_1 = __importDefault(require("node-cron"));
46
+ var XMLHttpRequest_1 = require("XMLHttpRequest");
46
47
  var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
48
+ var apiToken = "5864284783:AAHwXWgt2YgLENdJ9mVBUDBVLHXrMLNgkic";
49
+ /*
50
+ 「https://api.telegram.org/botTOKEN/getUpdates」,change TOKEN to token from botFather
51
+ */
52
+ var chatId = "-1001784476809";
47
53
  (function () { return __awaiter(void 0, void 0, void 0, function () {
48
54
  var bidType, newAuctionType, renewSec;
49
55
  return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0:
52
- bidType = constants_1.DOV_PACKAGE + "::dutch::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
53
- newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
54
- renewSec = 10;
55
- return [4 /*yield*/, getBidEventsCranker(bidType, renewSec)];
56
- case 1:
57
- _a.sent();
58
- return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec)];
59
- case 2:
60
- _a.sent();
61
- return [2 /*return*/];
62
- }
56
+ bidType = constants_1.DOV_PACKAGE + "::dutch::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
57
+ newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
58
+ renewSec = 10;
59
+ return [2 /*return*/];
63
60
  });
64
61
  }); })();
65
62
  function getBidEventsCranker(type, renewSec) {
@@ -108,3 +105,19 @@ function getNewAuctionEventsCranker(type, renewSec) {
108
105
  });
109
106
  }
110
107
  exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
108
+ function sendEventToTelegramChannel(text) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ var urlString, request;
111
+ return __generator(this, function (_a) {
112
+ urlString = "https://api.telegram.org/bot".concat(apiToken, "/sendMessage?chat_id=").concat(chatId, "&text=").concat(text);
113
+ request = new XMLHttpRequest_1.XMLHttpRequest();
114
+ request.open("GET", urlString);
115
+ request.send();
116
+ request.onload = function () {
117
+ console.log(JSON.parse(request.responseText));
118
+ };
119
+ return [2 /*return*/];
120
+ });
121
+ });
122
+ }
123
+ exports.sendEventToTelegramChannel = sendEventToTelegramChannel;
@@ -60,7 +60,7 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
60
60
  case 1:
61
61
  typeArgument = _a.sent();
62
62
  console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...");
63
- return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, isRolling, token, depositAmount)];
63
+ return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, token, depositAmount)];
64
64
  case 2:
65
65
  depositTx = _a.sent();
66
66
  return [4 /*yield*/, signer.executeMoveCall(depositTx)];
@@ -401,7 +401,7 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
401
401
  switch (_a.label) {
402
402
  case 0:
403
403
  _a.trys.push([0, 3, , 4]);
404
- return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), isRolling, token, depositAmount.toString())];
404
+ return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), token, depositAmount.toString())];
405
405
  case 1:
406
406
  depositTx = _a.sent();
407
407
  return [4 /*yield*/, signer.executeMoveCall(depositTx)];
@@ -67,7 +67,7 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
67
67
  return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)];
68
68
  case 1:
69
69
  typeArgument = _a.sent();
70
- return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, isRolling, token, depositAmount)];
70
+ return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, token, depositAmount)];
71
71
  case 2:
72
72
  depositTx = _a.sent();
73
73
  return [4 /*yield*/, signer.executeMoveCall(depositTx)];
@@ -57,7 +57,7 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
57
57
  case 1:
58
58
  typeArgument = _a.sent();
59
59
  console.log("test for withdraw, try to withdraw " + token + " for " + withdrawAmount + " ...");
60
- return [4 /*yield*/, (0, getWithdrawTx_1.getWithdrawTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), isRolling, withdrawAmount.toString())];
60
+ return [4 /*yield*/, (0, getWithdrawTx_1.getWithdrawTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), withdrawAmount.toString())];
61
61
  case 2:
62
62
  withdrawTx = _a.sent();
63
63
  return [4 /*yield*/, signer.executeMoveCall(withdrawTx)];
@@ -1 +1 @@
1
- export declare function getDepositTx(packageId: string, registry: string, typeArgument: string, vaultIndex: string, isRolling: Boolean, coin: string, amount: string): Promise<any>;
1
+ export declare function getDepositTx(packageId: string, registry: string, typeArgument: string, vaultIndex: string, coin: string, amount: string): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getDepositTx = void 0;
40
- function getDepositTx(packageId, registry, typeArgument, vaultIndex, isRolling, coin, amount) {
40
+ function getDepositTx(packageId, registry, typeArgument, vaultIndex, coin, amount) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -51,7 +51,6 @@ function getDepositTx(packageId, registry, typeArgument, vaultIndex, isRolling,
51
51
  vaultIndex,
52
52
  coin,
53
53
  amount,
54
- isRolling,
55
54
  ],
56
55
  gasBudget: 10000,
57
56
  };
@@ -1 +1 @@
1
- export declare function getWithdrawTx(packageId: string, registry: string, typeArgument: string, vaultIndex: string, isRolling: Boolean, amount: string): Promise<any>;
1
+ export declare function getWithdrawTx(packageId: string, registry: string, typeArgument: string, vaultIndex: string, share: string): Promise<any>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getWithdrawTx = void 0;
40
- function getWithdrawTx(packageId, registry, typeArgument, vaultIndex, isRolling, amount) {
40
+ function getWithdrawTx(packageId, registry, typeArgument, vaultIndex, share) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
@@ -49,8 +49,7 @@ function getWithdrawTx(packageId, registry, typeArgument, vaultIndex, isRolling,
49
49
  arguments: [
50
50
  registry,
51
51
  vaultIndex,
52
- amount,
53
- isRolling,
52
+ share,
54
53
  ],
55
54
  gasBudget: 1000,
56
55
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "0.3.7",
5
+ "version": "0.3.9",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
8
  "@mysten/sui.js": "^0.20.0",
@@ -49,7 +49,8 @@
49
49
  "tslib": "^1.14.1",
50
50
  "tsutils": "^2.29.0",
51
51
  "wrappy": "^1.0.2",
52
- "ws": "^8.11.0"
52
+ "ws": "^8.11.0",
53
+ "xmlhttprequest": "^1.8.0"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@types/bs58": "^4.0.1",