@pioneer-platform/pioneer-discovery 8.14.1 ā 8.15.13
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/CHANGELOG.md +8 -0
- package/data/coingecko-mapping.json +1 -1
- package/lib/generatedAssetData.json +42489 -14165
- package/lib/generatedAssetData.json.backup +99199 -0
- package/package.json +2 -2
- package/scripts/standardize-asset-metadata.ts +91 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-discovery",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.15.13",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/main.d.ts",
|
|
6
6
|
"_moduleAliases": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
32
|
-
"@pioneer-platform/pioneer-caip": "^9.10.
|
|
32
|
+
"@pioneer-platform/pioneer-caip": "^9.10.1",
|
|
33
33
|
"ethers": "5.7.2"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 2: Standardize metadata structure in generatedAssetData.json
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const TAG = ' | standardize-metadata | ';
|
|
9
|
+
|
|
10
|
+
function inferTypeFromCaip(caip: string): 'native' | 'token' | 'unknown' {
|
|
11
|
+
if (caip.includes('/slip44:')) return 'native';
|
|
12
|
+
if (caip.includes('/erc20:') || caip.includes('/bep20:') || caip.includes('/spl:')) return 'token';
|
|
13
|
+
if (caip.includes('/denom:')) return 'native';
|
|
14
|
+
return 'unknown';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function standardizeMetadata() {
|
|
18
|
+
const assetsPath = path.join(__dirname, '../lib/generatedAssetData.json');
|
|
19
|
+
|
|
20
|
+
console.log(TAG, 'Loading generatedAssetData.json from:', assetsPath);
|
|
21
|
+
|
|
22
|
+
const rawData = fs.readFileSync(assetsPath, 'utf8');
|
|
23
|
+
const assetData = JSON.parse(rawData);
|
|
24
|
+
|
|
25
|
+
const caips = Object.keys(assetData);
|
|
26
|
+
console.log(TAG, `Processing ${caips.length} assets...`);
|
|
27
|
+
|
|
28
|
+
let updated = 0;
|
|
29
|
+
let alreadyHadType = 0;
|
|
30
|
+
let inferredFromIsNative = 0;
|
|
31
|
+
let inferredFromCaip = 0;
|
|
32
|
+
|
|
33
|
+
for (const caip of caips) {
|
|
34
|
+
const asset = assetData[caip];
|
|
35
|
+
|
|
36
|
+
if (asset.type) {
|
|
37
|
+
alreadyHadType++;
|
|
38
|
+
if (!asset.hasOwnProperty('isNative')) {
|
|
39
|
+
asset.isNative = (asset.type === 'native');
|
|
40
|
+
updated++;
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (asset.hasOwnProperty('isNative')) {
|
|
46
|
+
asset.type = asset.isNative ? 'native' : 'token';
|
|
47
|
+
inferredFromIsNative++;
|
|
48
|
+
} else {
|
|
49
|
+
const inferredType = inferTypeFromCaip(caip);
|
|
50
|
+
asset.type = inferredType;
|
|
51
|
+
asset.isNative = (inferredType === 'native');
|
|
52
|
+
inferredFromCaip++;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
updated++;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log(TAG, '\nš Summary:');
|
|
59
|
+
console.log(TAG, ` Total assets: ${caips.length}`);
|
|
60
|
+
console.log(TAG, ` Already had type: ${alreadyHadType}`);
|
|
61
|
+
console.log(TAG, ` Inferred from isNative: ${inferredFromIsNative}`);
|
|
62
|
+
console.log(TAG, ` Inferred from CAIP: ${inferredFromCaip}`);
|
|
63
|
+
console.log(TAG, ` Total updated: ${updated}`);
|
|
64
|
+
|
|
65
|
+
const backupPath = assetsPath + '.backup';
|
|
66
|
+
console.log(TAG, '\nš¾ Creating backup:', backupPath);
|
|
67
|
+
fs.writeFileSync(backupPath, rawData);
|
|
68
|
+
|
|
69
|
+
console.log(TAG, 'š¾ Writing updated data...');
|
|
70
|
+
fs.writeFileSync(assetsPath, JSON.stringify(assetData, null, 2));
|
|
71
|
+
|
|
72
|
+
const srcPath = path.join(__dirname, '../src/generatedAssetData.json');
|
|
73
|
+
if (fs.existsSync(srcPath)) {
|
|
74
|
+
console.log(TAG, 'š¾ Updating src version:', srcPath);
|
|
75
|
+
fs.writeFileSync(srcPath, JSON.stringify(assetData, null, 2));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(TAG, '\nā
Metadata standardization complete!');
|
|
79
|
+
|
|
80
|
+
return { total: caips.length, updated, alreadyHadType, inferredFromIsNative, inferredFromCaip };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
standardizeMetadata()
|
|
84
|
+
.then((stats) => {
|
|
85
|
+
console.log(TAG, '\n⨠Done!', stats);
|
|
86
|
+
process.exit(0);
|
|
87
|
+
})
|
|
88
|
+
.catch((error) => {
|
|
89
|
+
console.error(TAG, 'ā Error:', error);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
});
|