-
Notifications
You must be signed in to change notification settings - Fork 0
Setup WingridersV2 on testnet-preprod #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
616b810
wingriders-v2
ljttl3q04t a210533
s1
ljttl3q04t adc4515
fix
ljttl3q04t 7b6ac17
wip
ljttl3q04t 4c9a2dc
format
ljttl3q04t cdb9859
update logic
ljttl3q04t 0cf7a35
format
ljttl3q04t a358348
typo
ljttl3q04t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| description: Fetch a Cardano transaction CBOR from Maestro and print the parsed ECSL JSON | ||
| argument-hint: <mainnet|testnet-preprod|testnet-preview> <txHash> | ||
| allowed-tools: [Bash] | ||
| --- | ||
|
|
||
| # /tx-info | ||
|
|
||
| Runs the script at [apps/example/src/tx-info.ts](apps/example/src/tx-info.ts) to fetch a transaction from Maestro and print its decoded JSON. | ||
|
|
||
| ## Arguments | ||
|
|
||
| `$ARGUMENTS` = `<network> <txHash>`, e.g. `mainnet 1867a29bf1243f5850ccebdeaf58466325c3c8a13be7a057f3063edc1ff0c144` | ||
|
|
||
| Valid networks: `mainnet`, `testnet-preprod`, `testnet-preview`. | ||
|
|
||
| ## Instructions | ||
|
|
||
| Run exactly this command from the repo root, passing `$ARGUMENTS` through verbatim: | ||
|
|
||
| ```bash | ||
| cd apps/example && pnpm tsx src/tx-info.ts $ARGUMENTS | ||
| ``` | ||
|
|
||
| The script reads `MAESTRO_MAINNET_KEY` / `MAESTRO_PREPROD_KEY` / `MAESTRO_PREVIEW_KEY` from the environment depending on the network. If the corresponding env var is missing, the Maestro fetch returns `{"message": "..."}` rather than `{"data": "..."}` and `ECSL.Transaction.from_hex` will throw — surface that error to the user and suggest setting the right env var. | ||
|
|
||
| Do not modify or re-interpret the arguments. Print the command's stdout back to the user. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Image for running CLI scripts in apps/example (e.g. src/w2.ts). | ||
| # Same multi-stage turbo-prune layout as Dockerfile.backend. | ||
|
|
||
| # Stage 1: Base | ||
| FROM node:22-slim AS base | ||
| WORKDIR /usr/src/app | ||
|
|
||
| RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* | ||
| RUN corepack enable && corepack prepare pnpm@9.0.0 --activate | ||
|
|
||
| ENV PNPM_HOME="/root/.local/share/pnpm" | ||
| ENV PATH="${PNPM_HOME}:${PATH}" | ||
|
|
||
| # Stage 2: Prune | ||
| FROM base AS cleaner | ||
| RUN pnpm add -g turbo | ||
| COPY . . | ||
| ARG APP_NAME=@apps/example | ||
| RUN turbo prune ${APP_NAME} --docker | ||
|
|
||
| # Stage 3: Install | ||
| FROM base AS installer | ||
| COPY --from=cleaner /usr/src/app/out/json/ . | ||
| COPY --from=cleaner /usr/src/app/out/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| RUN pnpm install --frozen-lockfile | ||
|
|
||
| # Stage 4: Build (compiles all workspace deps of @apps/example) | ||
| FROM base AS builder | ||
| COPY --from=installer /usr/src/app ./ | ||
| COPY --from=cleaner /usr/src/app/out/full/ . | ||
| COPY turbo.json turbo.json | ||
| ARG APP_NAME=@apps/example | ||
| RUN pnpm turbo build --filter=${APP_NAME} | ||
|
|
||
| # Stage 5: Release | ||
| FROM base AS release | ||
| COPY --from=builder /usr/src/app ./ | ||
|
|
||
| # Override in k8s with `args:` — defaults to printing CLI help. | ||
| CMD ["pnpm", "--filter=@apps/example", "exec", "tsx", "src/w2.ts", "--help"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5799,4 +5799,4 @@ | |
| "assetA": "lovelace", | ||
| "assetB": "1dd1a7dde0e1e82761325ee5f4719d0d4b7c24dfba77d9bee01eed4b.4d454f57" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| /** | ||
| * Kupo CLI — query a Kupo indexer for UTxOs, datums, and health. | ||
| * | ||
| * Usage: | ||
| * pnpm tsx src/kupo.ts <query> --network <mainnet|testnet-preprod|testnet-preview> [targets...] [--raw] | ||
| * | ||
| * Queries (pick one): | ||
| * --health Ping the Kupo instance. | ||
| * --datum --datum-hash <hash> [...] Resolve one or more datum hashes. | ||
| * --utxo <target flags...> Fetch UTxOs matching any of the targets. | ||
| * | ||
| * Targets for --utxo (repeatable, combined as a union): | ||
| * --tx-in <txId#index> UTxO at a specific output reference. | ||
| * --address <bech32> All UTxOs at an address. | ||
| * --payment-credential <hex> All UTxOs at a payment credential hash. | ||
| * --asset <policyId.tokenName|lovelace> UTxOs containing the asset. | ||
| * --policy-id <hex> UTxOs containing any asset under the policy. | ||
| * | ||
| * Output: | ||
| * Default: pretty XJSON (BigInt-safe). | ||
| * --raw Print one hex-encoded UTxO per line (only with --utxo). | ||
| * | ||
| * Env: | ||
| * KUPO_MAINNET_URL, KUPO_PREPROD_URL, KUPO_PREVIEW_URL override defaults. | ||
| * | ||
| * Examples: | ||
| * pnpm tsx src/kupo.ts --health --network mainnet | ||
| * pnpm tsx src/kupo.ts --utxo --network testnet-preprod --address addr_test1... | ||
| * pnpm tsx src/kupo.ts --utxo --network mainnet --tx-in abcd...#0 --raw | ||
| * pnpm tsx src/kupo.ts --datum --network mainnet --datum-hash <hash> | ||
| */ | ||
| import { Address, Asset, Bytes, NetworkEnvironment, TxIn, Utxo, XJSON } from "@minswap/felis-ledger-core"; | ||
| import { RustModule } from "@minswap/felis-ledger-utils"; | ||
| import { KupoService } from "@minswap/felis-provider"; | ||
|
|
||
| type Flags = { | ||
| // Query kind | ||
| utxo: boolean; | ||
| health: boolean; | ||
| datum: boolean; | ||
| // Output | ||
| raw: boolean; | ||
| // Target | ||
| network?: string; | ||
| txIns: string[]; | ||
| addresses: string[]; | ||
| paymentCredentials: string[]; | ||
| assets: string[]; | ||
| policyIds: string[]; | ||
| datumHashes: string[]; | ||
| }; | ||
|
|
||
| const parseArgs = (argv: string[]): Flags => { | ||
| const flags: Flags = { | ||
| utxo: false, | ||
| health: false, | ||
| datum: false, | ||
| raw: false, | ||
| txIns: [], | ||
| addresses: [], | ||
| paymentCredentials: [], | ||
| assets: [], | ||
| policyIds: [], | ||
| datumHashes: [], | ||
| }; | ||
| const take = (i: number): string => { | ||
| const v = argv[i + 1]; | ||
| if (!v) throw new Error(`Missing value for ${argv[i]}`); | ||
| return v; | ||
| }; | ||
| for (let i = 0; i < argv.length; i++) { | ||
| const a = argv[i]; | ||
| switch (a) { | ||
| case "--utxo": | ||
| flags.utxo = true; | ||
| break; | ||
| case "--health": | ||
| flags.health = true; | ||
| break; | ||
| case "--datum": | ||
| flags.datum = true; | ||
| break; | ||
| case "--raw": | ||
| flags.raw = true; | ||
| break; | ||
| case "--network": | ||
| flags.network = take(i); | ||
| i++; | ||
| break; | ||
| case "--tx-in": | ||
| flags.txIns.push(take(i)); | ||
| i++; | ||
| break; | ||
| case "--address": | ||
| flags.addresses.push(take(i)); | ||
| i++; | ||
| break; | ||
| case "--payment-credential": | ||
| flags.paymentCredentials.push(take(i)); | ||
| i++; | ||
| break; | ||
| case "--asset": | ||
| flags.assets.push(take(i)); | ||
| i++; | ||
| break; | ||
| case "--policy-id": | ||
| flags.policyIds.push(take(i)); | ||
| i++; | ||
| break; | ||
| case "--datum-hash": | ||
| flags.datumHashes.push(take(i)); | ||
| i++; | ||
| break; | ||
| default: | ||
| throw new Error(`Unknown argument: ${a}`); | ||
| } | ||
| } | ||
| return flags; | ||
| }; | ||
|
|
||
| const parseNetwork = (s?: string): NetworkEnvironment => { | ||
| switch (s) { | ||
| case "mainnet": | ||
| return NetworkEnvironment.MAINNET; | ||
| case "testnet-preview": | ||
| return NetworkEnvironment.TESTNET_PREVIEW; | ||
| case "testnet-preprod": | ||
| return NetworkEnvironment.TESTNET_PREPROD; | ||
| default: | ||
| throw new Error(`--network must be one of mainnet|testnet-preprod|testnet-preview (got ${s})`); | ||
| } | ||
| }; | ||
|
|
||
| const resolveKupoUrl = (network: NetworkEnvironment): string => { | ||
| switch (network) { | ||
| case NetworkEnvironment.MAINNET: | ||
| return process.env["KUPO_MAINNET_URL"] ?? "http://mainnet-staging:1442"; | ||
| case NetworkEnvironment.TESTNET_PREPROD: | ||
| return process.env["KUPO_PREPROD_URL"] ?? "http://testnet-preprod:1442"; | ||
| case NetworkEnvironment.TESTNET_PREVIEW: | ||
| return process.env["KUPO_PREVIEW_URL"] ?? "http://dev-3:1442"; | ||
| } | ||
| }; | ||
|
|
||
| const printJson = (v: unknown) => { | ||
| console.log(XJSON.stringify(v, 2)); | ||
| }; | ||
|
|
||
| const main = async () => { | ||
| await RustModule.load(); | ||
| const flags = parseArgs(process.argv.slice(2)); | ||
| const network = parseNetwork(flags.network); | ||
| const kupo = new KupoService(resolveKupoUrl(network)); | ||
|
|
||
| if (flags.health) { | ||
| printJson(await kupo.health()); | ||
| return; | ||
| } | ||
|
|
||
| if (flags.datum) { | ||
| if (flags.datumHashes.length === 0) throw new Error("--datum requires --datum-hash <hash>"); | ||
| const mapDatum = await kupo.getDatums(flags.datumHashes); | ||
| printJson(mapDatum); | ||
| return; | ||
| } | ||
|
|
||
| if (!flags.utxo) throw new Error("Specify a query: --utxo | --health | --datum"); | ||
| const utxos: Utxo[] = []; | ||
| if (flags.txIns.length > 0) { | ||
| const txIns = flags.txIns.map((s) => TxIn.fromString(s)); | ||
| utxos.push(...(await kupo.utxosByTxIn(...txIns))); | ||
| } | ||
| if (flags.addresses.length > 0) { | ||
| const addresses = flags.addresses.map((s) => Address.fromBech32(s)); | ||
| utxos.push(...(await kupo.utxosByAddress(addresses))); | ||
| } | ||
| for (const pc of flags.paymentCredentials) { | ||
| utxos.push(...(await kupo.getUtxosByPaymentCredential(Bytes.fromHex(pc)))); | ||
| } | ||
| for (const asset of flags.assets) { | ||
| const kupoUtxos = await kupo.kupoUtxosByAsset(Asset.fromString(asset)); | ||
| for (const u of kupoUtxos) utxos.push(Utxo.fromKupo(u)); | ||
| } | ||
| for (const policyId of flags.policyIds) { | ||
| const kupoUtxos = await kupo.kupoUtxosByPolicyID(Bytes.fromHex(policyId)); | ||
| for (const u of kupoUtxos) utxos.push(Utxo.fromKupo(u)); | ||
| } | ||
|
|
||
| if (utxos.length === 0) { | ||
| console.error("No UTXOs found"); | ||
| return; | ||
| } | ||
|
|
||
| if (flags.raw) { | ||
| for (const u of utxos) console.log(Utxo.toHex(u)); | ||
| } else { | ||
| printJson(utxos); | ||
| } | ||
| }; | ||
|
|
||
| main().catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.