@clonegod/ttd-sui-common 1.0.69 → 1.0.71
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/dist/grpc/grpc-connection.js +16 -7
- package/dist/test/test_grpc.js +12 -2
- package/dist/trade/test/test_parse_sui_tx_result.js +24 -24
- package/package.json +1 -1
- package/dist/rpc/account-api.d.ts +0 -14
- package/dist/rpc/account-api.js +0 -113
- package/dist/rpc/coin-api.d.ts +0 -0
- package/dist/rpc/coin-api.js +0 -0
- package/dist/rpc/rpc-connection.d.ts +0 -8
- package/dist/rpc/rpc-connection.js +0 -54
- package/dist/test/test_checkpoint_processor.d.ts +0 -1
- package/dist/test/test_checkpoint_processor.js +0 -112
- package/dist/test/test_checkpoint_subscription.d.ts +0 -1
- package/dist/test/test_checkpoint_subscription.js +0 -132
- package/dist/test/test_checkpoint_with_schema.d.ts +0 -1
- package/dist/test/test_checkpoint_with_schema.js +0 -250
- package/dist/test/test_dynamic_bcs.d.ts +0 -1
- package/dist/test/test_dynamic_bcs.js +0 -82
- package/dist/test/test_github_extractor.d.ts +0 -1
- package/dist/test/test_github_extractor.js +0 -69
- package/dist/test/test_hybrid_bcs.d.ts +0 -1
- package/dist/test/test_hybrid_bcs.js +0 -98
- package/dist/test/test_momentum_events.d.ts +0 -1
- package/dist/test/test_momentum_events.js +0 -113
- package/dist/test/test_rpc.d.ts +0 -1
- package/dist/test/test_rpc.js +0 -34
- package/dist/test/test_schema_database.d.ts +0 -1
- package/dist/test/test_schema_database.js +0 -91
- package/dist/test/test_simple_schema.d.ts +0 -1
- package/dist/test/test_simple_schema.js +0 -78
- package/dist/test/test_single_momentum_event.d.ts +0 -1
- package/dist/test/test_single_momentum_event.js +0 -44
- package/dist/ttd-sui-common/src/constants/index.d.ts +0 -4
- package/dist/ttd-sui-common/src/constants/index.js +0 -8
- package/dist/ttd-sui-common/src/grpc/gas-price-cache.d.ts +0 -21
- package/dist/ttd-sui-common/src/grpc/gas-price-cache.js +0 -83
- package/dist/ttd-sui-common/src/grpc/grpc-connection.d.ts +0 -13
- package/dist/ttd-sui-common/src/grpc/grpc-connection.js +0 -99
- package/dist/ttd-sui-common/src/grpc/index.d.ts +0 -7
- package/dist/ttd-sui-common/src/grpc/index.js +0 -17
- package/dist/ttd-sui-common/src/grpc/ledger-service.d.ts +0 -12
- package/dist/ttd-sui-common/src/grpc/ledger-service.js +0 -161
- package/dist/ttd-sui-common/src/grpc/live-data-service.d.ts +0 -10
- package/dist/ttd-sui-common/src/grpc/live-data-service.js +0 -107
- package/dist/ttd-sui-common/src/grpc/subscription-service.d.ts +0 -7
- package/dist/ttd-sui-common/src/grpc/subscription-service.js +0 -69
- package/dist/ttd-sui-common/src/grpc/sui-grpc-client.d.ts +0 -16
- package/dist/ttd-sui-common/src/grpc/sui-grpc-client.js +0 -38
- package/dist/ttd-sui-common/src/grpc/transaction-service.d.ts +0 -7
- package/dist/ttd-sui-common/src/grpc/transaction-service.js +0 -49
- package/dist/ttd-sui-common/src/index.d.ts +0 -9
- package/dist/ttd-sui-common/src/index.js +0 -25
- package/dist/ttd-sui-common/src/quote/index.d.ts +0 -1
- package/dist/ttd-sui-common/src/quote/index.js +0 -17
- package/dist/ttd-sui-common/src/quote/pricing/index.d.ts +0 -1
- package/dist/ttd-sui-common/src/quote/pricing/index.js +0 -17
- package/dist/ttd-sui-common/src/quote/pricing/token_price_cache.d.ts +0 -9
- package/dist/ttd-sui-common/src/quote/pricing/token_price_cache.js +0 -42
- package/dist/ttd-sui-common/src/redis/index.d.ts +0 -1
- package/dist/ttd-sui-common/src/redis/index.js +0 -17
- package/dist/ttd-sui-common/src/redis/redis_client.d.ts +0 -21
- package/dist/ttd-sui-common/src/redis/redis_client.js +0 -155
- package/dist/ttd-sui-common/src/test/test.d.ts +0 -1
- package/dist/ttd-sui-common/src/test/test.js +0 -126
- package/dist/ttd-sui-common/src/test/test_checkpoint.d.ts +0 -1
- package/dist/ttd-sui-common/src/test/test_checkpoint.js +0 -64
- package/dist/ttd-sui-common/src/test/test_grpc.d.ts +0 -1
- package/dist/ttd-sui-common/src/test/test_grpc.js +0 -84
- package/dist/ttd-sui-common/src/trade/abstract_sui_dex_trade_plus.d.ts +0 -32
- package/dist/ttd-sui-common/src/trade/abstract_sui_dex_trade_plus.js +0 -216
- package/dist/ttd-sui-common/src/trade/check/index.d.ts +0 -1
- package/dist/ttd-sui-common/src/trade/check/index.js +0 -5
- package/dist/ttd-sui-common/src/trade/check/tx_result_checker.d.ts +0 -13
- package/dist/ttd-sui-common/src/trade/check/tx_result_checker.js +0 -111
- package/dist/ttd-sui-common/src/trade/index.d.ts +0 -4
- package/dist/ttd-sui-common/src/trade/index.js +0 -20
- package/dist/ttd-sui-common/src/trade/parse/index.d.ts +0 -1
- package/dist/ttd-sui-common/src/trade/parse/index.js +0 -5
- package/dist/ttd-sui-common/src/trade/parse/sui_tx_parser.d.ts +0 -13
- package/dist/ttd-sui-common/src/trade/parse/sui_tx_parser.js +0 -167
- package/dist/ttd-sui-common/src/trade/send_tx/index.d.ts +0 -10
- package/dist/ttd-sui-common/src/trade/send_tx/index.js +0 -48
- package/dist/ttd-sui-common/src/trade/test/test_parse_sui_tx_result.d.ts +0 -1
- package/dist/ttd-sui-common/src/trade/test/test_parse_sui_tx_result.js +0 -105
- package/dist/ttd-sui-common/src/type/index.d.ts +0 -18
- package/dist/ttd-sui-common/src/type/index.js +0 -2
- package/dist/ttd-sui-common/src/utils/checkpoint_parse.d.ts +0 -0
- package/dist/ttd-sui-common/src/utils/checkpoint_parse.js +0 -0
- package/dist/ttd-sui-common/src/utils/decode.d.ts +0 -2
- package/dist/ttd-sui-common/src/utils/decode.js +0 -43
- package/dist/ttd-sui-common/src/utils/format.d.ts +0 -1
- package/dist/ttd-sui-common/src/utils/format.js +0 -18
- package/dist/ttd-sui-common/src/utils/index.d.ts +0 -2
- package/dist/ttd-sui-common/src/utils/index.js +0 -18
- package/dist/ttd-sui-market-data/src/sui_objects/config_manager.d.ts +0 -22
- package/dist/ttd-sui-market-data/src/sui_objects/config_manager.js +0 -169
- package/dist/ttd-sui-market-data/src/sui_objects/example.d.ts +0 -1
- package/dist/ttd-sui-market-data/src/sui_objects/example.js +0 -72
- package/dist/ttd-sui-market-data/src/sui_objects/index.d.ts +0 -6
- package/dist/ttd-sui-market-data/src/sui_objects/index.js +0 -15
- package/dist/ttd-sui-market-data/src/sui_objects/object_mgt.d.ts +0 -47
- package/dist/ttd-sui-market-data/src/sui_objects/object_mgt.js +0 -483
- package/dist/ttd-sui-market-data/src/sui_objects/types.d.ts +0 -60
- package/dist/ttd-sui-market-data/src/sui_objects/types.js +0 -24
- package/dist/ttd-sui-market-data/src/sui_objects/version_checker.d.ts +0 -30
- package/dist/ttd-sui-market-data/src/sui_objects/version_checker.js +0 -207
- package/dist/utils/bcs-parser.d.ts +0 -8
- package/dist/utils/bcs-parser.js +0 -121
- package/dist/utils/checkpoint-processor.d.ts +0 -7
- package/dist/utils/checkpoint-processor.js +0 -123
- package/dist/utils/checkpoint.d.ts +0 -7
- package/dist/utils/checkpoint.js +0 -26
- package/dist/utils/dex-parser-manager.d.ts +0 -7
- package/dist/utils/dex-parser-manager.js +0 -138
- package/dist/utils/dex_event_parser.d.ts +0 -34
- package/dist/utils/dex_event_parser.js +0 -132
- package/dist/utils/dex_schema_database.d.ts +0 -206
- package/dist/utils/dex_schema_database.js +0 -169
- package/dist/utils/dynamic_bcs_parser.d.ts +0 -21
- package/dist/utils/dynamic_bcs_parser.js +0 -166
- package/dist/utils/github_schema_extractor.d.ts +0 -20
- package/dist/utils/github_schema_extractor.js +0 -153
- package/dist/utils/hybrid_bcs_parser.d.ts +0 -22
- package/dist/utils/hybrid_bcs_parser.js +0 -194
- package/dist/utils/simple_schema_parser.d.ts +0 -76
- package/dist/utils/simple_schema_parser.js +0 -193
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require('dotenv').config();
|
|
4
|
-
const dex_schema_database_1 = require("../utils/dex_schema_database");
|
|
5
|
-
const db = new dex_schema_database_1.DexSchemaDatabase();
|
|
6
|
-
const testSchemaDatabase = () => {
|
|
7
|
-
console.log('=== 测试 DEX Schema 数据库 ===');
|
|
8
|
-
console.log('\n1. 测试获取 DEX 信息...');
|
|
9
|
-
const momentumInfo = db.getDexInfo('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860');
|
|
10
|
-
console.log('Momentum 信息:', momentumInfo);
|
|
11
|
-
console.log('\n2. 测试获取事件 schema...');
|
|
12
|
-
const swapSchema = db.getEventSchema('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860', 'SwapEvent');
|
|
13
|
-
console.log('SwapEvent schema:', swapSchema);
|
|
14
|
-
console.log('\n3. 测试检查支持...');
|
|
15
|
-
const isSupported = db.isSupported('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860');
|
|
16
|
-
console.log('Momentum 是否支持:', isSupported);
|
|
17
|
-
console.log('\n4. 测试获取支持的包...');
|
|
18
|
-
const supportedPackages = db.getSupportedPackages();
|
|
19
|
-
console.log('支持的包:', supportedPackages);
|
|
20
|
-
console.log('\n5. 测试添加新 schema...');
|
|
21
|
-
db.addDexSchema('0xnewdex', 'New DEX', 'https://github.com/newdex', {
|
|
22
|
-
'NewEvent': {
|
|
23
|
-
field1: 'u64',
|
|
24
|
-
field2: 'address'
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
console.log('添加新 DEX 后支持的包:', db.getSupportedPackages());
|
|
28
|
-
console.log('\n6. 测试添加新事件...');
|
|
29
|
-
db.addEventSchema('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860', 'NewMomentumEvent', {
|
|
30
|
-
new_field: 'u128'
|
|
31
|
-
});
|
|
32
|
-
const newEventSchema = db.getEventSchema('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860', 'NewMomentumEvent');
|
|
33
|
-
console.log('新事件 schema:', newEventSchema);
|
|
34
|
-
};
|
|
35
|
-
const testCodeGeneration = () => {
|
|
36
|
-
console.log('\n=== 测试代码生成 ===');
|
|
37
|
-
const tsCode = db.generateTypeScriptCode();
|
|
38
|
-
console.log('生成的 TypeScript 代码:');
|
|
39
|
-
console.log(tsCode);
|
|
40
|
-
const json = db.exportToJSON();
|
|
41
|
-
console.log('\n导出的 JSON:');
|
|
42
|
-
console.log(json);
|
|
43
|
-
};
|
|
44
|
-
const testActualParsing = () => {
|
|
45
|
-
console.log('\n=== 测试实际解析 ===');
|
|
46
|
-
const testEvents = [
|
|
47
|
-
{
|
|
48
|
-
name: 'Momentum SwapEvent',
|
|
49
|
-
event: {
|
|
50
|
-
type: '0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860::pool::SwapEvent',
|
|
51
|
-
bcs: {
|
|
52
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'Cetus SwapEvent',
|
|
58
|
-
event: {
|
|
59
|
-
type: '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::pool::SwapEvent',
|
|
60
|
-
bcs: {
|
|
61
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
];
|
|
66
|
-
for (const testCase of testEvents) {
|
|
67
|
-
console.log(`\n测试: ${testCase.name}`);
|
|
68
|
-
const parts = testCase.event.type.split('::');
|
|
69
|
-
const packageId = parts[0];
|
|
70
|
-
const eventName = parts[parts.length - 1];
|
|
71
|
-
const schema = db.getEventSchema(packageId, eventName);
|
|
72
|
-
console.log('Schema:', schema);
|
|
73
|
-
if (schema) {
|
|
74
|
-
console.log('✅ 找到 schema,可以解析 BCS 数据');
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
console.log('❌ 未找到 schema');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const main = () => {
|
|
82
|
-
try {
|
|
83
|
-
testSchemaDatabase();
|
|
84
|
-
testCodeGeneration();
|
|
85
|
-
testActualParsing();
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
console.error('测试失败:', error);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
main();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require('dotenv').config();
|
|
4
|
-
const simple_schema_parser_1 = require("../utils/simple_schema_parser");
|
|
5
|
-
const parser = new simple_schema_parser_1.SimpleSchemaParser();
|
|
6
|
-
const testSimpleSchemaParsing = () => {
|
|
7
|
-
console.log('=== 测试简单Schema解析 ===');
|
|
8
|
-
const testEvents = [
|
|
9
|
-
{
|
|
10
|
-
name: 'Momentum SwapEvent',
|
|
11
|
-
event: {
|
|
12
|
-
type: '0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860::pool::SwapEvent',
|
|
13
|
-
bcs: {
|
|
14
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'Cetus SwapEvent',
|
|
20
|
-
event: {
|
|
21
|
-
type: '0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::pool::SwapEvent',
|
|
22
|
-
bcs: {
|
|
23
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'Momentum RepayFlashSwapEvent',
|
|
29
|
-
event: {
|
|
30
|
-
type: '0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860::pool::RepayFlashSwapEvent',
|
|
31
|
-
bcs: {
|
|
32
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'Unknown Event',
|
|
38
|
-
event: {
|
|
39
|
-
type: '0xunknown::module::UnknownEvent',
|
|
40
|
-
bcs: {
|
|
41
|
-
value: '00096703000000000000d9690d000000000000af9374ff98010000202a10443fdf509da5b8a6f8d7b4a58f46a8b3827e11c18cc9ec98a8524bab5daa010020430948c6b6336d3c3fef5a9b710799b0afae62c780592c5a38a99b6e19ce17b30000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
for (const testCase of testEvents) {
|
|
47
|
-
console.log(`\n测试: ${testCase.name}`);
|
|
48
|
-
try {
|
|
49
|
-
const result = parser.parseEvent(testCase.event);
|
|
50
|
-
console.log('解析结果:', JSON.stringify(result, null, 2));
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
console.error('解析失败:', error);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const testFeatures = () => {
|
|
58
|
-
console.log('\n=== 测试功能 ===');
|
|
59
|
-
const supportedPackages = parser.getSupportedPackages();
|
|
60
|
-
console.log('支持的包:', supportedPackages);
|
|
61
|
-
const isMomentumSupported = parser.isSupported('0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860');
|
|
62
|
-
console.log('Momentum 是否支持:', isMomentumSupported);
|
|
63
|
-
parser.addSchema('0xnewpackage', 'NewEvent', {
|
|
64
|
-
field1: 'u64',
|
|
65
|
-
field2: 'address'
|
|
66
|
-
});
|
|
67
|
-
console.log('添加新 schema 后支持的包:', parser.getSupportedPackages());
|
|
68
|
-
};
|
|
69
|
-
const main = () => {
|
|
70
|
-
try {
|
|
71
|
-
testSimpleSchemaParsing();
|
|
72
|
-
testFeatures();
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error('测试失败:', error);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
main();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const bcs_parser_1 = require("../utils/bcs-parser");
|
|
13
|
-
function testSingleMomentumEvent() {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
console.log('=== 测试单个 Momentum CLMM 事件 ===');
|
|
16
|
-
const eventContent = {
|
|
17
|
-
name: "0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860::trade::SwapEvent",
|
|
18
|
-
value: {
|
|
19
|
-
type: "Buffer",
|
|
20
|
-
data: [154, 230, 249, 141, 148, 184, 44, 192, 8, 246, 65, 36, 6, 149, 48, 11, 214, 15, 238, 101, 255, 70, 84, 152, 195, 209, 187, 84, 193, 116, 25, 136, 115, 126, 198, 164, 211, 237, 12, 126, 108, 193, 141, 139, 160, 78, 127, 253, 72, 6, 183, 38, 201, 126, 253, 137, 134, 117, 151, 54, 140, 77, 6, 169, 1, 82, 183, 76, 0, 0, 0, 0, 0, 151, 182, 76, 0, 0, 0, 0, 0, 115, 225, 47, 61, 52, 30, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 253, 119, 207, 36, 52, 30, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 120, 142, 66, 203, 245, 161, 37, 3, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 41, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 15, 38, 97, 42, 249, 2, 0, 0, 13, 27, 26, 0, 195, 18, 0, 0]
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
console.log('事件类型:', eventContent.name);
|
|
24
|
-
const result = bcs_parser_1.BcsParser.parseEventWithDecodeBytes(eventContent);
|
|
25
|
-
if (result) {
|
|
26
|
-
console.log('解析结果:');
|
|
27
|
-
console.log('- DEX:', result.dex);
|
|
28
|
-
console.log('- Hex 数据:', result.hexData);
|
|
29
|
-
if (result.parsedData) {
|
|
30
|
-
console.log('- BCS 解析数据:', result.parsedData);
|
|
31
|
-
if (result.calculatedPrice) {
|
|
32
|
-
console.log('- 计算价格:', result.calculatedPrice);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
console.log('- BCS 解析失败');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.log('解析失败');
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
testSingleMomentumEvent().catch(console.error);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUI_TOKEN_ADDRESS = void 0;
|
|
4
|
-
var SUI_TOKEN_ADDRESS;
|
|
5
|
-
(function (SUI_TOKEN_ADDRESS) {
|
|
6
|
-
SUI_TOKEN_ADDRESS["SHORT"] = "0x2::sui::SUI";
|
|
7
|
-
SUI_TOKEN_ADDRESS["LONG"] = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
8
|
-
})(SUI_TOKEN_ADDRESS || (exports.SUI_TOKEN_ADDRESS = SUI_TOKEN_ADDRESS = {}));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare class GasPriceCache {
|
|
2
|
-
private static instance;
|
|
3
|
-
private cachedGasPrice;
|
|
4
|
-
private lastUpdateTime;
|
|
5
|
-
private updateInterval;
|
|
6
|
-
private ledgerService;
|
|
7
|
-
private refreshTimer?;
|
|
8
|
-
private constructor();
|
|
9
|
-
static getInstance(ledgerService: any): GasPriceCache;
|
|
10
|
-
getGasPrice(): Promise<number>;
|
|
11
|
-
refreshGasPrice(): Promise<void>;
|
|
12
|
-
private startAutoRefresh;
|
|
13
|
-
stopAutoRefresh(): void;
|
|
14
|
-
getCacheInfo(): {
|
|
15
|
-
cachedGasPrice: number;
|
|
16
|
-
lastUpdateTime: number;
|
|
17
|
-
isExpired: boolean;
|
|
18
|
-
timeUntilNextRefresh: number;
|
|
19
|
-
};
|
|
20
|
-
destroy(): void;
|
|
21
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GasPriceCache = void 0;
|
|
13
|
-
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
14
|
-
class GasPriceCache {
|
|
15
|
-
constructor(ledgerService) {
|
|
16
|
-
this.cachedGasPrice = 0;
|
|
17
|
-
this.lastUpdateTime = 0;
|
|
18
|
-
this.updateInterval = 60 * 60 * 1000;
|
|
19
|
-
this.ledgerService = ledgerService;
|
|
20
|
-
this.startAutoRefresh();
|
|
21
|
-
}
|
|
22
|
-
static getInstance(ledgerService) {
|
|
23
|
-
if (!GasPriceCache.instance) {
|
|
24
|
-
GasPriceCache.instance = new GasPriceCache(ledgerService);
|
|
25
|
-
}
|
|
26
|
-
return GasPriceCache.instance;
|
|
27
|
-
}
|
|
28
|
-
getGasPrice() {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (Date.now() - this.lastUpdateTime > this.updateInterval || this.cachedGasPrice === 0) {
|
|
31
|
-
yield this.refreshGasPrice();
|
|
32
|
-
}
|
|
33
|
-
return this.cachedGasPrice;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
refreshGasPrice() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
try {
|
|
39
|
-
const epochRes = yield this.ledgerService.getEpoch();
|
|
40
|
-
this.cachedGasPrice = Number(epochRes['epoch']['reference_gas_price']);
|
|
41
|
-
this.lastUpdateTime = Date.now();
|
|
42
|
-
(0, dist_1.log_info)(`refreshGasPrice success: ${this.cachedGasPrice} MIST`);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
(0, dist_1.log_error)('refresh gas price failed', error);
|
|
46
|
-
this.cachedGasPrice = Number(process.env.DEFAULT_GAS_PRICE || '600');
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
startAutoRefresh() {
|
|
51
|
-
this.refreshGasPrice().catch(error => {
|
|
52
|
-
(0, dist_1.log_error)('initial gas price refresh failed', error);
|
|
53
|
-
});
|
|
54
|
-
this.refreshTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
yield this.refreshGasPrice();
|
|
56
|
-
}), this.updateInterval);
|
|
57
|
-
(0, dist_1.log_info)('Gas price auto refresh started, refresh interval: 5 minutes');
|
|
58
|
-
}
|
|
59
|
-
stopAutoRefresh() {
|
|
60
|
-
if (this.refreshTimer) {
|
|
61
|
-
clearInterval(this.refreshTimer);
|
|
62
|
-
this.refreshTimer = undefined;
|
|
63
|
-
(0, dist_1.log_info)('Gas price auto refresh stopped');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
getCacheInfo() {
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
const timeSinceLastUpdate = now - this.lastUpdateTime;
|
|
69
|
-
const isExpired = timeSinceLastUpdate > this.updateInterval;
|
|
70
|
-
const timeUntilNextRefresh = Math.max(0, this.updateInterval - timeSinceLastUpdate);
|
|
71
|
-
return {
|
|
72
|
-
cachedGasPrice: this.cachedGasPrice,
|
|
73
|
-
lastUpdateTime: this.lastUpdateTime,
|
|
74
|
-
isExpired,
|
|
75
|
-
timeUntilNextRefresh
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
destroy() {
|
|
79
|
-
this.stopAutoRefresh();
|
|
80
|
-
GasPriceCache.instance = null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.GasPriceCache = GasPriceCache;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
export declare class GrpcConnection {
|
|
3
|
-
private static instance;
|
|
4
|
-
private channel;
|
|
5
|
-
private endpoint;
|
|
6
|
-
private metadata;
|
|
7
|
-
private constructor();
|
|
8
|
-
static getInstance(grpc_endpoint: string, grpc_token: string): GrpcConnection;
|
|
9
|
-
private getChannel;
|
|
10
|
-
createServiceClient<T>(protoFileName: string, serviceName: string): T;
|
|
11
|
-
getMetadata(): grpc.Metadata;
|
|
12
|
-
close(): void;
|
|
13
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GrpcConnection = void 0;
|
|
37
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
38
|
-
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
class GrpcConnection {
|
|
41
|
-
constructor(grpc_endpoint, grpc_token) {
|
|
42
|
-
this.channel = null;
|
|
43
|
-
this.endpoint = grpc_endpoint;
|
|
44
|
-
this.metadata = new grpc.Metadata();
|
|
45
|
-
this.metadata.add('x-token', grpc_token);
|
|
46
|
-
}
|
|
47
|
-
static getInstance(grpc_endpoint, grpc_token) {
|
|
48
|
-
if (!GrpcConnection.instance) {
|
|
49
|
-
GrpcConnection.instance = new GrpcConnection(grpc_endpoint, grpc_token);
|
|
50
|
-
}
|
|
51
|
-
return GrpcConnection.instance;
|
|
52
|
-
}
|
|
53
|
-
getChannel() {
|
|
54
|
-
if (!this.channel) {
|
|
55
|
-
this.channel = new grpc.Channel(this.endpoint, grpc.credentials.createSsl(), {
|
|
56
|
-
'grpc.keepalive_time_ms': 120000,
|
|
57
|
-
'grpc.keepalive_timeout_ms': 20000,
|
|
58
|
-
'grpc.keepalive_permit_without_calls': 0,
|
|
59
|
-
'grpc.http2.max_pings_without_data': 0,
|
|
60
|
-
'grpc.http2.min_time_between_pings_ms': 120000,
|
|
61
|
-
'grpc.http2.min_ping_interval_without_data_ms': 120000
|
|
62
|
-
});
|
|
63
|
-
console.log(`创建 gRPC 通道: ${this.endpoint}`);
|
|
64
|
-
}
|
|
65
|
-
return this.channel;
|
|
66
|
-
}
|
|
67
|
-
createServiceClient(protoFileName, serviceName) {
|
|
68
|
-
var _a, _b, _c;
|
|
69
|
-
const protoPath = path.join(__dirname, 'protos/sui/rpc/v2beta2', protoFileName);
|
|
70
|
-
const packageDefinition = protoLoader.loadSync(protoPath, {
|
|
71
|
-
keepCase: true,
|
|
72
|
-
longs: String,
|
|
73
|
-
enums: String,
|
|
74
|
-
defaults: true,
|
|
75
|
-
oneofs: true,
|
|
76
|
-
includeDirs: [path.join(__dirname, 'protos')]
|
|
77
|
-
});
|
|
78
|
-
const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
|
|
79
|
-
const service = (_c = (_b = (_a = protoDescriptor.sui) === null || _a === void 0 ? void 0 : _a.rpc) === null || _b === void 0 ? void 0 : _b.v2beta2) === null || _c === void 0 ? void 0 : _c[serviceName];
|
|
80
|
-
if (!service) {
|
|
81
|
-
throw new Error(`Service ${serviceName} not found in proto file`);
|
|
82
|
-
}
|
|
83
|
-
const channel = this.getChannel();
|
|
84
|
-
return new service(this.endpoint, grpc.credentials.createSsl(), {
|
|
85
|
-
channelOverride: channel
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
getMetadata() {
|
|
89
|
-
return this.metadata;
|
|
90
|
-
}
|
|
91
|
-
close() {
|
|
92
|
-
if (this.channel) {
|
|
93
|
-
this.channel.close();
|
|
94
|
-
this.channel = null;
|
|
95
|
-
console.log('gRPC 通道已关闭');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.GrpcConnection = GrpcConnection;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { GrpcConnection } from './grpc-connection';
|
|
2
|
-
export { LedgerService } from './ledger-service';
|
|
3
|
-
export { LiveDataService } from './live-data-service';
|
|
4
|
-
export { TransactionService } from './transaction-service';
|
|
5
|
-
export { SubscriptionService } from './subscription-service';
|
|
6
|
-
export { SuiGrpcClient } from './sui-grpc-client';
|
|
7
|
-
export { GasPriceCache } from './gas-price-cache';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GasPriceCache = exports.SuiGrpcClient = exports.SubscriptionService = exports.TransactionService = exports.LiveDataService = exports.LedgerService = exports.GrpcConnection = void 0;
|
|
4
|
-
var grpc_connection_1 = require("./grpc-connection");
|
|
5
|
-
Object.defineProperty(exports, "GrpcConnection", { enumerable: true, get: function () { return grpc_connection_1.GrpcConnection; } });
|
|
6
|
-
var ledger_service_1 = require("./ledger-service");
|
|
7
|
-
Object.defineProperty(exports, "LedgerService", { enumerable: true, get: function () { return ledger_service_1.LedgerService; } });
|
|
8
|
-
var live_data_service_1 = require("./live-data-service");
|
|
9
|
-
Object.defineProperty(exports, "LiveDataService", { enumerable: true, get: function () { return live_data_service_1.LiveDataService; } });
|
|
10
|
-
var transaction_service_1 = require("./transaction-service");
|
|
11
|
-
Object.defineProperty(exports, "TransactionService", { enumerable: true, get: function () { return transaction_service_1.TransactionService; } });
|
|
12
|
-
var subscription_service_1 = require("./subscription-service");
|
|
13
|
-
Object.defineProperty(exports, "SubscriptionService", { enumerable: true, get: function () { return subscription_service_1.SubscriptionService; } });
|
|
14
|
-
var sui_grpc_client_1 = require("./sui-grpc-client");
|
|
15
|
-
Object.defineProperty(exports, "SuiGrpcClient", { enumerable: true, get: function () { return sui_grpc_client_1.SuiGrpcClient; } });
|
|
16
|
-
var gas_price_cache_1 = require("./gas-price-cache");
|
|
17
|
-
Object.defineProperty(exports, "GasPriceCache", { enumerable: true, get: function () { return gas_price_cache_1.GasPriceCache; } });
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { GrpcConnection } from './grpc-connection';
|
|
2
|
-
export declare class LedgerService {
|
|
3
|
-
private ledgerClient;
|
|
4
|
-
private connection;
|
|
5
|
-
constructor(connection: GrpcConnection);
|
|
6
|
-
getServiceInfo(): Promise<unknown>;
|
|
7
|
-
getEpoch(epoch?: number, includeGasPrice?: boolean): Promise<unknown>;
|
|
8
|
-
getCheckpoint(checkpointId?: string): Promise<any>;
|
|
9
|
-
getObject(objectId: string, readMask?: string[]): Promise<unknown>;
|
|
10
|
-
batchGetObjects(objectIds: string[], readMask?: string[]): Promise<unknown>;
|
|
11
|
-
getTransaction(digest: string, readMask?: string[]): Promise<unknown>;
|
|
12
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LedgerService = void 0;
|
|
13
|
-
class LedgerService {
|
|
14
|
-
constructor(connection) {
|
|
15
|
-
this.connection = connection;
|
|
16
|
-
this.ledgerClient = connection.createServiceClient('ledger_service.proto', 'LedgerService');
|
|
17
|
-
}
|
|
18
|
-
getServiceInfo() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
const request = {};
|
|
22
|
-
this.ledgerClient.GetServiceInfo(request, this.connection.getMetadata(), (error, response) => {
|
|
23
|
-
if (error)
|
|
24
|
-
reject(error);
|
|
25
|
-
else
|
|
26
|
-
resolve(response);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
getEpoch(epoch_1) {
|
|
32
|
-
return __awaiter(this, arguments, void 0, function* (epoch, includeGasPrice = true) {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const request = {};
|
|
35
|
-
if (epoch)
|
|
36
|
-
request.epoch = epoch;
|
|
37
|
-
const paths = ['epoch'];
|
|
38
|
-
if (includeGasPrice) {
|
|
39
|
-
paths.push('reference_gas_price');
|
|
40
|
-
}
|
|
41
|
-
request.read_mask = {
|
|
42
|
-
paths: paths
|
|
43
|
-
};
|
|
44
|
-
this.ledgerClient.GetEpoch(request, this.connection.getMetadata(), (error, response) => {
|
|
45
|
-
if (error)
|
|
46
|
-
reject(error);
|
|
47
|
-
else
|
|
48
|
-
resolve(response);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
getCheckpoint(checkpointId) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
const request = checkpointId ? { digest: checkpointId } : {};
|
|
57
|
-
this.ledgerClient.GetCheckpoint(request, this.connection.getMetadata(), (error, response) => {
|
|
58
|
-
if (error)
|
|
59
|
-
reject(error);
|
|
60
|
-
else
|
|
61
|
-
resolve(response);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
getObject(objectId, readMask) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return new Promise((resolve, reject) => {
|
|
69
|
-
const request = {
|
|
70
|
-
object_id: objectId
|
|
71
|
-
};
|
|
72
|
-
if (readMask && readMask.length > 0) {
|
|
73
|
-
request.read_mask = {
|
|
74
|
-
paths: readMask
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
request.read_mask = {
|
|
79
|
-
paths: [
|
|
80
|
-
"object_id",
|
|
81
|
-
"version",
|
|
82
|
-
"digest",
|
|
83
|
-
"owner",
|
|
84
|
-
"object_type",
|
|
85
|
-
"has_public_transfer",
|
|
86
|
-
"previous_transaction",
|
|
87
|
-
"storage_rebate",
|
|
88
|
-
"balance"
|
|
89
|
-
]
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
this.ledgerClient.GetObject(request, this.connection.getMetadata(), (error, response) => {
|
|
93
|
-
if (error)
|
|
94
|
-
reject(error);
|
|
95
|
-
else {
|
|
96
|
-
resolve(response);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
batchGetObjects(objectIds, readMask) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
return new Promise((resolve, reject) => {
|
|
105
|
-
const requests = objectIds.map(id => ({ object_id: id }));
|
|
106
|
-
const request = { requests };
|
|
107
|
-
if (readMask && readMask.length > 0) {
|
|
108
|
-
request.read_mask = {
|
|
109
|
-
paths: readMask
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
request.read_mask = {
|
|
114
|
-
paths: [
|
|
115
|
-
"object_id",
|
|
116
|
-
"version",
|
|
117
|
-
"digest",
|
|
118
|
-
"owner",
|
|
119
|
-
"object_type",
|
|
120
|
-
"has_public_transfer",
|
|
121
|
-
"previous_transaction",
|
|
122
|
-
"storage_rebate",
|
|
123
|
-
"balance"
|
|
124
|
-
]
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
this.ledgerClient.BatchGetObjects(request, this.connection.getMetadata(), (error, response) => {
|
|
128
|
-
if (error)
|
|
129
|
-
reject(error);
|
|
130
|
-
else {
|
|
131
|
-
resolve(response);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
getTransaction(digest, readMask) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
return new Promise((resolve, reject) => {
|
|
140
|
-
const request = { digest };
|
|
141
|
-
if (readMask && readMask.length > 0) {
|
|
142
|
-
request.read_mask = {
|
|
143
|
-
paths: readMask
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
request.read_mask = {
|
|
148
|
-
paths: ['digest', 'effects.gas_used', 'checkpoint', 'timestamp', 'balance_changes', 'input_objects', 'output_objects']
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
this.ledgerClient.GetTransaction(request, this.connection.getMetadata(), (error, response) => {
|
|
152
|
-
if (error)
|
|
153
|
-
reject(error);
|
|
154
|
-
else
|
|
155
|
-
resolve(response);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
exports.LedgerService = LedgerService;
|