@typus/typus-sdk 0.4.8 → 0.4.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.
- package/lib/constants.d.ts +30 -0
- package/lib/constants.js +38 -0
- package/lib/scripts/getSubVault.d.ts +0 -0
- package/lib/scripts/getSubVault.js +6 -0
- package/lib/scripts/sui.d.ts +1 -0
- package/lib/scripts/sui.js +187 -0
- package/lib/test/eventListener.d.ts +5 -0
- package/lib/test/eventListener.js +294 -0
- package/lib/test/getBidData.d.ts +1 -0
- package/lib/test/getBidData.js +53 -0
- package/lib/test/getMakersShares.d.ts +1 -0
- package/lib/test/getMakersShares.js +52 -0
- package/lib/test/getUsersShares.d.ts +1 -0
- package/lib/test/getUsersShares.js +52 -0
- package/lib/test/getVaultData.d.ts +1 -0
- package/lib/test/getVaultData.js +53 -0
- package/lib/test/testClaim.d.ts +1 -0
- package/lib/test/testClaim.js +81 -0
- package/lib/test/testCrypto.d.ts +1 -0
- package/lib/test/testCrypto.js +54 -0
- package/lib/test/testDeposit.d.ts +1 -0
- package/lib/test/testDeposit.js +73 -0
- package/lib/test/testDepositV2.d.ts +0 -0
- package/lib/test/testDepositV2.js +62 -0
- package/lib/test/testMint.d.ts +1 -0
- package/lib/test/testMint.js +136 -0
- package/lib/test/testNewAuction.d.ts +1 -0
- package/lib/test/testNewAuction.js +93 -0
- package/lib/test/testNewVault.d.ts +1 -0
- package/lib/test/testNewVault.js +152 -0
- package/lib/test/testOracle.d.ts +1 -0
- package/lib/test/testOracle.js +93 -0
- package/lib/test/testSettle.d.ts +1 -0
- package/lib/test/testSettle.js +589 -0
- package/lib/test/testSubscribeEvent.d.ts +1 -0
- package/lib/test/testSubscribeEvent.js +97 -0
- package/lib/test/testUnsubscribe.d.ts +1 -0
- package/lib/test/testUnsubscribe.js +87 -0
- package/lib/test/testWithdraw.d.ts +1 -0
- package/lib/test/testWithdraw.js +70 -0
- package/lib/utils/auction/getBid.d.ts +2 -0
- package/lib/utils/auction/getBid.js +79 -0
- package/lib/utils/auction/sealedAuction.d.ts +33 -0
- package/lib/utils/auction/sealedAuction.js +64 -0
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedDeliveryTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedEvolutionTx.js +63 -0
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +62 -0
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +61 -0
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +77 -0
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedSettleTx.js +61 -0
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +65 -0
- package/lib/utils/coveredCall/createPriceOracle.d.ts +1 -0
- package/lib/utils/coveredCall/createPriceOracle.js +92 -0
- package/lib/utils/coveredCall/createTimeOracle.d.ts +1 -0
- package/lib/utils/coveredCall/createTimeOracle.js +91 -0
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +61 -0
- package/lib/utils/coveredCall/getClaimAllTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimAllTx.js +59 -0
- package/lib/utils/coveredCall/getClaimTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimTx.js +59 -0
- package/lib/utils/coveredCall/getDeliveryTx.d.ts +1 -0
- package/lib/utils/coveredCall/getDeliveryTx.js +61 -0
- package/lib/utils/coveredCall/getDepositTx.d.ts +1 -0
- package/lib/utils/coveredCall/getDepositTx.js +65 -0
- package/lib/utils/coveredCall/getEvolutionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getEvolutionTx.js +64 -0
- package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getLastEvolutionTx.js +63 -0
- package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +1 -0
- package/lib/utils/coveredCall/getMakerClaimAllTx.js +59 -0
- package/lib/utils/coveredCall/getMakerClaimTx.d.ts +1 -0
- package/lib/utils/coveredCall/getMakerClaimTx.js +59 -0
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewAuctionTx.js +66 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +64 -0
- package/lib/utils/coveredCall/getNewBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewBidTx.js +62 -0
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +77 -0
- package/lib/utils/coveredCall/getNewManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewManagerTx.js +59 -0
- package/lib/utils/coveredCall/getRefundTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRefundTx.js +59 -0
- package/lib/utils/coveredCall/getRemoveBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveBidTx.js +60 -0
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +61 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.js +58 -0
- package/lib/utils/coveredCall/getRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRollOverTx.js +60 -0
- package/lib/utils/coveredCall/getSettleTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleTx.js +62 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +62 -0
- package/lib/utils/coveredCall/getSubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSubscribeTx.js +60 -0
- package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUnsubscribeTx.js +63 -0
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +66 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +62 -0
- package/lib/utils/coveredCall/getWithdrawTx.d.ts +1 -0
- package/lib/utils/coveredCall/getWithdrawTx.js +60 -0
- package/lib/utils/fetchData.d.ts +83 -0
- package/lib/utils/fetchData.js +206 -0
- package/lib/utils/getCreateTokenRegistryTx.d.ts +1 -0
- package/lib/utils/getCreateTokenRegistryTx.js +59 -0
- package/lib/utils/getMakersShares.d.ts +7 -0
- package/lib/utils/getMakersShares.js +148 -0
- package/lib/utils/getMintTx.d.ts +1 -0
- package/lib/utils/getMintTx.js +62 -0
- package/lib/utils/getNewOracleTx.d.ts +1 -0
- package/lib/utils/getNewOracleTx.js +59 -0
- package/lib/utils/getNewTimeOracleTx.d.ts +1 -0
- package/lib/utils/getNewTimeOracleTx.js +56 -0
- package/lib/utils/getTypeArgumentFromToken.d.ts +1 -0
- package/lib/utils/getTypeArgumentFromToken.js +71 -0
- package/lib/utils/getUpdateOracleTx.d.ts +1 -0
- package/lib/utils/getUpdateOracleTx.js +64 -0
- package/lib/utils/getUpdateTimeOracleTx.d.ts +1 -0
- package/lib/utils/getUpdateTimeOracleTx.js +60 -0
- package/lib/utils/getUsersShares.d.ts +8 -0
- package/lib/utils/getUsersShares.js +147 -0
- package/lib/utils/getVaultData.d.ts +3 -0
- package/lib/utils/getVaultData.js +262 -0
- package/lib/utils/getVaultIndexInRegistry.d.ts +1 -0
- package/lib/utils/getVaultIndexInRegistry.js +61 -0
- package/lib/utils/isObjAvailable.d.ts +0 -0
- package/lib/utils/isObjAvailable.js +14 -0
- package/lib/utils/loadUsersDepositData.d.ts +8 -0
- package/lib/utils/loadUsersDepositData.js +160 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const TOKEN_PACKAGE = "0xa1d0cdb1b41c786d53a03d30340ab05718010e04";
|
|
2
|
+
export declare const TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
|
|
3
|
+
export declare const TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
|
|
4
|
+
export declare const TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
|
|
5
|
+
export declare const TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
|
|
6
|
+
export declare const TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
|
|
7
|
+
export declare const TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
|
|
8
|
+
export declare const ORACLE_PACKAGE = "0x0a55a6dfa713f83cb3be5e3ca8a8435ccdbb500d";
|
|
9
|
+
export declare const TIME_ORACLE = "0x38a0254841edf9532ae51def6b46f1b34725bdaa";
|
|
10
|
+
export declare const COVERED_CALL_PACKAGE = "0x503ac615e4844aa31b5e3ca2feadea0d74e1b8af";
|
|
11
|
+
export declare const COVERED_CALL_REGISTRY = "0xdf5e52550dc82396ea48a97dbbec65322779db77";
|
|
12
|
+
export declare const COVERED_CALL_MANAGER = "0x9be7316b23f19c89073852ad7b8881f8cc89f727";
|
|
13
|
+
export declare const USER_SHARE_TABLE = "0xd41260528fe89a571cbcabeefd9c5bd560f01b07";
|
|
14
|
+
export declare const USER_REFUND_TABLE = "0xca101b960ca0f71f5d7c090a912e70a22a7b3587";
|
|
15
|
+
export declare const MAKER_SHARE_TABLE = "0xe66a7a0051082bdc728077ac6309a7baee208f57";
|
|
16
|
+
export declare const DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
|
|
17
|
+
export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
18
|
+
export declare const PRICE_DECIMAL = 8;
|
|
19
|
+
export declare const TOKEN_DECIMAL = 9;
|
|
20
|
+
export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
21
|
+
export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
22
|
+
export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
|
23
|
+
export declare const TOKEN_NAME: string[];
|
|
24
|
+
export declare const TOKEN_NAME_TO_MODULE: {
|
|
25
|
+
BTC: string;
|
|
26
|
+
ETH: string;
|
|
27
|
+
SUI: string;
|
|
28
|
+
USDC: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const TESTNET_RPC_ENDPOINT = "https://fullnode.testnet.sui.io:443";
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TESTNET_RPC_ENDPOINT = exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TOKEN_DECIMAL = exports.PRICE_DECIMAL = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_REFUND_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.TIME_ORACLE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_USDC = exports.TOKEN_REGISTRY_DOGE = exports.TOKEN_REGISTRY_APT = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
|
|
4
|
+
//publish from sui-dev-token
|
|
5
|
+
exports.TOKEN_PACKAGE = "0xa1d0cdb1b41c786d53a03d30340ab05718010e04";
|
|
6
|
+
exports.TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
|
|
7
|
+
exports.TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
|
|
8
|
+
exports.TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
|
|
9
|
+
exports.TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
|
|
10
|
+
exports.TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
|
|
11
|
+
exports.TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
|
|
12
|
+
//publish from typus-oracle
|
|
13
|
+
exports.ORACLE_PACKAGE = "0x0a55a6dfa713f83cb3be5e3ca8a8435ccdbb500d";
|
|
14
|
+
exports.TIME_ORACLE = '0x38a0254841edf9532ae51def6b46f1b34725bdaa';
|
|
15
|
+
//publish from typus-dov/cover_call
|
|
16
|
+
exports.COVERED_CALL_PACKAGE = "0x503ac615e4844aa31b5e3ca2feadea0d74e1b8af";
|
|
17
|
+
exports.COVERED_CALL_REGISTRY = "0xdf5e52550dc82396ea48a97dbbec65322779db77";
|
|
18
|
+
exports.COVERED_CALL_MANAGER = "0x9be7316b23f19c89073852ad7b8881f8cc89f727";
|
|
19
|
+
exports.USER_SHARE_TABLE = "0xd41260528fe89a571cbcabeefd9c5bd560f01b07";
|
|
20
|
+
exports.USER_REFUND_TABLE = "0xca101b960ca0f71f5d7c090a912e70a22a7b3587";
|
|
21
|
+
exports.MAKER_SHARE_TABLE = "0xe66a7a0051082bdc728077ac6309a7baee208f57";
|
|
22
|
+
//publish from typus-dov/typus-dov
|
|
23
|
+
exports.DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
|
|
24
|
+
exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
25
|
+
exports.PRICE_DECIMAL = 8;
|
|
26
|
+
exports.TOKEN_DECIMAL = 9;
|
|
27
|
+
exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
28
|
+
exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
29
|
+
exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
|
30
|
+
exports.TOKEN_NAME = ["BTC", "ETH", "SUI", "USDC", "USDT", "SUI"];
|
|
31
|
+
exports.TOKEN_NAME_TO_MODULE = {
|
|
32
|
+
"BTC": "btc",
|
|
33
|
+
"ETH": "eth",
|
|
34
|
+
"SUI": "sui",
|
|
35
|
+
"USDC": "usdc",
|
|
36
|
+
// "USDT": "token_usdt",
|
|
37
|
+
};
|
|
38
|
+
exports.TESTNET_RPC_ENDPOINT = "https://fullnode.testnet.sui.io:443";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
7
|
+
var fs_1 = __importDefault(require("fs"));
|
|
8
|
+
var constants_1 = require("../constants");
|
|
9
|
+
var execSync = require('child_process').execSync;
|
|
10
|
+
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
11
|
+
var owner = "0xd28103a499003bed0b1b9ee52988ecdd2db82224";
|
|
12
|
+
var obj1 = "0x7e9e58daeb94bbd0450bb9ee9f00e219a1f2b734"; //obj owned by owner
|
|
13
|
+
var obj2 = "0x74aa838eb6627c8e74b0645484abb463e6fd6669"; //obj owned by owner
|
|
14
|
+
var obj1Digest = "tclmc0L6hewmfWxQAxSl9eUe14C82+hzE4OblKgY38U=";
|
|
15
|
+
var obj2Digest = "tclmc0L6hewmfWxQAxSl9eUe14C82+hzE4OblKgY38U=";
|
|
16
|
+
var receiver = "0x15ca0895f29101085cb26e00ede89420741b3140";
|
|
17
|
+
var tx1 = "GRiBgktRqgJ4MSoRhCfSm/+1R/Zh9jy4UncoQeFAu5I=";
|
|
18
|
+
// export PRIVATEKEY=~/.sui/sui_config/sui.keystore
|
|
19
|
+
var secretKeysPath = process.env.PRIVATEKEY;
|
|
20
|
+
var subVault = "0xd3b2d3ee74afe2b5af0f810b3368955f068188e8";
|
|
21
|
+
var TEST_MNEMONIC = "tackle wheat jungle viable memory dwarf swift fold purpose cattle impose horn";
|
|
22
|
+
var VALID_SECRET_KEY = "Itk7iNFs91kXKdqVqmLrBKJItNIoSyWAOh+ZC2qaSihpxiAxNYwKPjwfresk9CSbKCmwNwvXfPQoeLL4rVa4OQ=="; //'mdqVWeFekT7pqy5T49+tV12jO0m+ESW7ki4zSU9JiCgbL0kJbj5dvQ/PqcDAzZLZqzshVEs01d1KZdmLh4uZIg==';
|
|
23
|
+
// let secretKeys = (readJsonFile<any>(secretKeysPath as string))
|
|
24
|
+
// let sender = secretKeys[0]
|
|
25
|
+
// let keypair = Ed25519Keypair.fromSecretKey(fromB64(sender))// Error: Wrong secretKey size. Expected 64 bytes, got 65.
|
|
26
|
+
// let keypair = Ed25519Keypair.fromSecretKey(fromB64(VALID_SECRET_KEY))
|
|
27
|
+
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(TEST_MNEMONIC);
|
|
28
|
+
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
29
|
+
function readJsonFile(filePath) {
|
|
30
|
+
return JSON.parse(fs_1.default.readFileSync(filePath, "utf-8"));
|
|
31
|
+
}
|
|
32
|
+
// //Success
|
|
33
|
+
// (async () => {
|
|
34
|
+
// console.log("test for getObjectsOwnedByAddress()")
|
|
35
|
+
// const objects = await provider.getObjectsOwnedByAddress(
|
|
36
|
+
// owner
|
|
37
|
+
// )
|
|
38
|
+
// console.log(objects)
|
|
39
|
+
// })();
|
|
40
|
+
// //Success
|
|
41
|
+
// (async () => {
|
|
42
|
+
// console.log("test for getObjectsOwnedByObject()")
|
|
43
|
+
// const objects = await provider.getObjectsOwnedByObject(
|
|
44
|
+
// obj1
|
|
45
|
+
// )
|
|
46
|
+
// console.log(objects)
|
|
47
|
+
// //filter obj by type
|
|
48
|
+
// for (let object of objects) {
|
|
49
|
+
// if (object.type.includes("dynamic_field")) console.log("it's dynamic field object")
|
|
50
|
+
// }
|
|
51
|
+
// })();
|
|
52
|
+
// //Success
|
|
53
|
+
// (async () => {
|
|
54
|
+
// console.log("test for getObject() and getObjectBatch()")
|
|
55
|
+
// const txn = await provider.getObject(
|
|
56
|
+
// obj1
|
|
57
|
+
// );
|
|
58
|
+
// console.log(txn)
|
|
59
|
+
// // You can also fetch multiple objects in one batch request
|
|
60
|
+
// const txns = await provider.getObjectBatch([
|
|
61
|
+
// obj1,
|
|
62
|
+
// obj2,
|
|
63
|
+
// ]);
|
|
64
|
+
// console.log(txns)
|
|
65
|
+
// })();
|
|
66
|
+
// // Fail
|
|
67
|
+
// (async () => {
|
|
68
|
+
// console.log("test for getTransactionWithEffects() and getTransactionWithEffectsBatch()")
|
|
69
|
+
// const txn = await provider.getTransactionWithEffects(
|
|
70
|
+
// obj1Digest
|
|
71
|
+
// );
|
|
72
|
+
// console.log(txn)
|
|
73
|
+
// You can also fetch multiple transactions in one batch request
|
|
74
|
+
// const txns = await provider.getTransactionWithEffectsBatch([
|
|
75
|
+
// obj1Digest,
|
|
76
|
+
// obj2Digest,
|
|
77
|
+
// ]);
|
|
78
|
+
// console.log(txns)
|
|
79
|
+
// })();
|
|
80
|
+
// //Fail (without correct signer)
|
|
81
|
+
// (async () => {
|
|
82
|
+
// console.log("test for transferObject()")
|
|
83
|
+
// const transferTxn = await signer.transferObject({
|
|
84
|
+
// objectId: obj1,
|
|
85
|
+
// gasBudget: 1000,
|
|
86
|
+
// recipient: receiver,
|
|
87
|
+
// });
|
|
88
|
+
// console.log('transferTxn', transferTxn);
|
|
89
|
+
// })();
|
|
90
|
+
// //Fail (without correct signer)
|
|
91
|
+
// (async () => {
|
|
92
|
+
// console.log("test for executeMoveCall()")
|
|
93
|
+
// const moveCallTxn = await signer.executeMoveCall({
|
|
94
|
+
// packageObjectId: '0x2',
|
|
95
|
+
// module: 'devnet_nft',
|
|
96
|
+
// function: 'mint',
|
|
97
|
+
// typeArguments: [],
|
|
98
|
+
// arguments: [
|
|
99
|
+
// 'Example NFT',
|
|
100
|
+
// 'An NFT created by the wallet Command Line Tool',
|
|
101
|
+
// 'ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty',
|
|
102
|
+
// ],
|
|
103
|
+
// gasBudget: 10000,
|
|
104
|
+
// });
|
|
105
|
+
// console.log('moveCallTxn', moveCallTxn);
|
|
106
|
+
// })();
|
|
107
|
+
// //Fail( Error subscribing to event)
|
|
108
|
+
// (async () => {
|
|
109
|
+
// console.log("test for subscribeEvent()")
|
|
110
|
+
// // calls RPC method 'sui_subscribeEvent' with params:
|
|
111
|
+
// // [ { SenderAddress: '0xbff6ccc8707aa517b4f1b95750a2a8c666012df3' } ]
|
|
112
|
+
// const subscriptionId = await provider.subscribeEvent(
|
|
113
|
+
// { SenderAddress: '0xbff6ccc8707aa517b4f1b95750a2a8c666012df3' },
|
|
114
|
+
// (event: SuiEventEnvelope) => {
|
|
115
|
+
// console.log(event)
|
|
116
|
+
// // handle subscription notification message here. This function is called once per subscription message.
|
|
117
|
+
// }
|
|
118
|
+
// );
|
|
119
|
+
// // later, to unsubscribe
|
|
120
|
+
// // calls RPC method 'sui_unsubscribeEvent' with params: [ subscriptionId ]
|
|
121
|
+
// const subFoundAndRemoved = await provider.unsubscribeEvent(subscriptionId);
|
|
122
|
+
// })();
|
|
123
|
+
// //Fail (without correct signer)
|
|
124
|
+
//refer: https://docs.sui.io/build/json-rpc
|
|
125
|
+
// (async () => {
|
|
126
|
+
// console.log("test for publish()")
|
|
127
|
+
// const compiledModules = JSON.parse(
|
|
128
|
+
// execSync(
|
|
129
|
+
// `${cliPath} move build --dump-bytecode-as-base64 --path ${packagePath}`,
|
|
130
|
+
// { encoding: 'utf-8' }
|
|
131
|
+
// )
|
|
132
|
+
// );
|
|
133
|
+
// const modulesInBytes = compiledModules.map((m) =>
|
|
134
|
+
// Array.from(new Base64DataBuffer(m).getData())
|
|
135
|
+
// );
|
|
136
|
+
// const publishTxn = await signer.publish({
|
|
137
|
+
// compiledModules: modulesInBytes,
|
|
138
|
+
// gasBudget: 10000,
|
|
139
|
+
// });
|
|
140
|
+
// console.log('publishTxn', publishTxn);
|
|
141
|
+
// })();
|
|
142
|
+
// //Success
|
|
143
|
+
// (async () => {
|
|
144
|
+
// console.log("test for getTransactions()") // return digest
|
|
145
|
+
// let txs = await provider.getTransactionsForObject(
|
|
146
|
+
// obj1
|
|
147
|
+
// )
|
|
148
|
+
// console.log(txs)
|
|
149
|
+
// let tx = await provider.getTransactionWithEffects(
|
|
150
|
+
// txs[0]
|
|
151
|
+
// )
|
|
152
|
+
// console.log(tx)
|
|
153
|
+
// })();
|
|
154
|
+
// //Success
|
|
155
|
+
// (async () => {
|
|
156
|
+
// console.log("test for getEvents()")//input type: EventQuery
|
|
157
|
+
// const senderEvents = await provider.getEvents(
|
|
158
|
+
// { "Transaction": tx1 },
|
|
159
|
+
// null,
|
|
160
|
+
// null,
|
|
161
|
+
// );
|
|
162
|
+
// for (let e of senderEvents.data) {
|
|
163
|
+
// console.log(e.event)
|
|
164
|
+
// }
|
|
165
|
+
// })();
|
|
166
|
+
// let packageId = "0xfbbdd33ab4c02e7a315e2477931bae4cbdf46381";
|
|
167
|
+
// let registry = "0x0a9d87a1b6c00415708d2f1c62784b52f797213c";
|
|
168
|
+
// let coin = "0x84e5c5702bfbb00a830fb43e720a3a412cc2a8db";
|
|
169
|
+
// console.log("test for deposit()")
|
|
170
|
+
// await deposit(packageId, registry, coin)
|
|
171
|
+
// async function deposit(packageId: string, registry: string, coin: string) {
|
|
172
|
+
// let txn = {
|
|
173
|
+
// packageObjectId: packageId,
|
|
174
|
+
// module: 'shark_fin',
|
|
175
|
+
// function: 'deposit',
|
|
176
|
+
// typeArguments: ["0x2::sui::SUI"],
|
|
177
|
+
// arguments: [
|
|
178
|
+
// registry,
|
|
179
|
+
// 0,
|
|
180
|
+
// true,
|
|
181
|
+
// coin
|
|
182
|
+
// ],
|
|
183
|
+
// gasBudget: 1000,
|
|
184
|
+
// }
|
|
185
|
+
// const moveCallTxn = await signer.executeMoveCall(txn);
|
|
186
|
+
// console.log('moveCallTxn', moveCallTxn);
|
|
187
|
+
// }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CoveredCallVault } from '../utils/fetchData';
|
|
2
|
+
export declare function getBidEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
|
|
3
|
+
export declare function getNewAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
|
|
4
|
+
export declare function getEndAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
|
|
5
|
+
export declare function sendEventToTelegramChannel(text: any): Promise<void>;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.sendEventToTelegramChannel = exports.getEndAuctionEventsCranker = exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
|
|
43
|
+
var constants_1 = require("../constants");
|
|
44
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
45
|
+
var getVaultData_1 = require("../utils/getVaultData");
|
|
46
|
+
var node_cron_1 = __importDefault(require("node-cron"));
|
|
47
|
+
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
|
|
48
|
+
var moment_1 = __importDefault(require("moment"));
|
|
49
|
+
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
50
|
+
var apiToken = process.env.API_TOKEN;
|
|
51
|
+
var chatId = process.env.CHAT_ID;
|
|
52
|
+
/*
|
|
53
|
+
「https://api.telegram.org/botTOKEN/getUpdates」,change TOKEN to token from botFather
|
|
54
|
+
*/
|
|
55
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var bidTypes, newAuctionType, endAuctionType, renewSec, vault;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
bidTypes = [
|
|
61
|
+
constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>",
|
|
62
|
+
constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::btc::BTC>",
|
|
63
|
+
constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
|
|
64
|
+
];
|
|
65
|
+
newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
|
|
66
|
+
endAuctionType = constants_1.DOV_PACKAGE + "::dutch::Delivery<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
|
|
67
|
+
renewSec = 10;
|
|
68
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY)];
|
|
69
|
+
case 1:
|
|
70
|
+
vault = _a.sent();
|
|
71
|
+
bidTypes.map(function (bidType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, vault)]; //new_bid
|
|
75
|
+
case 1:
|
|
76
|
+
_a.sent(); //new_bid
|
|
77
|
+
return [2 /*return*/];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); });
|
|
81
|
+
return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec, vault)]; //evolution
|
|
82
|
+
case 2:
|
|
83
|
+
_a.sent(); //evolution
|
|
84
|
+
return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec, vault)];
|
|
85
|
+
case 3:
|
|
86
|
+
_a.sent();
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); })();
|
|
91
|
+
function twoObjArrAreSame(x, y) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
if (JSON.stringify(x) === JSON.stringify(y)) {
|
|
95
|
+
return [2 /*return*/, true];
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return [2 /*return*/, false];
|
|
99
|
+
}
|
|
100
|
+
return [2 /*return*/];
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function generateBidId(vault) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var liveVault, res;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
liveVault = vault === null || vault === void 0 ? void 0 : vault.filter(function (v) {
|
|
109
|
+
var start = moment_1.default.unix(Number(v.config.activationTsMs) / 1000);
|
|
110
|
+
var settled = v.vault.ableToDeposit === false && v.vault.ableToWithdraw === true;
|
|
111
|
+
return start.isBefore((0, moment_1.default)()) && !settled;
|
|
112
|
+
});
|
|
113
|
+
res = liveVault.map(function (v) {
|
|
114
|
+
var time = v.config.expirationTsMs;
|
|
115
|
+
var expiration = moment_1.default
|
|
116
|
+
.unix(Number(time) / 1000)
|
|
117
|
+
.format("DDMMMYY");
|
|
118
|
+
var bidId = "".concat(v.asset, "-").concat(expiration, "-").concat(v.config.payoffConfig.strike, "-C");
|
|
119
|
+
var obj = {
|
|
120
|
+
bidFormat: bidId,
|
|
121
|
+
bidTime: Number(time)
|
|
122
|
+
};
|
|
123
|
+
return obj;
|
|
124
|
+
});
|
|
125
|
+
return [2 /*return*/, res];
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function getBidEventsCranker(type, renewSec, vault) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
+
var res;
|
|
132
|
+
var _this = this;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
res = [];
|
|
135
|
+
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
136
|
+
var events, newRes, newBid, format_1, bidIds_1, telegramText;
|
|
137
|
+
var _this = this;
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
|
|
141
|
+
case 1:
|
|
142
|
+
events = _a.sent();
|
|
143
|
+
newRes = events.data;
|
|
144
|
+
if (!(newRes.length != res.length)) return [3 /*break*/, 3];
|
|
145
|
+
console.log("the total bid event number now: " + events.data.length);
|
|
146
|
+
console.log("there are " + (newRes.length - res.length).toString() + " new bids");
|
|
147
|
+
newBid = newRes.filter(function (_a) {
|
|
148
|
+
var id1 = _a.timestamp;
|
|
149
|
+
return !res.some(function (_a) {
|
|
150
|
+
var id2 = _a.timestamp;
|
|
151
|
+
return id2 === id1;
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
console.log("new bid amount: " + newBid.length);
|
|
155
|
+
format_1 = "";
|
|
156
|
+
return [4 /*yield*/, generateBidId(vault)];
|
|
157
|
+
case 2:
|
|
158
|
+
bidIds_1 = _a.sent();
|
|
159
|
+
// [
|
|
160
|
+
// 'ETH-18Jan23-1750-C',
|
|
161
|
+
// 'BTC-18Jan23-21800-C',
|
|
162
|
+
// 'ETH-17Jan23-1750-C',
|
|
163
|
+
// 'SUI-18Jan23-9-C'
|
|
164
|
+
// ]
|
|
165
|
+
// console.log(bidIds)
|
|
166
|
+
newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
|
|
167
|
+
var bidId, size;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
bidId = bidIds_1.find(function (bidId) {
|
|
170
|
+
var type = e.event.moveEvent.type;
|
|
171
|
+
var asset = bidId.bidFormat.split("-")[0];
|
|
172
|
+
return e.event.moveEvent.type.includes(bidId.bidFormat.split("-")[0]);
|
|
173
|
+
});
|
|
174
|
+
if (bidId) {
|
|
175
|
+
size = (Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString();
|
|
176
|
+
format_1 += bidId.bidFormat + " is bid with " + size + " " + bidId.bidFormat.split("-")[0] + "! \n";
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
console.log("can't get bidId in getBidEventsCranker");
|
|
180
|
+
}
|
|
181
|
+
return [2 /*return*/];
|
|
182
|
+
});
|
|
183
|
+
}); });
|
|
184
|
+
telegramText = format_1;
|
|
185
|
+
console.log(telegramText);
|
|
186
|
+
sendEventToTelegramChannel(telegramText);
|
|
187
|
+
res = newRes;
|
|
188
|
+
_a.label = 3;
|
|
189
|
+
case 3: return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); });
|
|
193
|
+
return [2 /*return*/];
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
exports.getBidEventsCranker = getBidEventsCranker;
|
|
198
|
+
function getNewAuctionEventsCranker(type, renewSec, vault) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
var res;
|
|
201
|
+
var _this = this;
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
res = [];
|
|
204
|
+
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
+
var events, newRes, format_2, bidIds, telegramText;
|
|
206
|
+
var _this = this;
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
switch (_a.label) {
|
|
209
|
+
case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
|
|
210
|
+
case 1:
|
|
211
|
+
events = _a.sent();
|
|
212
|
+
newRes = events.data;
|
|
213
|
+
return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
|
|
214
|
+
case 2:
|
|
215
|
+
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
216
|
+
format_2 = "";
|
|
217
|
+
return [4 /*yield*/, generateBidId(vault)];
|
|
218
|
+
case 3:
|
|
219
|
+
bidIds = _a.sent();
|
|
220
|
+
bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
format_2 += bidId.bidFormat + " auction is live now! \n";
|
|
223
|
+
return [2 /*return*/];
|
|
224
|
+
});
|
|
225
|
+
}); });
|
|
226
|
+
telegramText = format_2;
|
|
227
|
+
console.log(telegramText);
|
|
228
|
+
sendEventToTelegramChannel(telegramText);
|
|
229
|
+
res = newRes;
|
|
230
|
+
_a.label = 4;
|
|
231
|
+
case 4: return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}); });
|
|
235
|
+
return [2 /*return*/];
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
|
|
240
|
+
function getEndAuctionEventsCranker(type, renewSec, vault) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
+
var res;
|
|
243
|
+
var _this = this;
|
|
244
|
+
return __generator(this, function (_a) {
|
|
245
|
+
res = [];
|
|
246
|
+
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
247
|
+
var events, newRes, format_3, bidIds, telegramText;
|
|
248
|
+
var _this = this;
|
|
249
|
+
return __generator(this, function (_a) {
|
|
250
|
+
switch (_a.label) {
|
|
251
|
+
case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
|
|
252
|
+
case 1:
|
|
253
|
+
events = _a.sent();
|
|
254
|
+
newRes = events.data;
|
|
255
|
+
return [4 /*yield*/, twoObjArrAreSame(newRes, res)];
|
|
256
|
+
case 2:
|
|
257
|
+
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
258
|
+
format_3 = "";
|
|
259
|
+
return [4 /*yield*/, generateBidId(vault)];
|
|
260
|
+
case 3:
|
|
261
|
+
bidIds = _a.sent();
|
|
262
|
+
bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
format_3 += bidId.bidFormat + " auction is closed! \n";
|
|
265
|
+
return [2 /*return*/];
|
|
266
|
+
});
|
|
267
|
+
}); });
|
|
268
|
+
telegramText = format_3;
|
|
269
|
+
console.log(telegramText);
|
|
270
|
+
sendEventToTelegramChannel(telegramText);
|
|
271
|
+
res = newRes;
|
|
272
|
+
_a.label = 4;
|
|
273
|
+
case 4: return [2 /*return*/];
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}); });
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
exports.getEndAuctionEventsCranker = getEndAuctionEventsCranker;
|
|
282
|
+
function sendEventToTelegramChannel(text) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
+
var urlString, request;
|
|
285
|
+
return __generator(this, function (_a) {
|
|
286
|
+
urlString = "https://api.telegram.org/bot".concat(apiToken, "/sendMessage?chat_id=").concat(chatId, "&text=").concat(text);
|
|
287
|
+
request = new XMLHttpRequest();
|
|
288
|
+
request.open("GET", urlString);
|
|
289
|
+
request.send();
|
|
290
|
+
return [2 /*return*/];
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
exports.sendEventToTelegramChannel = sendEventToTelegramChannel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var getBid_1 = require("../utils/auction/getBid");
|
|
40
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var vault, bid;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
vault = "0x1e5807f118c2fc7e0f74eeb439b34f448532a900";
|
|
46
|
+
return [4 /*yield*/, (0, getBid_1.getBid)(vault)];
|
|
47
|
+
case 1:
|
|
48
|
+
bid = _a.sent();
|
|
49
|
+
console.log(bid);
|
|
50
|
+
return [2 /*return*/];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|