@clonegod/ttd-sui-common 1.0.57 → 1.0.59
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/rpc/index.d.ts +3 -5
- package/dist/rpc/index.js +83 -11
- package/dist/trade/send_tx/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/rpc/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export { TransactionService } from './transaction-service';
|
|
5
|
-
export { NetworkService } from './network-service';
|
|
1
|
+
import { SuiClient } from "@mysten/sui/dist/cjs/client/client";
|
|
2
|
+
export declare function get_all_objects_in_wallet(suiClient: SuiClient, walletAddress: string, limit?: number): Promise<any[]>;
|
|
3
|
+
export declare function print_group_objects(allObjects: any[]): Promise<void>;
|
package/dist/rpc/index.js
CHANGED
|
@@ -1,13 +1,85 @@
|
|
|
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
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
exports.get_all_objects_in_wallet = get_all_objects_in_wallet;
|
|
13
|
+
exports.print_group_objects = print_group_objects;
|
|
14
|
+
function get_all_objects_in_wallet(suiClient_1, walletAddress_1) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* (suiClient, walletAddress, limit = 50) {
|
|
16
|
+
if (!walletAddress) {
|
|
17
|
+
throw new Error('walletAddress is required');
|
|
18
|
+
}
|
|
19
|
+
let allObjects = [];
|
|
20
|
+
let hasNextPage = true;
|
|
21
|
+
let cursor = null;
|
|
22
|
+
while (hasNextPage) {
|
|
23
|
+
const response = yield suiClient.getOwnedObjects({
|
|
24
|
+
owner: walletAddress,
|
|
25
|
+
limit: limit,
|
|
26
|
+
cursor: cursor,
|
|
27
|
+
options: {
|
|
28
|
+
showType: true,
|
|
29
|
+
showContent: true,
|
|
30
|
+
showDisplay: true,
|
|
31
|
+
showPreviousTransaction: true,
|
|
32
|
+
showStorageRebate: true
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
allObjects = allObjects.concat(response.data);
|
|
36
|
+
hasNextPage = response.hasNextPage;
|
|
37
|
+
cursor = response.nextCursor || null;
|
|
38
|
+
console.log(`当前已查询到 ${allObjects.length} 个对象。 hasNextPage= ${hasNextPage}`);
|
|
39
|
+
}
|
|
40
|
+
return allObjects;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function print_group_objects(allObjects) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const objectTypeMap = new Map();
|
|
46
|
+
allObjects.forEach(obj => {
|
|
47
|
+
var _a;
|
|
48
|
+
const type = ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.type) || 'unknown';
|
|
49
|
+
const count = objectTypeMap.get(type) || 0;
|
|
50
|
+
objectTypeMap.set(type, count + 1);
|
|
51
|
+
});
|
|
52
|
+
console.log(`\n=== 按类型分组的所有对象 ===`);
|
|
53
|
+
objectTypeMap.forEach((count, type) => {
|
|
54
|
+
console.log(`${type}: ${count} 个对象`);
|
|
55
|
+
});
|
|
56
|
+
console.log(`\n=== Coins ===`);
|
|
57
|
+
const typeGroups = new Map();
|
|
58
|
+
allObjects.forEach(obj => {
|
|
59
|
+
var _a;
|
|
60
|
+
const type = ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.type) || 'unknown';
|
|
61
|
+
if (!typeGroups.has(type)) {
|
|
62
|
+
typeGroups.set(type, []);
|
|
63
|
+
}
|
|
64
|
+
typeGroups.get(type).push(obj);
|
|
65
|
+
});
|
|
66
|
+
let coinIndex = 1;
|
|
67
|
+
typeGroups.forEach((objects, type) => {
|
|
68
|
+
console.log(`\nCoin ${coinIndex} - ${type} (${objects.length} 个对象):`);
|
|
69
|
+
objects.forEach((obj, objIndex) => {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
console.log(` object ${objIndex + 1}:`);
|
|
72
|
+
console.log(` - objectId: ${(_a = obj.data) === null || _a === void 0 ? void 0 : _a.objectId}`);
|
|
73
|
+
console.log(` - version: ${(_b = obj.data) === null || _b === void 0 ? void 0 : _b.version}`);
|
|
74
|
+
console.log(` - digest: ${(_c = obj.data) === null || _c === void 0 ? void 0 : _c.digest}`);
|
|
75
|
+
if (((_d = obj.data) === null || _d === void 0 ? void 0 : _d.content) && 'fields' in obj.data.content) {
|
|
76
|
+
const fields = obj.data.content.fields;
|
|
77
|
+
if (fields.balance) {
|
|
78
|
+
console.log(` - balance: ${fields.balance}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
coinIndex++;
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -21,7 +21,7 @@ class SuiTxSender {
|
|
|
21
21
|
else {
|
|
22
22
|
yield this.sendTxByRpc(signedTxBytes, signature, txDigest);
|
|
23
23
|
}
|
|
24
|
-
(0, dist_1.log_info)(`
|
|
24
|
+
(0, dist_1.log_info)(`send_tx, txid=${txDigest}, send_grpc=${send_grpc}, cost=${Date.now() - start_time}ms`);
|
|
25
25
|
});
|
|
26
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
27
|
return this.send_tx(signedTxBytes, signature, txDigest, send_grpc, ['transaction']);
|