Add smart wallet upgrade example script #20
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.
Add smart wallet upgrade example script
Summary
This PR adds a new example script
smart-wallet-upgrade.tsthat demonstrates how to upgrade a deployed smart wallet contract to a new WASM version. The script follows the same patterns as the existingsmart-wallet-deployment.tsexample but focuses specifically on the upgrade workflow.Key additions:
smart-wallet-upgrade.tsscript that takes a smart wallet contract ID as inputupgradefunction from theSmartWalletUpgradeabletrait using direct contract invocationSW_WASM_HASH_TESTINGas the target WASM versionnpm run upgradefor convenient executionTechnical approach:
(smartWalletClient as any).call("upgrade", ...)since the upgrade function isn't exposed in the TypeScript client interfaceADMIN_SIGNER_KEYPAIR)Review & Testing Checklist for Human
npm run upgrade <CONTRACT_ID>with a real deployed smart wallet to verify it workssmartWalletClient.call("upgrade", Buffer.from(SW_WASM_HASH_TESTING, "hex"))uses the correct function signatureSW_WASM_HASH_TESTINGis the appropriate target hash for upgrade testingRecommended test plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end PackageJson["examples/package.json<br/>(add upgrade script)"]:::minor-edit UpgradeScript["examples/smart-wallet-upgrade.ts<br/>(new upgrade script)"]:::major-edit ConstsFile["examples/consts.ts<br/>(SW_WASM_HASH_TESTING)"]:::context UtilsFile["examples/utils.ts<br/>(printAuthEntries)"]:::context DeployScript["examples/smart-wallet-deployment.ts<br/>(reference patterns)"]:::context UpgradeableTrait["contracts/upgradeable/src/lib.rs<br/>(SmartWalletUpgradeable trait)"]:::context UpgradeScript -->|"imports constants"| ConstsFile UpgradeScript -->|"imports utilities"| UtilsFile UpgradeScript -->|"follows patterns from"| DeployScript UpgradeScript -->|"calls upgrade function from"| UpgradeableTrait PackageJson -->|"runs"| UpgradeScript classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
SmartWalletUpgradeabletrait but not exposed in the TypeScript client, requiring direct contract invocationLink to Devin run: https://app.devin.ai/sessions/e70d61b35273403d9f2b46be887d0cf1
Requested by: @alberto-crossmint