Skip to content

fix: transfer offer expiry configurable per call in the Canton SDK #290

@sadiq1971

Description

@sadiq1971

Background

USDCx offers (Splice TransferInstruction) already carry an executeBefore : Time field on-ledger. The Go SDK currently hardcodes it to requestedAt + 1h (pkg/cantonsdk/token/client.go:32, 651-653, 893, 1422), so callers have no control over offer validity.

Scope

Plumb a per-call validity duration through the SDK while keeping current callers behaviourally identical.

  • Replace defaultTransferValidity = time.Hour with a much larger default (effectively unbounded, e.g. ~100 years) so existing callers that don't pass a value continue to work, and accidentally expired offers stop appearing in lab/dev environments.
  • Add an optional Validity time.Duration (or ExecuteBefore time.Time) to PrepareTransferRequest and TransferRequest in pkg/cantonsdk/token/types.go. When set, the SDK uses it; when zero, falls back to the default.
  • Custodial path (Client.Transfer / transferViaFactory): consume the new field directly.
  • Non-custodial path (Client.PrepareTransfer): same plumbing, but the HTTP API doesn't yet expose the field. Leave a // TODO(#<this-issue>+1): pass validity from API request next to the call site so the next issue can wire it up.

Out of scope

Indexer changes, API request shape, claim-back. Tracked in follow-up issues.

Acceptance

  • New optional validity field accepted on prepare/transfer requests.
  • Default validity is effectively infinite — no behaviour change for existing callers, no offer accidentally expires.
  • All current tests pass without modification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: FeatureAdded to issues and PRs to identify that the change is a new feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions