fix(sdk): land deploy_treasury arg-order fix on main (+ doc corrections) - #8
Merged
Merged
Conversation
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
…to fix/land-deploy-treasury-args
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why this PR exists
#7 (the
deploy_treasuryfix) was stacked on #6. #6 merged intomainfirst, and GitHub didn't retarget #7, so #7 merged into the oldfix/sdk-contract-error-enumsbranch instead ofmain.mainstill has the broken call.packages/sdk/src/contracts/factory.tspassesaddressArg(admin)first, so every deploy traps withError(WasmVm, InvalidAction)and org creation doesn't work.This PR branches from
main, merges that branch in (bringinge06be00with its history), and fixes the docs that contradict the change.Changes
From #7 (already reviewed there, unchanged):
e06be00deployTreasurynow encodes args in the contract's order:deploy_treasury(name, admin, approvers, threshold, token) -> u32(charter-contract/contracts/factory/src/lib.rs:87-94).u32org-id return by reading the org back withget_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.mdtold 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 whenadminis the stored deployer" paragraph and contradicted it. Removed.docs/smart-contracts/factory.md: it still said treasury errors likeInvalidThresholdpass throughdeploy_treasury. It now says they surface asTreasuryInitFailed(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
mainhas no conflicts (checked withgit merge-tree).npm run typecheckpasses for@charter/sdkand@charter/webon this branch.CBLP…37CG:b1fe3777…cf73, statusSUCCESS, org chore: add batch issue generation script #1, treasuryCAZK…3W2X.FactoryCallErrorcode 5 with theTreasuryInitFailedmessage, and the org count is unchanged.Still open (not in this PR)
NEXT_PUBLIC_FACTORY_CONTRACT_IDstill points at the old factory.🤖 Generated with Claude Code