Add lst restricted wallet#548
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for creating and operating an lst_restricted_wallet type, including the extra metadata needed for deployment (treasury + liquid pool addresses) and new deployment flows that depend on ton-http-api.
Changes:
- Extend
nw(new wallet) to acceptlst_restricted_walletparameters and propagate them into wallet creation. - Add ton-http-api get-method helper(s) and use them to fetch liquid pool deploy data and to simplify loan amount calculation.
- Add Fift scripts for
lst_restricted_walletcreation and controller StateInit building, and update controller deployment to supportlst_restricted_walletwallets (using init BoC + extra flags).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/test_wallet_commands.py | Adds an integration test case for nw ... lst_restricted_wallet ... arguments and propagation. |
| mytoncore/mytoncore.py | Adds init BoC/extra flag support for wallet signing, introduces ton-http-api get-method helper, and reworks liquid-staking get-method usage. |
| mytoncore/contracts/lst-restricted-wallet/new-wallet.fif | New Fift script to generate an lst_restricted_wallet state/init message and files. |
| mytoncore/contracts/lst-restricted-wallet/build-controller-init.fif | New Fift script to build controller StateInit and save *-init.boc. |
| modules/wallet.py | Extends nw parsing, adds lst_restricted_wallet wallet creation path, and refactors the wallet-creation Fift runner(s). |
| modules/controller.py | Adds direct controller deployment path for lst_restricted_wallet wallets using computed init BoC. |
| modules/init.py | Adds tonHttpApiUrl setting used by the new ton-http-api helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def run_new_wallet_fift_args(self, version: str, workchain: int, wallet_path: str, subwallet: int) -> list[str]: | ||
| if "v1" in version: | ||
| fift_script = "new-wallet.fif" | ||
| args = [fift_script, workchain, wallet_path] | ||
| args = [fift_script, str(workchain), wallet_path] | ||
| elif "v2" in version: | ||
| fift_script = "new-wallet-v2.fif" | ||
| args = [fift_script, workchain, wallet_path] | ||
| args = [fift_script, str(workchain), wallet_path] | ||
| elif "v3" in version: | ||
| fift_script = "new-wallet-v3.fif" | ||
| args = [fift_script, workchain, subwallet, wallet_path] | ||
| args = [fift_script, str(workchain), str(subwallet), wallet_path] | ||
| else: | ||
| raise Exception(f"get_wallet_fift error: fift script for `{version}` not found") | ||
| return list(map(str, args)) | ||
|
|
||
| return self.ton.fift.run(args) | ||
|
|
| def run_new_lst_restricted_wallet_fift_args(self, workchain: int, wallet_path: str, treasury_addr: str, liquid_pool_addr: str) -> list[str]: | ||
| deploy_data = self.ton.get_liquid_pool_deploy_data(liquid_pool_addr) | ||
| with (get_package_resource_path('mytoncore', 'contracts/lst-restricted-wallet/wallet-code.boc') as wallet_code_path, | ||
| get_package_resource_path('mytoncore', 'contracts/lst-restricted-wallet/new-wallet.fif') as fift_script): | ||
| args = [ | ||
| fift_script, | ||
| wallet_code_path, | ||
| deploy_data["controller_code_path"], | ||
| treasury_addr, | ||
| liquid_pool_addr, | ||
| self.ton.GetFullConfigAddr(), | ||
| self.ton.GetFullElectorAddr(), | ||
| str(workchain), | ||
| wallet_path, | ||
| ] | ||
| return self.ton.fift.run(args) |
| res = requests.post(url, json=data, timeout=5) | ||
| res_data = res.json() | ||
| if res_data.get("ok") is False: | ||
| error = res_data.get("error") or res_data.get("message") or res_data | ||
| raise Exception(f"Failed to run get method: {error}. Make sure ton-http-api is enabled (installer -> enable THA)") | ||
| result = res_data.get("result") | ||
| if result is None or "stack" not in result: | ||
| raise Exception(f"Failed to run get method: malformed response: {res_data}") | ||
| return result["stack"] |
| controller_code_bytes = base64.b64decode(stack[25][1]["bytes"]) | ||
| controller_code_path = self.tempDir + self.nodeName + "controller-code.boc" | ||
| with open(controller_code_path, "wb") as file: | ||
| file.write(controller_code_bytes) | ||
| return { |
| computed_controller_addr, init_boc_path = self._build_liquid_staking_controller_state_init(controller_id) | ||
| if computed_controller_addr != expected_controller_addr: | ||
| raise Exception( | ||
| f"DirectDeployLiquidStakingController error: computed address {computed_controller_addr} does not match pool address {expected_controller_addr}" |
fe44dc0 to
48dd3b1
Compare
simplify and fix lst wallet usage Wire governance voting into restricted wallet Add lst restricted wallet operator guide Pass lst wallet create args explicitly Add lst restricted wallet create wallet support Add lst restricted wallet integration notes Integrate lst restricted wallet deploy flow
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9769b05c5d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| result = res_data.get("result") | ||
| if result is None or "stack" not in result: | ||
| raise Exception(f"Failed to run get method: malformed response: {res_data}") |
There was a problem hiding this comment.
Handle v3 runGetMethod response format
Update this parser to accept the v3 runGetMethod schema (top-level stack) in addition to the v2 wrapper (result.stack). With tonHttpApiUrl set to a modern /api/v3/runGetMethod endpoint, result is absent so this path always raises malformed response, which breaks the new lst_restricted flows that depend on run_ton_http_get_method (wallet/controller deploy data retrieval and CalculateLoanAmount).
Useful? React with 👍 / 👎.
No description provided.