0xSpaceShard / 0xSpaceShard/starknet-hardhat-plugin
getAccountFromAddress not working if account not deployed
- Dominant language
- TypeScript
- Stars
- 197
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
When doing
```typescript
starknet.OpenZeppelinAccount.getAccountFromAddress(address, privateKey);
```
the plugin performs an internal validation that the provided private key matches the deployed public key.
Source code: [OpenZeppelinAccount](https://github.com/Shard-Labs/starknet-hardhat-plugin/blob/9e4809b54ef10b371994a30d655112aef42aa94d/src/account.ts#L506-L514), [ArgentAccount](https://github.com/Shard-Labs/starknet-hardhat-plugin/blob/9e4809b54ef10b371994a30d655112aef42aa94d/src/account.ts#L778)
Since `starknet-hardhat-plugin` v0.7.0, it is a problem if the account contract hasn't yet been deployed (so there is no public key deployed to check against). When can this happen? Assume the following use-case:
```typescript
const account = await starknet.OpenZeppelinAccount.createAccount(...);
console.log("Account address:", account.address);
// you exit the script to fund the account
```
Then a new script is run which first tries to get the account:
```typescript
const account = await starknet.OpenZeppelinAccount.getAccountFromAddress(...);
// FAILS with reporting an UNINITIALIZED_CONTRACT
```
Originally reported on [Discord](https://discord.com/channels/793094838509764618/1053041010193739776/1053248910233178163).
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue is in the account.ts file, specifically the getAccountFromAddress method for OpenZeppelinAccount and ArgentAccount. The validation check for the public key fails when the account contract is not deployed. Start by examining the linked source code lines to understand the validation logic. Look for how the plugin checks the contract state and consider adding a condition to skip validation if the contract is not deployed. Test by creating an account, noting its address, and then trying to get the account from that address before deployment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- blockchain, typescript
- Domain
- blockchain, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100