Skip to content

feat(payment-kit): use codegen config arguments - #1164

Draft
hayes-mysten wants to merge 7 commits into
codegen-config-argumentsfrom
codegen-config-args-payment-kit
Draft

feat(payment-kit): use codegen config arguments#1164
hayes-mysten wants to merge 7 commits into
codegen-config-argumentsfrom
codegen-config-args-payment-kit

Conversation

@hayes-mysten

Copy link
Copy Markdown
Contributor

Description

Adopts the codegen configArguments support for Payment Kit.

  • Adds generated config mappings for the Payment Kit package ID and shared namespace object.
  • Regenerates Payment Kit bindings with the generated config slice.
  • Updates wrapper calls to pass the existing package config into generated helpers while keeping registry/admin/user-owned objects explicit.
  • Adds focused transaction JSON coverage for the wrapper behavior.

Test plan

  • pnpm exec tsx ../codegen/src/bin/cli.ts generate --noSummaries true from packages/payment-kit
  • pnpm --filter @mysten/payment-kit lint:fix
  • pnpm --filter @mysten/payment-kit lint
  • pnpm --filter @mysten/payment-kit build
  • pnpm --filter @mysten/payment-kit test

AI Assistance Notice

Please disclose the usage of AI. This is primarily to help inform reviewers of how careful they need to review PRs, and to keep track of AI usage across our team. Please fill this out accurately, and do not modify the content or heading for this section!

  • This PR was primarily written by AI.
  • I used AI for docs / tests, but manually wrote the source code.
  • I used AI to understand the problem space / repository.
  • I did not use AI for this PR.

hayes-mysten and others added 7 commits July 22, 2026 13:06
… object

Adds a configArguments option to @mysten/codegen that maps Move types and
package addresses to keys of a runtime config object. Matched function
parameters become optional in generated arguments and resolve from a typed
per-function config slice instead; generic types require resolver functions
that receive the matched parameter's instantiation. Also treats
0x2::accumulator::AccumulatorRoot as a well-known auto-injected object.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…guments

- Make the generated config property optional; missing values fail with the
  descriptive resolveConfigArgument error instead of a TypeError
- Defer the name-matcher-on-nameless-params error until the matcher would
  actually win, so shared global blocks survive bytecode summaries; degrade
  bare-matcher double matches on nameless signatures to warn-and-skip
- Route resolver-context type tags through type-origin/MVR addresses and
  normalize hex tags at runtime, so resolvers see consistent canonical tags
- Add call-site metadata (packageAddress/module/function/parameter) to
  ConfigResolverContext and validate resolver return values
- Harden the matcher parser (bracket balance, identifier/address validation,
  dedicated partial-instantiation error) and reject prototype-polluting keys
- Error on unresolved package-scoped matchers, validate package entries
  against the run's packages, and warn on keys that match nothing
- Guard applyConfigArguments against argument holes and inherited properties
- Rename matcher field name -> parameterName, resolveConfigArg ->
  resolveConfigArgument, generated file config-args.ts -> config-arguments.ts;
  restrict generated interfaces to the package's own package key
- Tuple-form matched suffixes become genuinely optional elements
- Expand tests (172 passing) and rewrite the configArguments docs section

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ization)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Matchers no longer contain package addresses (codegen output must work
across networks). Types are identified as module::Type, scoped to the
declaring package's own block, qualified with a package identifier from
the packages config (@myapp/core::pool::Pool) for cross-package
references, or with the chain-stable framework addresses 0x1-0x3. The
CLI resolves each run package's root address up front so matchers can
reference any package in the run; matcher typos error in the run of the
package they target, replacing the unresolved-key warn/aggregate
machinery. Global-block matchers must be package-qualified.

Also reformat the create-dapp template utils file that was failing
prettier:check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lver context

- Function matchers ({ function: 'module::fn', parameterName | parameterIndex })
  configure a single function parameter directly, with the type derived from
  the signature; the parameter can be inferred for single-argument functions.
  Highest matcher specificity, scoped/qualified like type matchers.
- One config key may declare an array of matchers (multiple types); any key
  that can resolve more than one binding (multiple matchers, a generic, or
  multiple parameters in one signature) is typed resolver-only in generated
  config slices and interfaces. This replaces the bare-matcher-two-params
  hard error: multi-matches are legal and disambiguated in the resolver.
- ConfigResolverContext gains parameterIndex, so nameless (bytecode)
  positions are distinguishable in resolvers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A config key with multiple matchers (e.g. several functions) that all bind
the same concrete type keeps a plain config value; only keys spanning
multiple distinct types, or binding a generic, are typed resolver-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hayes-mysten
hayes-mysten temporarily deployed to sui-typescript-aws-kms-test-env July 22, 2026 23:12 — with GitHub Actions Inactive
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-typescript-docs Ready Ready Preview, Comment Jul 22, 2026 11:15pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ 🦋 Changesets Warning: This PR has changes to public npm packages, but does not contain a changeset. You can create a changeset easily by running pnpm changeset in the root of the Sui repo, and following the prompts. If your change does not need a changeset (e.g. a documentation-only change), you can ignore this message. This warning will be removed when a changeset is added to this pull request.

Learn more about Changesets.

@hayes-mysten
hayes-mysten force-pushed the codegen-config-arguments branch 5 times, most recently from eb429d7 to 85977c1 Compare August 17, 2026 03:06
An error occurred while trying to automatically change base from codegen-config-arguments to fix/codegen-resolve-mvr August 17, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant