feat(factory): atomic deploy-and-initialize token via factory (#368) - #442
Merged
Merged
Conversation
…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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #368
Deploys a Soroban factory contract that performs token deploy +
initializein 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):deployer.require_auth(),deployer + salt,initializewith the token's admin = deployer, anddeploy_token_reverts_atomically_on_initialize_failure).get_deployment_address(deployer, salt)/get_deployments_paginated(...): deterministic-address and listing helpers.Frontend (
useDeployToken)NEXT_PUBLIC_USE_LEGACY_DEPLOYflag (defaultfalse). Whenfalse(default), deploys via the factory: builds theTokenConfigscvals, hands the deterministic token address from the simulation result, and submits a single signed transaction.true, keeps the previous two-transaction path (deploy then initialize) as a fallback.NEXT_PUBLIC_FACTORY_ADDRESS/NEXT_PUBLIC_TOKEN_WASM_HASHenv vars documented in.env.example.Nonehandling, 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.