Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better ergonomics for proxied contract calls #3145

Closed
arboleya opened this issue Sep 11, 2024 · 2 comments
Closed

Provide better ergonomics for proxied contract calls #3145

arboleya opened this issue Sep 11, 2024 · 2 comments
Assignees
Labels
feat Issue is a feature

Comments

@arboleya
Copy link
Member

We should provide a type-safe API that can work behind proxied contracts.

This should go in tandem with:

Original request:

  • So, the proxy contract works on dynamically dispatching calls based on the function selector. Previously, to call a contract method, they could use the TS SDK to generate the types for the contract and call the contract by contractA.functions.someRandomFunc().call(). However, they're saying for the proxy contract, there isn't any way to call a particular function (say, "someRandomFunc") that is defined in the implementation because the base proxy contract has essentially just a "fallback" method. They've found this, but it mentions the usage of forc that isn't ideal for their use case.
@arboleya arboleya added the feat Issue is a feature label Sep 11, 2024
@Dhaiwat10 Dhaiwat10 self-assigned this Sep 17, 2024
@danielbate
Copy link
Member

At face value I think this should work out of the box with addContracts however we'll get type errors, consider the following example:

const myContract = new Contract('0x01', MyContractAbi, wallet);
const myProxyContract = new Contract('0x02', MyProxyAbi, wallet);

await myContract.functions.myContractXyz().addContracts([myProxyContract]).call();

The proxy and it's ABI is added to the call so can use it and it's logs. However, the ABI is only really useful for logged types. For proxy calls, we also want to be able to call methods available to myProxyContact.

The solution addProxyContract should perform everything addContracts can, but also allow us to safely perform functions from the proxy.

await myContract.functions.myProxyContractXyz().addProxyContracts([myProxyContract]).call();

I'd recommend testing this first with a proxy contract and seeing how it works with the current SDK before informing the solution.

@arboleya
Copy link
Member Author

It turns out that proxy contracts are supported out of the box.

The only thing that needs handling is proxy deployments:

@arboleya arboleya reopened this Sep 23, 2024
@arboleya arboleya closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
@arboleya arboleya reopened this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants