@atomiqlabs/chain-starknet 7.0.13 → 7.0.14
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.
|
@@ -66,14 +66,28 @@ class StarknetTransactions extends StarknetModule_1.StarknetModule {
|
|
|
66
66
|
const subscription = await this.root.wsChannel.subscribeTransactionStatus({
|
|
67
67
|
transactionHash: txId
|
|
68
68
|
});
|
|
69
|
-
const
|
|
69
|
+
const endSubscription = async () => {
|
|
70
|
+
if (this.root.wsChannel.isConnected() && await subscription.unsubscribe())
|
|
71
|
+
return;
|
|
72
|
+
this.root.wsChannel.removeSubscription(subscription.id);
|
|
73
|
+
};
|
|
74
|
+
if (abortSignal != null && abortSignal.aborted) {
|
|
75
|
+
await endSubscription();
|
|
76
|
+
abortSignal.throwIfAborted();
|
|
77
|
+
}
|
|
78
|
+
const status = await new Promise((resolve, reject) => {
|
|
79
|
+
if (abortSignal != null)
|
|
80
|
+
abortSignal.onabort = () => {
|
|
81
|
+
endSubscription().catch(err => this.logger.error("confirmTransactionWs(): End subscription error: ", err));
|
|
82
|
+
reject(abortSignal.reason);
|
|
83
|
+
};
|
|
70
84
|
subscription.on((data) => {
|
|
71
85
|
if (data.status.finality_status !== starknet_1.ETransactionStatus.ACCEPTED_ON_L2 && data.status.finality_status !== starknet_1.ETransactionStatus.ACCEPTED_ON_L1)
|
|
72
86
|
return; //No pre-confs
|
|
73
87
|
resolve(data.status.execution_status === starknet_1.ETransactionExecutionStatus.SUCCEEDED ? "success" : "reverted");
|
|
74
88
|
});
|
|
75
89
|
});
|
|
76
|
-
await
|
|
90
|
+
await endSubscription();
|
|
77
91
|
this.logger.debug(`confirmTransactionWs(): Transaction ${txId} confirmed, transaction status: ${status}`);
|
|
78
92
|
return {
|
|
79
93
|
txId,
|
package/package.json
CHANGED
|
@@ -99,13 +99,25 @@ export class StarknetTransactions extends StarknetModule {
|
|
|
99
99
|
const subscription = await this.root.wsChannel.subscribeTransactionStatus({
|
|
100
100
|
transactionHash: txId
|
|
101
101
|
});
|
|
102
|
-
const
|
|
102
|
+
const endSubscription = async () => {
|
|
103
|
+
if(this.root.wsChannel.isConnected() && await subscription.unsubscribe()) return;
|
|
104
|
+
this.root.wsChannel.removeSubscription(subscription.id);
|
|
105
|
+
}
|
|
106
|
+
if(abortSignal!=null && abortSignal.aborted) {
|
|
107
|
+
await endSubscription();
|
|
108
|
+
abortSignal.throwIfAborted();
|
|
109
|
+
}
|
|
110
|
+
const status = await new Promise<"reverted" | "success">((resolve, reject) => {
|
|
111
|
+
if(abortSignal!=null) abortSignal.onabort = () => {
|
|
112
|
+
endSubscription().catch(err => this.logger.error("confirmTransactionWs(): End subscription error: ", err));
|
|
113
|
+
reject(abortSignal.reason);
|
|
114
|
+
};
|
|
103
115
|
subscription.on((data) => {
|
|
104
116
|
if(data.status.finality_status!==ETransactionStatus.ACCEPTED_ON_L2 && data.status.finality_status!==ETransactionStatus.ACCEPTED_ON_L1) return; //No pre-confs
|
|
105
117
|
resolve(data.status.execution_status===ETransactionExecutionStatus.SUCCEEDED ? "success" : "reverted");
|
|
106
118
|
});
|
|
107
119
|
});
|
|
108
|
-
await
|
|
120
|
+
await endSubscription();
|
|
109
121
|
this.logger.debug(`confirmTransactionWs(): Transaction ${txId} confirmed, transaction status: ${status}`);
|
|
110
122
|
return {
|
|
111
123
|
txId,
|