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

More flexibility to contract DSL, Async contract caller #118

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

yglukhov
Copy link
Contributor

@yglukhov yglukhov commented Jan 9, 2024

One thing bugging me about contract dsl was the necessity to call call/send/exec over each invocation (e.g. let myValue = await myContract.getMyValue().call()). So I tried to fix that and here's what I came up with. Contract dsl is still async-and-web3-agnostic, but requires sender to define createMutableContractInvocation, createImutableContractInvocation and createContractDeployment functions, whose results are blindly passed to the caller. This allows to define async contract sender, while still keeping the old api around. See diff test_contracts.nim for demonstration of how new api looks like. With send/exec/call functions gone, the new way to adjust invocation options (like value, gas, gasPrice, etc) is the adjust macro, that creates a copy of async sender, adjusting its fields. E.g.

await myContract.adjust(value = 5.u256, gas = 10000).myContractMethod()

Any feedback is welcome.

@jangko
Copy link
Contributor

jangko commented Jan 9, 2024

This is great. Looks more natural and intuitive.
But honestly, I don't know much about the web3 usage and internals.
Need more eye on this, ping @arnetheduck @zah

@jangko jangko merged commit eea0344 into status-im:master Jan 10, 2024
12 checks passed
@yglukhov yglukhov deleted the contract-async-caller branch January 11, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants