@clonegod/ttd-sui-common 1.0.24 → 1.0.25
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.
|
@@ -13,7 +13,6 @@ const dist_1 = require("@clonegod/ttd-core/dist");
|
|
|
13
13
|
const fs_1 = require("fs");
|
|
14
14
|
const grpc_connection_1 = require("../grpc/grpc-connection");
|
|
15
15
|
const subscription_service_1 = require("../grpc/subscription-service");
|
|
16
|
-
const checkpoint_1 = require("../utils/checkpoint");
|
|
17
16
|
const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT;
|
|
18
17
|
const grpc_token = process.env.SUI_GRPC_TOKEN;
|
|
19
18
|
const test_subscribe_checkpoints = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -47,19 +46,6 @@ const test_subscribe_checkpoints = () => __awaiter(void 0, void 0, void 0, funct
|
|
|
47
46
|
};
|
|
48
47
|
response.checkpoint.transactions.forEach((transaction) => {
|
|
49
48
|
let event_types = transaction.events.events.map((event) => event.event_type) || [];
|
|
50
|
-
if (event_types.some((event_type) => (0, checkpoint_1.is_dex_package_id)(event_type.split('::')[0]))) {
|
|
51
|
-
blockUpdateEvent.transactions.push({
|
|
52
|
-
txHash: transaction.digest,
|
|
53
|
-
txIndex: transaction.index || 0,
|
|
54
|
-
txType: transaction.transaction.kind.kind,
|
|
55
|
-
events: event_types.map((event_type) => {
|
|
56
|
-
return {
|
|
57
|
-
dex_name: (0, checkpoint_1.get_dex_name_by_package_id)(event_type.split('::')[0]),
|
|
58
|
-
event_type: event_type
|
|
59
|
-
};
|
|
60
|
-
}) || []
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
49
|
});
|
|
64
50
|
if (blockUpdateEvent.transactions.length > 0) {
|
|
65
51
|
(0, fs_1.writeFileSync)(`./dist/checkpoint_${response.cursor}_decoded.json`, JSON.stringify(response, null, 2));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
require('dotenv').config();
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const sui_tx_parser_1 = require("../parse/sui_tx_parser");
|
|
18
|
+
const index_1 = require("../../index");
|
|
19
|
+
const index_2 = require("../../index");
|
|
20
|
+
function test_get_tx_result() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT || '';
|
|
23
|
+
const grpc_token = process.env.SUI_GRPC_TOKEN || '';
|
|
24
|
+
const grpcConnection = index_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
25
|
+
const ledgerService = new index_1.LedgerService(grpcConnection);
|
|
26
|
+
let wallet_address = '0x6367c8755b8c39cab7305bfa75cb17d050508d2e55f6862a7682377ad6d46ee7';
|
|
27
|
+
let test_tx_success_buy = {
|
|
28
|
+
txid: '',
|
|
29
|
+
filename: './src/trade/test/receipt_buy_sui.json'
|
|
30
|
+
};
|
|
31
|
+
let test_tx_success_sell = {
|
|
32
|
+
txid: '28FaeTYoctpP1VdWCuyPxNEBeaMm3ebj27kdF5umi9YL',
|
|
33
|
+
filename: './src/trade/test/receipt_sell_sui.json'
|
|
34
|
+
};
|
|
35
|
+
let { txid, filename } = test_tx_success_sell;
|
|
36
|
+
console.log('=== 测试 SUI 链交易结果查询 ===');
|
|
37
|
+
console.log('交易哈希:', txid);
|
|
38
|
+
try {
|
|
39
|
+
const raw_tx_result = yield ledgerService.getTransaction(txid, ['*']);
|
|
40
|
+
console.log('✅ 成功获取交易结果');
|
|
41
|
+
const decoded_tx_result = (0, index_2.decodeBytes)(raw_tx_result);
|
|
42
|
+
fs_1.default.writeFileSync(filename, JSON.stringify(decoded_tx_result, null, 2));
|
|
43
|
+
let poolInfo = get_pool_info();
|
|
44
|
+
const parser = new sui_tx_parser_1.SuiTransactionParser(wallet_address);
|
|
45
|
+
const result = yield parser.parseTransaction(raw_tx_result, poolInfo);
|
|
46
|
+
console.log('解析交易结果:', JSON.stringify(result, null, 2));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('❌ 查询失败:', error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function get_pool_info() {
|
|
54
|
+
return {
|
|
55
|
+
"program_id": "",
|
|
56
|
+
"authority": "",
|
|
57
|
+
"subscribe_type": "grpc",
|
|
58
|
+
"pair": "SUI/USDT",
|
|
59
|
+
"dex_id": "MOMENTUM-CLMM",
|
|
60
|
+
"pool_name": "SUI/USDC",
|
|
61
|
+
"pool_address": "0x455cf8d2ac91e7cb883f515874af750ed3cd18195c970b7a2d46235ac2b0c388",
|
|
62
|
+
"pool_address_hex": "",
|
|
63
|
+
"tokenA": {
|
|
64
|
+
"symbol": "SUI",
|
|
65
|
+
"address": "0x2::sui::SUI",
|
|
66
|
+
"address_hex": "",
|
|
67
|
+
"decimals": 9,
|
|
68
|
+
"name": "Sui",
|
|
69
|
+
"is_token2022": false,
|
|
70
|
+
"market_price": "3.27",
|
|
71
|
+
"update_time": "2025-09-01 20:25:48 469",
|
|
72
|
+
"alias": "",
|
|
73
|
+
"enable": true
|
|
74
|
+
},
|
|
75
|
+
"tokenB": {
|
|
76
|
+
"symbol": "USDC",
|
|
77
|
+
"address": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
78
|
+
"address_hex": "",
|
|
79
|
+
"decimals": 6,
|
|
80
|
+
"name": "USDC",
|
|
81
|
+
"is_token2022": false,
|
|
82
|
+
"market_price": "0.9992228892",
|
|
83
|
+
"update_time": "2025-09-01 20:25:48 469",
|
|
84
|
+
"alias": "",
|
|
85
|
+
"enable": true
|
|
86
|
+
},
|
|
87
|
+
"vaultA": "",
|
|
88
|
+
"vaultB": "",
|
|
89
|
+
"router_id": null,
|
|
90
|
+
"fee_rate": 25,
|
|
91
|
+
"quote_token": "USDC",
|
|
92
|
+
"quote_amount_usd": 200,
|
|
93
|
+
"quote_price_decimals": 18,
|
|
94
|
+
"is_reverse_token": false,
|
|
95
|
+
"cu_limit": 200000,
|
|
96
|
+
"tvl": 14160391.2697,
|
|
97
|
+
"vol_24h": 21668306.2082508,
|
|
98
|
+
"update_time": "2025-09-01 20:25:48 899",
|
|
99
|
+
"enable": true,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (require.main === module) {
|
|
103
|
+
test_get_tx_result()
|
|
104
|
+
.catch(console.error);
|
|
105
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./decode"), exports);
|
|
18
|
-
__exportStar(require("./checkpoint"), exports);
|
|
19
18
|
__exportStar(require("./format"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sui-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "Sui common library",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"push": "npm run build && npm publish"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@clonegod/ttd-core": "2.0.
|
|
18
|
+
"@clonegod/ttd-core": "2.0.63",
|
|
19
19
|
"@grpc/grpc-js": "^1.9.14",
|
|
20
20
|
"@grpc/proto-loader": "^0.7.10",
|
|
21
21
|
"@mysten/sui": "^1.37.5",
|