Skip to content

feat!: add TIP-1011 authorizeKey with KeyRestrictions (T3+)#39

Merged
grandizzy merged 13 commits intomainfrom
rusowsky/tip-1011-authorize-key-compat
Apr 7, 2026
Merged

feat!: add TIP-1011 authorizeKey with KeyRestrictions (T3+)#39
grandizzy merged 13 commits intomainfrom
rusowsky/tip-1011-authorize-key-compat

Conversation

@decofe
Copy link
Copy Markdown
Member

@decofe decofe commented Apr 2, 2026

Adds support for the TIP-1011 authorizeKey ABI change that ships with the T3 hardfork.

Breaking Change

AccountKeychain.authorize_key() now emits the T3+ authorizeKey(address,uint8,KeyRestrictions) selector. Callers targeting pre-T3 nodes must switch to AccountKeychain.authorize_key_legacy().

Changes

  • IAccountKeychain.json: Added new authorizeKey(address,uint8,KeyRestrictions) ABI entry with CallScope and KeyRestrictions struct types. Added LegacyAuthorizeKeySelectorChanged error. Legacy overload preserved.
  • account_keychain.py: authorize_key() now builds the T3+ call with KeyRestrictions (includes allow_any_calls and allowed_calls params). Added authorize_key_legacy() for pre-T3 nodes.
  • keychain.py: Added CallScope dataclass for strongly-typed call scope restrictions.
  • __init__.py: Exported CallScope.

Integration tests use inline KeyAuthorization (RLP-encoded in the tx), not the ABI-encoded precompile call, so they work on both T2 and T3 without changes.

Testing

uv run pytest tests/ -v  # 77 passed
uv run ruff check . && uv run ruff format --check .  # clean

Prompted by: rusowsky

Add the new authorizeKey(address,uint8,KeyRestrictions) ABI entry and
the CallScope/KeyRestrictions types to IAccountKeychain.json.

Rename the existing authorize_key() to authorize_key_legacy() (pre-T3)
and make authorize_key() use the T3+ KeyRestrictions struct with
allow_any_calls and allowed_calls params.

Co-Authored-By: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
github-actions bot and others added 2 commits April 2, 2026 08:32
Co-Authored-By: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
@decofe decofe changed the title feat: add TIP-1011 authorizeKey with KeyRestrictions (T3+) feat!: add TIP-1011 authorizeKey with KeyRestrictions (T3+) Apr 2, 2026
decofe and others added 8 commits April 2, 2026 08:47
Co-Authored-By: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
- TokenLimit: add period (uint64) field for T3+ overload
- CallScope: use SelectorRule[] instead of flat bytes4
- Add missing functions: setAllowedCalls, removeAllowedCalls,
  getRemainingLimitWithPeriod, getAllowedCalls
- Add AccessKeySpend event
- Fix ruff lint warnings (UP045/UP037)

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
- Sync base ABI from tempo-std via tempo_abis.sh --sync
- Add T3 authorizeKey overload + new T3 functions on top (tempo-std
  not yet updated for T3)
- Resolve cherry-pick conflict with PR #40 RLP fix (expiry=0 handling
  already in as_rlp_payload)
- Fix test_inline_key_auth_with_limits: pass SignedKeyAuthorization
  object instead of raw bytes

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
The test calls authorize_key() which defaults to T3 ABI. On pre-T3
nodes (testnet/devnet nightly), the T3 selector is rejected. Detect
hardfork and pass legacy=True on T2 nodes.

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
The previous approach queried eth_getBlockByNumber for t3Time but that
field is in the chain config, not block data. Instead, probe the
AccountKeychain precompile with the T3 authorizeKey selector (0x980a6025)
and check if it returns UnknownFunctionSelector.

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
Read TEMPO_HARDFORK (default T3), use is_t2 fixture to gate legacy ABI.
Pass TEMPO_HARDFORK=T2 in testnet CI workflow.

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
@grandizzy grandizzy marked this pull request as ready for review April 6, 2026 11:06
@@ -0,0 +1,5 @@
---
pytempo: minor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be a major, as the SDK has been refactored to be more strongly typed, and breaks some previous API patterns

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, updated in a663382

decofe and others added 2 commits April 7, 2026 06:12
Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d6690-d702-750b-9b66-34568bdf245d
@grandizzy grandizzy merged commit bbbe2b1 into main Apr 7, 2026
12 checks passed
@grandizzy grandizzy deleted the rusowsky/tip-1011-authorize-key-compat branch April 7, 2026 06:38
@github-actions github-actions bot mentioned this pull request Apr 7, 2026
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.

3 participants