feat(ctf): add support for proxy wallet when calling CTF contract#15
Open
jclmnop wants to merge 1 commit intoPolymarket:mainfrom
Open
feat(ctf): add support for proxy wallet when calling CTF contract#15jclmnop wants to merge 1 commit intoPolymarket:mainfrom
jclmnop wants to merge 1 commit intoPolymarket:mainfrom
Conversation
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.
Problem
CTF client can currently only perform write operations (split/merge/redeem) for EOA type wallets. Read operations work for all types.
Solution
I added a
wallet_typefield to the CTF client (defaults toEOAso default behaviour isn't changed if user doesn't set it).The
send_call()method takes a call to the CTF contract and uses the appropriate mechanism to send the tx based on wallet type.send_call()is only used for split/merge/redeem.For EOA type it doesn't do anything differently.
The reason I created a separate
WalletTypeenum instead of using the existingSignatureTypeenum is becauseGNOSISisn't yet implemented, and I wanted to limit the variants to types that are actually implemented. If GNOSIS is eventually implemented, then you can just re-use the signature type enum (to avoid breaking the API at that point, just change the param type toimpl Into<WalletType>and implementFrom<SignatureType> for WalletType).Also derived
Deserializeon the enum so users can include it in their own configs etc (same forSerializein case people want to be able toSerializetheir own configs to another format or something).Example usage
For EOA wallets, CTF initialisation is the same:
For proxy wallets, just one extra method is required when initialising the client:
Added example usage to
examples/ctf.rs.Risk
THIS CHANGE WAS WRITTEN FOR V1 AND HASN'T BEEN TESTED WITH V2 so if there are any differences I'm unaware of regarding the CTF contract etc, this will need some modifications.
Existing behaviour isn't changed. CTF client uses EOA by default, which makes contract calls in exactly the same way as before.
In V1, I've been using this implementation myself to do all 3 types of write calls (split, merge and redeem) with a proxy wallet and had no issues. Beforehand I couldn't make those calls using the CTF client with a proxy wallet.
Tests
I did attempt to write some unit tests, using the same mocking logic as the other CTF client tests, but I have no idea how the raw expected responses are formed and didn't really have time to dive into it.
If unit tests are required, then just point me in the direction of how to find expected response bodies for each request type and I'll implement them.
Note
Medium Risk
Adds a new transaction-sending path for CTF write operations that routes calls through a
ProxyFactory, which can affect how on-chain transactions are constructed/sent and may fail on chains without the proxy contract configured.Overview
Adds proxy-wallet support for CTF write operations by introducing a
WalletType(defaulting toEOA) and routingsplit/merge/redeem(including NegRisk redeem) through a newsend_callhelper that either sends directly or wraps the call in aProxyFactory.proxy()transaction.Updates client construction to optionally load the chain’s proxy factory address (
wallet_contract_config) and providesClient::with_wallet_type(...)for selecting proxy behavior, plus updates theexamples/ctf.rsCLI to accepteoa/proxyflags for write-mode runs.Reviewed by Cursor Bugbot for commit c5c3fa4. Bugbot is set up for automated code reviews on this repo. Configure here.