Skip to content

feat(external-signer): add data_prepare_upload for in-memory data#15

Merged
Nic-dorman merged 1 commit intomainfrom
feat/data-prepare-upload
Mar 30, 2026
Merged

feat(external-signer): add data_prepare_upload for in-memory data#15
Nic-dorman merged 1 commit intomainfrom
feat/data-prepare-upload

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

Summary

Adds data_prepare_upload(content: Bytes) -> PreparedUpload to complete the external signer story for raw byte data.

file_prepare_upload exists for file-based two-phase uploads, but there was no equivalent for in-memory data (data_upload). This meant external signers (WalletConnect, hardware wallets, enterprise key management) could only use the two-phase flow for files on disk, not for raw bytes passed via the REST API.

The fix

data_prepare_upload mirrors file_prepare_upload exactly:

  1. Encrypts content via self_encryption::encrypt
  2. Calls prepare_chunk_payment() on each chunk (quotes, no payment)
  3. Returns PreparedUpload with PaymentIntent

The caller then signs externally and calls finalize_upload() with tx hashes — same phase 2 as file uploads.

No breaking changes

All existing methods work identically. This only adds a new public method.

Test plan

  • cargo check -p ant-core clean
  • cargo test -p ant-core --lib — 108 tests pass (105 existing + 3 send assertions)
  • Compile-time Send assertion for data_prepare_upload
  • E2E: data_prepare_upload → external payment → finalize_upload

🤖 Generated with Claude Code

file_prepare_upload exists for file-based external signer flow but
there was no equivalent for raw byte data (data_upload). This meant
external signers could only upload files, not in-memory content.

Add data_prepare_upload(content: Bytes) -> PreparedUpload that:
1. Encrypts content via self-encryption
2. Collects quotes for each chunk via prepare_chunk_payment()
3. Returns PreparedUpload with PaymentIntent for external signing

The caller then signs externally and calls finalize_upload() with
tx hashes — same phase 2 as file uploads.

Also adds compile-time Send assertion for the new method.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Nic-dorman Nic-dorman merged commit 7bcb6cb into main Mar 30, 2026
11 of 12 checks passed
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.

2 participants