# partner:configure-test-source — Ammora SDK 0.3.9

Draft the published synthetic standard's configuration from a partner's own inputs.

[Read in Docs](https://docs.ammora.org/examples?command=partner%3Aconfigure-test-source) · [Detailed guide](https://docs.ammora.org/guides/self-service) · [Local setup](https://docs.ammora.org/guides/example-setup) · [Approval and review boundaries](https://docs.ammora.org/guides/permissions)

## Context and execution

GIWA Sepolia 91342. Public SDK 0.3.9, Math 0.3.0. Source revision: `0f3a73158fa5d86ed9f24ae1b2320e351e0e91e6`.
Install the SDK in your app, or prepare the example project using the local setup guide for its npm commands. Review the entry source and guide for required arguments, roles and deployment selection. `AMMORA_SEND=0` does not turn send-only commands into previews. Never put CLI keys in a browser or resend an uncertain transaction.

Command: `npm run partner:configure-test-source -- <arguments from the source below>` (`tsx src/partner/self-service/configuration.ts`). Omit `--` and arguments when the source accepts none.

## Entry file: `src/partner/self-service/configuration.ts`

```typescript
/** Draft the published synthetic standard's configuration from a partner's own inputs. */
import { readFileSync } from "node:fs";
import type { ExtensionConfigV2 } from "@ammora-protocol/sdk/partner";
import type { Address, Hex } from "viem";
import { address, hash, cli, required, loadSelfServiceProfile, type SelfServiceProfile } from "./context.js";

const terms = JSON.parse(readFileSync(new URL("../../../fixtures/self-service-standard-terms.test.json", import.meta.url), "utf8"));
export interface SelfServiceTestConfigurationInput {
  templateId: Hex; source: Address; controller: Address; partner: Address;
  recipients: Address[]; weights: number[];
  consentHash: Hex; economicId: Hex; rightsEvidence: Hex;
  quote?: Address; base?: Address; market?: Address;
}

export function prepareSelfServiceTestConfiguration(profile: SelfServiceProfile, value: unknown) {
  if (!profile.testOnly || profile.chainId !== 91342 || !terms.testOnly || terms.chainId !== profile.chainId) throw new Error("Synthetic GIWA configuration only");
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Expected partner configuration inputs");
  const input = value as Record<string, unknown>;
  const fields = ["templateId", "source", "controller", "partner", "recipients", "weights", "consentHash", "economicId", "rightsEvidence"];
  if (Object.keys(input).some(k => ![...fields, "quote", "base", "market"].includes(k)) || fields.some(k => !(k in input))) throw new Error("Use the explicit configuration input fields; no wallet secrets or executable values");
  const templateId = hash(input.templateId);
  const standard = terms.standards.find((s: { templateId: string }) => s.templateId.toLowerCase() === templateId.toLowerCase());
  if (!standard) throw new Error("Unknown bundled synthetic standard");
  const source = address(input.source), controller = address(input.controller), partner = address(input.partner), ammora = address(standard.ammoraReceiver);
  if (partner.toLowerCase() === ammora.toLowerCase()) throw new Error("Original partner must differ from the standard Ammora receiver");
  const quote = address(input.quote ?? terms.quote.address), base = address(input.base ?? terms.base.address), market = address(input.market ?? standard.market.address);
  if (quote.toLowerCase() === base.toLowerCase()) throw new Error("Distinct test assets required");
  if (!Array.isArray(input.recipients) || !Array.isArray(input.weights) || !input.recipients.length || input.recipients.length > 8 || input.recipients.length !== input.weights.length) throw new Error("Provide one to eight explicit holders and matching weights");
  const recipients = input.recipients.map(address), weights = input.weights;
  if (new Set(recipients.map(x => x.toLowerCase())).size !== recipients.length || !weights.every(w => Number.isSafeInteger(w) && Number(w) > 0 && Number(w) <= 10000) || weights.reduce((a, b) => a + Number(b), 0) !== 10000) throw new Error("Unique holders and positive integer weights totaling 10000 required");
  if (!recipients.some(x => x.toLowerCase() === partner.toLowerCase())) throw new Error("Keep the original partner among the initial rights holders");
  const configuration: ExtensionConfigV2 = {
    source: {
      source, sourceRuntimeHash: hash(standard.sourceRuntimeHash),
      driver: address(standard.driver.address), driverRuntimeHash: hash(standard.driver.runtimeHash),
      registry: profile.registry.address, registryRuntimeHash: profile.registry.runtimeHash,
      quoteToken: quote, quoteRuntimeHash: hash(terms.quote.runtimeHash),
      baseToken: base, baseRuntimeHash: hash(terms.base.runtimeHash),
      sourceOwner: controller, controller, ammora, partner,
      family: standard.family, maxFeeBps: standard.maxFeeBps,
      consentHash: hash(input.consentHash), economicId: hash(input.economicId),
      dependencies: [{ target: market, runtimeHash: hash(standard.market.runtimeHash) }],
    },
    recipients, weights: weights.map(Number), rightsEvidence: hash(input.rightsEvidence),
  };
  return { configuration, templateId, testOnly: true, automaticSend: false, eligibility: "PREPARED_ONLY: diagnose the exact live source and obtain every holder's actual consent" };
}

// Configuration JSON is plain input data, never a serialized executable SDK plan.
cli(import.meta.url, () => prepareSelfServiceTestConfiguration(loadSelfServiceProfile(required(2, "profile.json")), JSON.parse(readFileSync(required(3, "partner-input.json"), "utf8"))).configuration);
```

## Supporting files

Keep relative paths intact. Local imports are listed recursively; JSON templates are choices to review, not approved inputs. Runtime-selected files and wallet/environment setup still follow the detailed guide.

- [fixtures/self-service-standard-terms.test.json](https://docs.ammora.org/examples/source/fixtures/self-service-standard-terms.test.json.txt)
- [src/partner/self-service/context.ts](https://docs.ammora.org/examples/source/src/partner/self-service/context.ts.txt)
- [src/partner/self-service/rpc.ts](https://docs.ammora.org/examples/source/src/partner/self-service/rpc.ts.txt)
- [fixtures/self-service-configuration-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-configuration-input.template.json.txt)
- [fixtures/self-service-giwa.test.json](https://docs.ammora.org/examples/source/fixtures/self-service-giwa.test.json.txt)
- [fixtures/self-service-known-deployment.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-known-deployment.template.json.txt)
- [fixtures/self-service-source-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-source-input.template.json.txt)
- [fixtures/self-service-test-artifacts.json](https://docs.ammora.org/examples/source/fixtures/self-service-test-artifacts.json.txt)
- [fixtures/self-service-trade-input.template.json](https://docs.ammora.org/examples/source/fixtures/self-service-trade-input.template.json.txt)
- [package.json](https://docs.ammora.org/examples/source/package.json.txt)
- [package-lock.json](https://docs.ammora.org/examples/source/package-lock.json.txt)
- [tsconfig.json](https://docs.ammora.org/examples/source/tsconfig.json.txt)
- [.env.giwa.example](https://docs.ammora.org/examples/source/file.env.giwa.example.txt)
- [.nvmrc](https://docs.ammora.org/examples/source/file.nvmrc.txt)

## AI implementation checklist

Use the actual SDK exports and parameter types in the linked files. Start with reads and unsigned plans where supported. Use a connected wallet for browser signing. Preserve raw integer units, exact approvals, caller authority, deadlines and receipt reconciliation. Report local checks separately from live-chain verification.
