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

feat: update nonce to return managed nonce for contract accounts #502

Closed
Tracked by #33
ftupas opened this issue Aug 31, 2023 · 0 comments · Fixed by #513
Closed
Tracked by #33

feat: update nonce to return managed nonce for contract accounts #502

ftupas opened this issue Aug 31, 2023 · 0 comments · Fixed by #513
Assignees
Labels
new-feature New features or options.

Comments

@ftupas
Copy link
Contributor

ftupas commented Aug 31, 2023

Feature Request

Describe the Feature Request

Currently, we return the protocol-level nonce both for EOA and Contract Accounts

async fn nonce(&self, ethereum_address: Address, block_id: BlockId) -> Result<U256, EthApiError<P::Error>> {
let starknet_block_id: StarknetBlockId = EthBlockId::new(block_id).try_into()?;
let starknet_address = self.compute_starknet_address(ethereum_address, &starknet_block_id).await?;
self.starknet_provider
.get_nonce(starknet_block_id, starknet_address)
.await
.map(|nonce| {
let nonce: Felt252Wrapper = nonce.into();
nonce.into()
})
.or_else(|err| match err {
ProviderError::StarknetError(StarknetError::ContractNotFound) => Ok(U256::from(0)),
_ => Err(EthApiError::from(err)),
})
}

Describe Preferred Solution

When this pr is merged, we need to do the following:

  • update nonce so that for EOA we take the native nonce and for Contract Accounts, the managed nonce
  • add tests for the new nonce logic
@ftupas ftupas added the new-feature New features or options. label Aug 31, 2023
@ftupas ftupas self-assigned this Aug 31, 2023
anukkrit149 pushed a commit to karnotxyz/kakarot-rpc that referenced this issue Aug 9, 2024
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days. Did you spend 0.5 days on this PR or rather 2 days? -->

Time spent on this PR: 0.5d

## Pull request type

<!-- Please try to limit your pull request to one type, submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [X] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->
Account contracts have to be deployed by interaction with kakarot and
can't be deployed via the EOA.

Resolves kkrt-labs#491 

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Sending a transaction (legacy or default) with the "to" address set to
"" will result in a contract deployment instead of a standard
transaction.
- An event containing the new contracts EVM address is emitted on
contract creation

## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

---------

Co-authored-by: Elias Tazartes <66871571+Eikix@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature New features or options.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant