@clonegod/ttd-sui-common 1.0.0 → 1.0.2
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/README.md +12 -0
- package/dist/grpc/grpc-connection.d.ts +13 -0
- package/dist/grpc/grpc-connection.js +99 -0
- package/dist/grpc/index.d.ts +5 -0
- package/dist/grpc/index.js +13 -0
- package/dist/grpc/ledger-service.d.ts +12 -0
- package/dist/grpc/ledger-service.js +159 -0
- package/dist/grpc/live-data-service.d.ts +10 -0
- package/dist/grpc/live-data-service.js +101 -0
- package/dist/grpc/subscription-service.d.ts +7 -0
- package/dist/grpc/subscription-service.js +63 -0
- package/dist/grpc/transaction-service.d.ts +7 -0
- package/dist/grpc/transaction-service.js +48 -0
- package/dist/index.js +1 -1
- package/dist/rpc/account-api.d.ts +14 -0
- package/dist/rpc/account-api.js +113 -0
- package/dist/rpc/coin-api.d.ts +0 -0
- package/dist/rpc/coin-api.js +0 -0
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/index.js +13 -0
- package/dist/rpc/rpc-connection.d.ts +8 -0
- package/dist/rpc/rpc-connection.js +54 -0
- package/dist/test/test.d.ts +1 -0
- package/dist/test/test.js +126 -0
- package/dist/test/test_grpc.d.ts +1 -0
- package/dist/test/test_grpc.js +93 -0
- package/dist/test/test_rpc.d.ts +1 -0
- package/dist/test/test_rpc.js +34 -0
- package/dist/transaction_28FaeTYoctpP1VdWCuyPxNEBeaMm3ebj27kdF5umi9YL.json +4754 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +43 -0
- package/package.json +21 -16
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeBytes = decodeBytes;
|
|
4
|
+
exports.parseObjectAmount = parseObjectAmount;
|
|
5
|
+
function decodeBytes(obj) {
|
|
6
|
+
if (Array.isArray(obj)) {
|
|
7
|
+
return obj.map((item) => decodeBytes(item));
|
|
8
|
+
}
|
|
9
|
+
else if (obj && typeof obj === 'object') {
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const key of Object.keys(obj)) {
|
|
12
|
+
const val = obj[key];
|
|
13
|
+
if (Buffer.isBuffer(val) || (Array.isArray(val) && typeof val[0] === 'number')) {
|
|
14
|
+
result[key] = Buffer.from(val).toString('hex');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result[key] = decodeBytes(val);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
function parseObjectAmount(objectResponse) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
try {
|
|
27
|
+
if (!((_b = (_a = objectResponse === null || objectResponse === void 0 ? void 0 : objectResponse.object) === null || _a === void 0 ? void 0 : _a.contents) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const contentsValue = objectResponse.object.contents.value;
|
|
31
|
+
if (contentsValue.length < 80) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const balanceHex = contentsValue.substring(64, 80);
|
|
35
|
+
const balanceBytes = Buffer.from(balanceHex, 'hex');
|
|
36
|
+
const balance = balanceBytes.readBigUInt64LE(0).toString();
|
|
37
|
+
return balance;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error('提取代币余额失败:', error);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sui-common",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Sui common library",
|
|
5
|
+
"license": "UNLICENSED",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"types": "
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
10
11
|
"scripts": {
|
|
11
12
|
"clean": "rm -rf dist node_modules",
|
|
12
|
-
"build": "
|
|
13
|
+
"build": "yarn tsc --outDir ./dist",
|
|
13
14
|
"push": "npm run build && npm publish"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"@clonegod/ttd-core": "2.0.57",
|
|
18
|
+
"@grpc/grpc-js": "^1.9.14",
|
|
19
|
+
"@grpc/proto-loader": "^0.7.10",
|
|
20
|
+
"axios": "^1.11.00",
|
|
21
|
+
"dotenv": "^16.4.7",
|
|
22
|
+
"google-protobuf": "^4.0.0",
|
|
23
|
+
"protobufjs": "^7.5.4"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
|
-
"@types/
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
+
"@types/google-protobuf": "^3.15.12",
|
|
27
|
+
"@types/node": "^22.14.0",
|
|
28
|
+
"grpc-tools": "^1.13.0",
|
|
29
|
+
"protoc-gen-ts": "^0.8.7",
|
|
30
|
+
"typescript": "^5.8.2"
|
|
26
31
|
},
|
|
27
32
|
"overrides": {},
|
|
28
33
|
"publishConfig": {
|
|
29
34
|
"access": "public"
|
|
30
35
|
}
|
|
31
|
-
}
|
|
36
|
+
}
|