Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Conversation

@tallesborges
Copy link
Contributor

@tallesborges tallesborges commented Oct 14, 2025

User description

Summary

  • Add new metadata v1023 for canary-matrix chain
  • Update canaryLatest() to return v1023
  • Add v1023 case to canarySpec() switch statement
  • Reorganize export statements in alphabetical order across all const files
  • Add fetch_metadata script for automation

PR Type

Enhancement, Other


Description

  • Add matrix canary metadata v1023

  • Update canaryLatest and switch mapping

  • Alphabetize/normalize export orders

  • Add fetch_metadata automation script


Diagram Walkthrough

flowchart LR
  v1023["Add canary v1023 metadata"] -- "available via exports" --> exports["Update export lists"]
  exports -- "enjin & matrix, canary/production" --> consts["Consts modules"]
  matrixLatest["Update canaryLatest() to v1023"] -- "default version" --> routing["Spec routing"]
  routing -- "add case 1023" --> cSpec["canarySpec()"]
  script["Add fetch_metadata.sh"] -- "auto-generate files + exports" --> consts
Loading

File Walkthrough

Relevant files
Enhancement
6 files
canary.dart
Reorder and add enjin canary exports                                         
+7/-7     
canary.dart
Add v1023 and reorder matrix canary exports                           
+7/-6     
matrix.dart
Point canaryLatest to v1023; map 1023                                       
+3/-1     
production.dart
Reorder and add enjin production exports                                 
+2/-2     
production.dart
Add/reorder matrix production exports                                       
+3/-3     
v1023.dart
Introduce matrix canary metadata v1023 constant                   
+2/-0     
Other
1 files
fetch_metadata.sh
Add metadata fetch and export update script                           
+110/-0 

- Add new metadata v1023 for canary-matrix chain
- Reorganize export statements in alphabetical order
- Add fetch_metadata script for automation
- Update canaryLatest() to return v1023
- Add v1023 case to canarySpec() switch statement
@tallesborges tallesborges self-assigned this Oct 14, 2025
@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Default Path

Ensure canaryLatest() and the default return in canarySpec() align; after adding case 1023 the default now also returns v1023. Confirm this matches intended rollout so older/unknown versions correctly resolve.

String canaryLatest() {
  return c.v1023;
}
Robustness

The script assumes HTTPS endpoint works for former WSS by sed replacement; verify all RPC endpoints support HTTPS JSON-RPC and CORS. Consider retry/backoff and clearer error messages per network to avoid silent failures in automation.

rpc_call() {
  url=$(echo "$1" | sed 's/wss:/https:/')
  curl -s --connect-timeout 30 \
    -H "Content-Type: application/json" \
    -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"$2\",\"params\":[]}" \
    "$url"
}

fetch_spec_version() {
  response=$(rpc_call "$1" "state_getRuntimeVersion")
  version=$(echo "$response" | jq -r '.result.specVersion // empty')

  [ -z "$version" ] || [ "$version" = "null" ] && return 1
  echo "$version"
}

fetch_metadata() {
  response=$(rpc_call "$1" "state_getMetadata")
  metadata=$(echo "$response" | jq -r '.result // empty')

  [ -z "$metadata" ] || [ "$metadata" = "null" ] && return 1
  echo "$metadata" | grep -q '^0x.\{8,\}' || return 1
  echo "$metadata"
}
Sorting Exports

The numeric sort in update_exports may misorder non-numeric filenames or leading zeros; validate it preserves intended alphabetical/numeric order across all exports.

  grep '^export ' "$export_file" |
    awk -F"v|\\.dart" '{print $2, $0}' |
    sort -n |
    awk '{$1=""; print substr($0,2)}' >"$export_file.tmp"
  mv "$export_file.tmp" "$export_file"
}

@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Correct wss-to-https URL rewrite

Preserve hostnames and paths when converting wss to https. The current sed only
swaps the scheme and may break URLs missing // handling; use a more precise
substitution to avoid malformed URLs.

scripts/fetch_metadata.sh [16-22]

 rpc_call() {
-  url=$(echo "$1" | sed 's/wss:/https:/')
+  url=$(printf '%s' "$1" | sed -E 's%^wss://%https://%')
   curl -s --connect-timeout 30 \
     -H "Content-Type: application/json" \
     -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"$2\",\"params\":[]}" \
     "$url"
 }
Suggestion importance[1-10]: 8

__

Why: The improvement makes the scheme substitution precise (wss:// to https://), reducing risk of malformed URLs. It’s accurate and has meaningful reliability impact.

Medium
Enforce integer specVersion type

Validate specVersion type to avoid unexpected matches (e.g., strings). Explicitly
type it as int to prevent runtime issues in the switch.

lib/consts/matrix/matrix.dart [59-66]

-String canarySpec(specVersion) {
+String canarySpec(int specVersion) {
   switch (specVersion) {
     case 1000:
       return c.v1000;
     ...
     case 1022:
       return c.v1022;
     case 1023:
       return c.v1023;
     default:
       return canaryLatest();
   }
 }
Suggestion importance[1-10]: 7

__

Why: Typing specVersion as int is a reasonable, accurate improvement that prevents mismatches in the switch. It’s a maintainability/type-safety enhancement, not critical.

Medium
General
Guard against stale latest version

Ensure canaryLatest() always returns the highest exported version. If a newer
version (e.g., v1024) exists, this hardcoded return will become stale and incorrect.

lib/consts/matrix/matrix.dart [5-6]

 String canaryLatest() {
-  return c.v1023;
+  return c.v1023; // Update this when adding a higher canary spec export.
 }
Suggestion importance[1-10]: 4

__

Why: The note is valid but minimal; it doesn't change behavior and just warns to keep canaryLatest() updated. Impact is low and it's already correct in the PR.

Low

@tallesborges tallesborges requested a review from Bradez October 14, 2025 01:42
@tallesborges tallesborges merged commit 7b30a31 into master Oct 14, 2025
1 check passed
@tallesborges tallesborges deleted the feature/PLA-2297/canary-matrixchain-v1023 branch October 14, 2025 13:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants