feat(ctf): add support for proxy wallet when calling CTF contract#278
Open
jclmnop wants to merge 2 commits intoPolymarket:mainfrom
Open
feat(ctf): add support for proxy wallet when calling CTF contract#278jclmnop wants to merge 2 commits intoPolymarket:mainfrom
jclmnop wants to merge 2 commits intoPolymarket:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
==========================================
- Coverage 85.54% 85.10% -0.44%
==========================================
Files 32 32
Lines 5167 5210 +43
==========================================
+ Hits 4420 4434 +14
- Misses 747 776 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5afd623 to
2d6410a
Compare
7343e7d to
e48a19b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
e48a19b to
dd84c39
Compare
dd84c39 to
e50d306
Compare
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.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
Existing behaviour isn't changed. CTF client uses EOA by default, which makes contract calls in exactly the same way as before.
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.
fixes #277
Note
Medium Risk
Adds a new transaction-sending path that routes CTF write calls through a
ProxyFactory, which can change how on-chain writes are executed and may fail on chains without the proxy contract configured.Overview
CTF write operations (
split,merge,redeem) can now be executed from proxy wallets. The CTF client gains aWalletType(defaulting toEOA) and awith_wallet_typebuilder to switch behavior.When
WalletType::Proxyis selected, write calls are wrapped into aProxyCalland sent via a newly addedIProxyFactorycontract instance (wired fromwallet_contract_config); EOA behavior remains directcall.send().The
examples/ctf.rsexample is updated to accept an optional wallet type argument (e.g.proxy) for--writemode and initialize the client accordingly.Written by Cursor Bugbot for commit 4733c46. This will update automatically on new commits. Configure here.