Skip to content

Factory: Deploy method to batch wallet creation and contract call#92

Open
alberto-crossmint wants to merge 2 commits intomainfrom
alb/deploy-and-call
Open

Factory: Deploy method to batch wallet creation and contract call#92
alberto-crossmint wants to merge 2 commits intomainfrom
alb/deploy-and-call

Conversation

@alberto-crossmint
Copy link
Copy Markdown
Contributor

@alberto-crossmint alberto-crossmint commented Feb 13, 2026

Contract Factory: Deploy-and-Call

Adds atomic deploy-and-call functionality to the contract factory, enabling deployment followed by immediate contract invocations in a single transaction.

Changes

New Function: deploy_and_call

  • Accepts deployment arguments plus a vector of ContractCall structs
  • Deploys contract idempotently (skips deployment if already exists)
  • Executes each call sequentially against specified contracts
  • Reverts entire transaction if any call fails (atomicity guarantee)
  • Requires deployer role authorization

Refactoring

  • Extracted deploy_idempotent_inner as internal helper to avoid duplication
  • deploy_idempotent now delegates to this internal function
  • Both public functions maintain identical deployment behavior

New Types

  • ContractCall: encapsulates target contract address, function name, and arguments

Use Cases

  • Initialize contract state immediately after deployment
  • Grant permissions or set roles atomically with deployment
  • Execute setup sequences that must succeed together
  • Predict contract address before deployment and call functions on it

Test Coverage

  • Empty calls vector (equivalent to deploy_idempotent)
  • Address prediction matches actual deployed address
  • Idempotency: second call with same args returns same address without redeployment
  • Role enforcement: non-deployers cannot execute
  • Self-authorization: deployed contract can authorize calls to itself
  • External signer authorization: calls requiring external auth work correctly

Testing Infrastructure

  • Added HELLO_WORLD_WASM constant for testing (416 lines of WASM bytecode)
  • Extended hello-world contract with hello_requires_auth and is_deployed functions
  • Tests cover authorization patterns both with the deployed contract as caller and with external signers

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.

1 participant