Skip to content

fix(sdk): land deploy_treasury arg-order fix on main (+ doc corrections) - #8

Merged
K1NGD4VID merged 4 commits into
mainfrom
fix/land-deploy-treasury-args
Sep 15, 2026
Merged

K1NGD4VID merged 4 commits into
mainfrom
fix/land-deploy-treasury-args

Conversation

@fadesany

Copy link
Copy Markdown
Contributor

Why this PR exists

#7 (the deploy_treasury fix) was stacked on #6. #6 merged into main first, and GitHub didn't retarget #7, so #7 merged into the old fix/sdk-contract-error-enums branch instead of main. main still has the broken call. packages/sdk/src/contracts/factory.ts passes addressArg(admin) first, so every deploy traps with Error(WasmVm, InvalidAction) and org creation doesn't work.

This PR branches from main, merges that branch in (bringing e06be00 with its history), and fixes the docs that contradict the change.

Changes

From #7 (already reviewed there, unchanged): e06be00

  • deployTreasury now encodes args in the contract's order: deploy_treasury(name, admin, approvers, threshold, token) -> u32 (charter-contract/contracts/factory/src/lib.rs:87-94).
  • It handles the real u32 org-id return by reading the org back with get_org (retrying once for testnet RPC lag), and returns { hash, orgId, treasuryAddress }.

New in this PR: 33c384b (docs only)

  • docs/for-organization-admins/getting-started.md told admins their wallet would ask them to sign twice. It signs once: the SDK signs only the transaction envelope, so a deploy succeeds only when the connected wallet is the factory's deployer. The section now says that plainly.
  • docs/developer-guide/sdk-reference.md: main's "asked to sign twice" lines sat directly under fix(sdk): call deploy_treasury with contract arg order and org-id return #7's "succeeds only when admin is the stored deployer" paragraph and contradicted it. Removed.
  • docs/smart-contracts/factory.md: it still said treasury errors like InvalidThreshold pass through deploy_treasury. It now says they surface as TreasuryInitFailed (Feat/dashboard redesign #5) with the deploy rolled back, and Feat/dashboard redesign #5 is added to the error table. The "needs two signatures" note stays, because it's accurate for the contract (deployer and admin both authorize).

Testing

Still open (not in this PR)

  • Deployer-only deploys: only the factory's deployer wallet can deploy from the new-org form. Opening this up needs a contract auth change or a deployer co-signing step.
  • Old factory: NEXT_PUBLIC_FACTORY_CONTRACT_ID still points at the old factory.

🤖 Generated with Claude Code

fadesany and others added 4 commits September 15, 2026 21:16
deployTreasury encoded its args as (admin, name, ...) but the contract
signature is deploy_treasury(name, admin, approvers, threshold, token)
-> u32 (charter-contract contracts/factory/src/lib.rs L87-94). Every
call trapped with Error(WasmVm, InvalidAction) before any contract
logic ran, so org creation was broken on every factory deployment.

The SDK also expected a treasury address string back, but the contract
returns the new org id, so a successful deploy would still have thrown.
Read the org record back with get_org (retrying once for testnet RPC
read-after-write lag) and return { hash, orgId, treasuryAddress }. A
failed read-back after a confirmed deploy is reported as such rather
than as a contract rejection.

Update the SDK reference docs for the return shape and argument order.
fix(sdk): call deploy_treasury with contract arg order and org-id return
The getting-started guide and SDK reference said the wallet signs a
deploy twice. It signs once: the SDK signs only the transaction
envelope, so deploy_treasury (which needs both the stored deployer and
the admin to authorize) succeeds only when the connected wallet is the
factory's deployer. Say that plainly instead.

factory.md still said treasury init panics like InvalidThreshold pass
through deploy_treasury. They now surface as TreasuryInitFailed (#5)
with the deploy rolled back; document that and add #5 to the error
table.
@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
app-web Ready Ready Preview Sep 15, 2026 8:23pm UTC

@K1NGD4VID
K1NGD4VID merged commit 9a68bad into main Sep 15, 2026
6 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