@clonegod/ttd-sui-common 1.0.28 → 1.0.30
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.
|
@@ -6,5 +6,5 @@ export declare class SuiTxSender {
|
|
|
6
6
|
sui_client: SuiClient;
|
|
7
7
|
grpcClient: SuiGrpcClient;
|
|
8
8
|
constructor(appConfig: AppConfig, sui_client: SuiClient, grpcClient: SuiGrpcClient);
|
|
9
|
-
send_tx: (signedTxBytes: string, signature: string, txDigest: string) => void
|
|
9
|
+
send_tx: (signedTxBytes: string, signature: string, txDigest: string) => Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.SuiTxSender = void 0;
|
|
4
13
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
5
14
|
class SuiTxSender {
|
|
6
15
|
constructor(appConfig, sui_client, grpcClient) {
|
|
7
|
-
this.send_tx = (signedTxBytes, signature, txDigest) => {
|
|
8
|
-
const promises = [];
|
|
16
|
+
this.send_tx = (signedTxBytes, signature, txDigest) => __awaiter(this, void 0, void 0, function* () {
|
|
9
17
|
const bcsBytes = Buffer.from(signedTxBytes, 'base64');
|
|
10
18
|
const signatureBytes = Buffer.from(signature, 'base64');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
try {
|
|
20
|
+
let _response = yield this.sui_client.executeTransactionBlock({
|
|
21
|
+
transactionBlock: signedTxBytes,
|
|
22
|
+
signature: signature,
|
|
23
|
+
options: {
|
|
24
|
+
showEvents: true,
|
|
25
|
+
showBalanceChanges: true,
|
|
26
|
+
showObjectChanges: true,
|
|
27
|
+
showEffects: true
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, txDigest);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
(0, dist_1.log_error)(`send tx by rpc failed!!! txid=${txDigest}`, error);
|
|
34
|
+
try {
|
|
35
|
+
let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes);
|
|
36
|
+
this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, response);
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}).catch((error) => {
|
|
30
|
-
(0, dist_1.log_error)(`submit tx to sui_client failed`, error);
|
|
31
|
-
return { type: 'rpc', success: false, error };
|
|
32
|
-
});
|
|
33
|
-
promises.push(rpcPromise);
|
|
34
|
-
Promise.race(promises).then((result) => {
|
|
35
|
-
if (result.type === 'rpc') {
|
|
36
|
-
this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, txDigest);
|
|
38
|
+
catch (error) {
|
|
39
|
+
(0, dist_1.log_error)(`send tx by grpc failed!!! txid=${txDigest}`, error);
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
43
|
this.appConfig = appConfig;
|
|
44
44
|
this.sui_client = sui_client;
|
|
45
45
|
this.grpcClient = grpcClient;
|