@pioneer-platform/pioneer-discovery 8.15.13 ā 8.15.15
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 +14 -0
- package/lib/generatedAssetData.json +28349 -14167
- package/package.json +2 -2
- package/scripts/add-colors-from-shapeshift.js +87 -0
- package/scripts/add-random-colors.js +97 -0
- package/scripts/generate-native-assets.js +52 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-discovery",
|
|
3
|
-
"version": "8.15.
|
|
3
|
+
"version": "8.15.15",
|
|
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.2",
|
|
33
33
|
"ethers": "5.7.2"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Add Colors from ShapeShift Color Map
|
|
4
|
+
*
|
|
5
|
+
* This script merges color data from ShapeShift's color-map.json into our generatedAssetData.json.
|
|
6
|
+
* ShapeShift has extensive color data for 10,000+ assets that we can leverage.
|
|
7
|
+
*
|
|
8
|
+
* Usage: node scripts/add-colors-from-shapeshift.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
const SHAPESHIFT_COLOR_MAP_PATH = '/Users/highlander/WebstormProjects/web/scripts/generateAssetData/color-map.json';
|
|
15
|
+
const ASSET_DATA_PATH = path.join(__dirname, '../src/generatedAssetData.json');
|
|
16
|
+
|
|
17
|
+
async function addColorsFromShapeShift() {
|
|
18
|
+
console.log('šØ Adding colors from ShapeShift color map...\n');
|
|
19
|
+
|
|
20
|
+
// Load ShapeShift color map
|
|
21
|
+
if (!fs.existsSync(SHAPESHIFT_COLOR_MAP_PATH)) {
|
|
22
|
+
console.error('ā ShapeShift color-map.json not found at:', SHAPESHIFT_COLOR_MAP_PATH);
|
|
23
|
+
console.error(' Make sure the web repository is cloned');
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const colorMap = JSON.parse(fs.readFileSync(SHAPESHIFT_COLOR_MAP_PATH, 'utf8'));
|
|
28
|
+
console.log(`ā
Loaded ${Object.keys(colorMap).length} colors from ShapeShift`);
|
|
29
|
+
|
|
30
|
+
// Load our asset data
|
|
31
|
+
const assetData = JSON.parse(fs.readFileSync(ASSET_DATA_PATH, 'utf8'));
|
|
32
|
+
const totalAssets = Object.keys(assetData).length;
|
|
33
|
+
console.log(`ā
Loaded ${totalAssets} assets from generatedAssetData.json`);
|
|
34
|
+
|
|
35
|
+
// Merge colors
|
|
36
|
+
let matchedColors = 0;
|
|
37
|
+
let alreadyHadColor = 0;
|
|
38
|
+
let noMatch = 0;
|
|
39
|
+
|
|
40
|
+
for (const [caip, asset] of Object.entries(assetData)) {
|
|
41
|
+
// Skip if already has color
|
|
42
|
+
if (asset.color) {
|
|
43
|
+
alreadyHadColor++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Try to find color in ShapeShift map
|
|
48
|
+
const color = colorMap[caip];
|
|
49
|
+
if (color) {
|
|
50
|
+
asset.color = color;
|
|
51
|
+
matchedColors++;
|
|
52
|
+
} else {
|
|
53
|
+
noMatch++;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log('\nš Results:');
|
|
58
|
+
console.log(` Matched colors: ${matchedColors}`);
|
|
59
|
+
console.log(` Already had color: ${alreadyHadColor}`);
|
|
60
|
+
console.log(` No match found: ${noMatch}`);
|
|
61
|
+
console.log(` Total assets: ${totalAssets}`);
|
|
62
|
+
console.log(` Coverage: ${((matchedColors + alreadyHadColor) / totalAssets * 100).toFixed(1)}%`);
|
|
63
|
+
|
|
64
|
+
// Write updated asset data
|
|
65
|
+
fs.writeFileSync(ASSET_DATA_PATH, JSON.stringify(assetData, null, 2));
|
|
66
|
+
console.log(`\nā
Updated ${ASSET_DATA_PATH}`);
|
|
67
|
+
|
|
68
|
+
// Show some sample matches
|
|
69
|
+
console.log('\nš Sample matched assets:');
|
|
70
|
+
const samples = Object.entries(assetData)
|
|
71
|
+
.filter(([_, asset]) => asset.color && colorMap[_])
|
|
72
|
+
.slice(0, 5);
|
|
73
|
+
|
|
74
|
+
for (const [caip, asset] of samples) {
|
|
75
|
+
console.log(` ${asset.symbol?.padEnd(8)} ${caip.substring(0, 40)}... ā ${asset.color}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('\nš Done! Run: bun run build');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Execute
|
|
82
|
+
addColorsFromShapeShift()
|
|
83
|
+
.then(() => process.exit(0))
|
|
84
|
+
.catch(err => {
|
|
85
|
+
console.error('ā Error:', err.message);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Add Random Deterministic Colors
|
|
4
|
+
*
|
|
5
|
+
* This script generates random but consistent colors for all assets that don't have colors.
|
|
6
|
+
* Uses a hash-based approach so the same asset always gets the same color.
|
|
7
|
+
*
|
|
8
|
+
* Usage: node scripts/add-random-colors.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const crypto = require('crypto');
|
|
14
|
+
|
|
15
|
+
const ASSET_DATA_PATH = path.join(__dirname, '../src/generatedAssetData.json');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate a deterministic color from a string
|
|
19
|
+
* @param {string} str - Input string (CAIP or symbol)
|
|
20
|
+
* @returns {string} Hex color code
|
|
21
|
+
*/
|
|
22
|
+
function generateDeterministicColor(str) {
|
|
23
|
+
// Create hash from string
|
|
24
|
+
const hash = crypto.createHash('md5').update(str).digest('hex');
|
|
25
|
+
|
|
26
|
+
// Use first 6 chars as RGB values
|
|
27
|
+
const r = parseInt(hash.substring(0, 2), 16);
|
|
28
|
+
const g = parseInt(hash.substring(2, 4), 16);
|
|
29
|
+
const b = parseInt(hash.substring(4, 6), 16);
|
|
30
|
+
|
|
31
|
+
// Ensure colors are vibrant enough (not too dark or too light)
|
|
32
|
+
const adjust = (val) => {
|
|
33
|
+
// Avoid very dark (< 50) and very light (> 230) colors
|
|
34
|
+
if (val < 50) return val + 100;
|
|
35
|
+
if (val > 230) return val - 100;
|
|
36
|
+
return val;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const adjustedR = adjust(r);
|
|
40
|
+
const adjustedG = adjust(g);
|
|
41
|
+
const adjustedB = adjust(b);
|
|
42
|
+
|
|
43
|
+
return `#${adjustedR.toString(16).padStart(2, '0')}${adjustedG.toString(16).padStart(2, '0')}${adjustedB.toString(16).padStart(2, '0')}`.toUpperCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function addRandomColors() {
|
|
47
|
+
console.log('šØ Adding random deterministic colors...\n');
|
|
48
|
+
|
|
49
|
+
// Load our asset data
|
|
50
|
+
const assetData = JSON.parse(fs.readFileSync(ASSET_DATA_PATH, 'utf8'));
|
|
51
|
+
const totalAssets = Object.keys(assetData).length;
|
|
52
|
+
console.log(`ā
Loaded ${totalAssets} assets from generatedAssetData.json`);
|
|
53
|
+
|
|
54
|
+
// Add colors
|
|
55
|
+
let alreadyHadColor = 0;
|
|
56
|
+
let addedColors = 0;
|
|
57
|
+
|
|
58
|
+
for (const [caip, asset] of Object.entries(assetData)) {
|
|
59
|
+
if (asset.color) {
|
|
60
|
+
alreadyHadColor++;
|
|
61
|
+
} else {
|
|
62
|
+
// Generate deterministic color from CAIP
|
|
63
|
+
asset.color = generateDeterministicColor(caip);
|
|
64
|
+
addedColors++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log('\nš Results:');
|
|
69
|
+
console.log(` Already had color: ${alreadyHadColor} (${((alreadyHadColor/totalAssets)*100).toFixed(1)}%)`);
|
|
70
|
+
console.log(` Added random colors: ${addedColors} (${((addedColors/totalAssets)*100).toFixed(1)}%)`);
|
|
71
|
+
console.log(` Total assets: ${totalAssets}`);
|
|
72
|
+
console.log(` Coverage: 100.0%`);
|
|
73
|
+
|
|
74
|
+
// Write updated asset data
|
|
75
|
+
fs.writeFileSync(ASSET_DATA_PATH, JSON.stringify(assetData, null, 2));
|
|
76
|
+
console.log(`\nā
Updated ${ASSET_DATA_PATH}`);
|
|
77
|
+
|
|
78
|
+
// Show some sample new colors
|
|
79
|
+
console.log('\nš Sample newly added colors:');
|
|
80
|
+
const samples = Object.entries(assetData)
|
|
81
|
+
.filter(([caip, _]) => !assetData[caip].color || assetData[caip].color === generateDeterministicColor(caip))
|
|
82
|
+
.slice(0, 10);
|
|
83
|
+
|
|
84
|
+
for (const [caip, asset] of samples) {
|
|
85
|
+
console.log(` ${(asset.symbol || 'N/A').padEnd(8)} ${asset.color}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.log('\nš Done! All assets now have colors. Run: bun run build');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Execute
|
|
92
|
+
addRandomColors()
|
|
93
|
+
.then(() => process.exit(0))
|
|
94
|
+
.catch(err => {
|
|
95
|
+
console.error('ā Error:', err.message);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Generate Native Gas Asset Definitions
|
|
4
4
|
*
|
|
5
5
|
* This script generates asset definitions for native blockchain gas assets
|
|
6
|
-
* (BTC, ETH, ATOM, etc.)
|
|
6
|
+
* (BTC, ETH, ATOM, etc.) and chain-specific tokens (MAYA, etc.) using data
|
|
7
|
+
* from pioneer-coins and pioneer-caip.
|
|
7
8
|
*
|
|
8
9
|
* These assets were missing from generatedAssetData.json, causing getGasAssets()
|
|
9
10
|
* to fail during SDK initialization.
|
|
@@ -128,12 +129,30 @@ const NATIVE_GAS_ASSETS = [
|
|
|
128
129
|
},
|
|
129
130
|
];
|
|
130
131
|
|
|
132
|
+
// Denom-based tokens (Cosmos SDK chains)
|
|
133
|
+
// Format: { symbol, name, chainId, denom, icon URL, decimals, color, explorer }
|
|
134
|
+
const DENOM_TOKENS = [
|
|
135
|
+
{
|
|
136
|
+
symbol: 'MAYA',
|
|
137
|
+
name: 'Maya Token',
|
|
138
|
+
chainId: 'cosmos:mayachain-mainnet-v1',
|
|
139
|
+
denom: 'maya',
|
|
140
|
+
icon: 'https://pioneers.dev/coins/maya.png',
|
|
141
|
+
decimals: 4,
|
|
142
|
+
color: '#00D4AA',
|
|
143
|
+
explorer: 'https://explorer.mayachain.info',
|
|
144
|
+
explorerAddressLink: 'https://explorer.mayachain.info/address/{{address}}',
|
|
145
|
+
explorerTxLink: 'https://explorer.mayachain.info/tx/{{txid}}',
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
|
|
131
149
|
/**
|
|
132
150
|
* Generate asset data entries in the format expected by generatedAssetData.json
|
|
133
151
|
*/
|
|
134
152
|
function generateNativeAssetData() {
|
|
135
153
|
const assetData = {};
|
|
136
154
|
|
|
155
|
+
// Generate native gas assets (slip44 format)
|
|
137
156
|
for (const asset of NATIVE_GAS_ASSETS) {
|
|
138
157
|
// Create CAIP assetId with slip44 for native assets
|
|
139
158
|
const assetId = `${asset.chainId}/slip44:${getSlip44(asset.symbol)}`;
|
|
@@ -146,6 +165,29 @@ function generateNativeAssetData() {
|
|
|
146
165
|
assetId: assetId,
|
|
147
166
|
decimals: asset.decimals,
|
|
148
167
|
isNative: true, // Mark as native gas asset for easy filtering
|
|
168
|
+
type: 'native',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Generate denom-based tokens
|
|
173
|
+
for (const token of DENOM_TOKENS) {
|
|
174
|
+
// Create CAIP assetId with denom for tokens
|
|
175
|
+
const assetId = `${token.chainId}/denom:${token.denom}`;
|
|
176
|
+
|
|
177
|
+
assetData[assetId] = {
|
|
178
|
+
symbol: token.symbol,
|
|
179
|
+
name: token.name,
|
|
180
|
+
chainId: token.chainId,
|
|
181
|
+
icon: token.icon,
|
|
182
|
+
assetId: assetId,
|
|
183
|
+
decimals: token.decimals,
|
|
184
|
+
isToken: true,
|
|
185
|
+
type: 'token',
|
|
186
|
+
denom: token.denom,
|
|
187
|
+
color: token.color,
|
|
188
|
+
explorer: token.explorer,
|
|
189
|
+
explorerAddressLink: token.explorerAddressLink,
|
|
190
|
+
explorerTxLink: token.explorerTxLink,
|
|
149
191
|
};
|
|
150
192
|
}
|
|
151
193
|
|
|
@@ -188,11 +230,13 @@ function getSlip44(symbol) {
|
|
|
188
230
|
* Output the generated asset data
|
|
189
231
|
*/
|
|
190
232
|
function main() {
|
|
191
|
-
const
|
|
233
|
+
const allAssets = generateNativeAssetData();
|
|
234
|
+
const nativeCount = NATIVE_GAS_ASSETS.length;
|
|
235
|
+
const tokenCount = DENOM_TOKENS.length;
|
|
192
236
|
|
|
193
|
-
console.log('Generated
|
|
194
|
-
console.log(JSON.stringify(
|
|
195
|
-
console.log(`\nTotal: ${Object.keys(
|
|
237
|
+
console.log('Generated Asset Definitions:');
|
|
238
|
+
console.log(JSON.stringify(allAssets, null, 2));
|
|
239
|
+
console.log(`\nTotal: ${Object.keys(allAssets).length} assets (${nativeCount} native gas, ${tokenCount} denom tokens)`);
|
|
196
240
|
|
|
197
241
|
// Instructions for manual integration
|
|
198
242
|
console.log('\n=== Integration Instructions ===');
|
|
@@ -200,7 +244,8 @@ function main() {
|
|
|
200
244
|
console.log('2. Add it to the TOP of generatedAssetData.json (before ERC20 tokens)');
|
|
201
245
|
console.log('3. Run: cd modules/pioneer/pioneer-discovery && bun run build');
|
|
202
246
|
console.log('4. Run: cd modules/pioneer/pioneer-sdk && bun run build');
|
|
203
|
-
console.log('5. Test: getGasAssets() should now return native assets
|
|
247
|
+
console.log('5. Test: getGasAssets() should now return all native assets');
|
|
248
|
+
console.log('6. Test: MAYA token should load without hardcoded definition\n');
|
|
204
249
|
}
|
|
205
250
|
|
|
206
251
|
// Execute if run directly
|
|
@@ -208,4 +253,4 @@ if (require.main === module) {
|
|
|
208
253
|
main();
|
|
209
254
|
}
|
|
210
255
|
|
|
211
|
-
module.exports = { generateNativeAssetData, NATIVE_GAS_ASSETS };
|
|
256
|
+
module.exports = { generateNativeAssetData, NATIVE_GAS_ASSETS, DENOM_TOKENS };
|