Skip to content

feat(factory): atomic deploy-and-initialize token via factory (#368) - #442

Merged
zachyo merged 3 commits into
soropad:masterfrom
Amas-01:feat/factory-atomic-deploy-368
Sep 2, 2026
Merged

feat(factory): atomic deploy-and-initialize token via factory (#368)#442
zachyo merged 3 commits into
soropad:masterfrom
Amas-01:feat/factory-atomic-deploy-368

Conversation

@Amas-01

@Amas-01 Amas-01 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #368
Deploys a Soroban factory contract that performs token deploy + initialize in a single atomic transaction, removing the front-running / partial-initialization window of the legacy two-step deploy.

Factory contract (contracts/factory)

  • initialize(admin): sets the factory admin and the token WASM hash (once).
  • set_token_wasm_hash(hash): admin-only; swaps the WASM used for deploys.
  • deploy_token(deployer, salt, config):
    • enforces deployer.require_auth(),
    • deploys the token contract at the deterministic address derived from deployer + salt,
    • invokes the token's initialize with the token's admin = deployer, and
    • reverts atomically if initialization fails (tested: deploy_token_reverts_atomically_on_initialize_failure).
  • get_deployment_address(deployer, salt) / get_deployments_paginated(...): deterministic-address and listing helpers.
  • Returns the token address; unit tests (10) cover auth, atomicity, determinism, and pagination.

Frontend (useDeployToken)

  • New NEXT_PUBLIC_USE_LEGACY_DEPLOY flag (default false). When false (default), deploys via the factory: builds the TokenConfig scvals, hands the deterministic token address from the simulation result, and submits a single signed transaction.
  • When true, keeps the previous two-transaction path (deploy then initialize) as a fallback.
  • New NEXT_PUBLIC_FACTORY_ADDRESS / NEXT_PUBLIC_TOKEN_WASM_HASH env vars documented in .env.example.
  • Jest coverage (6 tests) for both paths, including config encoding, optional-field None handling, and validation errors.

CI note

Verified locally: factory cargo test (10/10), cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --check. Pre-existing upstream failures (vesting/token tests, frontend type-check, events-doc check, bindings drift) are out of scope for this change.

Amas-01 and others added 2 commits August 30, 2026 00:02
…d#368)

Add a factory contract that deploys and initializes a Soroban token in a
single transaction, eliminating the front-running window between the
legacy two-step deploy and initialize.

- contracts/factory: deploy_token(deployer, salt, config) requires
  deployer auth and returns the deterministic token address; reverts
  atomically if initialize fails.
- frontend: useDeployToken grows a NEXT_PUBLIC_USE_LEGACY_DEPLOY flag;
  the factory path builds the TokenConfig scvals and submits one
  signed transaction, with the deterministic address read from the
  simulation result. Legacy two-transaction path retained as fallback.
- clippy: fix pre-existing token/vesting warnings so workspace clippy
  (-D warnings) passes; restore missing past-cliff test + snapshot.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Amas-01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@zachyo
zachyo merged commit 89a857d into soropad:master Sep 2, 2026
1 check failed
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.

Deploy factory contract: make deploy and initialize atomic

2 participants