Skip to content

Add envelopes technical specification and integration guide#114

Open
Douglasacost wants to merge 1 commit intomainfrom
feat/envelopes-spec
Open

Add envelopes technical specification and integration guide#114
Douglasacost wants to merge 1 commit intomainfrom
feat/envelopes-spec

Conversation

@Douglasacost
Copy link
Copy Markdown
Collaborator

This pull request primarily introduces documentation for the Envelopes feature and updates the project's spell-check configuration to include relevant new terminology. The documentation provides an overview of bearer-link asset transfer and references detailed technical and integration guides.

Documentation additions:

  • Added a new README.md in src/envelopes/doc/ that describes the Envelopes feature, its security properties, and links to the technical specification and integration guide.

Project configuration updates:

  • Updated .cspell.json to include new terms related to Envelopes (e.g., "autonumber", "dedup", "Linkdrop", "keypair", "typedata", "exfiltrated", "runbook") to avoid false positives in spell-checking.
    This pull request adds new documentation for the Envelopes feature and updates the spell-check configuration to recognize several new domain-specific terms.

Documentation:

  • Added a new README.md in src/envelopes/doc that provides an overview of the Envelopes bearer-link asset transfer system, including a contents table linking to the technical specification and integration guide.

Developer tooling:

  • Updated .cspell.json to include new terms such as autonumber, dedup, Linkdrop, keypair, typedata, exfiltrated, and runbook to reduce false positives in spell checking.

…n guide

Specifies a bearer-link asset transfer system: a sender wraps assets
in an on-chain envelope, gets a shareable URL containing a fresh
ECDSA private key in the URL fragment, and anyone holding the URL
can claim the contents through the app. Front-run-safe by
construction — claim signature commits to the claimer's address, so
a third party who observes a claim transaction cannot hijack it.

Architecture: one BaseEnvelope abstract + four concrete contracts
(EthEnvelope, Erc20Envelope, Erc721Envelope, Erc1155Envelope), each
multi-tenant and immutable. Sender chooses single-claim or multi-claim
per envelope; equal-share slots; on-chain dedup by claimer address.
Optional expiration with sender reclaim post-expiry. Configurable
flat per-envelope fee in ETH (default 0). Permissionless creation;
no operator role.

Two documents under src/envelopes/doc/:

- spec/envelopes-specification.md — full technical specification
  (architecture, roles, interfaces, flows, storage, security model,
  testing strategy, deployment & ops, file layout, deferred items).
- integration-guide.md — operational runbook mirroring
  src/swarms/doc/upgradeable-contracts.md: TypeScript/ethers.js v6
  examples for sender create flows across all four asset classes,
  URL parsing and EIP-712 claim signing, recipient claim and
  reclaim flows, admin operations (setFee, setTreasury, pause/
  unpause, role rotation), bug-fix rollout (replace, don't upgrade)
  with pre-replace and post-replace checklists, monitoring (events
  to index, cast event-streaming, health signals), and security
  considerations covering the bearer model's limits, front-run
  safety, reentrancy, and pause semantics.

Operational sections describe the actual zkSync flow: deployment via
a Forge script + ops/ shell wrapper mirroring the swarms pattern,
source-code verification via ops/verify_zksync_contracts.py.

Adds Linkdrop, keypair, typedata, autonumber, dedup, exfiltrated,
and runbook to the project cspell ignoreWords list.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds documentation for the Envelopes bearer-link transfer feature and updates spell-check configuration to accept new domain terminology, so the docs can land without cspell noise.

Changes:

  • Added Envelopes technical specification (src/envelopes/doc/spec/envelopes-specification.md).
  • Added Envelopes integration & operations guide (src/envelopes/doc/integration-guide.md) plus a doc index README.
  • Updated .cspell.json to ignore new Envelopes-related terms.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/envelopes/doc/spec/envelopes-specification.md Adds the technical specification (architecture, interfaces, flows, security, ops).
src/envelopes/doc/integration-guide.md Adds an integration/runbook guide with deployment, app, sender, and admin workflows.
src/envelopes/doc/README.md Adds a short documentation index linking to spec and integration guide.
.cspell.json Extends ignoreWords for new Envelopes terminology to reduce spellcheck false positives.

if (parts.length !== 3 || parts[0] !== "envelope") {
throw new Error("malformed envelope URL");
}
const asset = parts[1] as Parsed["asset"];
Comment on lines +882 to +916
## 10. File Layout

```
src/envelopes/
BaseEnvelope.sol
EthEnvelope.sol
Erc20Envelope.sol
Erc721Envelope.sol
Erc1155Envelope.sol
interfaces/
IBaseEnvelope.sol
IEthEnvelope.sol
IErc20Envelope.sol
IErc721Envelope.sol
IErc1155Envelope.sol
EnvelopeTypes.sol
doc/
README.md
spec/
envelopes-specification.md
test/envelopes/
BaseEnvelopeShared.t.sol
EthEnvelope.t.sol
Erc20Envelope.t.sol
Erc721Envelope.t.sol
Erc1155Envelope.t.sol
Envelopes.integration.t.sol
mocks/
MockEnvelope.sol (minimal subclass for shared tests)
MockReentrantClaimer.sol (test helper for reentrancy)
script/
DeployEnvelopesZkSync.s.sol
ops/
deploy_envelopes_zksync.sh (mirrors deploy_swarm_contracts_zksync.sh)
```
Comment on lines +1 to +10
# Envelopes — Documentation

Bearer-link asset transfer: a sender wraps ETH, ERC-20, ERC-721, or ERC-1155 assets in an on-chain envelope, gets a shareable URL, and anyone holding the URL can claim the contents through the app. Front-run-safe by construction (claim signature commits to the claimer's address).

## Contents

| Document | Description |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [spec/envelopes-specification.md](spec/envelopes-specification.md) | Full technical specification (architecture, roles, interfaces, flows, storage, security, testing, ops) |
| [integration-guide.md](integration-guide.md) | Operational runbook — TypeScript/ethers.js integration, Cast CLI, sender + app + recipient flows, admin operations, bug-fix rollout |
Comment on lines +81 to +92
Use the orchestration script (mirrors `ops/deploy_swarm_contracts_zksync.sh`):

```bash
# Testnet (dry run)
./ops/deploy_envelopes_zksync.sh testnet

# Testnet (broadcast)
./ops/deploy_envelopes_zksync.sh testnet --broadcast

# Mainnet (broadcast)
./ops/deploy_envelopes_zksync.sh mainnet --broadcast
```
Comment on lines +104 to +111
The script:

1. Compiles with `forge build --zksync`.
2. Calls `script/DeployEnvelopesZkSync.s.sol`, which deploys all four contracts in any order (no inter-contract dependencies).
3. Sanity-checks each deployment via `cast` (admin role, pauser role, treasury, fee).
4. Verifies source code on the zkSync block explorer via `python3 ops/verify_zksync_contracts.py` (see [Repo Convention on zkSync Verification](#repo-convention-on-zksync-verification)).
5. Appends addresses to the env file.

Comment on lines +330 to +336

# Create a single-claim ETH envelope (1 ETH, no expiry)
ENVELOPE_ID=0xbeef...
SLOT_AMOUNT=1000000000000000000 # 1 ETH in wei
SLOTS=1
EXPIRES=0
TOTAL_VALUE=$(cast --to-dec $(echo "$FEE + $SLOT_AMOUNT * $SLOTS" | bc))
@github-actions
Copy link
Copy Markdown

LCOV of commit f0ffbfe during checks #667

Summary coverage rate:
  lines......: 30.6% (771 of 2517 lines)
  functions..: 26.9% (105 of 390 functions)
  branches...: 35.5% (140 of 394 branches)

Files changed coverage rate: n/a

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