@clonegod/ttd-sui-common 1.0.56 → 1.0.57
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.
|
@@ -3,5 +3,5 @@ export declare class TransactionService {
|
|
|
3
3
|
private transactionClient;
|
|
4
4
|
private connection;
|
|
5
5
|
constructor(connection: GrpcConnection);
|
|
6
|
-
executeTransaction(transactionBytes: Uint8Array, signatureBytes: Uint8Array, fields
|
|
6
|
+
executeTransaction(transactionBytes: Uint8Array, signatureBytes: Uint8Array, fields: string[]): Promise<unknown>;
|
|
7
7
|
}
|
|
@@ -15,8 +15,11 @@ class TransactionService {
|
|
|
15
15
|
this.connection = connection;
|
|
16
16
|
this.transactionClient = connection.createServiceClient('transaction_execution_service.proto', 'TransactionExecutionService');
|
|
17
17
|
}
|
|
18
|
-
executeTransaction(
|
|
19
|
-
return __awaiter(this,
|
|
18
|
+
executeTransaction(transactionBytes, signatureBytes, fields) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (!fields || fields.length === 0) {
|
|
21
|
+
fields = ['transaction', 'finality'];
|
|
22
|
+
}
|
|
20
23
|
return new Promise((resolve, reject) => {
|
|
21
24
|
const request = {
|
|
22
25
|
transaction: {
|
|
@@ -6,7 +6,9 @@ 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, send_grpc?: boolean,
|
|
9
|
+
send_tx: (signedTxBytes: string, signature: string, txDigest: string, send_grpc?: boolean, read_mask_fields?: string[]) => Promise<void>;
|
|
10
10
|
private sendTxByGrpc;
|
|
11
11
|
private sendTxByRpc;
|
|
12
|
+
send_tx_fast: (signedTxBytes: string, signature: string, txDigest: string, send_grpc?: boolean) => Promise<void>;
|
|
13
|
+
send_tx_safe: (signedTxBytes: string, signature: string, txDigest: string, send_grpc?: boolean) => Promise<void>;
|
|
12
14
|
}
|
|
@@ -13,25 +13,32 @@ exports.SuiTxSender = void 0;
|
|
|
13
13
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
14
14
|
class SuiTxSender {
|
|
15
15
|
constructor(appConfig, sui_client, grpcClient) {
|
|
16
|
-
this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = false,
|
|
17
|
-
|
|
16
|
+
this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = false, read_mask_fields = ['transaction']) {
|
|
17
|
+
const start_time = Date.now();
|
|
18
18
|
if (send_grpc) {
|
|
19
|
-
yield this.sendTxByGrpc(signedTxBytes, signature, txDigest,
|
|
19
|
+
yield this.sendTxByGrpc(signedTxBytes, signature, txDigest, read_mask_fields);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
22
|
yield this.sendTxByRpc(signedTxBytes, signature, txDigest);
|
|
23
23
|
}
|
|
24
|
+
(0, dist_1.log_info)(`send tx:txid=${txDigest}, send_grpc=${send_grpc}, cost=${Date.now() - start_time}ms`);
|
|
25
|
+
});
|
|
26
|
+
this.send_tx_fast = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = true) {
|
|
27
|
+
return this.send_tx(signedTxBytes, signature, txDigest, send_grpc, ['transaction']);
|
|
28
|
+
});
|
|
29
|
+
this.send_tx_safe = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = true) {
|
|
30
|
+
return this.send_tx(signedTxBytes, signature, txDigest, send_grpc, ['transaction', 'finality']);
|
|
24
31
|
});
|
|
25
32
|
this.appConfig = appConfig;
|
|
26
33
|
this.sui_client = sui_client;
|
|
27
34
|
this.grpcClient = grpcClient;
|
|
28
35
|
}
|
|
29
36
|
sendTxByGrpc(signedTxBytes_1, signature_1, txDigest_1) {
|
|
30
|
-
return __awaiter(this, arguments, void 0, function* (signedTxBytes, signature, txDigest,
|
|
37
|
+
return __awaiter(this, arguments, void 0, function* (signedTxBytes, signature, txDigest, read_mask_fields = ['transaction']) {
|
|
31
38
|
const bcsBytes = Buffer.from(signedTxBytes, 'base64');
|
|
32
39
|
const signatureBytes = Buffer.from(signature, 'base64');
|
|
33
40
|
try {
|
|
34
|
-
let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes,
|
|
41
|
+
let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes, read_mask_fields);
|
|
35
42
|
this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, response);
|
|
36
43
|
}
|
|
37
44
|
catch (error) {
|