Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/komodo_defi_framework/app_build/BUILD_CONFIG_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@ Paths in the config are relative to that package directory.
- Use `--concurrent` for faster downloads in development
- Override behavior per build via env `OVERRIDE_DEFI_API_DOWNLOAD=true|false`

### Using Nebula mirror and short commit hashes

- You can add Nebula as an additional source in `api.source_urls`:

```
"source_urls": [
"https://api.github.com/repos/KomodoPlatform/komodo-defi-framework",
"https://sdk.devbuilds.komodo.earth/",
"https://nebula.decker.im/kdf"
]
```

- The downloader supports directory listings that are either branch-scoped (e.g., `.../dev/`) or flat. It searches for artifacts that match the platform patterns and contain either the full commit hash or a 7-char short hash.
- To pin a specific commit (e.g., `4025b8c`) without changing branches, update `api.api_commit_hash` or use the CLI with `--commit`:

```bash
dart run packages/komodo_wallet_cli/bin/update_api_config.dart \
--source mirror \
--mirror-url https://nebula.decker.im/ \
--commit 4025b8c \
--config packages/komodo_defi_framework/app_build/build_config.json \
--output-dir packages/komodo_defi_framework/app_build/temp_downloads \
--verbose
```

- To switch to a different Nebula commit in the future, either:
- Edit `api.api_commit_hash` in `build_config.json` to the new short/full hash, or
- Re-run the CLI with a different `--commit <hash>` value.

Notes:
- Nebula index includes additional files like `komodo-wallet-*`; these are automatically ignored by the downloader.
- macOS on Nebula uses `kdf-macos-universal2-<hash>.zip` (special case handled in `matching_pattern`). Other platforms use `kdf_<hash>-<platform>.zip`.

## Troubleshooting

- Missing files: verify `config_output_path` points to this folder and the file exists
Expand Down
25 changes: 13 additions & 12 deletions packages/komodo_defi_framework/app_build/build_config.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
{
"api": {
"api_commit_hash": "476262f0d3390e24cfe672d5e15a78a46397dbfa",
"branch": "hotfix-remove-memorydb-size-metric",
"api_commit_hash": "4025b8c",
"branch": "main",
"fetch_at_build_enabled": true,
"concurrent_downloads_enabled": true,
"source_urls": [
"https://api.github.com/repos/KomodoPlatform/komodo-defi-framework",
"https://sdk.devbuilds.komodo.earth/"
"https://sdk.devbuilds.komodo.earth/",
"https://nebula.decker.im/kdf"
],
"platforms": {
"web": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-wasm|mm2_[a-f0-9]{7,40}-wasm|mm2-[a-f0-9]{7,40}-wasm)\\.zip$",
"valid_zip_sha256_checksums": [
"1ce88c3ef6ee4da3839b392e77d9f667a897c4b0b9f4459f878a1561193541a7"
"d7cfd4dfa47f455ee283aa02c4dd11542b4bcf349928ec5b07a1f20b7141bd65"
],
"path": "web/kdf/bin"
},
"ios": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-ios-aarch64|mm2_[a-f0-9]{7,40}-ios-aarch64|mm2-[a-f0-9]{7,40}-ios-aarch64-CI)\\.zip$",
"valid_zip_sha256_checksums": [
"68569c2bb3362dc94dd54b0e696559962fab8b29bd1203dd252078aeb1863ca3"
"49c26280232fadbe456fbdd1dacc2cfd7697272202e59e41612691e50376a347"
],
"path": "ios"
},
"macos": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-mac-arm64|mm2-[a-f0-9]{7,40}-Darwin-Release)\\.zip$",
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-mac-arm64|kdf-macos-universal2-[a-f0-9]{7,40}|mm2-[a-f0-9]{7,40}-Darwin-Release)\\.zip$",
"valid_zip_sha256_checksums": [
"9613497ec79dab437251fb0c1ca6301c1b389325a01a8a979fde690d975c9902"
"30550ace9e66a1303ce3295ccd14f73759ff8fb56396419bd2d1d6e2da2cf54e"
],
"path": "macos/bin"
},
"windows": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-win-x86-64|mm2_[a-f0-9]{7,40}-win-x86-64|mm2-[a-f0-9]{7,40}-Win64)\\.zip$",
"valid_zip_sha256_checksums": [
"d25b417ef17685e439f6be9f1100dfa46b5e9b3ef646037066a5b5db0852f107"
"db77335c8637d03e467c2cbb275ea4e57962ca22ed29542941f7105e5ba69e9a"
],
"path": "windows/bin"
},
"android-armv7": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-android-armv7|mm2_[a-f0-9]{7,40}-android-armv7|mm2-[a-f0-9]{7,40}-android-armv7-CI)\\.zip$",
"valid_zip_sha256_checksums": [
"92e0d9515d3fb662bf90dc37802f901944d99b3c4b8e41566e6defacd59e213c"
"129f6f2467f14c9b7d9f7629d33d70197cb94b2237cbdb01a58e567a1b3260ee"
],
"path": "android/app/src/main/cpp/libs/armeabi-v7a"
},
"android-aarch64": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-android-aarch64|mm2_[a-f0-9]{7,40}-android-aarch64|mm2-[a-f0-9]{7,40}-android-aarch64-CI)\\.zip$",
"valid_zip_sha256_checksums": [
"4d6dc94ba31087180df09136c51bc61c75fd217e77889eb45ef40e0c6a34537f"
"00ea932edb7750c60c5d91705907b52ab018a7230f270a0f4286e41ee42cdf74"
],
"path": "android/app/src/main/cpp/libs/arm64-v8a"
},
"linux": {
"matching_pattern": "^(?:kdf_[a-f0-9]{7,40}-linux-x86-64|mm2_[a-f0-9]{7,40}-linux-x86-64|mm2-[a-f0-9]{7,40}-Linux-Release)\\.zip$",
"valid_zip_sha256_checksums": [
"7ab3d56bd0ad56e383903e3f0a444369f67b7945661f6fd0076a96b8d795cfbb"
"e25067ddb7b51455a109874722a595d7bc2ee4243ebd3af3e98426874d42f23d"
],
"path": "linux/bin"
}
Expand All @@ -63,7 +64,7 @@
"coins": {
"fetch_at_build_enabled": true,
"update_commit_on_build": true,
"bundled_coins_repo_commit": "f235190081e821996333c95e34b2629df331b333",
"bundled_coins_repo_commit": "163c0946bbeb9c4a0e4f9d9553569167e7c147e0",
"coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins",
"coins_repo_content_url": "https://raw.githubusercontent.com/KomodoPlatform/coins",
"coins_repo_branch": "master",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,64 @@ class DevBuildsArtefactDownloader implements ArtefactDownloader {
ApiFileMatchingConfig matchingConfig,
String platform,
) async {
final url = '$sourceUrl/$apiBranch/';
final response = await http.get(Uri.parse(url));
response.throwIfNotSuccessResponse();
// Try both branch-scoped and base-scoped listings to support different mirrors (devbuilds, Nebula, etc.)
final candidateListingUrls = <String>{
// Typical devbuilds layout: <mirror>/<branch>/
if (apiBranch.isNotEmpty) '$sourceUrl/$apiBranch/',
// Nebula may host a flat listing without branch segment
'$sourceUrl/',
};

final document = parser.parse(response.body);
final extensions = ['.zip'];

// Support both full and short hash variants
final fullHash = apiCommitHash;
final shortHash = apiCommitHash.substring(0, 7);
_log.info('Looking for files with hash $fullHash or $shortHash');

// Look for files with either hash length
final attemptedFiles = <String>[];
for (final element in document.querySelectorAll('a')) {
final href = element.attributes['href'];
if (href != null) attemptedFiles.add(href);
if (href != null &&
matchingConfig.matches(href) &&
extensions.any(href.endsWith)) {
if (href.contains(fullHash) || href.contains(shortHash)) {
_log.info('Found matching file: $href');
return '$sourceUrl/$apiBranch/$href';
for (final listingUrl in candidateListingUrls) {
try {
final response = await http.get(Uri.parse(listingUrl));
response.throwIfNotSuccessResponse();
final document = parser.parse(response.body);

final attemptedFiles = <String>[];
for (final element in document.querySelectorAll('a')) {
final href = element.attributes['href'];
if (href == null) continue;
attemptedFiles.add(href);

// Normalize href for directory indexes that include absolute paths
final fileName = path.basename(href);

// Ignore wallet archives on Nebula index
if (fileName.contains('wallet')) {
continue;
}

if (matchingConfig.matches(fileName) &&
extensions.any(fileName.endsWith)) {
if (fileName.contains(fullHash) || fileName.contains(shortHash)) {
_log.info('Found matching file: $fileName at $listingUrl');
// Build absolute URL respecting whether href is absolute or relative
final resolvedUrl = href.startsWith('http')
? href
: Uri.parse(listingUrl).resolve(fileName).toString();
return resolvedUrl;
}
}
}

_log.fine(
'No matching files found in $listingUrl. '
'\nPattern: ${matchingConfig.matchingPattern}, '
'\nHashes tried: [$fullHash, $shortHash]'
'\nAvailable assets: ${attemptedFiles.join('\n')}',
);
} catch (e) {
_log.fine('Failed to query listing $listingUrl: $e');
}
}

final availableAssets = attemptedFiles.join('\n');
_log.fine(
'No matching files found in $sourceUrl. '
'\nPattern: ${matchingConfig.matchingPattern}, '
'\nHashes tried: [$fullHash, $shortHash]'
'\nAvailable assets: $availableAssets',
);

throw Exception('Zip file not found for platform $platform');
throw Exception('Zip file not found for platform $platform from $sourceUrl');
}

@override
Expand Down
Loading
Loading