Proposal to Upgrade SwapFactory Canister
Summary
GitHub commit
https://github.com/ICPSwap-Labs/icpswap-v3-service/commit/94eeb92ad6ecc2713d38fd3bef48cd4f328a3513
Changelog
- Removed infoCid from constructor arguments, getInitArgs() return type, the internal _infoAct actor reference, and all install/upgrade call sites. Calls to _infoAct.addClient(...) were dropped.
- createPool now has an idempotency fast-path: if the pool key already exists in _poolDataService, the function returns #ok immediately without acquiring the lock.
- createPool lock redesigned as a generation-token scheme. _lock() returns ?Time.Time (the acquisition timestamp doubles as the unique token); _unlock(myTime) only releases when _lockState.time == myTime. After a TTL takeover, the original holder's late _unlock is a no-op instead of releasing the next caller's lock.
- TTL extracted as constant _LOCK_TTL_NS = 10 * 60 * 1_000_000_000 (10 minutes) instead of the inline 1_000_000_000 * 60.
- createPool body restructured: the nested switch / case (_) block was flattened into a top-level try/catch, with every return path explicitly calling _unlock(myLockTime).
- New stable variable _upgradeWasmSnapshot : Blob. When a batch upgrade starts (batchSetPoolAdmins entry point), the active WASM is snapshotted into _upgradeWasmSnapshot. stepUpgrade now consumes this snapshot rather than calling _wasmManager.getActiveWasm() per step, so the WASM cannot change mid-batch.
- Local install path asserts activeWasm.size() > 0 before install_code, rejecting empty WASM.
- uploadWasmChunk now passes msg.caller to _wasmManager.uploadChunk(caller, chunk) for per-caller upload isolation.
- setNextPoolVersion: parsing logic extracted into _parseVersion, which returns ?[Nat]. Invalid semver input now throws Error.reject("...") instead of silently coercing non-numeric components to 0 via Nat.fromText.
- batchAddPoolControllers and batchAddInstallerControllers now reject anonymous principals at the entry point.
- setAdmins: added duplicate-principal detection (O(n²) check) on top of the existing anonymous rejection; empty array is explicitly allowed as an admin reset.
- icrc21_canister_call_consent_message now passes two empty token-address strings to ICRC21.icrc21_canister_call_consent_message, with a comment noting that the factory has no per-pool token context.
- InstallerFunc type signature reduced from 6 parameters to 5 (dropped infoCid); both #External and #Local branches updated to match.
- Version bumped from 3.6.2 to 3.7.0.
Wasm Verification
git fetch
git checkout 94eeb92ad6ecc2713d38fd3bef48cd4f328a3513
./build.sh
sha256sum .dfx/local/canisters/SwapFactory/SwapFactory.wasm
Payload
Proposal to Upgrade an SNS Controlled Canister
Target canister: 4mmnk-kiaaa-aaaag-qbllq-cai
Wasm info
Embedded module with 704269 bytes and SHA256 645cab652c02615643ad8ab9fc1b48c83dcdf9befc6eee3d9b5a66f72e7fc6f3.
Mode: Upgrade
Argument info
Upgrade argument with 87 bytes and SHA256 4449444c016e6806686868680068010a0000000000d014b80101010a0000000000d019ac0101010a0000000000d019af0101010a0000000000d06883010101010a00000000020000ab0101010a0000000000d014b90101.
Overview