Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file is used to define a set of default reviewers.
* @v16Studios @leonardocustodio @enjinabner
* @tallesborges
14 changes: 7 additions & 7 deletions lib/consts/enjin/canary/canary.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export 'v100.dart';
export 'v101.dart';
export 'v102.dart';
export 'v103.dart';
export 'v104.dart';
export 'v105.dart';
export 'v106.dart';
export 'v107.dart';
export 'v110.dart';
export 'v120.dart';
export 'v1021.dart';
export 'v1022.dart';
export 'v1023.dart';
export 'v1024.dart';
export 'v1025.dart';
export 'v1026.dart';
export 'v103.dart';
export 'v1030.dart';
export 'v1031.dart';
export 'v1032.dart';
export 'v1033.dart';
export 'v1050.dart';
export 'v104.dart';
export 'v105.dart';
export 'v106.dart';
export 'v107.dart';
export 'v110.dart';
export 'v120.dart';
4 changes: 2 additions & 2 deletions lib/consts/enjin/production/production.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export 'v100.dart';
export 'v101.dart';
export 'v102.dart';
export 'v110.dart';
export 'v120.dart';
export 'v1021.dart';
export 'v1022.dart';
export 'v1023.dart';
Expand All @@ -9,5 +11,3 @@ export 'v1025.dart';
export 'v1026.dart';
export 'v1032.dart';
export 'v1050.dart';
export 'v110.dart';
export 'v120.dart';
13 changes: 7 additions & 6 deletions lib/consts/matrix/canary/canary.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export 'v500.dart';
export 'v600.dart';
export 'v601.dart';
export 'v602.dart';
export 'v604.dart';
export 'v605.dart';
export 'v1000.dart';
export 'v1001.dart';
export 'v1002.dart';
Expand All @@ -12,9 +18,4 @@ export 'v1013.dart';
export 'v1020.dart';
export 'v1021.dart';
export 'v1022.dart';
export 'v500.dart';
export 'v600.dart';
export 'v601.dart';
export 'v602.dart';
export 'v604.dart';
export 'v605.dart';
export 'v1023.dart';
2 changes: 2 additions & 0 deletions lib/consts/matrix/canary/v1023.dart

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/consts/matrix/matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'canary/canary.dart' as c;
import 'production/production.dart' as p;

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

String productionLatest() {
Expand Down Expand Up @@ -59,6 +59,8 @@ String canarySpec(specVersion) {
return c.v1021;
case 1022:
return c.v1022;
case 1023:
return c.v1023;
default:
return canaryLatest();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/consts/matrix/production/production.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export 'v603.dart';
export 'v604.dart';
export 'v605.dart';
export 'v1000.dart';
export 'v1002.dart';
export 'v1003.dart';
Expand All @@ -7,6 +10,3 @@ export 'v1006.dart';
export 'v1012.dart';
export 'v1014.dart';
export 'v1022.dart';
export 'v603.dart';
export 'v604.dart';
export 'v605.dart';
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: platform_decoder
description: Enjin Platform Decoder
version: 2.3.0
version: 2.6.0
publish_to: none

environment:
Expand All @@ -21,4 +21,4 @@ dev_dependencies:
lints: ^5.1.1

assets:
- .env
- .env
110 changes: 110 additions & 0 deletions scripts/fetch_metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/sh
set -e

NETWORKS="enjin-matrixchain canary-matrixchain enjin-relaychain canary-relaychain"

get_network_config() {
case "$1" in
enjin-matrixchain) echo "wss://archive.matrix.blockchain.enjin.io,matrix,production" ;;
enjin-relaychain) echo "wss://rpc.relay.blockchain.enjin.io,enjin,production" ;;
canary-matrixchain) echo "wss://archive.matrix.canary.enjin.io,matrix,canary" ;;
canary-relaychain) echo "wss://rpc.relay.canary.enjin.io,enjin,canary" ;;
*) return 1 ;;
esac
}

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"
}

write_metadata_file() {
dir="$1/lib/consts/$2/$3"
mkdir -p "$dir"
cat >"$dir/v$4.dart" <<EOF
const v$4 =
'$5';
EOF
}

update_exports() {
export_file="$1/lib/consts/$2/$3/$3.dart"
export_line="export 'v$4.dart';"

touch "$export_file"
grep -Fxq "$export_line" "$export_file" || echo "$export_line" >>"$export_file"

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"
}

process_network() {
network="$1"
config=$(get_network_config "$network") || return 1

rpc=$(echo "$config" | cut -d, -f1)
category=$(echo "$config" | cut -d, -f2)
environment=$(echo "$config" | cut -d, -f3)
base="$2"

echo "Processing $network..."

version=$(fetch_spec_version "$rpc") || return 1
metadata=$(fetch_metadata "$rpc") || return 1

write_metadata_file "$base" "$category" "$environment" "$version" "$metadata"
update_exports "$base" "$category" "$environment" "$version"

echo "$network: v$version -> lib/consts/$category/$environment/v$version.dart"
}

command -v jq >/dev/null || {
echo "ERROR: jq required" >&2
exit 1
}
command -v curl >/dev/null || {
echo "ERROR: curl required" >&2
exit 1
}

BASE=$(cd "$(dirname "$0")/.." && pwd)

if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 [network]"
echo "Networks: $NETWORKS"
exit 0
fi

if [ $# -eq 1 ]; then
process_network "$1" "$BASE" || {
echo "Unknown network: $NETWORKS" >&2
exit 1
}
else
for network in $NETWORKS; do
process_network "$network" "$BASE" || echo "$network failed" >&2
done
fi