Skip to content

[CONTRACTS] Add InvalidExpiration error for past expires_at on add #643

@wheval

Description

@wheval

Summary

Contract InvalidExpiration error when expires_at is in the past on add_session_key with SDK mapping and tests.

Background

Past expiry must fail at contract level consistently; medium adds error enum, unit tests, SDK error code, and doc update.

This is a medium task: expect multiple files, tests, and integration with existing flows—not a single-line or docs-only change.

Scope

  • contracts/account/src/lib.rs
  • contracts/account/src/test.rs
  • packages/core-sdk/src/errors.ts

Files to create / modify

Define error; guard in add path; contract tests; map in SDK when simulation returns error.

Example implementation

#[contracterror]
pub enum Error {
  InvalidExpiration = 12,
}

Acceptance criteria

  • Adding key with past ledger time fails with InvalidExpiration
  • Contract tests cover boundary (now vs now-1)
  • SDK surfaces typed error to wallets
  • docs/contract-methods.md updated
  • Snapshot test updated if applicable

Difficulty

Medium

Labels

enhancement, medium, contract

Metadata

Metadata

Assignees

Labels

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