@clonegod/ttd-sol-common 1.0.73 → 1.0.75
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.
|
@@ -16,8 +16,10 @@ export declare class TransactionResultChecker {
|
|
|
16
16
|
price_msg: PriceMessageType;
|
|
17
17
|
order_msg: OrderMessageType;
|
|
18
18
|
pool_info: StandardPoolInfoType;
|
|
19
|
+
intervalId: any;
|
|
19
20
|
check_count: number;
|
|
20
21
|
transactionParser: TransactionResultParser;
|
|
22
|
+
trade_result_already_processed: boolean;
|
|
21
23
|
constructor(env_args: any, event_emitter: EventEmitter, context: TradeContext, txid: string);
|
|
22
24
|
init_tx_status(): this;
|
|
23
25
|
check(): Promise<void>;
|
|
@@ -29,6 +29,7 @@ class TransactionResultChecker {
|
|
|
29
29
|
this.trace_id = context.order_msg.order_trace_id;
|
|
30
30
|
this.check_count = 0;
|
|
31
31
|
this.transactionParser = new tx_result_parse_1.TransactionResultParser(this.env_args, this.wallet, this.event_emitter);
|
|
32
|
+
this.trade_result_already_processed = false;
|
|
32
33
|
}
|
|
33
34
|
init_tx_status() {
|
|
34
35
|
let empty_trade_result = JSON.parse(JSON.stringify({
|
|
@@ -47,12 +48,13 @@ class TransactionResultChecker {
|
|
|
47
48
|
on_subscibe_transaction() {
|
|
48
49
|
this.event_emitter.once(constants_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + this.txid, (messageStr) => {
|
|
49
50
|
try {
|
|
51
|
+
this.trade_result_already_processed = true;
|
|
50
52
|
(0, dist_1.log_debug)('on events: EVENT_WALLET_TRANSACTION', messageStr);
|
|
51
53
|
const messageObj = JSON.parse(messageStr);
|
|
52
54
|
const result = messageObj.params.result;
|
|
53
55
|
const _txid = result.signature;
|
|
54
56
|
const slot = result.slot;
|
|
55
|
-
|
|
57
|
+
(0, dist_1.log_info)('check txid:', { _txid, txid: this.txid, slot });
|
|
56
58
|
result.transaction.transaction.signatures = [_txid];
|
|
57
59
|
let tx_result = {
|
|
58
60
|
slot,
|
|
@@ -101,11 +103,16 @@ class TransactionResultChecker {
|
|
|
101
103
|
clearInterval(intervalId);
|
|
102
104
|
let swap_result = this.transactionParser.parse_transaction_data(tx_result, this.pool_info);
|
|
103
105
|
let trade_result = this.map_swap_result_to_tx_result(swap_result);
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
+
if (this.trade_result_already_processed) {
|
|
107
|
+
(0, dist_1.log_warn)(`trade_result_already_processed=${this.trade_result_already_processed}, ignore trade result fetch by interval check!`);
|
|
106
108
|
}
|
|
107
109
|
else {
|
|
108
|
-
|
|
110
|
+
if (trade_result.success) {
|
|
111
|
+
this.event_emitter.emit(dist_1.TRANSACTION_STATE_SUCCESS, trade_result);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.event_emitter.emit(dist_1.TRANSACTION_STATE_FAILED, trade_result);
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
117
|
setTimeout(() => {
|
|
111
118
|
console.log('<====================================================');
|
|
@@ -122,6 +129,7 @@ class TransactionResultChecker {
|
|
|
122
129
|
(0, dist_1.log_error)('parse transaction error!', err);
|
|
123
130
|
}
|
|
124
131
|
}), check_interval);
|
|
132
|
+
this.intervalId = intervalId;
|
|
125
133
|
});
|
|
126
134
|
}
|
|
127
135
|
map_swap_result_to_tx_result(swap_result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sol-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.75",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"push": "npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-common": "^1.0.
|
|
16
|
+
"@clonegod/ttd-common": "^1.0.158",
|
|
17
17
|
"@irys/sdk": "^0.2.10",
|
|
18
18
|
"@metaplex-foundation/mpl-token-metadata": "^2.5.2",
|
|
19
19
|
"@solana/web3.js": "1.91.6",
|