diff --git a/.github/workflows/examples-drift.yml b/.github/workflows/examples-drift.yml new file mode 100644 index 000000000..ed88bc1fe --- /dev/null +++ b/.github/workflows/examples-drift.yml @@ -0,0 +1,48 @@ +name: Examples drift + +# Fails when a src/examples/**/index.js is out of sync with the native +# source files (kit.js, umi.js, cli.sh, etc.) it's generated from, so a +# hand-edited source can no longer drift silently from the published docs. + +on: + pull_request: + paths: + - 'src/examples/**' + - 'scripts/build-examples.js' + - 'package.json' + - '.github/workflows/examples-drift.yml' + push: + branches: [main] + +# This job checks out and installs pull-request-controlled code, so it gets no +# more than read access and never keeps the checkout token on disk. +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + steps: + # Actions are pinned to commit SHAs; a tag can be moved, a SHA cannot. + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false + + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 + + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: 20 + cache: pnpm + + - run: pnpm install --frozen-lockfile + + - run: pnpm run build-examples + + - name: Fail if build-examples produced a diff + run: | + if ! git diff --quiet -- src/examples; then + echo "::error::src/examples/**/index.js is out of sync with its source files. Run 'pnpm run build-examples' locally and commit the result." + git diff --stat -- src/examples + exit 1 + fi diff --git a/src/examples/core/create-asset/cli.sh b/src/examples/core/create-asset/cli.sh index e1c544bd6..90017fbf5 100644 --- a/src/examples/core/create-asset/cli.sh +++ b/src/examples/core/create-asset/cli.sh @@ -7,4 +7,10 @@ mplx core asset create --wizard mplx core asset create --name "My NFT" --uri "https://example.com/metadata.json" # Create with files (image + metadata) -mplx core asset create --files --image "./my-nft.png" --json "./metadata.json" +mplx core asset create --files --image "./my-nft.png" --offchain "./metadata.json" + +# Create with a vanity asset address +mplx core asset create \ + --name "My NFT" \ + --uri "https://example.com/metadata.json" \ + --mint-keypair ./vanity-asset.json diff --git a/src/examples/token-metadata/fungibles/create/cli.sh b/src/examples/token-metadata/fungibles/create/cli.sh index a69d5fff4..43d98b64b 100644 --- a/src/examples/token-metadata/fungibles/create/cli.sh +++ b/src/examples/token-metadata/fungibles/create/cli.sh @@ -18,6 +18,13 @@ mplx toolbox token create \ --decimals 9 \ --mint-amount 1000000000000000 +# Create with a vanity mint address +mplx toolbox token create \ + --name "Cool Token" \ + --symbol "COOL" \ + --mint-amount 1000000 \ + --mint-keypair ./vanity-mint.json + # Note: mint-amount is in smallest units # With --decimals 9, to mint 1,000,000 tokens: --mint-amount 1000000000000000 # With --decimals 0 (default), to mint 1,000,000 tokens: --mint-amount 1000000