Skip to content

Commit e74251b

Browse files
committed
feat(contract): verify creator-earnings wasm build in CI deploy script
1 parent 4703562 commit e74251b

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

.github/workflows/contract-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ jobs:
102102
content_access
103103
content_likes
104104
creator_registry
105+
creator_earnings
105106
earnings
106107
treasury
107108
)

.github/workflows/contract-release.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,29 @@ jobs:
134134
fi
135135
working-directory: contract
136136

137+
- name: 📦 Verify creator-earnings wasm build
138+
id: creator-earnings-build
139+
run: |
140+
WASM_PATH="target/wasm32-unknown-unknown/release/creator_earnings.wasm"
141+
if [[ -f "$WASM_PATH" && -s "$WASM_PATH" ]]; then
142+
WASM_SIZE=$(du -sh "$WASM_PATH" | cut -f1)
143+
# Validate WebAssembly magic bytes: 0x00 0x61 0x73 0x6D
144+
MAGIC=$(xxd -p -l 4 "$WASM_PATH" 2>/dev/null || od -A n -N 4 -t x1 "$WASM_PATH" | tr -d ' \n')
145+
if [[ "$MAGIC" != "0061736d" ]]; then
146+
echo "❌ creator_earnings.wasm is not a valid WASM binary (magic=$MAGIC)"
147+
echo "::error::creator_earnings.wasm failed magic-byte validation"
148+
exit 1
149+
fi
150+
echo "✅ creator-earnings.wasm successfully built and validated ($WASM_SIZE)"
151+
echo "### ✅ Creator-Earnings WASM Build" >> $GITHUB_STEP_SUMMARY
152+
echo "Artifact: creator_earnings.wasm ($WASM_SIZE)" >> $GITHUB_STEP_SUMMARY
153+
else
154+
echo "❌ creator-earnings.wasm not found or empty at $WASM_PATH"
155+
echo "::error::creator-earnings.wasm build verification failed — artifact not found or empty"
156+
exit 1
157+
fi
158+
working-directory: contract
159+
137160
- name: 📏 Generate Wasm size report
138161
run: |
139162
REPORT="wasm-size-report.txt"
@@ -269,6 +292,7 @@ jobs:
269292
echo "| Linting (cargo clippy) | ${{ steps.clippy.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
270293
echo "| Tests (cargo test) | ${{ steps.tests.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
271294
echo "| WASM build | ${{ steps.build.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
295+
echo "| creator-earnings WASM | ${{ steps.creator-earnings-build.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
272296
echo "| ABI snapshots | ${{ steps.abi.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
273297
echo "| Deploy output schema | ${{ steps.schema.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
274298
echo "| Release docs linked | ${{ steps.docs.outcome == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
@@ -285,8 +309,9 @@ jobs:
285309
fmt: '${{ steps.fmt.outcome }}',
286310
clippy: '${{ steps.clippy.outcome }}',
287311
tests: '${{ steps.tests.outcome }}',
288-
build: '${{ steps.build.outcome }}',
289-
abi: '${{ steps.abi.outcome }}',
312+
build: '${{ steps.build.outcome }}',
313+
creatorEarnings: '${{ steps.creator-earnings-build.outcome }}',
314+
abi: '${{ steps.abi.outcome }}',
290315
schema: '${{ steps.schema.outcome }}',
291316
docs: '${{ steps.docs.outcome }}',
292317
};
@@ -300,6 +325,7 @@ jobs:
300325
`| Linting (cargo clippy) | ${icon(steps.clippy)} |`,
301326
`| Tests (cargo test) | ${icon(steps.tests)} |`,
302327
`| WASM build | ${icon(steps.build)} |`,
328+
`| creator-earnings WASM | ${icon(steps.creatorEarnings)} |`,
303329
`| ABI snapshots | ${icon(steps.abi)} |`,
304330
`| Deploy output schema | ${icon(steps.schema)} |`,
305331
`| Release docs linked | ${icon(steps.docs)} |`,

contract/scripts/deploy.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ PACKAGES=(
169169
"subscription"
170170
"content-access"
171171
"earnings"
172+
"creator-earnings"
172173
)
173174

174175
for package in "${PACKAGES[@]}"; do
@@ -220,10 +221,12 @@ if [[ "$DRY_RUN" == "true" ]]; then
220221
fi
221222

222223
# ── Post-build WASM verification (Issue #888) ─────────────────────────────────
223-
# Always verify myfans-token wasm after build, even outside dry-run, so a
224-
# corrupted or missing artifact is caught before any on-chain deployment.
225-
echo "[deploy] verifying myfans-token WASM artifact"
226-
verify_wasm "myfans-token"
224+
# Always verify all built WASM artifacts after build, even outside dry-run, so
225+
# a corrupted or missing artifact is caught before any on-chain deployment.
226+
echo "[deploy] verifying WASM artifacts"
227+
for package in "${PACKAGES[@]}"; do
228+
verify_wasm "$package"
229+
done
227230

228231
deploy_contract() {
229232
local package="$1"

0 commit comments

Comments
 (0)